/* ==========================================================================
   site.css — Shared foundation (dark art direction)
   Palette + type from the Figma direction: near-black, Instrument Serif +
   Inter, moody and confident.
   ========================================================================== */

:root {
    --bg: #121212;          /* page */
    --bg-deep: #060606;     /* portrait panel / deeper wells */
    --ink: #ffffff;         /* headlines, emphasis, values */
    --text: #b4b4b4;        /* body copy */
    --muted: #9a9a9a;       /* secondary, labels, captions */
    --faint: #8a8a8a;       /* quietest (still AA on the dark bg) */
    --line: #464646;        /* dividers */
    --line-soft: #2a2a2a;   /* subtle dividers */

    --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --page: 1180px;
    --measure: 62ch;
    --nav-h: 4.75rem;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-h) + 1rem);
    -webkit-text-size-adjust: 100%;
    background: var(--bg);
}

body {
    font-family: var(--sans);
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--ink); color: var(--bg); }

/* Serif display uses Instrument Serif; give it a hair more line spacing default */
h1, h2, h3 { font-weight: 400; }

/* Focus (light ring on dark) */
:focus:not(:focus-visible) { outline: none; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
    border-radius: 1px;
}

.skip-link {
    position: absolute; left: 1rem; top: -3.5rem; z-index: 200;
    background: var(--ink); color: var(--bg);
    padding: 0.7rem 1.1rem; font-size: 0.85rem; font-weight: 500;
    transition: top 0.2s ease;
}
.skip-link:focus { top: 0; outline: 2px solid var(--bg); outline-offset: -4px; }

/* Shared atoms ------------------------------------------------------------- */
.section-label, .section-head__title {
    font-family: var(--sans);
    font-size: 0.72rem; font-weight: 500; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--muted);
}

/* Facts — a bordered block, serif, value white + label grey (from the design) */
.facts { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: clamp(1.5rem, 3vw, 2.25rem) 0; display: grid; gap: clamp(0.8rem, 1.6vw, 1.3rem); }
.facts__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; font-family: var(--serif); font-size: clamp(1.5rem, 2.2vw, 1.9rem); line-height: 1.05; }
.facts__row dt { color: var(--ink); font-variant-numeric: tabular-nums; }
.facts__row dd { color: var(--muted); }

.link-quiet {
    color: var(--ink); border-bottom: 1px solid var(--line);
    transition: border-color 0.2s ease, color 0.2s ease;
}
.link-quiet:hover { border-color: var(--ink); }

/* ==========================================================================
   Masthead / navigation (transparent over the dark page)
   ========================================================================== */
.masthead {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(120%) blur(12px);
    -webkit-backdrop-filter: saturate(120%) blur(12px);
    border-bottom: 1px solid var(--line-soft);
}
.masthead__inner {
    max-width: var(--page); margin: 0 auto; min-height: var(--nav-h);
    padding: 0.85rem 2.5rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
}
.wordmark { font-family: var(--serif); font-size: 1.5rem; letter-spacing: 0; color: var(--ink); white-space: nowrap; }
.wordmark:hover { color: var(--muted); }

.nav-links { display: flex; align-items: center; gap: 0.25rem; list-style: none; }
.nav-links a {
    display: inline-flex; align-items: center; min-height: 44px;
    padding: 0 0.85rem; font-size: 0.95rem; color: var(--muted);
    transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 0.35em; text-decoration-thickness: 1px; }
.nav-links li:last-child a { padding-right: 0; }

.nav-toggle { display: none; align-items: center; justify-content: center; width: 44px; height: 44px; margin-right: -0.5rem; background: none; border: none; color: var(--ink); cursor: pointer; }
.nav-toggle__bars { position: relative; display: block; width: 22px; height: 14px; }
.nav-toggle__bars span { position: absolute; left: 0; width: 100%; height: 1.5px; background: currentColor; border-radius: 1px; transition: transform 0.25s ease, opacity 0.2s ease; }
.nav-toggle__bars span:nth-child(1) { top: 0; }
.nav-toggle__bars span:nth-child(2) { top: 6px; }
.nav-toggle__bars span:nth-child(3) { top: 12px; }
.masthead.nav-open .nav-toggle__bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.masthead.nav-open .nav-toggle__bars span:nth-child(2) { opacity: 0; }
.masthead.nav-open .nav-toggle__bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.nav-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.55); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.28s ease, visibility 0.28s ease; }
.nav-backdrop.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

/* ==========================================================================
   Colophon / footer
   ========================================================================== */
.colophon { border-top: 1px solid var(--line-soft); margin-top: clamp(5rem, 12vw, 9rem); }
.colophon__inner { max-width: var(--page); margin: 0 auto; padding: 3rem 2.5rem 3.5rem; display: grid; grid-template-columns: 1fr auto; gap: 2rem 3rem; align-items: start; }
.colophon__name { font-family: var(--serif); font-size: 1.9rem; line-height: 1.05; color: var(--ink); }
.colophon__role { font-size: 0.9rem; color: var(--muted); margin-top: 0.4rem; }
.colophon__nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; justify-self: end; }
.colophon__nav a { color: var(--muted); transition: color 0.2s ease; min-height: 32px; display: inline-flex; align-items: center; }
.colophon__nav a:hover { color: var(--ink); }
.colophon__note { grid-column: 1 / -1; padding-top: 1.5rem; border-top: 1px solid var(--line-soft); font-size: 0.82rem; color: var(--faint); }

/* ==========================================================================
   Closing (shared) — quiet statement, not a CTA banner
   ========================================================================== */
.closing { max-width: var(--page); margin: clamp(5rem, 10vw, 8rem) auto 0; padding: 0 2.5rem; }
.closing__statement { font-family: var(--serif); font-size: clamp(2.1rem, 4.5vw, 3.4rem); line-height: 1.12; letter-spacing: -0.01em; max-width: 24ch; color: var(--ink); }
.closing__note { margin-top: 1rem; font-size: 1rem; color: var(--muted); font-style: italic; }
.closing__links { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 1.5rem; font-size: 1.1rem; font-family: var(--serif); }
.closing__links a { color: var(--ink); border-bottom: 1px solid var(--line); transition: border-color 0.2s ease; }
.closing__links a:hover { border-color: var(--ink); }
@media (max-width: 680px) { .closing { padding-left: 1.5rem; padding-right: 1.5rem; } }

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(6,6,6,0.96); display: flex; align-items: center; justify-content: center; padding: 2rem; opacity: 0; transition: opacity 0.3s ease; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox.active { opacity: 1; }
.lightbox-content { max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; }
.lightbox-content img { max-width: 100%; max-height: 80vh; object-fit: contain; box-shadow: 0 4px 60px rgba(0,0,0,0.7); }
.lightbox-caption { color: rgba(255,255,255,0.8); font-size: 0.9rem; line-height: 1.5; margin-top: 1rem; text-align: center; max-width: 640px; }
.lightbox-close { position: absolute; top: 1.25rem; right: 1.25rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border: none; background: transparent; color: rgba(255,255,255,0.8); cursor: pointer; }
.lightbox-close:hover { color: #fff; }
.lightbox-close svg { width: 24px; height: 24px; }

/* ==========================================================================
   Motion — cinematic, layered on static content, all opt-out under reduce
   ========================================================================== */

/* Cross-page transitions: clicking a project morphs its image into the
   case-study hero (Chromium; other browsers just navigate normally). */
@view-transition { navigation: auto; }

/* Hero entrance: the name reveals letter by letter (blurred cascade) */
.hero-intro__you .ch { display: inline-block; will-change: transform, filter, opacity; }
.hero-intro__you .ch--space { width: 0.26em; }

@media (prefers-reduced-motion: no-preference) {
    .hero-intro__pre   { animation: ri-fade 0.9s 0.15s both cubic-bezier(0.2, 0.7, 0.2, 1); }
    .hero-intro__you .ch { animation: ch-in 0.9s both cubic-bezier(0.16, 1, 0.3, 1); animation-delay: calc(0.35s + var(--i, 0) * 0.04s); }
    .hero-intro__links { animation: ri-fade 0.9s 1.2s both cubic-bezier(0.2, 0.7, 0.2, 1); }

    /* Scroll-linked exit — the name scales + blurs away as you scroll into the intro */
    @supports (animation-timeline: scroll()) {
        .hero-intro__name { animation: hero-exit linear both; animation-timeline: scroll(root); animation-range: 12vh 92vh; }
    }
}
@keyframes ri-fade { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes ch-in { from { opacity: 0; filter: blur(18px); transform: translateY(0.12em) scale(1.35); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes hero-exit { to { opacity: 0; filter: blur(9px); transform: scale(1.16) translateY(-28px); } }

/* Cursor glow on the hero (added by enhance.js via the .anim flag) */
.hero-intro { position: relative; }
.hero-intro > * { position: relative; z-index: 1; }
.hero-intro::before {
    content: ""; position: absolute; inset: -20% 0; z-index: 0; pointer-events: none;
    background: radial-gradient(560px circle at var(--mx, 50%) var(--my, 42%), rgba(255, 255, 255, 0.07), transparent 62%);
    opacity: 0; transition: opacity 1s ease;
}
.anim .hero-intro::before { opacity: 1; }

/* Scroll reveals — only when JS + motion allow (so no-JS keeps content visible) */
.anim .reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: calc(var(--d, 0) * 0.1s); }
.anim .reveal.is-visible { opacity: 1; transform: none; }

/* Curtain-drop image reveal + a slow settle on the image itself */
.anim .reveal-media { clip-path: inset(0 0 100% 0); transition: clip-path 1.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.anim .reveal-media.is-visible { clip-path: inset(0 0 0 0); }
.anim .reveal-media img { transform: scale(1.07); transition: transform 1.3s cubic-bezier(0.16, 1, 0.3, 1); }
.anim .reveal-media.is-visible img { transform: none; }

/* "Develop into focus" — when the portrait scrolls into view it resolves from
   dark + blurred to sharp, like a photo developing / a lens pulling focus, with a
   slow push-in. Driven by the reveal observer; static + sharp with no JS. */
.anim .develop img {
    filter: grayscale(100%) blur(28px) brightness(0.2) contrast(1.6);
    transform: scale(1.18);
    transition: filter 1.6s cubic-bezier(0.16, 1, 0.3, 1), transform 1.9s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: filter, transform;
}
.anim .develop.is-visible img {
    filter: grayscale(100%) blur(0) brightness(0.92) contrast(1.04);
    transform: none;
}

/* Magnetic 3D tilt on work images (enhance.js sets the transform) */
.band { perspective: 1100px; }
.band__media { transform-style: preserve-3d; }

/* A heavier, blurred cross-dissolve on the cross-page morph */
@media (prefers-reduced-motion: no-preference) {
    ::view-transition-group(*) { animation-duration: 0.55s; animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
    ::view-transition-old(root) { animation: vt-old 0.4s both cubic-bezier(0.5, 0, 1, 1); }
    ::view-transition-new(root) { animation: vt-new 0.55s 0.04s both cubic-bezier(0, 0, 0.2, 1); }
}
@keyframes vt-old { to { opacity: 0; filter: blur(8px); } }
@keyframes vt-new { from { opacity: 0; filter: blur(8px); } }

/* Film grain — cinematic texture over the whole dark canvas */
body::after {
    content: ""; position: fixed; inset: -60px; z-index: 60; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.05;
}
@media (prefers-reduced-motion: no-preference) {
    body::after { animation: grain 5s steps(5) infinite; }
}
@keyframes grain {
    0% { transform: translate(0, 0); } 20% { transform: translate(-8px, 6px); }
    40% { transform: translate(6px, -8px); } 60% { transform: translate(-6px, -6px); }
    80% { transform: translate(8px, 8px); } 100% { transform: translate(0, 0); }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
    .reveal, .reveal-media { opacity: 1 !important; transform: none !important; clip-path: none !important; }
    .develop img { filter: grayscale(100%) contrast(1.04) brightness(0.92) !important; transform: none !important; }
}

/* ==========================================================================
   Responsive — nav + footer
   ========================================================================== */
@media (max-width: 720px) {
    :root { --nav-h: 4rem; }
    .masthead__inner { padding: 0.6rem 1.5rem; flex-wrap: nowrap; }
    .nav-toggle { display: inline-flex; }
    .site-nav {
        position: absolute; top: 100%; left: 0; right: 0;
        background: var(--bg); border-bottom: 1px solid var(--line-soft);
        box-shadow: 0 16px 30px rgba(0,0,0,0.5);
        max-height: 0; overflow: hidden; visibility: hidden;
        transition: max-height 0.28s ease, visibility 0.28s ease;
    }
    .masthead.nav-open .site-nav { max-height: 80vh; visibility: visible; }
    .nav-links { flex-direction: column; align-items: stretch; gap: 0; padding: 0.25rem 0 0.75rem; }
    .nav-links a { display: flex; width: 100%; min-height: 52px; padding: 0.75rem 1.5rem; font-size: 1.05rem; border-top: 1px solid var(--line-soft); }
    .nav-links li:first-child a { border-top: none; }
    .nav-links li:last-child a { padding-right: 1.5rem; }
    .nav-links a:hover { background: var(--bg-deep); }
    .colophon__inner { grid-template-columns: 1fr; padding: 2.5rem 1.5rem 3rem; }
    .colophon__nav { justify-self: start; }
}
