@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Lora:wght@400;600;700&display=swap");

:root {
    --font-family-sans:
        "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans", sans-serif;
    --font-family-serif: "Lora", Georgia, "Times New Roman", Times, serif;
    font-family: var(--font-family-serif);
}

i,
em {
    font-family: "InterItalic", var(--font-family-sans);
    font-style: normal;
}

strong,
b {
    font-weight: 600;
}

html {
    height: 100%;
}

body {
    /* Make page a column flex container so footer can sit at the bottom on short pages */
    display: flex;
    flex-direction: column;
    min-height: 100vh;

    font-size: 1.05rem;
    font-weight: 400;
    font-family: var(--font-family-sans);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Improve vertical rhythm for prose */
    line-height: 1.7;
}

/* Ensure paragraphs have comfortable spacing */
p {
    margin: 0 0 1.15rem 0;
}

/* Slightly reduce heading line-height so headings remain compact */
h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.25;
}

/* Prevent horizontal overflow on small viewports */
html,
body {
    min-width: 0;
}

/* Global text wrapping for headings, paragraphs, lists, anchors and common containers */
.container,
.content,
.site-main,
.body,
.posts,
.tagged-posts,
.all-tags,
.post-list-element,
h1,
h2,
h3,
h4,
h5,
h6,
p,
li,
blockquote,
figcaption,
th,
td,
a,
code {
    overflow-wrap: anywhere;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    white-space: normal;
}

/* Keep code blocks scrollable but constrained */
pre,
code {
    max-width: 100%;
    box-sizing: border-box;
}

/* Make fenced code blocks preserve whitespace, allow both X/Y scrolling and avoid vertical squish */
pre {
    position: relative;
    /* for the copy button */
    white-space: pre;
    /* do not wrap code lines */
    display: block;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 520px;
    /* limit vertical size and enable scroll */
    padding: 1.25rem 1.2rem;
    margin: 0.9rem 0;
    border-radius: 12px;
    background-color: var(--inline-code-bg);
    border: 1px solid rgba(2, 6, 23, 0.06);
    -webkit-overflow-scrolling: touch;
    /* smooth scrolling on mobile */
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
}

pre>code {
    white-space: pre;
    /* ensure code inside pre does not wrap */
    display: block;
}

/* Page container to make a readable docs layout */
.container {
    box-sizing: border-box;
    margin: 0 auto;
    /* a little more breathing room inside the page container */
    padding: 1rem;
    /* Use characters-based measure for optimal line length on articles */
    max-width: 65ch;
}

/* Larger container for very wide viewports while keeping measure readable */
@media (min-width: 1400px) {
    .container {
        max-width: 75ch;
    }
}

/* Increase container padding on larger viewports for better rhythm */
@media (min-width: 900px) {
    .container {
        padding: 1.25rem;
    }
}

@media (min-width: 1100px) {
    .container {
        padding: 1.5rem;
    }
}

.site-main {
    flex: 1 0 auto;
    padding-top: 0.75rem;
    padding-bottom: 2rem;
}

.content {
    background: transparent;
}

.body {
    padding: 0;
}

/* Wider layout on larger screens */
@media (min-width: 900px) {
    .container {
        max-width: 48rem;
        padding: 1rem;
    }
}

@media (min-width: 1100px) {
    .container {
        max-width: 64rem;
    }
}

figure {
    margin: 0;

    &>figcaption>* {
        margin: 0;
    }
}

img {
    width: 100%;
    margin-left: auto;
    margin-right: auto;

    margin-top: 0.1rem;
    margin-bottom: 0.1rem;

    overflow: hidden;
    object-fit: cover;
    object-position: center center;
}

/* Responsive iframe helper for embedding live previews */
.responsive-iframe {
    width: 100%;
    margin: 1rem 0;
    /* Prefer modern aspect-ratio, fallback to 16:9 spacing for older browsers */
    aspect-ratio: 16/9;
    background: var(--inline-code-bg);
    border-radius: 6px;
    overflow: hidden;
}

.responsive-iframe iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: white;
}

/* Larger live preview iframe: portrait/vertical card on wider viewports */
#carousel-frame {
    aspect-ratio: 3/4 !important;
    width: 100%;
    max-width: 900px;
    margin: 1rem auto;
    border-radius: 10px;
    border: 1px solid rgba(2, 6, 23, 0.06);
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.08);
    background: transparent;
    height: auto;
}

@media (min-width: 1100px) {
    #carousel-frame {
        max-width: 720px;
    }
}

/* Embed card: visually matches the code card style (rounded, border, shadow) */
.embed-card {
    width: 100%;
    background: transparent;
    /* inner content fills the card */
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0;
    /* card has no inner padding so iframe fills it */
    position: relative;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
    overflow: hidden;
    margin: 1rem 0;
}

.embed-card .responsive-iframe {
    margin: 0;
    border-radius: 6px;
    background: #fff;
    /* bezel color */
}

/* Gallery styles: tilted preview cards with subtle float animation */
.embed-gallery {
    --embed-gap: 0.9rem;
    display: flex;
    gap: var(--embed-gap);
    justify-content: center;
    align-items: flex-end;
    margin: 1.25rem 0;
    padding: 0.1rem 0.1rem 0.9rem 0.1rem;
    width: 100%;
    box-sizing: border-box;
}

/* Desktop: show exactly four items in view and constrain to container width */
@media (min-width: 900px) {

    .marquee,
    .embed-gallery,
    .marquee-track {
        width: 100%;
        /* ensure the timeline fits inside page container / footer margins */
        box-sizing: border-box;
    }

    .embed-item {
        /* Calculate four equally sized items, accounting for three gaps */
        flex: 0 0 calc((100% - (var(--embed-gap) * 3)) / 4);
        max-width: calc((100% - (var(--embed-gap) * 3)) / 4);
    }
}

/* Keep four items visible on smaller screens as well */
@media (max-width: 899px) {
    .embed-item {
        /* same four-up calculation as desktop so the timeline shows 4 items consistently */
        flex: 0 0 calc((100% - (var(--embed-gap) * 3)) / 4);
        max-width: calc((100% - (var(--embed-gap) * 3)) / 4);
    }
}

/* Very small viewports: show two items to retain readability */
@media (max-width: 399px) {
    .embed-item {
        /* two-up calculation with one gap between items */
        flex: 0 0 calc((100% - var(--embed-gap)) / 2);
        max-width: calc((100% - var(--embed-gap)) / 2);
    }
}

.embed-item {
    /* flexible card that can shrink to keep four items visible on narrow viewports */
    width: auto;
    min-width: 0;
    max-width: none;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
    transform-origin: center bottom;
    transition:
        transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1),
        box-shadow 260ms cubic-bezier(0.2, 0.9, 0.2, 1);
    background: #fff;
    /* match the rendered-item card */
    border: 1px solid rgba(2, 6, 23, 0.03);
}

.embed-item:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 48px rgba(2, 6, 23, 0.12);
}

/* Portrait/mobile embedded item */
.embed-item.mobile {
    width: 180px;
    min-width: 120px;
    max-width: 240px;
}

.embed-item.mobile .responsive-iframe {
    /* portrait mobile frame */
    aspect-ratio: 9/16;
}

/* responsive adjustments for small screens are handled by the unified 900px rules elsewhere */

/* subtle base/bezel under the phone (smaller) — removed white cap gradient */
.embed-item::after {
    content: "";
    position: absolute;
    left: 14%;
    right: 14%;
    bottom: -6px;
    height: 8px;
    background: transparent;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
    z-index: 1;
    pointer-events: none;
}

/* Slight tilts for visual variety (base rotation applied to the card) */
.embed-item:nth-child(1) {
    transform: rotate(-6deg) translateY(4px);
}

.embed-item:nth-child(2) {
    transform: rotate(3deg) translateY(0);
}

.embed-item:nth-child(3) {
    transform: rotate(-1deg) translateY(6px);
}

.embed-item:nth-child(4) {
    transform: rotate(1.5deg) translateY(2px);
}

.embed-item:nth-child(5) {
    transform: rotate(-3deg) translateY(4px);
}

/* The inner frame gets the subtle float animation so outer rotate stays intact */
.embed-frame {
    /* stronger zoom out and top focus for portrait previews */
    --embed-zoom: 0.6;
    --embed-focus: 0%;

    display: block;
    width: 100%;
    aspect-ratio: 9/16;
    position: relative;
    transform-origin: center center;
    /* inner frames kept static; outer `.embed-item` provides the wobble */
    animation: none !important;
    overflow: hidden;
    /* allow taller portrait frames on larger screens */
    max-height: 720px;
    /* ensure the frame rounds to the same radius as the parent */
    border-radius: inherit;
    background: transparent;
}

/* larger viewport refinement */
@media (min-width: 1100px) {
    .embed-frame {
        max-height: 880px;
    }
}

/* small variations per card for a natural look */
.embed-item:nth-child(1) .embed-frame {
    animation-delay: 0s;
}

.embed-item:nth-child(2) .embed-frame {
    animation-delay: 0.15s;
}

.embed-item:nth-child(3) .embed-frame {
    animation-delay: 0.3s;
}

.embed-item:nth-child(4) .embed-frame {
    animation-delay: 0.45s;
}

.embed-item:nth-child(5) .embed-frame {
    animation-delay: 0.6s;
}

/* Pause animation on hover to let the hover lift feel clean */
.embed-item:hover .embed-frame {
    animation-play-state: paused;
}

@keyframes float {

    /* cartoony bounce with subtle overshoot and squash/stretch */
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
    }

    12% {
        transform: translateY(-14px) rotate(3deg) scale(1.02);
    }

    28% {
        transform: translateY(8px) rotate(-2deg) scale(0.98);
    }

    52% {
        transform: translateY(-9px) rotate(1.6deg) scale(1.01);
    }

    76% {
        transform: translateY(3px) rotate(-0.8deg) scale(0.995);
    }

    100% {
        transform: translateY(0) rotate(0deg) scale(1);
    }
}

/* 'Window' idle motion: subtle parallax/3d tilt that makes the content look like a floating window */
@keyframes windowFloat {

    /* playful window tilt with gentle 3D motion & scale */
    0% {
        transform: translateX(0) translateY(0) rotateX(0deg) rotateZ(0deg) scale(1);
    }

    20% {
        transform: translateX(-8px) translateY(-10px) rotateX(3deg) rotateZ(2deg) scale(1.01);
    }

    45% {
        transform: translateX(6px) translateY(-4px) rotateX(-1.8deg) rotateZ(-1deg) scale(0.995);
    }

    70% {
        transform: translateX(-4px) translateY(-8px) rotateX(2deg) rotateZ(1deg) scale(1.008);
    }

    100% {
        transform: translateX(0) translateY(0) rotateX(0deg) rotateZ(0deg) scale(1);
    }
}

/* allow a mild 3D perspective so rotateX looks natural */
.rendered-gallery,
.embed-gallery {
    perspective: 900px;
}

/* apply the window motion to inner content — images and iframe frames */
.rendered-item img {
    /* disabled heavy windowFloat motion for calmer UI */
    animation: none !important;
    transform-origin: center center;
}

.rendered-item:hover img {
    /* no animation to pause */
}

.embed-frame,
.embed-item iframe {
    /* keep inner frames static — wobble is handled by the outer `.embed-item` */
    animation: none !important;
    transform-origin: center center;
}

.embed-item:hover .embed-frame,
.embed-item:hover iframe {
    animation-play-state: paused;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {

    .rendered-item img,
    .embed-frame,
    .embed-item iframe,
    .embed-item {
        animation: none !important;
    }
}

/* Marquee / carousel styles */
@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(var(--marquee-distance));
    }
}

.marquee {
    /* switch to a horizontally scrollable container so users can drag/scroll the timeline */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    /* hide native scrollbars but keep scrollability */
    scrollbar-width: none;
    /* firefox */
}

.marquee::-webkit-scrollbar {
    display: none;
    /* webkit */
}

.marquee-track {
    display: flex;
    gap: 0.9rem;
    align-items: flex-end;
    /* no CSS transform-based animation anymore; JS handles auto-scroll */
}

.marquee:hover .marquee-track,
.marquee:focus-within .marquee-track {
    animation-play-state: paused !important;
}

.embed-item img,
.embed-item iframe,
.embed-frame img,
.embed-frame iframe {
    display: block;
    /* expand the iframe so scaling reveals more page; centered then nudged up */
    width: calc(100% / var(--embed-zoom, 0.6)) !important;
    height: calc(100% / var(--embed-zoom, 0.6)) !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, calc(-50% + var(--embed-focus, 0%))) scale(var(--embed-zoom, 0.6)) !important;
    border: 0;
    object-fit: cover;
    border-radius: inherit;
    background: transparent;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

@media (max-width: 899px) {
    .embed-gallery {
        gap: 0.6rem;
    }

    .embed-item {
        width: 30%;
    }

    .embed-item img,
    .embed-item iframe {
        max-height: 420px;
    }
}

/* Rendered gallery (matches 'Rendered with Anna' look) */
.rendered-gallery {
    display: flex;
    gap: 1.1rem;
    justify-content: center;
    align-items: flex-start;
    margin: 1.2rem 0 1.8rem;
}

.rendered-item {
    width: 22%;
    min-width: 180px;
    max-width: 360px;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
    transform-origin: center bottom;
    transition:
        transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1),
        box-shadow 260ms cubic-bezier(0.2, 0.9, 0.2, 1);
    border: 1px solid rgba(2, 6, 23, 0.03);
}

.rendered-item img {
    display: block;
    width: 100%;
    height: 360px;
    object-fit: cover;
    border: 0;
    background: white;
}

/* Slightly varied rotation/offsets to match the collage feeling */
.rendered-item:nth-child(1) {
    transform: rotate(-6deg) translateY(6px);
}

.rendered-item:nth-child(2) {
    transform: rotate(2deg) translateY(-10px);
}

.rendered-item:nth-child(3) {
    transform: rotate(-2deg) translateY(0px);
}

.rendered-item:nth-child(4) {
    transform: rotate(4deg) translateY(-6px);
}

.rendered-item:nth-child(5) {
    transform: rotate(-3deg) translateY(4px);
}

.rendered-item:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 48px rgba(2, 6, 23, 0.12);
}

@media (max-width: 899px) {
    .rendered-item {
        width: 29%;
    }

    .rendered-item img {
        height: 280px;
    }
}

@media (max-width: 620px) {
    .rendered-gallery {
        flex-direction: column;
        align-items: center;
    }

    .rendered-item {
        width: 92%;
        transform: none !important;
        margin-bottom: 1rem;
    }

    .rendered-item img {
        height: 320px;
    }
}

blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1.2rem;
    background-color: var(--inline-code-bg);

    /* Constrain and wrap to avoid overflowing the page container */
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
    overflow-x: auto;
    /* allow narrow horizontal scroll inside the quote */
}

blockquote>* {
    margin: 0;
}

/* Ensure any code or pre elements inside a blockquote do not push layout */

blockquote>* {
    color: var(--color-text);
}

/* Ensure any code or pre elements inside a blockquote do not push layout */
blockquote pre,
blockquote code {
    max-width: 100%;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-family-serif);
    font-weight: 600;
    color: var(--color-primary);
    line-height: 1.2;
}

/* Improved heading scale for docs (reduced for tighter layout) */
h1 {
    font-size: 1.75rem;
    margin: 1.25rem 0 0.6rem;
}

.page-date {
    color: var(--color-text-dim);
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.post-description {
    margin-bottom: 1rem;
}

.authors-placeholder p {
    margin: 0 0 0.6rem 0;
    color: var(--color-text);
    font-weight: 600;
}

h2 {
    font-size: 1.25rem;
    margin: 0.9rem 0 0.35rem;
}

h3 {
    font-size: 1.05rem;
    margin: 0.75rem 0 0.3rem;
}

/* Anchor link styling (the little '#') */
.anchor {
    color: var(--color-text-dim);
    text-decoration: none;
    margin-left: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    vertical-align: middle;
}

.anchor:hover {
    color: var(--color-primary-dim);
}

/* Table of Contents styling */
h1#table-of-contents {
    color: var(--color-primary);
    font-weight: 700;
}

h1#table-of-contents+ul {
    margin-top: 0.6rem;
    margin-bottom: 1.2rem;
    padding-left: 1.25rem;
}

h1#table-of-contents+ul li {
    margin: 0.5rem 0;
}

h1#table-of-contents+ul a {
    color: var(--color-primary-dim);
    text-decoration: none;
    border-bottom: none;
}

h1#table-of-contents+ul a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Graph visualization (Obsidian-like tag graph) */
.graph-container {
    width: 100%;
    max-width: 520px;
    height: 320px;
    margin: 0.6rem 0 1.2rem 0;
    padding: 0.6rem;
    border-radius: 10px;
    background: var(--inline-code-bg);
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.04);
    overflow: hidden;
}

.chart {
    width: 100%;
    height: 100%;
    display: block;
}

.link {
    stroke: var(--color-text-low);
    stroke-opacity: 0.65;
}

.link--active {
    stroke: var(--color-text);
    stroke-opacity: 0.95;
}

.node {
    cursor: pointer;
    transition: stroke-width 0.12s ease, transform 0.12s ease;
}

.node--faded {
    opacity: 0.25;
}

.node-label {
    font-size: 12px;
    font-weight: 600;
    pointer-events: auto;
    fill: var(--color-text);
    cursor: pointer;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Bottom page graph */
.graph-bottom {
    margin-top: 2rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-hr);
}

.graph-bottom-title {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    color: var(--color-text-dim);
    font-weight: 600;
}

.graph-container.mini {
    height: 220px;
    max-width: 100%;
    padding: 0.75rem;
}

/* mini graph label tweaks */
.graph-container.mini .node-label {
    font-size: 10px;
    fill: var(--color-text);
    font-weight: 600;
    pointer-events: auto;
}

/* Empty / error placeholder */
.graph-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-dim);
    font-size: 0.95rem;
    text-align: center;
    padding: 0.6rem;
}

.graph-loading {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-dim);
    font-size: 0.95rem;
    text-align: center;
    padding: 0.6rem;
}

@media (max-width: 900px) {
    .graph-mini {
        display: none;
    }

    .graph-container {
        max-width: 100%;
    }
}

/* Content paragraphs and lists spacing */
p {
    margin: 0.6rem 0;
}

ul,
ol {
    margin: 0.6rem 0 0.6rem 1.1rem;
}

/* Horizontal rule styling: lighter than borders, visible in dark mode */
hr {
    border: 0;
    border-top: 1px solid var(--color-hr);
    margin: 1.2rem 0;
    height: 0;
    background: transparent;
}

/* Code block: simplified, compact, and robust */
pre {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;

    background: var(--inline-code-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.6rem 1.2rem 0.6rem 0.9rem;
    /* reduced right padding so the card is tighter while the copy button is absolutely positioned */
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
    overflow: hidden;
    /* keep layout tidy; inner code scrolls */
}

pre>code,
pre code {
    display: block;
    margin: 0;
    padding: 0;
    /* rely on pre padding */
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
    font-size: 1.02rem;
    line-height: 1.6;
    white-space: pre;
    /* preserve formatting by default */
    overflow-x: auto;
    /* scroll inside the code area */
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* Copy button (square, vertically centered) */
pre button[class*="copy"],
pre .hljs-copy,
pre .copy-button {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    z-index: 10;
    background: #fff;
    border: 1px solid rgba(59, 130, 246, 0.12);
    /* subtle blue border */
    color: var(--color-primary);
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
    transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}

pre button[class*="copy"]:hover,
pre .hljs-copy:hover,
pre .copy-button:hover {
    transform: translateY(-50%) scale(1.04);
    background: var(--color-primary);
    color: #fff;
}

/* ensure icons inside copy buttons are appropriately sized */
pre button[class*="copy"] svg,
pre .copy-button svg,
pre .hljs-copy svg {
    width: 18px;
    height: 18px;
    display: block;
}

p>code,
li>code,
dd>code,
td>code,
h1>code,
h2>code,
h3>code,
h4>code,
a>code {
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

h1>i,
h1>em,
h2>i,
h2>em,
h3>i,
h3>em,
h4>i,
h4>em,
h5>i,
h5>em,
h6>i,
h6>em {
    font-family: InterItalic, sans-serif;
    font-style: normal;
    font-weight: 600;
    color: var(--color-primary);
    line-height: 1.2;
}

a {
    /* Make inline links slightly blue for better affordance */
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 4px;

    &:visited {
        color: var(--color-primary-dim);
        text-decoration: none;
    }

    &:hover {
        color: var(--color-primary-dim);
    }
}

nav {
    background-color: var(--color-surface);
    color: var(--color-text);
    padding: 0.5rem;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    /* keep nav items on a single line; allow horizontal scroll on narrow viewports */
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: none;
}

/* Underline-only 'diff' style for nav links */
nav a,
.site-nav .navitem {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 6px;
    text-decoration-thickness: 2px;
    text-decoration-color: transparent;
    margin: 0 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.015em;
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    /* prevent individual nav links from wrapping to the next line */
    white-space: nowrap;
    transition:
        color 0.15s,
        text-decoration-color 0.15s,
        transform 0.12s;
}

nav a:hover,
.site-nav .navitem:hover {
    color: var(--color-primary-dim);
    text-decoration-color: var(--color-primary);
    transform: translateY(-1px);
}

/* Ensure visited/nav-open/mobile keep usable nav underlines */
nav a:visited,
.site-nav .navitem:visited {
    /* don't inherit the global visited rule that removes underline */
    text-decoration: underline;
    text-decoration-color: transparent;
    color: inherit;
}

@media (max-width: 900px) {

    /* Mobile: keep nav collapsed by default; reveal in-flow on `nav-open` */
    .site-nav {
        display: block;
        max-height: 0;
        overflow: hidden;
        padding: 0 0;
        transition:
            max-height 0.28s ease,
            padding 0.18s ease;
        border-top: none;
        /* remove top bar */
    }

    .site-nav a,
    .site-nav .navitem {
        display: block;
        padding: 0.35rem 0.6rem;
        margin: 0;
        text-decoration: underline;
        text-underline-offset: 4px;
        text-decoration-thickness: 1.2px;
        text-decoration-color: transparent;
        border-bottom: none;
        font-weight: 600;
        font-size: 0.95rem;
    }

    .site-nav a:hover,
    .site-nav .navitem:hover {
        text-decoration-color: var(--color-primary);
        transform: none;
        color: var(--color-primary-dim);
    }

    /* Reveal the nav in-flow when hamburger is toggled */
    body.nav-open .site-nav {
        max-height: 480px;
        /* large enough for typical menus */
        padding: 0.6rem 0;
        background: var(--color-surface);
        border-top: none;
        box-shadow: none;
    }
}

nav>.navigations>.header-element,
nav>.navigations>.header-element-author {
    font-family: Inter;
    font-size: 1.1rem;
    font-weight: 500;
}

.image-grid {
    /* margin: 1rem 0 0rem 0; */
    column-count: 2;
    column-gap: 0.5rem;
}

.image-grid>* {
    display: inline-block;
    width: 100%;
    break-inside: avoid;
}

.image-grid>*>img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    border-radius: var(--style-border-radius);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.post-list-element {
    list-style-type: none;

    margin-bottom: 5px;

    &>div {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
    }
}

ul:has(.post-list-element) {
    padding: 0;
    margin: 0;
}

.post-list-element>div>div>.post-list-title {
    color: var(--color-primary);
    font-weight: 480;
}

.post-list-description {
    color: var(--color-text-dim);
    padding: 0;
    margin: 0;
}

.post-list-date {
    color: var(--color-text-dim);
    min-width: 100px;
    margin-left: 10px;
}

/* Tags listing - display as chips and grid on mobile */
.all-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
}

.all-tags a {
    display: inline-block;
    padding: 0.42rem 0.8rem;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    transition:
        background 0.12s,
        color 0.12s,
        transform 0.08s;
}

.all-tags a:hover {
    background: var(--color-primary);
    color: var(--color-background);
    transform: translateY(-2px);
}

@media (max-width: 900px) {
    .all-tags {
        gap: 0.4rem;
        padding: 0.6rem 0;
    }

    .all-tags a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 0.6rem 0.75rem;
        font-size: 0.95rem;
    }
}

/* Tag subpage list of posts */
.tagged-posts {
    display: grid;
    gap: 0.6rem;
    max-width: var(--style-container-width);
    margin: 0 auto;
    padding: 0.6rem 0;
}

.tagged-posts a {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-background);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
}

.tagged-posts a:hover {
    background: var(--inline-code-bg);
}

iframe {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    display: block;
    margin-left: auto;
    margin-right: auto;

    border: none;
    color: var(--color-text);
    background-color: var(--color-background);
}

/* iframe stylings */
.twitter-tweet {
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    height: auto;
}

pre {
    position: relative;
    overflow: visible;
    /* ensure button isn't clipped */
}

pre code {
    overflow-x: scroll;
    font-family: JuliaMono, monospace;
    font-variant-ligatures: common-ligatures;
    font-feature-settings: "liga" on;
    background-color: var(--inline-code-bg);
    line-height: 1.3;
    font-size: 0.95rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-inline: 0.5rem;
    padding-inline-end: 1.2rem;
    /* reduced inline-end space; copy button is absolutely positioned */
    box-sizing: border-box;
}

/* Copy button placed inside code blocks (works with highlightjs copy plugin) */
pre button[class*="copy"],
pre .hljs-copy,
pre .copy-button {
    position: absolute;
    top: 8px;
    right: 10px;
    /* nudge slightly inward for better overlap */
    z-index: 10;
    /* blend into the pre card: use the same background and mask the underlying border */
    background: var(--inline-code-bg);
    border: 1px solid rgba(0, 0, 0, 0.04);
    /* add a left border that matches the card background to mask the pre border */
    border-left: 1px solid var(--inline-code-bg);
    color: var(--color-text);
    padding: 0.18rem 0.45rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(2, 6, 23, 0.04);
    transition:
        background 0.12s,
        transform 0.08s,
        box-shadow 0.08s;
}

/* Removed right-edge mask; keep copy button flush with the card */
@media (min-width: 481px) {

    pre button[class*="copy"],
    pre .hljs-copy,
    pre .copy-button {
        right: 8px;
    }
}

/* Ensure code blocks are constrained to the page container and are touch-friendly.
   - width/max-width prevents the pre element from escaping the container
   - overscroll-behavior/touch-action keep panning inside the code block on mobile
   - pre>code min-width:0 lets inner blocks shrink instead of forcing overflow in flex contexts */
pre {
    width: 100%;
    /* ensure pre never exceeds the page container; subtract a small margin for padding/copy button */
    max-width: calc(100% - 2rem);
    margin: 0;
    /* don't let pre add extra margins outside the container */
    box-sizing: border-box;
    overscroll-behavior: contain;
    touch-action: pan-x;
    -webkit-text-size-adjust: 100%;
}

/* Make inner code cooperate with narrow containers and allow scrolling within */
pre>code,
pre .hljs,
pre * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

pre>code {
    overflow-wrap: normal;
    white-space: pre;
    /* preserve line breaks and allow horizontal scrolling */
}

/* Ensure links or very long tokens inside code do not blow out the layout; they scroll inside pre */
pre a {
    word-break: break-word;
    overflow-wrap: anywhere;
    color: inherit;
}

pre button[class*="copy"]:hover,
pre .hljs-copy:hover,
pre .copy-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 700px) {

    pre button[class*="copy"],
    pre .hljs-copy,
    pre .copy-button {
        top: 6px;
        right: 10px;
        /* pull slightly inwards to avoid edge cropping */
        font-size: 0.75rem;
        padding: 0.1rem 0.3rem;
    }

    /* Ensure code has right padding on mobile so the scroller doesn't hide button */
    pre code {
        padding-inline-end: 2.5rem;
    }
}

/* Extra safety for very small screens: allow long code lines to wrap instead of causing
   the page to zoom or overflow. On larger screens we still prefer horizontal scrolling. */

pre>code {
    display: block;
    text-indent: 0;
    /* use pre to preserve whitespace so scrolling is predictable */
    white-space: pre;
    box-sizing: border-box;
}

/* Make code blocks horizontally scrollable inside their own container
   to prevent page-level horizontal overflow on small screens */
pre {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    /* keep copy button positioned inside the pre */
}

pre>code {
    display: block;
    min-width: 100%;
    /* ensure scroller appears for long lines */
    white-space: pre;
    box-sizing: border-box;
}

p>code,
li>code,
dd>code,
td>code,
h1>code,
h2>code,
h3>code,
h4>code,
a>code {
    font-family: JuliaMono, monospace;
    color: var(--color-heading);
    background-color: var(--inline-code-bg);
    /* Allow inline code to wrap on small viewports */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-decoration-break: clone;
    padding: 0.1rem;
    padding-inline: 0.4rem;
    font-size: 1.05rem;
}

.video-container-1610 {
    position: relative;
    padding-bottom: 62.5%;
    height: 0;
    margin-bottom: 0.5rem;
}

.video-container-1610 iframe {
    margin-bottom: 0.5rem;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    margin-bottom: 0.5rem;
}

.video-container iframe {
    margin-bottom: 0.5rem;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Lastfm CSS */
#lastfm {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#lastfm .lastfm-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#lastfm .lastfm-row {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    align-items: center;
    gap: 1.2rem;
    padding: 0.45rem 0.45rem;
    border-bottom: 1px solid var(--color-text-low, #e0e0e0);
}

#lastfm .lastfm-row.now-playing {
    background-color: var(--inline-code-bg);
    padding: 0.75rem;
    padding-left: calc(0.75rem + 10px);
    padding-right: calc(0.75rem + 10px);
    border-bottom: none;
    margin: 0 -10px 0.75rem -10px;
}

#lastfm .lastfm-row:last-child {
    border-bottom: none;
}

#lastfm .cover {
    width: 56px;
    height: 56px;
    border: 1px solid var(--color-text-low, #dcdcdc);
    object-fit: cover;
    background: var(--color-surface, #f8f8f8);
    flex-shrink: 0;
}

#lastfm .meta {
    min-width: 0;
    flex: 1;
}

#lastfm .title {
    font-family: Inter, sans-serif;
    font-weight: 600;
    text-decoration: none;
    color: var(--color-heading, inherit);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

#lastfm .title:hover {
    text-decoration: underline;
}

#lastfm .artist {
    margin: 0.25rem 0 0;
    color: var(--color-text-dim, #666);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: Inter, sans-serif;
    font-weight: 400;
}

#lastfm .time {
    color: var(--color-text-dim, #999);
    font-size: 0.95rem;
    white-space: nowrap;
    text-align: right;
    flex-shrink: 0;
    font-family: Inter, sans-serif;
}

:root {
    --color-text: #24292f;
    --color-text-dim: #656d76;
    --color-text-low: #656d7690;

    --color-background: #ffffff;
    --color-background-dim: #ffffff7a;
    --color-background-low: #ffffff50;
    --color-background-contrast: #0969da;

    --inline-code-bg: #f6f8fa;
    --selection-bg: #0969da1a;

    --color-primary: #0969da;
    --color-primary-dim: #0969daef;
    --color-primary-low: #0969da1a;

    --color-border: #d1d9e0;
    /* subtle horizontal rule color (lighter than border) */
    --color-hr: rgba(2, 6, 23, 0.06);
    --color-surface: #f6f8fa;

    --style-border-radius: 6px;
    --style-border-radius-hover: 6px;
    --style-hover-scale: 1;
    --style-container-width: 40rem;

    --style-body-font: 1.1rem;
    --style-body-font-mobile: 1.1rem;

    --animation-bezier: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@font-face {
    font-family: monospace;
    src: url(/static/fonts/mono/JuliaMono.ttf);
    font-display: swap;
}

/* Inter font: removed local @font-face so browser will use Google-hosted Inter imported at the top of this file. */
/* If you want a local fallback, add a valid URL to the font files here. */

@supports (font-variation-settings: normal) {
    :root {
        font-family: Inter;
    }
}

/* InterItalic font: removed local @font-face so browser will use Google-hosted italic variant from the Inter family. */
/* If you want a local fallback, add a valid URL to the font files here. */

/* Desktop wide layout handled via .container; remove body max-width to avoid left-alignment */
@media (min-width: 900px) {

    /* keep container sizing only */
    .container {
        max-width: 58rem;
    }
}

/* Header spacing */
.site-header {
    padding: 0.75rem 0;
    position: relative;
    /* allow absolute mobile nav to position relative to header */
    z-index: 20;
}

.site-header .container {
    align-items: center;
}

/* Header and footer layout */
.site-header,
.site-footer {
    border-bottom: none;
    background: var(--color-surface);
}

.header-inner,
.footer-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
}

.brand a {
    display: inline-block;
    text-decoration: none;
    line-height: 1;
}

.brand-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    margin-right: 0.75rem;

    /* static by default — keep header calm; hover provides lift */
    position: relative;
    transform-origin: center;
    will-change: transform;
    animation: none !important;
}

.brand-logo:hover {
    transform: translateY(-4px) scale(1.06) rotate(-3deg);
    filter: drop-shadow(0 8px 18px rgba(2, 6, 23, 0.12));
}

@keyframes brand-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px) scale(1.03);
    }
}

@keyframes brand-shine {

    /* rest: small visible sheen, then quick strong sweep */
    0%,
    70% {
        transform: translateX(-40%) skewX(-20deg);
        opacity: 0.18;
    }

    75% {
        transform: translateX(-60%) skewX(-20deg);
        opacity: 0.95;
    }

    85% {
        transform: translateX(60%) skewX(-20deg);
        opacity: 0.95;
    }

    95%,
    100% {
        transform: translateX(150%) skewX(-20deg);
        opacity: 0.18;
    }
}

@media (prefers-reduced-motion: reduce) {

    .brand-logo,
    .brand-logo::after {
        animation: none !important;
        transition: none !important;
    }

    /* keep a subtle static sheen for reduced-motion users */
    .brand-logo::after {
        opacity: 0.12;
        filter: blur(1px);
    }

    /* styles handled by nav a, kept for markup compatibility */
}

/* subtle sheen for the logo (static, no animation) */
.brand-logo::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.95) 50%,
            rgba(255, 255, 255, 0) 100%);
    background-size: 30% 100%;
    background-repeat: no-repeat;
    transform: translateX(-40%) skewX(-20deg);
    opacity: 0.18;
    pointer-events: none;
    filter: blur(2px);
    animation: none !important;
}

.site-nav .navitem:hover {
    /* hover handled by unified nav styles above */
}

.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.actions button {
    background: transparent;
    border: 1px solid var(--color-border);
    padding: 0.2rem;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
}

.actions button>* {
    pointer-events: none;
}

.actions button:hover {
    transform: translateY(-1px);
}

@media (min-width: 900px) {

    /* hide mobile hamburger on desktop */
    .hamburger {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none;
    }
}

@media (max-width: 900px) {

    /* make action buttons even smaller on mobile */
    .actions button {
        width: 32px;
        height: 32px;
    }
}

@media (min-width: 900px) {

    /* Ensure any residual `nav-open` state does not trigger the mobile overlay on desktop */
    body.nav-open .site-nav {
        display: flex;
        position: static;
        box-shadow: none;
    }
}

/* Footer tweaks */
.site-footer {
    border-top: none;
    border-bottom: none;
    padding: 0.75rem 0;
}

/* Optional subtle separator for very short content pages */
.site-footer--separated {
    border-top: 1px solid var(--color-border);
}

.footer-inner {
    font-size: 0.95rem;
    color: var(--color-text-dim);
}

/* Search overlay and box - center to the page container */
.search-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    /* subtle backdrop blur for focus */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
}

.search-overlay.open {
    display: flex;
}

/* Slightly smaller search box to match screenshot, centered with fixed positioning */
.search-box {
    background: var(--color-background);
    color: var(--color-text);
    padding: 0.75rem;
    border-radius: 10px;
    width: calc(100% - 2rem);
    max-width: 46rem;
    /* match container */
    box-shadow: 0 6px 20px rgba(2, 6, 23, 0.08);
    border: 1px solid var(--color-border);

    /* center the dialog relative to the viewport */
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;

    /* keep the box from overflowing when keyboard opens or on very short viewports */
    max-height: calc(100vh - 4rem);
    overflow: auto;
}

/* prefer the modern dynamic viewport unit when available for mobile browsers */
@supports (height: 100dvh) {
    .search-box {
        max-height: calc(100dvh - 4rem);
    }
}

/* Input row: keep input and button aligned */
.search-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-input-row input[type="text"] {
    flex: 1 1 auto;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    background: transparent;
    color: var(--color-text);
}

.search-box .close-search {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.search-hint {
    margin-top: 0.45rem;
    font-size: 0.85rem;
    color: var(--color-text-dim);
}

.search-results {
    margin-top: 0.6rem;
    max-height: 50vh;
    overflow-y: auto;
}

/* Ensure footer container respects alignment; header uses .header-inner grid */
.site-footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* allow the footer to wrap on narrow viewports to avoid horizontal overflow */
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Small screens: stack footer items and center them so they don't exceed viewport */

/* Ensure long inline elements in footer (links, copyright etc.) wrap */
.site-footer .container a,
.site-footer .container * {
    overflow-wrap: anywhere;
    word-break: break-word;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.embed-item {
    /* make the card float with a bouncy, cartoony rhythm (slower) */
    --float-duration: 7s;
    animation: float var(--float-duration) cubic-bezier(0.22, 1.5, 0.35, 1) infinite;
}

/* Slightly exaggerate the hover lift to feel playful */
.embed-item:hover {
    transform: translateY(-14px) scale(1.04);
    box-shadow: 0 28px 60px rgba(2, 6, 23, 0.16);
}