/* ========== ROOT TOKENS ========== */
:root {
    --bg: #0e0e10;
    --text: #eaeaea;
    --muted: #b5b5b6;
    --accent: #8b5cf6;
    --accent-2: #22c1c3;
    --card: #151518;
    --gap: clamp(16px, 2.5vw, 28px);
    --radius: 16px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --hairline: color-mix(in oklab, var(--text) 12%, transparent);
    --page-pad: clamp(16px, 4vw, 56px);
    --header-h: 56px; /* matches your current header height */
    --rail-offset: 16px; /* extra gap below the fixed header when “locked” */
    --rail-btn: 44px; /* button size */
    --rail-gap: 40px; /* gap between button and content edge */
}

/* ========== LIGHT THEME (html-scoped) ========== */
html.light {
    --bg: #f7f8f9;
    --text: #0c0c0d;
    --muted: #5b5b5c;
    --card: #ffffff;
    --hairline: color-mix(in oklab, var(--text) 12%, transparent);
}

/* ========== BASE / RESETS ========== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    font: 400 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden; /* prevent stray horizontal scroll */
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
    position: relative;
}

/* ========== LAYOUT ========== */
.container {
    width: 100%;
    margin-inline: 0;
    padding-inline: var(--page-pad);
}

/* width-capped wrapper used in case study */
.wrap {
    width: min(1080px, calc(100% - 2 * var(--page-pad)));
    margin-inline: auto;
}

section {
    padding: 56px 0;
    position: relative;
}

/* full-width divider between sections (safe width) */
section + section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--hairline);
}

/* ====== Case study typography & helpers (from case-study inline CSS) ====== */
.overline {
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: .8rem;
    color: var(--muted);
    margin: 0 0 8px
}

.title {
    margin: 6px 0 10px 0;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.02em;
    font-size: clamp(40px, 7.5vw, 66px)
}

.lede {
    color: var(--muted);
    font-size: clamp(16px, 2.2vw, 20px);
    max-width: 65ch
}

.h2 {
    font-weight: 800;
    line-height: 1.18;
    font-size: clamp(22px, 2.6vw, 32px);
    margin: 0 0 10px
}

.muted {
    color: var(--muted)
}

.stack {
    display: grid;
    gap: var(--gap)
}

.grid-2 {
    display: grid;
    gap: var(--gap);
    grid-template-columns:1fr 1fr
}

@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns:1fr
    }
}

.caption {
    color: var(--muted);
    font-size: .95rem;
    margin-top: 10px
}

/* Cards + carousel visuals (case study) */
.media, .carousel {
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(255, 255, 255, .06), transparent 45%),
    radial-gradient(60% 60% at 15% 15%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 70%),
    var(--card);
    color: var(--muted);
    display: grid;
    place-items: center;
}

.media.wide, .carousel.wide {
    aspect-ratio: 21/9
}

.media.land, .carousel.land {
    aspect-ratio: 16/9
}

.media.tall {
    aspect-ratio: 9/16
}

/* ====== HEADER / NAV ========== */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5000;
    backdrop-filter: saturate(1.2) blur(8px);
    -webkit-backdrop-filter: saturate(1.2) blur(8px);
    background: color-mix(in oklab, var(--bg) 85%, transparent);
    border-bottom: 1px solid var(--hairline);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    padding-inline: var(--page-pad);
}

.brand {
    font-weight: 700;
    letter-spacing: .3px;
}

.menu {
    display: flex;
    gap: 18px;
    align-items: center;
}

.menu a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -4px;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s ease, opacity .25s ease;
    opacity: .55;
}

.menu a:hover::after {
    transform: scaleX(1);
    opacity: .95;
}

/* Theme toggle (moon) */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    min-width: 34px;
    min-height: 34px;
    line-height: 1;
    color: color-mix(in oklab, var(--text) 40%, var(--bg));
    transition: color .25s ease, transform .2s ease;
}

.theme-toggle:hover {
    color: var(--text);
    transform: scale(1.05);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

.theme-icon-moon {
    display: block;
}

.icon {
    fill: currentColor;
}

.icon-heart {
    color: #A855F7; vertical-align: -6px; margin: 0 4px;
}

/* ========== PROGRESS BAR & SELECTION ========== */
.progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    width: 0;
    z-index: 9999;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 50%, transparent);
    pointer-events: none;
    transition: width .15s linear;
}

::selection {
    background: color-mix(in oklab, var(--accent) 40%, transparent);
    color: #fff;
}

/* ========== HERO ========== */
.hero {
    padding: clamp(56px, 10vh, 120px) 0;
}

.hero h1 {
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.02em;
    font-size: clamp(40px, 7.5vw, 84px);
    margin: 0 0 12px 0;
    background: linear-gradient(92deg, var(--text), color-mix(in oklab, var(--accent) 65%, var(--text)));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero p {
    max-width: 65ch;
    color: var(--muted);
    font-size: clamp(16px, 2.2vw, 20px);
}

#hero {
    /* original hero spacing + header height */
    padding: calc(var(--header-h) + clamp(56px, 9vh, 128px)) 0 clamp(56px, 9vh, 128px);
    scroll-margin-top: var(--header-h);
}

/* ========== GRID / CARDS (home) ========== */
.grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns:repeat(auto-fit, minmax(260px, 1fr));
}

.grid.first {
    padding: 0 0 20px 0;
}

.card {
    background: color-mix(in oklab, var(--card) 75%, transparent);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .35s ease, border-color .2s ease, box-shadow .2s ease, opacity .6s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in oklab, var(--text) 22%, transparent);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
}

.thumb {
    aspect-ratio: 16/10;
    background: radial-gradient(80% 80% at 20% 0%, color-mix(in oklab, var(--accent) 28%, transparent), transparent 70%),
    #1c1c20;
}

.card-body {
    padding: 18px;
}

.card h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
}

.card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* ========== STORYTELLING (home) ========== */
.story-row {
    display: grid;
    gap: var(--gap);
    grid-template-columns:1.1fr .9fr;
    align-items: start;
}

.story-row.reverse {
    grid-template-columns:.9fr 1.1fr;
}

.story-copy p {
    margin: 0;
    color: var(--muted);
    max-width: 65ch;
}

.story-illustration {
    aspect-ratio: 4/3;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: radial-gradient(80% 80% at 20% 0%, color-mix(in oklab, var(--accent) 10%, transparent), transparent 68%);
}

.story-svg {
    width: min(84%, 520px);
    height: auto;
}

.story-svg path, .story-svg circle {
    fill: none;
    stroke: color-mix(in oklab, var(--text) 60%, var(--accent));
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: .88;
}

.story-grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns:1fr 1fr;
}

.story-grid h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
}

.story-grid p {
    margin: 0;
    color: var(--muted);
}

.story-center {
    text-align: center;
    color: var(--muted);
    font-size: clamp(16px, 2vw, 20px);
}

.story-mini {
    display: grid;
    gap: var(--gap);
    grid-template-columns:repeat(3, 1fr);
}

.mini {
    display: grid;
    grid-template-columns:14px 1fr;
    gap: 10px;
    align-items: start;
}

.mini h4 {
    margin: 0 0 4px 0;
    font-size: 15px;
}

.mini p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--accent), color-mix(in oklab, var(--text) 5%, transparent));
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 30%, transparent);
}

/* ========== REVEAL ANIMATIONS ========== */
.reveal {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .45s ease, transform .45s ease;
    will-change: opacity, transform;
}

.revealed {
    opacity: 1;
    transform: none;
}

/* ========== TIMELINE (home) ========== */
.timeline-wrapper {
    position: relative;
    z-index: 0;
}

/* vertical spine + progress (centered within container; mobile overrides below) */
.timeline-line,
.timeline-line-progress {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    pointer-events: none;
    will-change: height, transform;
    z-index: 1;
}

.timeline-line {
    bottom: 0;
    background: var(--hairline);
}

.timeline-line-progress {
    background: color-mix(in oklab, var(--accent) 60%, transparent);
    border-radius: 2px;
    height: 0; /* JS updates */
    box-shadow: 0 0 24px color-mix(in oklab, var(--accent) 35%, transparent);
    transition: height .25s ease;
}

/* intro header inside timeline */
.intro-block {
    position: relative; /* ensure normal flow above spine */
    z-index: 1;
    margin-top: 0;
    padding-top: 2rem;
    max-width: 38rem;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.intro-eyebrow {
    font-size: .75rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 500;
}

.intro-headline {
    font-size: clamp(1.5rem, 1vw + 1.2rem, 2rem);
    font-weight: 600;
    line-height: 1.25;
    margin: .75rem 0 1rem;
}

.intro-body {
    font-size: 1.0625rem;
    color: var(--muted);
    max-width: 32rem;
    margin: 0 auto;
    line-height: 1.6;
}

/* timeline rows */
.timeline-section {
    position: relative;
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: var(--gap);
    align-items: start;
    margin-bottom: clamp(48px, 8vw, 96px);
}

/* dot on the spine */
.milestone-dot {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, 0);
    width: .75rem;
    height: .75rem;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 16px color-mix(in oklab, var(--accent) 55%, transparent);
    z-index: 1;
}

/* columns */
.section-col {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    max-width: 36rem;
}

.section-eyebrow {
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 500;
}

.section-title {
    margin: 0;
}

.section-body {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

/* default (text left / media right) */
.timeline-section .text-col {
    grid-column: 1;
}

.timeline-section .media-col {
    grid-column: 2;
    justify-self: flex-end;
}

/* alt: flipped */
.timeline-section.alt .text-col {
    grid-column: 2;
    justify-self: flex-start;
}

.timeline-section.alt .media-col {
    grid-column: 1;
    justify-self: flex-start;
}

/* media placeholder */
.section-media {
    width: 100%;
    min-height: 260px;
    border-radius: var(--radius);
    border: 1px solid var(--hairline);
    background: radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--accent) 18%, transparent) 0%, transparent 70%),
    color-mix(in oklab, var(--card) 92%, transparent);
    box-shadow: 0 24px 48px rgba(0, 0, 0, .35),
    0 0 160px color-mix(in oklab, var(--accent) 14%, transparent) inset;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 500;
    letter-spacing: .04em;
    padding: 2rem;
    overflow: hidden;
}

.section-media img,
.section-media video,
.section-media svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* dot pulse (JS adds .pulse-once briefly) */
.milestone-dot.pulse-once {
    box-shadow: 0 0 24px color-mix(in oklab, var(--accent) 80%, transparent),
    0 0 64px color-mix(in oklab, var(--accent) 40%, transparent);
    transform: translate(-50%, 0) scale(1.15);
    transition: box-shadow .4s ease, transform .4s ease;
}

/* ========== LEFT RAIL (case study) ========== */
.left-rail {
    position: fixed;
    top: var(--header-h);
    /* content edge is (100% - 1080px)/2; subtract button width + gap */
    left: calc(max(16px, (100% - 1080px)/2 - (var(--rail-btn) + var(--rail-gap))));
    width: var(--rail-btn);
    z-index: 3;
    will-change: top;
}

.back-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--hairline);
    background: color-mix(in oklab, var(--card) 92%, transparent);
    color: color-mix(in oklab, var(--text) 85%, var(--bg));
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}

.back-btn:hover {
    transform: translateY(-1px) scale(1.03);
    color: var(--text);
}

.back-btn:active {
    transform: translateY(0) scale(.98);
}

.back-btn:focus-visible {
    outline: 2px solid color-mix(in oklab, var(--accent) 45%, transparent);
    outline-offset: 2px;
}

@media (max-width: 1280px) {
    .left-rail {
        display: none;
    }
}

/* ========== RIGHT RAIL (case study) ========== */
.right-rail {
    position: fixed;
    top: calc(var(--header-h) + var(--rail-offset)); /* fallback before JS runs */
    right: calc(max(16px, (100% - 1080px) / 2 - 260px));
    width: 220px;
    z-index: 3;
    display: grid;
    gap: 10px;
    will-change: top;
}

.toc {
    padding: 14px 14px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: color-mix(in oklab, var(--card) 92%, transparent);
    backdrop-filter: blur(6px) saturate(1.2);
}

.toc h6 {
    margin: 0 0 10px;
    font-size: .75rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--muted)
}

/* super subtle text-only interaction */
.toc a {
    display: block;
    padding: 6px 4px;
    color: var(--muted);
    border-radius: 6px;
    line-height: 1.1;
    transition: color .18s ease;
}

.toc a:hover {
    color: color-mix(in oklab, var(--accent) 65%, var(--muted));
}

.toc a[aria-current="true"] {
    color: color-mix(in oklab, var(--accent) 85%, var(--text));
    font-weight: 600;
}

.toc a:focus-visible {
    outline: 2px solid color-mix(in oklab, var(--accent) 35%, transparent);
    outline-offset: 2px;
}

@media (max-width: 1280px) {
    .right-rail {
        display: none
    }
}

/* ========== CAROUSEL (case study) ========== */
#ia-carousel {
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent
}

#ia-carousel .carousel-track {
    display: flex;
    height: 100%;
    width: 100%;
    transform: translate3d(0, 0, 0);
    transition: transform .45s cubic-bezier(.22, .61, .36, 1);
    touch-action: pan-y;
    will-change: transform
}

@media (prefers-reduced-motion: reduce) {
    #ia-carousel .carousel-track {
        transition: none
    }
}

#ia-carousel .slide {
    min-width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    padding: clamp(10px, 1.8vw, 18px)
}

#ia-carousel .slide > .ph {
    width: 100%;
    height: 100%;
    border-radius: calc(var(--radius) - 6px);
    display: grid;
    place-items: center;
    text-align: center;
    font-size: .95rem;
    color: color-mix(in oklab, var(--text) 70%, var(--muted));
    background: radial-gradient(80% 80% at 20% 0%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 65%), #1a1b1f;
    border: 1px solid var(--hairline);
}

#ia-carousel .car-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    border: 1px solid var(--hairline);
    background: color-mix(in oklab, var(--card) 90%, transparent);
    color: var(--text);
    opacity: .95;
    cursor: pointer;
    transition: opacity .2s, background .2s, transform .2s;
    z-index: 2;
}

#ia-carousel .car-btn:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.04)
}

#ia-carousel .car-btn:active {
    transform: translateY(-50%) scale(.98)
}

#ia-carousel .car-btn.prev {
    left: 10px
}

#ia-carousel .car-btn.next {
    right: 10px
}

#ia-carousel .car-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: color-mix(in oklab, var(--bg) 70%, transparent);
    border: 1px solid var(--hairline);
    backdrop-filter: saturate(1.2) blur(6px);
    flex-wrap: nowrap;
    z-index: 2;
}

#ia-carousel .car-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: color-mix(in oklab, var(--text) 35%, transparent);
    border: 1px solid var(--hairline);
    cursor: pointer;
    opacity: .8;
    transition: opacity .2s, transform .2s, background .2s, border-color .2s;
    padding: 6px;
    box-sizing: content-box;
}

#ia-carousel .car-dot[aria-current="true"] {
    transform: scale(1.6);
    background: color-mix(in oklab, var(--accent) 70%, var(--text));
    border-color: color-mix(in oklab, var(--accent) 50%, var(--hairline));
    opacity: 1;
}

/* ========== FOOTER ========== */
footer {
    padding: 48px 0;
    color: var(--muted);
    border-top: 1px solid var(--hairline);
    text-align: center; /* needed by case study footer */
}

/* ========== UTILITIES ========== */
.tag {
    display: inline-block;
    padding: .25rem .6rem;
    border: 1px solid color-mix(in oklab, var(--text) 18%, transparent);
    border-radius: 999px;
    font-size: 12px;
    color: var(--muted);
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid color-mix(in oklab, var(--text) 18%, transparent);
}

.btn:hover {
    border-color: var(--text);
}

/* ========== RESPONSIVE (home + case study) ========== */
@media (max-width: 880px) {
    .about {
        display: grid;
        gap: var(--gap);
        grid-template-columns:1fr;
    }

    .story-row, .story-row.reverse {
        grid-template-columns:1fr;
    }

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

    .story-mini {
        grid-template-columns:1fr;
    }
}

@media (max-width: 900px) {
    /* timeline: move spine to left; single column flow */
    .timeline-line,
    .timeline-line-progress {
        left: var(--page-pad);
        transform: none;
    }

    .milestone-dot {
        left: var(--page-pad);
        transform: none;
    }

    .timeline-wrapper {
        padding-top: .5rem;
    }

    .timeline-section,
    .timeline-section.alt {
        grid-template-columns:1fr;
        gap: 1.25rem;
        padding-left: calc(var(--page-pad) + 18px); /* room for line/dot */
    }

    .timeline-section .text-col,
    .timeline-section .media-col,
    .timeline-section.alt .text-col,
    .timeline-section.alt .media-col {
        grid-column: 1;
        justify-self: flex-start;
        max-width: 100%;
    }

    /* optional: media first on mobile */
    .timeline-section .media-col,
    .timeline-section.alt .media-col {
        order: -1;
    }

    .intro-block {
        text-align: left;
        margin-left: var(--page-pad);
        margin-right: var(--page-pad);
    }
}
