/* ========================================================================
   Thinking Digits
   Reference lock: Numbered (near-black canvas, monumental serif signature,
   unboxed underline actions, flush full-bleed media, uppercase captions).
   Borrowed from A24: small monospaced labels.
   Motion: BYQ gems "Sticky Media Swap" and "Hover Peek List".
   Palette: Thinking Digits visual identity (cinematic black, off-white,
   silver). Amber is reserved for the active index number only.
   ======================================================================== */

@font-face { font-family: 'Geist Mono'; font-weight: 400; font-display: swap; src: url('../fonts/geistmono-400-latin.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300 900; font-display: swap; src: url('../fonts/inter-var-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300 900; font-display: swap; src: url('../fonts/inter-var-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --td-bg: #08090b;
    --td-surface: #17191d;
    --td-ink: #f3f2ee;
    --td-muted: #a9adb5;
    --td-dim: rgba(243, 242, 238, 0.28);
    --td-rule: rgba(243, 242, 238, 0.14);
    --td-accent: #f2af63;
    --td-gutter: clamp(16px, 8.333vw, 120px);
    --td-mono: 'Geist Mono', ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --td-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --td-underline: cubic-bezier(0.77, 0, 0.175, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--td-bg); }
body.td-page { margin: 0; }
:where(.td-page) :where(h1, h2, p, ol, ul, dl, figure) { margin: 0; }
:where(.td-page) :where(img, video) { max-width: 100%; }

body.td-page {
    background: var(--td-bg);
    color: var(--td-ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.td-page ::selection { background: var(--td-ink); color: var(--td-bg); }

.td-skip {
    position: absolute; left: 16px; top: -60px; z-index: 2000;
    background: var(--td-ink); color: var(--td-bg); padding: 10px 14px;
    font-size: 14px; text-decoration: none;
}
.td-skip:focus { top: 16px; }

.td-page :focus-visible { outline: 2px solid var(--td-ink); outline-offset: 6px; }

/* ---------- Shared type ---------- */
.td-label {
    font-family: var(--td-mono);
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--td-muted);
}

.td-chapter {
    font-weight: 400;
    font-size: clamp(36px, 3.82vw, 55px);
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0;
}

.td-action {
    position: relative;
    display: inline-flex;
    gap: 0.5em;
    align-items: baseline;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--td-ink);
    text-decoration: none;
    padding-bottom: 3px;
    background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
    transition: background-size 0.6s var(--td-underline);
}
.td-action:hover { background-size: 0% 1px; background-position: 100% 100%; }
.td-action--primary { font-size: 17px; }

/* Persistent YouTube link (Numbered "persistent contact": one bold uppercase action, always visible) */
.td-yt {
    position: fixed; top: 40px; left: 25px; z-index: 999;
    display: inline-flex; align-items: center; gap: 10px;
    height: 40px; padding: 0 16px 0 12px;
    border-radius: 20px;
    background: rgba(8, 9, 11, 0.55);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    color: var(--td-ink); text-decoration: none;
    font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
    transition: background-color 0.4s var(--td-ease);
}
.td-yt:hover { background: rgba(243, 242, 238, 0.14); }
.td-yt__icon { width: 20px; height: 20px; flex: none; }
/* Shown once the opening (which has its own YouTube action and the top bar) scrolls away */
.td-yt { opacity: 0; transform: translateY(-12px); pointer-events: none; transition: opacity 0.45s var(--td-ease), transform 0.45s var(--td-ease), background-color 0.4s var(--td-ease); }
html.td-past-mast .td-yt { opacity: 1; transform: none; pointer-events: auto; }
html.site-nav-open .td-yt { opacity: 0; pointer-events: none; }

/* Top bar, matching css/v3.css (.topbar), placed over the opening */
.td-topbar {
    position: absolute; top: 40px; left: 40px; right: 40px; z-index: 2;
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    min-height: 40px; margin-right: 72px; color: var(--td-ink);
}
.td-topbar a { color: inherit; text-decoration: none; }
.td-topbar .topbar__mark { display: block; font-size: clamp(40px, 4vw, 56px); line-height: 1; }
.td-topbar .cb-logo { display: block; height: 0.85em; width: auto; }
.td-topbar .topbar__nav { display: flex; gap: 6px; }
.td-topbar .topbar__nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 100px; font-size: 16px; letter-spacing: -0.02em; transition: background-color 0.3s, color 0.3s; }
.td-topbar .topbar__nav a:hover { background: rgba(127, 127, 127, 0.16); }
.td-topbar .topbar__nav a[aria-current='page'] { box-shadow: inset 0 0 0 1px currentColor; }
.td-mast { padding-top: 136px; }

.td-wordmark { display: block; width: 100%; height: auto; }

/* ---------- 1. Masthead ---------- */
.td-mast {
    position: relative;
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 112px var(--td-gutter) 48px;
    overflow: hidden;
    isolation: isolate;
}
.td-mast__media { position: absolute; inset: 0; z-index: -1; }
.td-mast__video {
    width: 100%; height: 100%; object-fit: cover;
    filter: grayscale(1) contrast(1.05) brightness(0.62);
    transform: scale(1.06);
    will-change: transform;
}
.td-mast__wash {
    position: absolute; inset: 0;
    background:
        linear-gradient(180deg, rgba(8, 9, 11, 0.55) 0%, rgba(8, 9, 11, 0) 30%, rgba(8, 9, 11, 0) 55%, rgba(8, 9, 11, 0.92) 100%);
}
.td-mast__top {
    display: flex; justify-content: space-between; gap: 24px;
    border-top: 1px solid var(--td-rule);
    padding-top: 14px;
}
.td-mast__top .td-label { color: var(--td-ink); opacity: 0.8; }
.td-mast__mark { align-self: center; margin: 0; font-size: inherit; overflow: hidden; }
.td-mast__mark .td-wordmark { will-change: transform; }
.td-mast__actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 16px 40px; }
.td-mast__bottom {
    display: grid; justify-items: center; gap: 22px; text-align: center;
}
.td-mast__descriptor {
    font-size: clamp(18px, 1.53vw, 22px);
    line-height: 1.35;
    max-width: 34ch;
    text-wrap: balance;
    color: var(--td-ink);
}

/* ---------- 2. Manifesto ---------- */
.td-manifesto {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
    row-gap: 32px;
    padding: clamp(96px, 12.5vw, 180px) var(--td-gutter);
}
.td-manifesto__label { grid-column: 1 / -1; }
.td-manifesto__text {
    grid-column: 1 / 11;
    font-weight: 400;
    font-size: clamp(38px, 5.208vw, 75px);
    line-height: 1;
    letter-spacing: -0.015em;
    text-wrap: balance;
}
.td-manifesto__aside {
    grid-column: 8 / 13;
    font-size: 17px;
    line-height: 1.55;
    color: var(--td-muted);
    text-wrap: pretty;
}

/* Line-mask reveal used on large statements */
[data-td-lines] .td-line { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
[data-td-lines] .td-line > span { display: block; will-change: transform; }

/* ---------- 3. Episodes (sticky media swap) ---------- */
.td-eps {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    column-gap: clamp(32px, 5vw, 80px);
    padding: 0 var(--td-gutter);
    border-top: 1px solid var(--td-rule);
}
.td-ep {
    min-height: 100vh;
    display: grid;
    align-content: center;
    gap: 22px;
    padding: 64px 0;
}
.td-ep__inline { display: none; }
.td-ep__head {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: clamp(16px, 2.4vw, 28px);
    align-items: start;
    margin: 0; padding: 8px 0; border: 0; background: none;
    font: inherit; text-align: left; cursor: pointer;
    color: var(--td-dim);
    transition: color 0.5s var(--td-ease);
}
.td-ep__head:hover { color: rgba(243, 242, 238, 0.55); }
.td-ep.is-active .td-ep__head { color: var(--td-ink); }
.td-ep__num {
    display: inline-block;
    font-family: var(--td-mono);
    font-size: 13px;
    line-height: 1;
    width: 3rem;
    padding-top: 0.9em;
    backface-visibility: hidden;
    transition: color 0.4s var(--td-ease);
}
.td-ep.is-active .td-ep__num { color: var(--td-accent); animation: td-num-flip 0.55s var(--td-ease); }
@keyframes td-num-flip { from { transform: rotateX(-90deg); } to { transform: rotateX(0deg); } }
.td-ep__title {
    font-weight: 400;
    font-size: clamp(34px, 1.1rem + 3.6vw, 66px);
    line-height: 1.02;
    letter-spacing: -0.02em;
    text-wrap: balance;
}
.td-ep__line,
.td-ep__meta { margin-left: calc(3rem + clamp(16px, 2.4vw, 28px)); }
.td-ep__line {
    max-width: 40ch;
    font-size: 17px;
    line-height: 1.55;
    color: var(--td-muted);
    text-wrap: pretty;
    opacity: 0.55;
    transition: opacity 0.5s var(--td-ease);
}
.td-ep.is-active .td-ep__line { opacity: 1; }
.td-ep__meta {
    display: flex; flex-wrap: wrap; gap: 8px 32px;
    padding-top: 14px; border-top: 1px solid var(--td-rule);
    max-width: 40ch;
}
.td-ep__meta dt { font-family: var(--td-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--td-muted); opacity: 0.7; }
.td-ep__meta dd { margin: 4px 0 0; font-size: 14px; }

.td-eps__stage { position: relative; }
.td-eps__frame {
    position: sticky;
    top: 12vh;
    height: 76vh;
    overflow: hidden;
    isolation: isolate;
    background: var(--td-surface);
    transform: translateZ(0);
}
.td-eps__media {
    position: absolute; inset: 0; margin: 0;
    opacity: 0;
    will-change: transform, clip-path, opacity;
}
.td-eps__media:first-child { opacity: 1; }
.td-eps__media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.td-eps__media::after,
.td-exhibit figure::after {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 160px; pointer-events: none;
    background: linear-gradient(180deg, rgba(8, 9, 11, 0.62), rgba(8, 9, 11, 0));
}
.td-eps__media figcaption, .td-exhibit figcaption { z-index: 1; }
.td-eps__media figcaption,
.td-exhibit figcaption {
    position: absolute; left: 40px; top: 35px; right: 40px;
    font-size: 15px; line-height: 1.5; text-transform: uppercase;
    color: var(--td-ink);
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
}

/* ---------- 4. Interlude ---------- */
.td-interlude { padding: clamp(120px, 12.5vw, 180px) var(--td-gutter); }
.td-statement {
    max-width: 960px; margin: 0 auto; text-align: center;
    font-size: clamp(30px, 3.82vw, 55px);
    line-height: 1.05;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

/* ---------- 5. Flush exhibition ---------- */
.td-exhibit figure { position: relative; margin: 0; overflow: hidden; }
.td-exhibit img { display: block; width: 100%; height: 100%; object-fit: cover; }
.td-exhibit__wide { aspect-ratio: 16 / 9; max-height: 100vh; width: 100%; }
.td-exhibit__pair { display: grid; grid-template-columns: 1fr 1fr; }
.td-exhibit__pair figure { aspect-ratio: 4 / 5; }
.td-exhibit img.td-crop-left { object-position: 8% 50%; }
.td-exhibit figcaption span { font-family: var(--td-mono); font-size: 11px; letter-spacing: 0.08em; margin-right: 12px; opacity: 0.8; }
[data-td-reveal] img { will-change: transform; }

/* ---------- 6. Faces (hover peek list) ---------- */
.td-faces {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    column-gap: 24px;
    padding: clamp(120px, 12.5vw, 180px) var(--td-gutter);
}
.td-faces__head { align-self: start; position: sticky; top: 120px; display: grid; gap: 24px; padding-right: 24px; }
.td-faces__intro { font-size: 17px; line-height: 1.55; color: var(--td-muted); max-width: 30ch; }
.td-faces__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--td-rule); }
.td-face { border-bottom: 1px solid var(--td-rule); }
.td-face__row {
    display: grid;
    grid-template-columns: 3.25rem 1fr auto;
    align-items: center;
    gap: 16px;
    padding: clamp(12px, 1.6vw, 18px) 4px;
    color: var(--td-ink);
    transition: color 0.4s var(--td-ease);
}
.td-face__thumb { display: none; }
.td-face__num { font-family: var(--td-mono); font-size: 12px; opacity: 0.4; transition: opacity 0.4s var(--td-ease); }
.td-face__name {
    position: relative; width: fit-content;
    font-size: clamp(22px, 2.2vw, 32px); line-height: 1.1; letter-spacing: -0.01em;
    transition: transform 0.5s var(--td-ease);
}
.td-face__name::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -0.12em; height: 1px;
    background: var(--td-ink); transform: scaleX(0); transform-origin: left center;
    transition: transform 0.55s var(--td-ease);
}
.td-face__field { font-family: var(--td-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.5; white-space: nowrap; text-align: right; transition: opacity 0.4s var(--td-ease); }
.td-face:hover .td-face__num { opacity: 1; }
.td-face:hover .td-face__name { transform: translateX(0.9rem); }
.td-face:hover .td-face__name::after { transform: scaleX(1); }
.td-face:hover .td-face__field { opacity: 0.85; }
@media (hover: hover) {
    .td-faces.is-peeking .td-face:not(:hover) .td-face__row { color: rgba(243, 242, 238, 0.36); }
}
.td-peek {
    position: absolute; top: 0; left: 0; z-index: 5;
    width: clamp(200px, 17vw, 260px);
    aspect-ratio: 3 / 4;
    overflow: hidden;
    pointer-events: none;
    background: var(--td-surface);
    transform: translate3d(calc(var(--px, 0px) + 48px), calc(var(--py, 0px) - 50%), 0) rotate(var(--tilt, 0deg)) scale(var(--peek-scale, 0.9));
    opacity: 0;
    transition: opacity 0.45s var(--td-ease), transform 0.5s var(--td-ease);
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.7);
    will-change: transform, opacity;
}
.td-faces.is-peeking .td-peek { opacity: 1; --peek-scale: 1; }
.td-peek img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    opacity: 0; transform: scale(1.08);
    transition: opacity 0.5s var(--td-ease), transform 0.9s var(--td-ease);
}
.td-peek img.is-active { opacity: 1; transform: scale(1); }

/* ---------- 7. Signature closing ---------- */
.td-close { padding: 0 var(--td-gutter) 80px; border-top: 1px solid #4f4f4f; }
.td-close__nav {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 24px 48px;
    padding-top: 56px;
}
.td-close__lead { display: grid; gap: 14px; }
.td-close__yt {
    width: fit-content;
    font-size: clamp(30px, 3.82vw, 55px); line-height: 1; text-transform: uppercase;
    color: var(--td-ink); text-decoration: none; padding-bottom: 6px;
    background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
    transition: background-size 0.6s var(--td-underline);
}
.td-close__yt:hover { background-size: 0% 1px; background-position: 100% 100%; }
.td-close__links { list-style: none; display: flex; flex-wrap: wrap; gap: 16px 40px; margin: 0; padding: 0; }
.td-close__mark { margin-top: 60px; opacity: 0.96; }
.td-close__base {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 16px 40px;
    margin-top: 50px; font-size: 13px; line-height: 2; color: var(--td-muted);
}
.td-credits { max-width: 640px; }
.td-credits summary { cursor: pointer; text-align: right; list-style: none; text-decoration: underline; text-underline-offset: 3px; }
.td-credits summary::-webkit-details-marker { display: none; }
.td-credits p, .td-credits ul { margin: 12px 0 0; line-height: 1.6; }
.td-credits ul { padding-left: 18px; }
.td-credits a { color: inherit; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .td-manifesto__text, .td-manifesto__aside { grid-column: 1 / -1; }
    .td-faces { grid-template-columns: 1fr; row-gap: 40px; }
    .td-faces__head { position: static; }
}

@media (max-width: 767px) {
    .td-topbar { top: 22px; left: 20px; right: 20px; margin-right: 56px; }
    .td-topbar .topbar__nav { display: none; }
    .td-yt { top: 22px; left: 20px; padding: 0 14px 0 10px; font-size: 12px; }
}

@media (max-width: 768px) {
    .td-mast { padding-top: 104px; }

    .td-mast__top .td-label:nth-child(2) { display: none; }
    .td-eps { display: block; }
    .td-eps__stage { display: none; }
    .td-ep { min-height: 0; padding: 56px 0; gap: 18px; }
    .td-ep + .td-ep { border-top: 1px solid var(--td-rule); }
    .td-ep__inline { display: block; margin: 0 calc(var(--td-gutter) * -1) 8px; aspect-ratio: 16 / 10; overflow: hidden; }
    .td-ep__inline img { width: 100%; height: 100%; object-fit: cover; display: block; }
    .td-ep__head { color: var(--td-ink); }
    .td-ep__num { color: var(--td-accent); width: auto; }
    .td-ep__line { opacity: 1; }
    .td-ep__line, .td-ep__meta { margin-left: 0; }
    .td-exhibit__pair { grid-template-columns: 1fr; }
    .td-exhibit figcaption, .td-eps__media figcaption { left: 16px; top: 16px; right: 16px; font-size: 13px; }
    /* Phone: flush, full-bleed portrait wall. The first portrait leads at full width. */
    .td-faces { row-gap: 32px; }
    .td-faces__list {
        display: grid; grid-template-columns: 1fr 1fr;
        margin: 0 calc(var(--td-gutter) * -1);
        border-top: 0;
    }
    .td-face { border: 0; }
    .td-face:first-child { grid-column: 1 / -1; }
    .td-face__row {
        position: relative; display: block; padding: 0;
        aspect-ratio: 3 / 4; overflow: hidden; background: var(--td-surface);
    }
    .td-face:first-child .td-face__row { aspect-ratio: 4 / 5; }
    .td-face__row::after {
        content: ""; position: absolute; inset: 45% 0 0 0; pointer-events: none;
        background: linear-gradient(180deg, rgba(8, 9, 11, 0), rgba(8, 9, 11, 0.88));
    }
    .td-face__thumb { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
    .td-face__num, .td-face__name, .td-face__field { position: absolute; z-index: 1; }
    .td-face__num { display: block; top: 12px; left: 12px; font-size: 10px; opacity: 0.75; }
    .td-face__name { left: 12px; right: 12px; bottom: 30px; width: auto; font-size: 17px; line-height: 1.15; }
    .td-face__field { left: 12px; right: 12px; bottom: 12px; font-size: 9px; text-align: left; white-space: normal; opacity: 0.7; }
    .td-face:first-child .td-face__num { top: 16px; left: 16px; }
    .td-face:first-child .td-face__name { left: 16px; bottom: 40px; font-size: 32px; }
    .td-face:first-child .td-face__field { left: 16px; bottom: 18px; font-size: 11px; }
    .td-face:hover .td-face__name { transform: none; }
    .td-face__name::after { display: none; }
    .td-peek { display: none; }
    .td-credits summary { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    .td-page *, .td-page *::before, .td-page *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
    .td-mast__video { transform: none; }
}
