/* ==========================================================================
   Base: tokens (warm dark + light), reset, and page chrome
   (loader, cursor, header, tracker, buttons, chips, dialogs)
   ========================================================================== */

:root {
    --bg: #0c0c0e;
    --bg-2: #141417;
    --ink: #ecebe7;
    --ink-2: #c5c4bf;
    --muted: #8c8b93;
    --line: rgba(236, 235, 231, 0.12);
    --faint: rgba(236, 235, 231, 0.06);
    --card: rgba(20, 20, 23, 0.72);
    --card-solid: #161619;
    --paper: #f4f3f0;
    --paper-ink: #232227;
    --accent: #f2b56b;
    --accent-ink: #0c0c0e;
    --ok: #8fd19e;
    --shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.7);
    --vignette: rgba(0, 0, 0, 0.6);

    /* Archivo set wide for structure, Gambetta for the quoted, spoken parts,
       Geist Mono for labels. */
    --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --display-weight: 700;
    --display-stretch: 125%;
    --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --serif: "Gambetta", Georgia, "Times New Roman", serif;
    --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

    --gutter: clamp(20px, 5vw, 72px);
    --maxw: 1320px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #f3f2ef;
    --bg-2: #e9e8e4;
    --ink: #18181b;
    --ink-2: #3c3c42;
    --muted: #6f6e76;
    --line: rgba(24, 24, 27, 0.14);
    --faint: rgba(24, 24, 27, 0.07);
    --card: rgba(252, 251, 249, 0.8);
    --card-solid: #fcfbf9;
    --paper: #ffffff;
    --accent: #9c4522;
    --accent-ink: #ffffff;
    --ok: #3f7d4f;
    --shadow: 0 28px 50px -26px rgba(30, 30, 40, 0.35);
    --vignette: rgba(60, 60, 80, 0.12);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    transition: background-color 0.6s var(--ease), color 0.6s var(--ease);
}
body.is-loading { overflow: hidden; }

img, svg, canvas { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p, dl, dd, figure, blockquote { margin: 0; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

.skip-link { position: fixed; left: 16px; top: 16px; z-index: 200; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; transform: translateY(-160%); transition: transform 0.25s var(--ease); }
.skip-link:focus { transform: none; }
main:focus { outline: none; }
.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.03em; text-transform: uppercase; }
.muted { color: var(--muted); }
.accent { color: var(--accent); transition: color 1s var(--ease); }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 1101px) { .container { padding-left: max(var(--gutter), 104px); } }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.for-touch { display: none; }
@media (pointer: coarse) { .for-touch { display: inline; } .for-fine { display: none; } }

/* ---------- Atmosphere ---------- */
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; z-index: 0; pointer-events: none; }
.fallback-bg {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0;
    background:
        radial-gradient(60vw 60vw at 75% 40%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
        radial-gradient(50vw 50vw at 20% 80%, rgba(140, 160, 200, 0.1), transparent 60%);
}
.no-webgl .fallback-bg { opacity: 1; }
.vignette {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(120% 90% at 50% 50%, transparent 55%, var(--vignette) 100%);
}
.grain {
    position: fixed; inset: -50%; z-index: 60; pointer-events: none; opacity: 0.07;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    animation: grain 1.2s steps(6) infinite;
}
[data-theme="light"] .grain { opacity: 0.05; mix-blend-mode: multiply; }
@keyframes grain {
    0% { transform: translate(0, 0); } 20% { transform: translate(-4%, 3%); } 40% { transform: translate(3%, -5%); }
    60% { transform: translate(-6%, -2%); } 80% { transform: translate(5%, 4%); } 100% { transform: translate(0, 0); }
}
main { position: relative; z-index: 2; }

/* ---------- Loader ---------- */
.loader {
    position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
    background: var(--bg); transition: opacity 1s var(--ease), visibility 1s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader-inner { width: min(440px, 80vw); }
.loader-label { color: var(--muted); }
.loader-count { font-family: var(--display); font-weight: var(--display-weight); font-stretch: var(--display-stretch); font-size: clamp(72px, 13vw, 132px); line-height: 1; margin: 14px 0 18px; font-variant-numeric: tabular-nums; }
.loader-bar { height: 1px; background: var(--line); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.loader-quote { margin-top: 34px; opacity: 0; transform: translateY(10px); transition: opacity 0.8s var(--ease) 0.2s, transform 0.8s var(--ease) 0.2s; }
.loader-quote.is-in { opacity: 1; transform: none; }
.loader-quote p { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 22px; line-height: 1.35; color: var(--ink-2); }
.loader-quote cite { display: block; margin-top: 10px; font-style: normal; color: var(--muted); }

/* ---------- Cursor ---------- */
.cursor { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.cursor-dot, .cursor-ring { position: fixed; left: 0; top: 0; border-radius: 50%; pointer-events: none; will-change: transform; }
.cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--ink); }
.cursor-ring {
    width: 38px; height: 38px; margin: -19px 0 0 -19px;
    border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
    display: grid; place-items: center;
    transition: width 0.45s var(--ease), height 0.45s var(--ease), margin 0.45s var(--ease), background-color 0.45s var(--ease), border-color 0.45s var(--ease);
}
.cursor-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bg); opacity: 0; transition: opacity 0.3s; }
.cursor.is-hover .cursor-ring { width: 72px; height: 72px; margin: -36px 0 0 -36px; background: var(--ink); border-color: transparent; }
.cursor.is-hover .cursor-label { opacity: 1; }
.cursor.is-hover .cursor-dot { opacity: 0; }
/* The ring is placed with transform, so the dashed spin lives on a pseudo-element
   that turns around its own centre instead of the page's top-left corner */
.cursor-ring::before { content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 1px dashed var(--accent); opacity: 0; transition: opacity 0.3s; }
.cursor.is-down .cursor-ring { width: 120px; height: 120px; margin: -60px 0 0 -60px; border-color: transparent; }
.cursor.is-down .cursor-ring::before { opacity: 1; animation: spin 6s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.cursor.is-hidden { opacity: 0; }
@media (pointer: coarse) { .cursor { display: none; } }
@media (pointer: fine) { body, a, button { cursor: none; } }

/* ---------- Top bar ---------- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px var(--gutter) 34px; pointer-events: none;
    background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 88%, transparent), color-mix(in srgb, var(--bg) 50%, transparent) 55%, transparent);
}
.topbar > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark {
    display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--line); font-family: var(--display); font-weight: var(--display-weight); font-stretch: var(--display-stretch); font-size: 15px;
    transition: background 0.4s var(--ease), color 0.4s var(--ease);
}
.brand:hover .brand-mark { background: var(--ink); color: var(--bg); }
.brand-name { font-size: 14px; color: var(--ink-2); }
.topbar-meta { display: flex; align-items: center; gap: 24px; color: var(--muted); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 80%, 100% { box-shadow: 0 0 0 10px transparent; } }
.theme-toggle {
    position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); color: var(--ink);
    display: grid; place-items: center; overflow: hidden; transition: border-color 0.3s, background 0.3s;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .ico { position: absolute; transition: transform 0.6s var(--ease), opacity 0.4s; }
.theme-toggle .ico-moon { transform: translateY(140%) rotate(-40deg); opacity: 0; }
[data-theme="light"] .theme-toggle .ico-sun { transform: translateY(-140%) rotate(40deg); opacity: 0; }
[data-theme="light"] .theme-toggle .ico-moon { transform: none; opacity: 1; }

/* ---------- Section tracker ---------- */
.tracker { position: fixed; left: calc(var(--gutter) * 0.45); top: 50%; z-index: 40; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
.tracker::before {
    content: ""; position: absolute; inset: -18px -22px -18px -14px; z-index: -1; border-radius: 22px;
    background: var(--card); backdrop-filter: blur(12px); border: 1px solid var(--faint);
    opacity: 0; transition: opacity 0.4s var(--ease); pointer-events: none;
}
.tracker:hover::before { opacity: 1; }
.tracker-line { position: absolute; left: 17px; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.tracker-line i { position: absolute; inset: 0; background: var(--accent); transform-origin: top; transform: scaleY(0); }
.tracker-item { position: relative; display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 4px 0; transition: color 0.3s; }
.tracker-item .ico { width: 36px; height: 36px; padding: 9px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); transition: border-color 0.4s var(--ease), color 0.4s, background 0.6s; }
.tracker-item span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0; transform: translateX(-6px); transition: opacity 0.35s var(--ease), transform 0.35s var(--ease); }
.tracker:hover .tracker-item span { opacity: 1; transform: none; }
.tracker-item:hover, .tracker-item.is-active { color: var(--ink); }
.tracker-item.is-active .ico { border-color: var(--accent); color: var(--accent); }
.tracker-subs { display: flex; flex-direction: column; overflow: hidden; padding-left: 48px; max-height: 0; transition: max-height 0.5s var(--ease); }
.tracker-group.is-active .tracker-subs { max-height: 140px; }
.tracker-sub { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 4px 0; display: flex; align-items: center; gap: 8px; transition: color 0.3s; }
.tracker-sub::before { content: ""; width: 5px; height: 5px; border-radius: 50%; border: 1px solid currentColor; transition: background 0.3s; }
.tracker-sub:hover, .tracker-sub.is-active { color: var(--ink); }
.tracker-sub.is-active::before { background: var(--accent); border-color: var(--accent); }
.tracker:not(:hover) .tracker-sub { font-size: 0; }
@media (max-width: 1100px) { .tracker { display: none; } }

/* ---------- Buttons ---------- */
.btn {
    position: relative; display: inline-flex; align-items: center; gap: 12px; height: 54px; padding: 0 28px;
    border-radius: 999px; overflow: hidden; font-size: 15px; font-weight: 500; isolation: isolate;
    transition: color 0.5s var(--ease), border-color 0.5s var(--ease);
}
.btn::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; transform: translateY(101%); transition: transform 0.6s var(--ease); }
.btn:hover::before { transform: none; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary::before { background: var(--accent); }
.btn-primary:hover { color: var(--accent-ink); }
.btn-ghost { border: 1px solid var(--line); color: var(--ink); }
.btn-ghost::before { background: var(--ink); }
.btn-ghost:hover { color: var(--bg); border-color: var(--ink); }
.btn-arrow { transition: transform 0.5s var(--ease); }
.btn:hover .btn-arrow { transform: translateX(4px); }
.magnetic { will-change: transform; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
    font-family: var(--mono); font-size: 11.5px; padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--ink-2); background: var(--faint);
    transition: border-color 0.3s, color 0.3s;
}
.chips li:hover { border-color: var(--accent); color: var(--ink); }

/* ---------- Shared section bits ---------- */
.section { position: relative; }
.section-head { margin-bottom: clamp(40px, 7vw, 80px); }
.eyebrow { display: flex; align-items: center; gap: 12px; color: var(--muted); margin-bottom: 22px; }
.eyebrow .num { color: var(--accent); }
.eyebrow::after { content: ""; flex: 0 0 60px; height: 1px; background: var(--line); }
.section-title { font-family: var(--display); font-weight: var(--display-weight); font-stretch: var(--display-stretch); line-height: 1.02; letter-spacing: -0.025em; font-size: clamp(34px, 4.8vw, 74px); max-width: 16ch; }
.reveal-lines .rl-line { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.1em; }
.reveal-lines .rl-inner { display: inline-block; }
.word { display: inline-block; white-space: nowrap; }
.parallax-word {
    position: absolute; z-index: -1; top: 6%; right: -2vw; pointer-events: none; user-select: none;
    font-family: var(--display); font-weight: var(--display-weight); font-stretch: var(--display-stretch); font-size: clamp(120px, 22vw, 360px); line-height: 0.8; white-space: nowrap;
    color: transparent; -webkit-text-stroke: 1px color-mix(in srgb, var(--ink) 8%, transparent);
}

.spotlight { position: relative; isolation: isolate; }
.spotlight::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; opacity: 0;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
    transition: opacity 0.5s;
}
.spotlight:hover::before { opacity: 1; }

/* ---------- Dialogs ---------- */
.project-dialog, .lightbox {
    padding: 0; border: 1px solid var(--line); color: var(--ink);
    background: color-mix(in srgb, var(--card-solid) 92%, transparent); backdrop-filter: blur(24px) saturate(140%);
    overscroll-behavior: contain;
    opacity: 0; transform: translateY(30px) scale(0.97);
    transition: opacity 0.5s var(--ease), transform 0.6s var(--ease), overlay 0.5s allow-discrete, display 0.5s allow-discrete;
}
.project-dialog[open], .lightbox[open] { opacity: 1; transform: none; }
@starting-style { .project-dialog[open], .lightbox[open] { opacity: 0; transform: translateY(30px) scale(0.97); } }
.project-dialog::backdrop, .lightbox::backdrop { background: rgba(10, 7, 4, 0.55); backdrop-filter: blur(3px); }
.project-dialog { width: min(820px, calc(100vw - 32px)); max-height: min(90vh, 900px); border-radius: 22px; overflow: auto; }
.dialog-inner { padding: clamp(24px, 4vw, 48px); }
.dialog-bar { display: flex; justify-content: space-between; align-items: center; color: var(--muted); margin-bottom: 30px; gap: 16px; }
.dialog-close { white-space: nowrap; flex: none; font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-solid); transition: background 0.3s, color 0.3s; }
.dialog-close:hover { background: var(--ink); color: var(--bg); }
.dialog-title { font-family: var(--display); font-weight: var(--display-weight); font-stretch: var(--display-stretch); font-size: clamp(28px, 4vw, 46px); line-height: 1.02; letter-spacing: -0.02em; margin-bottom: 22px; }
.dialog-body p { color: var(--ink-2); font-size: 17px; line-height: 1.7; }
.dialog-body p + p { margin-top: 14px; }
.dialog-body .detail-extra { display: none; }
.dialog-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 30px 0; }
.dialog-stats div { background: var(--bg-2); padding: 18px 20px; }
.dialog-stats strong { display: block; font-family: var(--display); font-weight: var(--display-weight); font-stretch: var(--display-stretch); font-size: 26px; line-height: 1.1; }
.dialog-stats span { color: var(--muted); font-size: 13px; }
.dialog-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 30px; }
.dialog-gallery:empty { display: none; }
.dialog-gallery figure { margin: 0; }
.dialog-gallery figure.wide { grid-column: 1 / -1; }
.dialog-gallery .g-media { border-radius: 12px; overflow: hidden; background: var(--paper); color: var(--paper-ink); border: 1px solid var(--line); }
.dialog-gallery img { width: 100%; height: auto; }
.dialog-gallery button.g-media { display: block; width: 100%; text-align: left; }
.dialog-gallery figcaption { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.dialog-label { color: var(--muted); margin-bottom: 12px; }
.dialog-links { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 30px; }
.dialog-links a { display: inline-flex; gap: 10px; padding-bottom: 4px; border-bottom: 1px solid var(--line); transition: border-color 0.3s, gap 0.3s; }
.dialog-links a:hover { border-color: var(--accent); gap: 16px; }

.lightbox { width: min(1200px, calc(100vw - 32px)); max-height: 92vh; border-radius: 18px; padding: 16px; overflow: hidden; }
.lightbox .dialog-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.lightbox figure { display: flex; flex-direction: column; gap: 10px; }
.lightbox img { max-width: 100%; max-height: calc(92vh - 80px); width: auto; margin: 0 auto; border-radius: 10px; background: #fff; }
.lightbox figcaption { color: var(--muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
    .grain { animation: none; }
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
    /* No trailing custom cursor: give the system pointer back */
    .cursor { display: none; }
    body { cursor: auto !important; }
    a, button, [role="button"] { cursor: pointer !important; }
}
