/* ==========================================================================
   sly-modern.css — single-column layout, topbar, breadcrumb, heroic figures
   Loaded last: overrides style.less + dark-theme.less + sly-colors.css.
   All colors via sly-colors.css tokens; theme via html[data-theme].
   ========================================================================== */

:root {
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-mono: 'Source Code Pro', ui-monospace, 'SF Mono', Consolas, monospace;
    --container-w: 1200px;
    /* rem (root-relative) so the cap is identical for body prose AND larger
       headings; a `ch` value would resolve against each element's own font
       and let h2/h3 run ~1.5x wider than paragraphs. ~76 chars at body size. */
    --measure: 40rem;
    --radius: 6px;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 4.5rem;
    overflow-x: clip;
}

/* --------------------------------------------------------------------------
   Layout revolution: kill the sidebar, free the column
   -------------------------------------------------------------------------- */

aside {
    display: none;
}

main {
    padding-left: 0;
    height: auto;
    position: relative;
}

.container {
    max-width: var(--container-w);
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 3rem) 2rem;
}

/* Legacy Flex rules leak into in-<main> navs and articles:
   `main nav { font-size:0; text-transform:uppercase; text-align:center;
                padding:14px 0; border-bottom:... }` and `main article { margin:0 8% }`.
   The font-size:0 is especially dangerous: it zeroes the `ch` unit, so any
   `max-width: var(--measure)` (74ch) on these navs collapses to 0px.
   Reset both with specificity that beats `main nav` / `main article`. */
/* Free the article element from the legacy `main article { max-width: 760px }`
   media-query rule (style.less) so breakout figures reach the full container.
   Prose readability is preserved separately via the per-element --measure caps
   below. `.container article` covers article.single, index entries, and pages. */
main .container article {
    max-width: none;
    margin: 0;
}

main .breadcrumb,
main .toc-inline {
    font-size: 1rem;
    text-transform: none;
    text-align: left;
    border-bottom: none;
    padding: 0;
}

body {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.75;
    margin: 0;
    padding: 0;
}

img {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   Reading progress bar
   -------------------------------------------------------------------------- */

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--fox-rust), var(--fox-orange));
    z-index: 300;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.55rem clamp(1rem, 4vw, 3rem);
    background: color-mix(in oklch, var(--bg-base) 82%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--ember-deep);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    flex-shrink: 0;
}

.topbar-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 0;
    background-color: var(--logo-fg);
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-mode: alpha;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    mask-mode: alpha;
}

/* Full-bleed hero: spans the viewport edge to edge. The image keeps its
   natural aspect ratio because the template sets no width/height attributes
   and CSS uses height:auto (object-fit can't distort a height:auto box). */
.article-hero {
    margin: 0 0 1.75rem;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.article-hero img {
    display: block;
    width: 100%;
    height: auto;
}

.topbar-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.topbar-nav a {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    color: var(--text-secondary);
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    border-right: none;
    text-decoration: none;
    transition: color 120ms ease, background-color 120ms ease;
}

.topbar-nav a:hover {
    color: var(--fox-amber);
    background: var(--bg-elevated);
}

.topbar-nav a.active {
    color: var(--fox-orange);
}

.topbar-theme-toggle {
    margin-left: 0.5rem;
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--ember-deep);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    transition: color 120ms ease, border-color 120ms ease;
}

.topbar-theme-toggle:hover {
    color: var(--fox-amber);
    border-color: var(--fox-rust);
}

@media (max-width: 640px) {
    .topbar {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .topbar-nav {
        margin-left: 0;
        width: 100%;
        order: 3;
    }
}

/* --------------------------------------------------------------------------
   Breadcrumb
   -------------------------------------------------------------------------- */

.breadcrumb {
    margin: 1.25rem 0 0;
    font-size: 0.75rem;
}

.breadcrumb ol {
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    min-width: 0;
}

.breadcrumb li {
    display: flex;
    align-items: baseline;
    flex-shrink: 0;
    min-width: 0;
}

.breadcrumb li + li::before {
    content: "/";
    margin: 0 0.45rem;
    color: var(--ember-soft);
}

.breadcrumb li:last-child {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--fox-amber);
}

.breadcrumb-current {
    display: block;
    min-width: 0;
    color: var(--fox-amber);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    line-height: 1.25;
    font-weight: 600;
}

article.single > div h2 {
    font-size: 1.55rem;
    margin: 2.4rem 0 0.8rem;
}

article.single > div h3 {
    font-size: 1.25rem;
    margin: 2rem 0 0.6rem;
}

article.single > div h4 {
    font-size: 1.05rem;
    margin: 1.6rem 0 0.5rem;
}

article.single > div p {
    margin: 0.9rem 0;
}

article.single > div a,
.index-summary a {
    text-decoration: underline;
    text-decoration-color: var(--ember-deep);
    text-underline-offset: 3px;
    transition: text-decoration-color 120ms ease;
}

article.single > div a:hover,
.index-summary a:hover {
    text-decoration-color: var(--fox-orange);
}

:not(pre) > code {
    font-family: var(--font-mono);
    font-size: 0.87em;
    color: var(--fox-amber);
    background-color: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    padding: 0.1em 0.4em;
}

/* --------------------------------------------------------------------------
   Article header
   -------------------------------------------------------------------------- */

.article-kicker {
    margin: 2.5rem 0 0.6rem;
}

.article-kicker a {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ember-soft);
    text-decoration: none;
    border-bottom: 1px solid var(--ember-deep);
    padding-bottom: 2px;
}

.article-kicker a:hover {
    color: var(--fox-amber);
    border-color: var(--fox-rust);
}

article.single header h1 {
    font-size: clamp(1.9rem, 4.2vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.2em 0 0.3em;
    max-width: 24ch;
}

.article-meta {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 1rem;
}

.article-meta time {
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Prose measure + breakout: readable text, heroic figures
   -------------------------------------------------------------------------- */

article.single > div > p,
article.single > div > ul,
article.single > div > ol,
article.single > div > blockquote,
article.single > div > h2,
article.single > div > h3,
article.single > div > h4,
article.single > div > h5,
article.single > div > h6,
article.single > div > hr {
    max-width: var(--measure);
}

article.single > div > ul,
article.single > div > ol {
    padding-left: 1.4rem;
}

article.single > div > .mermaid,
article.single > div > table,
article.single > div > div.highlight,
article.single > div > pre,
article.single > div > figure {
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   Mermaid — full-width stage
   -------------------------------------------------------------------------- */

.mermaid {
    background: var(--bg-surface);
    border: 1px solid var(--ember-deep);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
    overflow-x: auto;
    cursor: zoom-in;
}

.mermaid svg {
    max-width: 100%;
    height: auto !important;
    display: block;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Zoom dialog (click a diagram or figure image)
   -------------------------------------------------------------------------- */

/* Zoom dialog — fullscreen, pannable, zoomable image/SVG viewer */
.zoom-dialog {
    border: none;
    background: var(--bg-base);
    color: var(--text-primary);
    border-radius: 0;
    padding: 0;
    margin: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
}

.zoom-dialog::backdrop {
    background: oklch(0.07 0.02 260 / 0.92);
    backdrop-filter: blur(4px);
}

.zoom-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--ember-deep);
    background: color-mix(in oklch, var(--bg-surface) 82%, transparent);
}

.zoom-title {
    margin-right: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.zoom-btn {
    width: 2.1rem;
    height: 2.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    line-height: 1;
    color: var(--text-primary);
    background: var(--bg-base);
    border: 1px solid var(--ember-deep);
    border-radius: var(--radius);
    cursor: pointer;
}

.zoom-btn:hover,
.zoom-btn:focus-visible {
    color: var(--fox-orange);
    border-color: var(--fox-orange);
    outline: none;
}

.zoom-stage {
    flex: 1 1 auto;
    display: flex;
    overflow: auto;
    touch-action: none;
    cursor: grab;
    background:
        repeating-conic-gradient(
            color-mix(in oklch, var(--bg-surface) 90%, transparent) 0% 25%,
            transparent 0% 50%) 50% / 22px 22px,
        var(--bg-base);
}

.zoom-stage.grabbing {
    cursor: grabbing;
}

.zoom-content {
    margin: auto;
    padding: 1.5rem;
}

.zoom-content img,
.zoom-content svg {
    display: block;
    margin: 0 auto;
    max-width: none !important;
    height: auto !important;
}

/* --------------------------------------------------------------------------
   Tables — full width, scroll on overflow
   -------------------------------------------------------------------------- */

article.single table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.92rem;
}

article.single th {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    text-align: left;
    padding: 0.6rem 0.9rem;
}

article.single td {
    padding: 0.55rem 0.9rem;
}

/* --------------------------------------------------------------------------
   Code blocks — copy button
   -------------------------------------------------------------------------- */

pre {
    font-family: var(--font-mono);
    font-size: 0.86rem;
    line-height: 1.65;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    margin: 1.75rem 0;
    overflow-x: auto;
}

.code-wrap {
    position: relative;
    max-width: 100%;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms ease, color 120ms ease, border-color 120ms ease;
}

.code-wrap:hover .copy-btn,
.copy-btn:focus-visible {
    opacity: 1;
}

.copy-btn:hover {
    color: var(--fox-amber);
}

.copy-btn.copied {
    color: var(--forest);
    border-color: var(--forest);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Blockquotes / citations
   -------------------------------------------------------------------------- */

article.single blockquote {
    margin: 1.5rem 0;
    padding: 0.5rem 1.3rem;
    border-left: 3px solid var(--fox-rust);
    color: var(--text-secondary);
    font-size: 0.94em;
    font-weight: 400;
}

article.single blockquote p {
    margin: 0.5em 0;
}

article.single blockquote a {
    text-decoration: underline;
    text-decoration-color: var(--ember-deep);
    text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Tag pills
   -------------------------------------------------------------------------- */

.tag-pills {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    margin: 2.75rem 0 1rem;
}

.tag-pills a {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    color: var(--ember-soft);
    background: var(--bg-surface);
    border: 1px solid var(--ember-deep);
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
    text-decoration: none;
    transition: color 120ms ease, border-color 120ms ease;
}

.tag-pills a:hover {
    color: var(--fox-amber);
    border-color: var(--fox-rust);
}

/* --------------------------------------------------------------------------
   Table of contents — inline details + fixed rail on very wide screens
   -------------------------------------------------------------------------- */

.toc-inline {
    max-width: var(--measure);
    margin: 0 0 2.25rem;
    font-size: 1rem;
}

.toc-inline details {
    border: 1px solid var(--ember-deep);
    border-radius: var(--radius);
    background: var(--bg-surface);
    padding: 0.65rem 1.1rem;
}

.toc-inline summary {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    cursor: pointer;
}

.toc-inline summary:hover {
    color: var(--fox-amber);
}

.toc ol {
    list-style: none;
    margin: 0.7rem 0 0.2rem;
    padding: 0;
    font-size: 0.88rem;
}

.toc li {
    margin: 0.35rem 0;
}

.toc li.toc-h3 {
    padding-left: 0.9rem;
}

.toc a {
    color: var(--text-secondary);
    text-decoration: none;
}

.toc a:hover {
    color: var(--fox-amber);
}

.toc a.active {
    color: var(--fox-orange);
}

.toc-rail {
    display: none;
}

@media (min-width: 1700px) {
    .toc-rail {
        display: block;
        position: fixed;
        top: 5.5rem;
        /* sit in the gutter just outside the centered 1200px container: the
           container's right edge is at 50vw + 600px, so pin the rail's left edge
           24px beyond it. box-sizing:border-box keeps the padded panel within
           width so it never overlaps breakout figures or overflows the viewport. */
        left: calc(50vw + 624px);
        right: auto;
        box-sizing: border-box;
        width: 210px;
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        scrollbar-width: none;
        font-size: 0.8rem;
        padding: 0.9rem 1.1rem;
        border: 1px solid var(--ember-deep);
        border-radius: var(--radius);
        background: color-mix(in oklch, var(--bg-base) 78%, transparent);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        box-shadow: 0 8px 28px color-mix(in oklch, var(--bg-base) 50%, transparent);
        opacity: 1;
        transform: translateX(0);
        transition: opacity 220ms ease, transform 220ms ease;
    }

    .toc-rail::-webkit-scrollbar {
        display: none;
    }

    /* faded out while the full-bleed hero is on screen (toggled by sly-modern.js)
       so the panel never overlaps the cover image */
    .toc-rail.is-hidden {
        opacity: 0;
        transform: translateX(10px);
        pointer-events: none;
    }

    .toc-rail h4 {
        font-family: var(--font-mono);
        font-size: 0.7rem;
        font-weight: 400;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        color: var(--text-muted);
        margin: 0 0 0.7rem;
    }

    .toc-inline {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   Index — editorial list
   -------------------------------------------------------------------------- */

.index-intro {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    margin: 2.25rem 0 1rem;
}

.index-entry {
    padding: 1.9rem 0;
    border-bottom: 1px solid var(--ember-deep);
}

.index-entry:last-of-type {
    border-bottom: none;
}

.index-entry h2 {
    font-size: 1.4rem;
    margin: 0 0 0.35rem;
}

.index-entry h2 a {
    color: var(--text-primary);
    text-decoration: none;
}

.index-entry h2 a:hover {
    color: var(--fox-amber);
}

.index-meta {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-muted);
    margin: 0 0 0.9rem;
}

.index-meta a {
    color: var(--ember-soft);
    text-decoration: none;
}

.index-meta a:hover {
    color: var(--fox-amber);
}

.index-summary {
    color: var(--text-secondary);
    max-width: var(--measure);
}

.index-summary p {
    margin: 0.6em 0;
}

.index-featured {
    padding-top: 2.75rem;
}

.index-featured h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
}

.index-featured h2 a {
    line-height: 1.2;
}

.index-featured .index-summary {
    font-size: 1.08rem;
}

.index-more {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fox-orange);
    text-decoration: none;
    display: inline-block;
    margin-top: 0.7rem;
}

.index-more:hover {
    color: var(--fox-amber);
}

/* --------------------------------------------------------------------------
   Neighbors (prev/next) + related posts — styled for when plugins land
   -------------------------------------------------------------------------- */

.neighbors {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 3rem 0 1rem;
    height: auto;
}

.neighbors .btn {
    float: none;
    flex: 1 1 220px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--bg-surface);
    border: 1px solid var(--ember-deep);
    color: var(--text-secondary);
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius);
    text-decoration: none;
    transition: border-color 120ms ease, color 120ms ease;
}

.neighbors .btn:hover {
    border-color: var(--fox-rust);
    color: var(--fox-amber);
}

.related-posts {
    border-top: 1px solid var(--ember-deep);
    margin-top: 2.5rem;
    padding-top: 1.25rem;
}

.related-posts h4 {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --------------------------------------------------------------------------
   Pagination + footer
   -------------------------------------------------------------------------- */

.pagination {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding: 2.5rem 0 1rem;
    margin: 0;
    height: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

main footer {
    border-top: 1px solid var(--ember-deep);
    padding: 1.75rem clamp(1rem, 4vw, 3rem);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-muted);
}

main footer p {
    max-width: var(--container-w);
    margin: 0.3rem auto;
}

/* --------------------------------------------------------------------------
   Scroll reveal (JS adds .reveal-target; default stays visible without JS)
   -------------------------------------------------------------------------- */

.reveal-target {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 320ms ease, transform 320ms ease;
}

.reveal-target.revealed {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .reveal-target {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
