/* =========================================================
   CASE STUDY
   ========================================================= */

.case-hero {
    width: min(calc(100% - 48px), var(--max));
    margin: 0 auto;
    padding: 180px 0 120px;

    border-bottom: 1px solid var(--line);
}

.case-hero-copy {
    max-width: 950px;
}

.case-hero h1 {
    margin: 25px 0;

    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(4rem, 8vw, 8rem);
    line-height: .88;
    letter-spacing: -.065em;
}

.case-hero h1 span {
    color: var(--accent);
}

.case-intro {
    max-width: 650px;

    margin: 35px 0;

    color: var(--muted);

    font-size: 1.2rem;
    line-height: 1.6;
}

.case-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 45px;

    margin-top: 45px;
}

.case-meta div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.case-meta span,
.mini-label {
    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    letter-spacing: .1em;
}

.case-meta strong {
    font-weight: 500;
}

.case-hero-video {
    position: relative;

    min-height: 700px;

    margin-top: 80px;

    border: 1px solid var(--line);

    background:
        radial-gradient(
            circle at 50% 45%,
            rgba(85,214,255,.10),
            transparent 28%
        ),
        var(--surface);

    overflow: hidden;
}

.case-hero-video::before,
.media-placeholder::before,
.experiment-media::before {
    content: "";

    position: absolute;
    inset: 0;

    opacity: .25;

    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);

    background-size: 40px 40px;
}

.video-placeholder,
.media-placeholder,
.experiment-media {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .65rem;
    letter-spacing: .12em;
}

.video-placeholder strong {
    position: absolute;

    width: 75px;
    height: 75px;

    display: grid;
    place-items: center;

    border: 1px solid var(--accent);
    border-radius: 50%;

    color: var(--accent);

    font-size: 1rem;
}



/* =========================================================
   GENERAL SECTIONS
   ========================================================= */

.case-section {
    width: min(calc(100% - 48px), var(--max));

    margin: 0 auto;

    padding: 150px 0;

    display: grid;
    grid-template-columns: 220px 1fr;

    gap: 70px;

    border-bottom: 1px solid var(--line);
}

.case-section-title {
    padding-top: 8px;

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .68rem;
    letter-spacing: .1em;
}

.case-section-content {
    max-width: 950px;
    min-width: 0;
}

.case-section-content h2 {
    margin: 0 0 40px;

    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(2.8rem, 5vw, 5rem);
    line-height: .95;
    letter-spacing: -.055em;
}

.case-section-content > p {
    max-width: 720px;

    color: var(--muted);

    font-size: 1.05rem;
}

.dark-section {
    width: 100%;
    padding-left: max(24px, calc((100vw - var(--max)) / 2));
    padding-right: max(24px, calc((100vw - var(--max)) / 2));

    background: var(--surface);
}

.case-hero video {
    display: block;
    width: 100%;
    max-width: 70vw;
    height: auto;
    margin-top: 40px;
    border: 1px solid var(--line);
}

.case-section-content video {
    display: block;
    width: 100%;
    height: auto;
    margin: 40px 0;
    border: 1px solid var(--line);
}

/* =========================================================
   ARCHITECTURE
   ========================================================= */

.architecture {
    margin: 70px 0;

    display: flex;
    align-items: center;
    gap: 15px;
}

.architecture-node {
    flex: 1;

    min-height: 150px;

    padding: 20px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    border: 1px solid var(--line);

    background: var(--bg);
}

.architecture-node span {
    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .65rem;
}

.architecture-node strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.1rem;
}

.architecture-node small {
    color: var(--muted);
    font-size: .72rem;
}

.architecture-arrow {
    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
}

.architecture-note {
    font-family: "IBM Plex Mono", monospace;
    font-size: .75rem !important;
}



/* =========================================================
   MEDIA
   ========================================================= */

.media-block {
    position: relative;

    aspect-ratio: 16 / 9;

    margin: 70px 0;

    border: 1px solid var(--line);

    background: var(--surface);

    overflow: hidden;
}

.media-block video {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    margin: 0;
    border: 0;

    display: block;
    object-fit: cover;
}

.media-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;

    padding: 18px;

    background: linear-gradient(to top, rgba(11, 13, 15, .85), transparent);

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .65rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}



/* =========================================================
   TWO COLUMN TEXT
   ========================================================= */

.two-column-text {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 70px;
}

.two-column-text p {
    color: var(--muted);
}



/* =========================================================
   FEATURE GRID
   ========================================================= */

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);

    gap: 40px;

    margin-top: 70px;
}

.feature-grid > div {
    padding-top: 20px;

    border-top: 1px solid var(--line);
}

.feature-grid span {
    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .65rem;
}

/* a section that runs long enough to need a second beat inside it - there is
   no generic h3 on these pages, so this is the one that gets styled */
.case-section-content .subhead {
    max-width: 650px;

    margin: 70px 0 -10px;

    font-family: "Space Grotesk", sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.035em;
}

.feature-grid h3 {
    margin: 25px 0 10px;

    font-family: "Space Grotesk", sans-serif;
    font-size: 1.5rem;
}

.feature-grid p {
    color: var(--muted);
}



/* =========================================================
   LEARNING FLOW
   ========================================================= */

/* Seven boxes and six arrows. This used to be one non-wrapping row with
   overflow-x: auto, which overflowed by a hair at every width and put a
   scrollbar under the diagram - a scrollbar being, for a pipeline you are
   meant to read at a glance, the worst possible affordance. It wraps now,
   and goes vertical on narrow screens where a row can't work at all. */

.learning-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;

    margin: 70px 0;
}

.learning-flow div {
    flex-shrink: 0;

    padding: 14px 16px;

    border: 1px solid var(--line);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    white-space: nowrap;
}

.learning-flow span {
    color: var(--accent);

    /* an arrow is a joint, not a step - it should never be the widest thing
       on a wrapped line, nor start one on its own */
    line-height: 1;
}



/* =========================================================
   EXPERIMENTS
   ========================================================= */

.experiment {
    display: grid;
    grid-template-columns: 1.2fr 1fr;

    gap: 60px;

    margin-top: 70px;
}

.experiment-media {
    position: relative;

    min-height: 450px;

    border: 1px solid var(--line);
}

.experiment h3 {
    margin: 15px 0;

    font-family: "Space Grotesk", sans-serif;
    font-size: 2rem;
}

.experiment strong {
    display: block;

    margin-top: 30px;

    font-family: "IBM Plex Mono", monospace;
    font-size: .7rem;
    text-transform: uppercase;
}



/* =========================================================
   STATUS
   ========================================================= */

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);

    gap: 12px;

    margin-top: 70px;
}

.status {
    min-height: 130px;

    padding: 25px;

    display: grid;
    grid-template-columns: 35px 1fr;
    grid-template-rows: auto auto;

    border: 1px solid var(--line);
}

.status span {
    grid-row: 1 / 3;

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
}

.status.complete span {
    color: var(--accent);
}

.status strong {
    font-family: "Space Grotesk", sans-serif;
}

.status small {
    color: var(--muted);
}



/* =========================================================
   NEXT
   ========================================================= */

.case-next {
    width: min(calc(100% - 48px), var(--max));

    margin: 0 auto;

    padding: 180px 0;

    text-align: center;
}

.case-next h2 {
    max-width: 900px;

    margin: 25px auto;

    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(3rem, 6vw, 6rem);
    line-height: .9;
    letter-spacing: -.06em;
}

.case-next > p:not(.eyebrow) {
    max-width: 600px;

    margin: 35px auto;

    color: var(--muted);
}



/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 900px) {

    .case-hero {
        padding-top: 140px;
    }

    .case-hero-video {
        min-height: 450px;
    }

    .case-hero video {
        max-width: 100%;
    }

    .case-section {
        grid-template-columns: 1fr;

        gap: 35px;

        padding-top: 100px;
        padding-bottom: 100px;
    }

    .architecture {
        flex-direction: column;
        align-items: stretch;
    }

    .architecture-arrow {
        text-align: center;
    }

    .two-column-text,
    .feature-grid,
    .experiment,
    .status-grid {
        grid-template-columns: 1fr;
    }

}

/* =========================================================
   FUTURE ROADMAP
   ========================================================= */

.future-roadmap {
    position: relative;

    display: grid;
    grid-template-columns: repeat(4, 1fr);

    gap: 20px;

    margin-top: 100px;
    padding-top: 35px;
}

.roadmap-line {
    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    height: 1px;

    background: var(--line);
}

.roadmap-item {
    display: flex;
    flex-direction: column;

    gap: 12px;
}

.roadmap-item span {
    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    letter-spacing: .1em;
}

.roadmap-item strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1rem;
}


@media (max-width: 900px) {

    .future-roadmap {
        grid-template-columns: 1fr 1fr;
    }

}
/* .case-next sets its own constrained width, and because it is declared after
   .dark-section it was winning the cascade - so the closing section's grey
   background stopped at the content column instead of running edge to edge.
   Same full-bleed treatment as .dark-section, at a specificity that holds. */
.case-next.dark-section {
    width: 100%;
    padding-left: max(24px, calc((100vw - var(--max)) / 2));
    padding-right: max(24px, calc((100vw - var(--max)) / 2));
}



/* =========================================================
   MULTI-PAGE CASE STUDIES
   The muscle project outgrew one page. It's split into three
   (story / under the hood / bug journal) and everything below
   exists to make that feel like one thing, not three.
   ========================================================= */

:root {
    --warn: #ffb454;   /* open bugs */
    --hot: #ff6b8b;    /* bugs the policy found before I did */
}

/* body-copy links. The global reset strips all link styling, which is right
   for nav and wrong for "see the bug journal" in the middle of a paragraph. */
.case-section-content p a,
.bug-meta dd a {
    color: var(--accent);
    border-bottom: 1px solid rgba(85, 214, 255, .35);
    transition: border-color .2s ease;
}

.case-section-content p a:hover,
.bug-meta dd a:hover {
    border-color: var(--accent);
}

/* ---- chapter strip ------------------------------------------------------
   sits under every hero and again at the very bottom, so you always know
   which rabbit hole you're in and where the other two are. A div with
   role=navigation, not a <nav>: style.css styles bare `nav` for the header. */

.chapters {
    width: min(calc(100% - 48px), var(--max));
    margin: 0 auto;

    display: grid;
    grid-template-columns: repeat(4, 1fr);

    border-bottom: 1px solid var(--line);
}

.chapters.is-footer {
    border-top: 1px solid var(--line);
}

.chapter {
    position: relative;

    display: flex;
    flex-direction: column;
    gap: 8px;

    padding: 30px 28px 32px;

    border-left: 1px solid var(--line);

    transition: background .2s ease;
}

.chapter:first-child {
    border-left: none;
}

/* the bar across the top is the "you are here" marker */
.chapter::before {
    content: "";

    position: absolute;
    top: -1px;
    left: 0;
    right: 0;

    height: 2px;

    background: transparent;

    transition: background .2s ease;
}

.chapter:hover {
    background: var(--surface);
}

.chapter:hover::before {
    background: var(--muted);
}

.chapter[aria-current="page"] {
    background: var(--surface);
}

.chapter[aria-current="page"]::before {
    background: var(--accent);
}

.chapter span {
    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    letter-spacing: .1em;
}

.chapter strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.35rem;
    line-height: 1.1;
    letter-spacing: -.03em;
}

.chapter small {
    color: var(--muted);

    font-size: .85rem;
    line-height: 1.45;
}

/* ---- in-page index --------------------------------------------------- */

.jump-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 40px;

    margin: 55px 0 0;
    padding: 0;

    list-style: none;
}

.jump-list a {
    display: flex;
    gap: 14px;

    padding: 12px 0;

    border-top: 1px solid var(--line);

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .68rem;
    letter-spacing: .06em;
    text-transform: uppercase;

    transition: color .2s ease;
}

.jump-list a span {
    color: var(--accent);
}

.jump-list a:hover {
    color: var(--text);
}

/* ---- big numbers ------------------------------------------------------ */

.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);

    margin: 70px 0 0;

    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.stat-strip > div {
    padding: 26px 22px 24px;

    border-left: 1px solid var(--line);
}

.stat-strip > div:first-child {
    padding-left: 0;
    border-left: none;
}

.stat-strip strong {
    display: block;

    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    line-height: 1;
    letter-spacing: -.05em;
}

.stat-strip span {
    display: block;

    margin-top: 10px;

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}

/* ---- video I haven't filmed yet ---------------------------------------
   Same .media-block box as a real clip, so the page layout is already final.
   To swap one in: delete the .video-slot div and drop a <video> in its place.
   Each slot has a comment above it with the exact markup and file name. */

.media-block.is-slot {
    border-style: dashed;

    background:
        radial-gradient(circle at 50% 42%, rgba(85, 214, 255, .08), transparent 32%),
        var(--surface);
}

.video-slot {
    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;

    padding: 24px 24px 64px;

    text-align: center;
}

.video-slot::before {
    content: "";

    position: absolute;
    inset: 0;

    opacity: .2;

    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 40px 40px;
}

.video-slot-icon {
    position: relative;

    width: 64px;
    height: 64px;

    display: grid;
    place-items: center;

    border: 1px solid var(--accent);
    border-radius: 50%;

    color: var(--accent);
}

.video-slot p {
    position: relative;

    max-width: 46ch;
    margin: 0;

    color: var(--muted);

    font-size: .9rem;
    line-height: 1.5;
}

.video-slot b {
    display: block;

    margin-bottom: 6px;

    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    font-weight: 500;
    letter-spacing: .12em;
}

/* ---- bug journal ------------------------------------------------------- */

.bug-tag {
    display: block;
    width: fit-content;

    margin-top: 14px;
    padding: 5px 9px;

    border: 1px solid currentColor;

    font-family: "IBM Plex Mono", monospace;
    font-size: .6rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
}

.bug-tag.fixed   { color: var(--accent); }
.bug-tag.open    { color: var(--warn); }
.bug-tag.exploit { color: var(--hot); }

.bug-index {
    margin: 60px 0 0;

    border-top: 1px solid var(--line);
}

.bug-index a {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    align-items: center;
    gap: 20px;

    padding: 18px 0;

    border-bottom: 1px solid var(--line);
}

.bug-index .num {
    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .68rem;
}

.bug-index .title {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.25rem;
    letter-spacing: -.02em;

    transition: color .2s ease;
}

.bug-index a:hover .title {
    color: var(--accent);
}

.bug-index .bug-tag {
    margin-top: 0;
}

.bug-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 40px;

    margin: 55px 0 0;
}

.bug-meta > div {
    padding: 18px 0 20px;

    border-top: 1px solid var(--line);
}

.bug-meta dt {
    margin-bottom: 8px;

    color: var(--accent);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.bug-meta dd {
    margin: 0;

    font-size: .98rem;
    line-height: 1.55;
}

/* one subsystem switched off per row, read against gravity. The culprit row
   is the one that suddenly lands near -200. */
.bisect-wrap {
    margin: 55px 0;

    overflow-x: auto;
}

.bisect {
    width: 100%;
    min-width: 460px;

    border-collapse: collapse;

    font-family: "IBM Plex Mono", monospace;
    font-size: .74rem;
}

.bisect caption {
    caption-side: bottom;

    padding-top: 14px;

    color: var(--muted);

    font-size: .68rem;
    text-align: left;
}

.bisect th {
    padding: 0 0 12px;

    border-bottom: 1px solid var(--line);

    color: var(--accent);

    font-size: .62rem;
    font-weight: 500;
    letter-spacing: .1em;
    text-align: left;
    text-transform: uppercase;
}

.bisect td {
    padding: 13px 0;

    border-bottom: 1px solid var(--line);

    color: var(--muted);
}

.bisect th:last-child,
.bisect td:last-child {
    color: var(--text);

    text-align: right;
    white-space: nowrap;
}

.bisect tr.is-baseline td:last-child {
    color: var(--hot);
}

.bisect tr.is-culprit td {
    color: var(--text);
}

.bisect tr.is-culprit td:last-child {
    color: var(--accent);
}

/* ---- code snippets ----------------------------------------------------
   Same language as the architecture nodes: hairline border, the page's
   darkest ground, a mono label bar. Colour is rationed - cyan for keywords,
   the bug-journal amber/pink for the bits you'd actually want to read. */

.code-window {
    margin: 55px 0;

    border: 1px solid var(--line);

    background: var(--bg);
}

/* on a light-ground section --bg would vanish into the page, so step up instead */
.case-section:not(.dark-section) .code-window {
    background: var(--surface);
}

.code-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;

    padding: 12px 18px;

    border-bottom: 1px solid var(--line);

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .62rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.code-head span:first-child::before {
    content: "■ ";

    color: var(--accent);
}

.code-block {
    margin: 0;
    padding: 22px 18px 24px;

    overflow-x: auto;

    color: var(--text);

    font-family: "IBM Plex Mono", monospace;
    font-size: .78rem;
    line-height: 1.75;
    tab-size: 4;
}

/* undo the inline-code pill from style.css inside a block */
.code-block code {
    padding: 0;
    border: 0;

    background: none;
    color: inherit;

    font-size: inherit;
}

.tok-kw      { color: var(--accent); }
.tok-type    { color: #b9c4cf; }
.tok-fn      { color: var(--warn); }
.tok-const   { color: var(--hot); }
.tok-num     { color: var(--hot); }
.tok-str     { color: var(--warn); }
.tok-op      { color: var(--muted); }
.tok-comment { color: var(--muted); font-style: italic; }

.code-caption {
    margin-top: -35px;

    color: var(--muted);

    font-family: "IBM Plex Mono", monospace;
    font-size: .68rem !important;
}

/* ---- tablet: four chapters don't fit in a row ------------------------ */

@media (max-width: 1100px) {

    .chapters {
        grid-template-columns: 1fr 1fr;
    }

    .chapter:nth-child(odd) {
        border-left: none;
    }

    .chapter:nth-child(n+3) {
        border-top: 1px solid var(--line);
    }

}

/* ---- mobile ---------------------------------------------------------- */

@media (max-width: 900px) {

    .chapters {
        grid-template-columns: 1fr;
    }

    .chapter {
        padding: 22px 20px 24px;

        border-left: none;
        border-top: 1px solid var(--line);
    }

    .chapter:first-child {
        border-top: none;
    }

    .stat-strip {
        grid-template-columns: 1fr 1fr;
    }

    .stat-strip > div:nth-child(odd) {
        padding-left: 0;
        border-left: none;
    }

    .stat-strip > div:nth-child(n+3) {
        border-top: 1px solid var(--line);
    }

    /* a 16:9 box at phone width is too short to hold the filming brief, so it
       gets a min-height instead. The aspect-ratio has to go with it: keeping
       both makes the browser widen the box to honour 16:9 at 300px tall
       (~533px), which pushed every page 157px past a 400px phone screen. */
    .media-block.is-slot {
        aspect-ratio: auto;
        min-height: 300px;
    }

    /* a seven-box row has no chance at phone width, so the pipeline turns and
       reads downward instead - same order, rotated arrows, no scrolling */
    .learning-flow {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .learning-flow div {
        text-align: center;
    }

    .learning-flow span {
        align-self: center;

        transform: rotate(90deg);
    }

    .bug-index a {
        grid-template-columns: 44px 1fr;
        gap: 6px 14px;
    }

    .bug-index .bug-tag {
        grid-column: 2;
    }

    .bug-meta {
        grid-template-columns: 1fr;
    }

}
