/* ==========================================================================
   Resogen AI, site styles
   One hue per theme, one accent, the etched map behind a translucent wash.
   ========================================================================== */

:root,
[data-theme="light"] {
    --bg-canvas:   oklch(0.990 0.003 250);
    --bg-wash:     rgba(255, 255, 255, 0.82);
    --surface:     rgba(255, 255, 255, 0.72);
    --surface-2:   rgba(255, 255, 255, 0.92);
    --ink:         oklch(0.20 0.035 25);
    --ink-soft:    oklch(0.30 0.035 25);
    --ink-quiet:   oklch(0.44 0.04 25);
    --accent:      oklch(0.38 0.14 22);
    --accent-deep: oklch(0.28 0.12 22);
    --on-accent:   oklch(0.985 0.006 80);
    --status-live: oklch(0.45 0.13 148);
    --line:        oklch(0.20 0.035 25 / 0.12);
    --line-strong: oklch(0.20 0.035 25 / 0.26);
    --line-accent: oklch(0.38 0.14 22 / 0.42);
    --shadow:      oklch(0.20 0.035 25 / 0.28);
    --bezel:       oklch(0.20 0.02 25);
    --bezel-hex:   #2a2220;
    --sigil-filter: brightness(0);
    --sigil-opacity: 0.88;
    --sweep:       rgba(255, 255, 255, 0.55);
    --dust:        oklch(0.38 0.14 22);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg-canvas:   oklch(0.155 0.028 42);
    --bg-wash:     rgba(28, 22, 17, 0.88);
    --surface:     rgba(40, 32, 25, 0.62);
    --surface-2:   rgba(46, 37, 29, 0.92);
    --ink:         oklch(0.94 0.012 80);
    --ink-soft:    oklch(0.86 0.014 80);
    --ink-quiet:   oklch(0.70 0.020 75);
    --accent:      oklch(0.80 0.135 70);
    --accent-deep: oklch(0.70 0.125 70);
    --on-accent:   oklch(0.17 0.03 42);
    --status-live: oklch(0.78 0.13 148);
    --line:        oklch(0.94 0.012 80 / 0.13);
    --line-strong: oklch(0.94 0.012 80 / 0.26);
    --line-accent: oklch(0.80 0.135 70 / 0.45);
    --shadow:      oklch(0.05 0.01 42 / 0.7);
    --bezel:       oklch(0.12 0.015 42);
    --bezel-hex:   #130e0b;
    --sigil-filter: none;
    --sigil-opacity: 0.92;
    --sweep:       oklch(0.80 0.135 70 / 0.22);
    --dust:        oklch(0.85 0.12 70);
    color-scheme: dark;
}

:root {
    --font-display: 'Wix Madefor Display', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body:    'Wix Madefor Text', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --pad-x:        clamp(1.25rem, 4.5vw, 4.5rem);
    --measure:      62ch;
    --max:          1360px;

    --ease:         cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-expo:    cubic-bezier(0.16, 1, 0.3, 1);
    --dur:          220ms;
    --dur-slow:     700ms;

    --z-masthead:   30;
    --z-skip:       100;
}

/* ---------- Base ---------------------------------------------------------- */

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

html {
    background-color: var(--bg-canvas);
    overflow-x: hidden;
    overflow-x: clip;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 5.5rem;
}

body {
    color: var(--ink);
    font-family: var(--font-body);
    font-size: clamp(1rem, 0.95rem + 0.15vw, 1.0625rem);
    line-height: 1.58;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    overflow-x: clip;
    min-height: 100svh;
    position: relative;
    z-index: 0;
    background-color: var(--bg-canvas);
}

/* The wallpaper: the etched map as a living layer behind everything */
.wallpaper { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.wallpaper-img {
    position: absolute;
    inset: -4%;
    background-image: linear-gradient(var(--bg-wash), var(--bg-wash)), url('../images/background.webp');
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    translate: var(--wx, 0px) var(--wy, 0px);
    animation: wall-breathe 80s ease-in-out infinite alternate;
    will-change: transform, translate;
}
@keyframes wall-breathe {
    from { scale: 1.02; }
    to   { scale: 1.08; }
}
.wallpaper-sweep {
    position: absolute;
    inset: 0;
    background: linear-gradient(112deg, transparent 38%, var(--sweep) 50%, transparent 62%);
    background-size: 260% 100%;
    background-repeat: no-repeat;
    mix-blend-mode: soft-light;
    animation: wall-sweep 26s linear infinite;
}
[data-theme="dark"] .wallpaper-sweep { mix-blend-mode: screen; }
@keyframes wall-sweep {
    from { background-position: 130% 0; }
    to   { background-position: -130% 0; }
}
.wallpaper-dust { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0.9; }

html.theme-switching body,
html.theme-switching .masthead,
html.theme-switching .footer { transition: background-color 360ms var(--ease), color 360ms var(--ease); }

::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); color: var(--ink); }

a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.arrow { display: inline-block; transition: transform var(--dur) var(--ease); }

.skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--ink);
    color: var(--bg-canvas);
    font-size: 0.875rem;
    font-weight: 600;
    transform: translateY(-200%);
    transition: transform var(--dur) var(--ease);
    z-index: var(--z-skip);
    text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

/* ---------- Masthead ------------------------------------------------------ */

.masthead {
    position: sticky;
    top: 0;
    z-index: var(--z-masthead);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(1.5rem, 4vw, 3rem);
    padding: clamp(0.8rem, 1.6vw, 1.1rem) var(--pad-x);
    border-bottom: 1px solid transparent;
    transition: background-color 320ms var(--ease), border-color 320ms var(--ease), box-shadow 320ms var(--ease);
}
.masthead.is-scrolled {
    background: var(--bg-wash);
    border-bottom-color: var(--line-accent);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
            backdrop-filter: blur(12px) saturate(140%);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: clamp(0.6rem, 1.4vw, 0.9rem);
    text-decoration: none;
    color: var(--ink);
}
.brand-sigil {
    height: clamp(34px, 4vw, 44px);
    width: auto;
    filter: var(--sigil-filter);
    opacity: var(--sigil-opacity);
    flex-shrink: 0;
    transition: transform 600ms var(--ease-expo);
}
.brand:hover .brand-sigil { transform: rotate(-6deg); }
.brand-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    letter-spacing: -0.014em;
}

.primary-nav { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 2rem); }
.nav-list { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 1.75rem); list-style: none; margin: 0; padding: 0; }
.nav-list a {
    font-size: clamp(0.875rem, 1vw, 0.9375rem);
    font-weight: 500;
    color: var(--ink-quiet);
    text-decoration: none;
    position: relative;
    padding: 0.3rem 0;
    transition: color var(--dur) var(--ease);
}
.nav-list a::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: -1px;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 320ms var(--ease-expo);
}
.nav-list a:hover { color: var(--accent); }
.nav-list a:hover::after { transform: scaleX(1); }

.nav-divider { width: 1px; height: 18px; background: var(--line-strong); display: inline-block; }

.lang-toggle { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8125rem; color: var(--ink-quiet); }
.lang-toggle button {
    background: transparent;
    border: none;
    color: var(--ink-quiet);
    cursor: pointer;
    padding: 0.3rem 0.15rem;
    transition: color var(--dur) var(--ease);
}
.lang-toggle button[aria-pressed='true'] {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 4px;
}
.lang-toggle button:not([aria-pressed='true']):hover { color: var(--ink); }
.lang-sep { opacity: 0.4; }

.theme-toggle {
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-quiet);
    cursor: pointer;
    padding: 0.5rem;
    display: inline-flex;
    line-height: 0;
    border-radius: 3px;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 500ms var(--ease-expo);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
.theme-toggle:hover { color: var(--accent); border-color: var(--line-accent); transform: rotate(-15deg); }

/* ---------- Shared type ---------------------------------------------------- */

.section-head { max-width: var(--max); margin: 0 auto; }
.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.9rem, 4.6vw, 3.4rem);
    line-height: 1.03;
    letter-spacing: -0.024em;
    margin: 0 0 clamp(0.9rem, 2vw, 1.35rem);
    max-width: 22ch;
    color: var(--ink);
}
.section-lede {
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.15rem);
    color: var(--ink-quiet);
    max-width: 58ch;
    margin: 0 0 clamp(2.5rem, 5.5vw, 4.5rem);
    line-height: 1.6;
}

.status { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.8125rem; color: var(--status-live); }
.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--status-live);
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--status-live) 45%, transparent);
    animation: pulse 2.6s ease-out infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--status-live) 45%, transparent); }
    70%  { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.link-ext, .link-read {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.2rem 0;
    position: relative;
}
.link-ext::after, .link-read::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0.35);
    transform-origin: left center;
    transition: transform 420ms var(--ease-expo);
}
.link-ext:hover::after, .link-read:hover::after { transform: scaleX(1); }
.link-ext:hover .arrow { transform: translate(3px, -3px); }
.link-read:hover .arrow { transform: translateX(5px); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.9rem 1.5rem;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 500ms var(--ease-expo), background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    will-change: transform;
}
.btn-primary { background: var(--ink); color: var(--bg-canvas); }
.btn-primary:hover { background: var(--accent); color: var(--on-accent); box-shadow: 0 18px 36px -18px var(--shadow); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-arrow { display: inline-block; transition: transform 400ms var(--ease-expo); }
.btn:hover .btn-arrow { transform: translateY(3px); }
.btn-primary[target="_blank"]:hover .btn-arrow { transform: translate(3px, -3px); }

/* ---------- Hero ----------------------------------------------------------- */

.hero {
    position: relative;
    min-height: calc(100svh - 4.5rem);
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(2rem, 5vw, 5rem);
    padding: clamp(1.5rem, 3.5vw, 2.75rem) var(--pad-x) clamp(2rem, 4vw, 3rem);
    max-width: calc(var(--max) + 2 * var(--pad-x));
    margin: 0 auto;
}

.hero-copy { position: relative; z-index: 2; }

.hero-sigil {
    width: clamp(48px, 5vw, 64px);
    height: auto;
    filter: var(--sigil-filter);
    opacity: var(--sigil-opacity);
    margin: 0 0 clamp(1rem, 2vw, 1.5rem);
    animation: sigil-in 1100ms var(--ease-expo) both;
}
@keyframes sigil-in {
    from { opacity: 0; clip-path: inset(0 0 100% 0); transform: translateY(-6px); }
    to   { opacity: var(--sigil-opacity); clip-path: inset(0); transform: none; }
}

.hero-overline {
    font-size: clamp(0.8125rem, 1vw, 0.875rem);
    font-weight: 600;
    color: var(--accent);
    margin: 0 0 clamp(1rem, 2vw, 1.4rem);
    letter-spacing: 0.01em;
    animation: fade-up 900ms var(--ease-expo) 150ms both;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.4rem, 4.9vw, 4.2rem);
    line-height: 1.02;
    letter-spacing: -0.03em;
    color: var(--ink);
    margin: 0;
    max-width: 14ch;
}
.w-wrap { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.w { display: inline-block; animation: word-in 1000ms var(--ease-expo) both; animation-delay: calc(240ms + var(--i, 0) * 55ms); }
@keyframes word-in {
    from { transform: translateY(105%) rotate(1.5deg); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

.hero-lede {
    font-size: clamp(1rem, 1.1vw, 1.125rem);
    line-height: 1.62;
    color: var(--ink-soft);
    max-width: 50ch;
    margin: clamp(1.25rem, 2.5vw, 1.75rem) 0 0;
    animation: fade-up 900ms var(--ease-expo) 520ms both;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-top: clamp(1.5rem, 3vw, 2.25rem);
    animation: fade-up 900ms var(--ease-expo) 640ms both;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}

/* Product index inside the hero: a strip under the copy and the stage */
.hero-index {
    grid-column: 1 / -1;
    list-style: none;
    margin: clamp(1rem, 2.5vw, 2rem) 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 clamp(1rem, 2.5vw, 2rem);
    border-top: 1px solid var(--line);
    animation: fade-up 900ms var(--ease-expo) 760ms both;
}
.hero-index li { border-bottom: 1px solid var(--line); min-width: 0; }
.hero-index a {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    padding: 1rem 0.25rem 1rem 0;
    text-decoration: none;
    color: var(--ink);
    position: relative;
    transition: color var(--dur) var(--ease), padding-left 420ms var(--ease-expo);
}
.hero-index a::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    height: 1px;
    width: 0;
    background: var(--accent);
    transition: width 700ms var(--ease-expo);
}
.hero-index .ix-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.05rem, 1.4vw, 1.25rem); letter-spacing: -0.015em; }
.hero-index .ix-line { grid-column: 1 / -1; font-size: 0.875rem; line-height: 1.4; color: var(--ink-quiet); }
.hero-index .ix-arrow { grid-column: 2; grid-row: 1; color: var(--ink-quiet); opacity: 0; transform: translateX(-6px); transition: opacity var(--dur), transform 420ms var(--ease-expo), color var(--dur); }
.hero-index li.is-active a, .hero-index a:hover, .hero-index a:focus-visible { padding-left: 0.5rem; }
.hero-index li.is-active .ix-name, .hero-index a:hover .ix-name { color: var(--accent); }
.hero-index li.is-active a::before { width: 100%; transition-duration: 5200ms; transition-timing-function: linear; }
.hero-index li.is-active .ix-arrow, .hero-index a:hover .ix-arrow { opacity: 1; transform: none; color: var(--accent); }
.hero-index.is-paused li.is-active a::before { transition-duration: 300ms; }

/* Hero background: a drifting copy of the etched map, a breathing accent glow and a dot grid */
.hero-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.hero-bg-map {
    position: absolute;
    inset: -8%;
    background: url('../images/background.webp') center / cover no-repeat;
    opacity: 0.38;
    filter: saturate(1.15) contrast(1.08);
    mask-image: radial-gradient(ellipse 62% 78% at 66% 46%, #000 15%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse 62% 78% at 66% 46%, #000 15%, transparent 72%);
    animation: bg-drift 52s ease-in-out infinite alternate;
    will-change: transform;
}
@keyframes bg-drift {
    from { transform: scale(1) translate3d(0, 0, 0); }
    to   { transform: scale(1.09) translate3d(-1.6%, -1.2%, 0); }
}
.hero-bg-glow {
    position: absolute;
    width: min(62vw, 980px);
    aspect-ratio: 1;
    right: -10%;
    top: 4%;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in oklab, var(--accent) 38%, transparent) 0%, color-mix(in oklab, var(--accent) 14%, transparent) 36%, transparent 64%);
    animation: glow-breathe 11s ease-in-out infinite alternate;
    will-change: transform, opacity;
}
@keyframes glow-breathe {
    from { transform: scale(0.9) translate3d(0, 2%, 0); opacity: 0.65; }
    to   { transform: scale(1.1) translate3d(-3%, -3%, 0); opacity: 1; }
}
.hero-bg-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(color-mix(in oklab, var(--ink) 22%, transparent) 1px, transparent 1.6px);
    background-size: 26px 26px;
    mask-image: radial-gradient(ellipse 58% 72% at 70% 48%, #000, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse 58% 72% at 70% 48%, #000, transparent 72%);
    opacity: 0.55;
}
[data-theme="dark"] .hero-bg-map { opacity: 0.5; }

/* The 3D stage */
.stage {
    position: relative;
    z-index: 1;
    min-height: clamp(340px, 54vh, 640px);
    perspective: 1600px;
    perspective-origin: 40% 50%;
}
.stage-fallback { animation: stage-in 1400ms var(--ease-expo) 200ms both; }
@keyframes stage-in {
    from { opacity: 0; translate: 40px 0; }
    to   { opacity: 1; translate: 0 0; }
}
.stage-canvas {
    position: absolute;
    left: -8%;
    top: -16%;
    width: 126%;
    height: 132%;
    display: block;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 900ms var(--ease);
}
.stage.is-gl .stage-canvas { opacity: 1; }
.stage.is-gl .stage-fallback { animation: none; opacity: 0; pointer-events: none; }

.stage-fallback {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transform: rotateY(-16deg) rotateX(6deg);
    transition: opacity 600ms var(--ease);
}
.stage-card {
    position: absolute;
    left: 6%;
    top: 12%;
    width: 78%;
    text-decoration: none;
    color: inherit;
    transform-style: preserve-3d;
    transition: transform 1100ms var(--ease-expo), opacity 900ms var(--ease), filter 900ms var(--ease);
    --k: 3;
    transform: translate3d(calc(var(--k) * 7%), calc(var(--k) * -8%), calc(var(--k) * -140px));
    opacity: calc(1 - var(--k) * 0.26);
    filter: saturate(calc(1 - var(--k) * 0.15));
    cursor: pointer;
}
.stage-card.is-active { --k: 0; z-index: 4; }
.stage-card[data-k="1"] { --k: 1; z-index: 3; }
.stage-card[data-k="2"] { --k: 2; z-index: 2; }
.stage-card[data-k="3"] { --k: 3; z-index: 1; }
.stage-card .frame { box-shadow: 0 40px 80px -30px var(--shadow); }

/* ---------- Frame (device chrome around screenshots) ----------------------- */

.frame {
    display: block;
    margin: 0;
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    transform: perspective(1400px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: transform 700ms var(--ease-expo), box-shadow 500ms var(--ease), border-color var(--dur);
    will-change: transform;
}
.frame-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 2rem;
    padding: 0 0.8rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface-2) 70%, var(--bg-canvas));
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--ink-quiet);
    letter-spacing: 0.01em;
}
.frame-dots {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--line-strong);
    box-shadow: 12px 0 0 var(--line-strong), 24px 0 0 var(--line-strong);
    margin-right: 24px;
}
.frame-url::before { content: 'https://'; opacity: 0.5; }
.frame-img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    object-position: top center;
    display: block;
}
.frame-hero .frame-img { aspect-ratio: 2 / 1.08; }
.frame-link { display: block; text-decoration: none; color: inherit; }
.frame-link:hover .frame, .frame-link:focus-visible .frame {
    box-shadow: 0 40px 70px -32px var(--shadow);
    border-color: var(--line-accent);
}

/* ---------- Work: the product index ---------------------------------------- */

.work, .method, .founder {
    padding: clamp(4rem, 9vw, 8rem) var(--pad-x);
    max-width: calc(var(--max) + 2 * var(--pad-x));
    margin: 0 auto;
    position: relative;
}
.work { padding-top: clamp(3rem, 7vw, 6rem); }

.product {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: clamp(2rem, 5vw, 5rem);
    align-items: center;
    padding: clamp(3rem, 7vw, 6rem) 0;
    border-top: 1px solid var(--line);
}
.product:nth-of-type(even) .product-text { order: 2; }
.product:nth-of-type(even) .frame-link { order: 1; }

.product-text, .product .frame-link { position: relative; z-index: 1; }

.product-kicker { font-size: 0.8125rem; font-weight: 600; color: var(--accent); margin: 0 0 0.9rem; }
.product-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 4.8vw, 3.4rem);
    line-height: 1.02;
    letter-spacing: -0.028em;
    margin: 0 0 clamp(1rem, 2.5vw, 1.5rem);
}
.product-name a { text-decoration: none; color: var(--ink); transition: color var(--dur); }
.product-name a:hover { color: var(--accent); }
.product-summary {
    font-size: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);
    line-height: 1.62;
    color: var(--ink-soft);
    max-width: 50ch;
    margin: 0 0 clamp(1.25rem, 3vw, 1.75rem);
}
.product-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem 1.4rem; margin: 0 0 1.1rem; font-size: 0.9375rem; }
.product .link-read { font-size: 1rem; }

/* ---------- Method --------------------------------------------------------- */

.method { border-top: 1px solid var(--line); }
.method-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: clamp(2rem, 4vw, 3.5rem);
}
.method-item { position: relative; padding-top: 1.5rem; }
.method-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    height: 1px;
    width: 100%;
    background: var(--line-strong);
}
.method-item::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    height: 1px;
    width: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 1200ms var(--ease-expo);
    transition-delay: calc(var(--i, 0) * 140ms);
}
.method-item.in-view::after { transform: scaleX(1); }
.method-item h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    letter-spacing: -0.016em;
    margin: 0 0 0.75rem;
}
.method-item p { margin: 0; color: var(--ink-soft); max-width: 42ch; }

/* ---------- Founder -------------------------------------------------------- */

.founder { border-top: 1px solid var(--line); }
.founder-row { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.founder-figure { margin: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 6px; }
.founder-figure img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.founder-name { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.25rem, 2.2vw, 1.5rem); letter-spacing: -0.014em; margin: 0 0 1rem; }
.founder-line { color: var(--ink-soft); max-width: 52ch; margin: 0 0 1.5rem; }
.founder-links { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0; }

/* ---------- Contact (the accent drench) ------------------------------------ */

.contact {
    background: var(--accent);
    color: var(--on-accent);
    padding: clamp(5rem, 11vw, 10rem) var(--pad-x);
    position: relative;
    overflow: hidden;
}
.contact-sigil {
    position: absolute;
    right: -6%;
    top: -10%;
    width: clamp(260px, 36vw, 560px);
    aspect-ratio: 1 / 1.5;
    background: url('../images/sigil.png') center / contain no-repeat;
    opacity: 0.07;
    filter: brightness(10);
    pointer-events: none;
    rotate: -8deg;
}
[data-theme="dark"] .contact-sigil { filter: brightness(0); opacity: 0.12; }
.contact-inner { max-width: var(--max); margin: 0 auto; position: relative; }
.contact .section-title { color: var(--on-accent); }
.contact-line { font-size: clamp(1.0625rem, 1.5vw, 1.2rem); line-height: 1.55; max-width: 56ch; margin: 0 0 clamp(2.25rem, 5vw, 3.25rem); opacity: 0.92; }
.contact-mail {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.7rem, 5.6vw, 4.6rem);
    letter-spacing: -0.032em;
    color: var(--on-accent);
    text-decoration: none;
    position: relative;
    padding-bottom: 0.08em;
    word-break: break-word;
    transition: transform 500ms var(--ease-expo);
    will-change: transform;
}
.contact-mail::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2px;
    background: currentColor;
    transform: scaleX(0.18);
    transform-origin: left center;
    transition: transform 800ms var(--ease-expo);
    opacity: 0.8;
}
.contact-mail:hover::after, .contact-mail:focus-visible::after { transform: scaleX(1); }
.contact-mail:focus-visible { outline-color: var(--on-accent); outline-offset: 10px; }
.contact-tools { margin-top: 1.75rem; }
.copy-btn {
    background: transparent;
    border: 1px solid color-mix(in oklab, var(--on-accent) 45%, transparent);
    color: var(--on-accent);
    padding: 0.6rem 1rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
    transition: border-color var(--dur), background-color var(--dur);
}
.copy-btn:hover { border-color: var(--on-accent); background: color-mix(in oklab, var(--on-accent) 10%, transparent); }
.copy-btn:focus-visible { outline-color: var(--on-accent); }
.copy-done:empty { display: none; }
.copy-done::before { content: '·'; opacity: 0.6; margin-right: 0.6rem; }

/* ---------- Footer --------------------------------------------------------- */

.footer { background: var(--bg-wash); border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--ink-quiet); }
.footer-inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: clamp(2.5rem, 5vw, 3.5rem) var(--pad-x);
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem 3rem;
}
.footer-brand { display: flex; align-items: flex-start; gap: 0.9rem; }
.footer-brand img { height: 40px; width: auto; filter: var(--sigil-filter); opacity: 0.7; }
.footer-name { margin: 0; font-family: var(--font-display); font-weight: 700; color: var(--ink); font-size: 1rem; }
.footer-tag { margin: 0.2rem 0 0; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.footer-links a { color: var(--ink); text-decoration: none; position: relative; transition: color var(--dur); }
.footer-links a:hover { color: var(--accent); }
.footer-ext { color: var(--ink-quiet) !important; font-size: 0.8125rem; margin-left: 0.5rem; }
.footer-ext:hover { color: var(--accent) !important; }
.footer-copy { color: var(--ink-quiet); }

/* ---------- Product page --------------------------------------------------- */

.page { max-width: calc(var(--max) + 2 * var(--pad-x)); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) var(--pad-x) 0; }
.page-hero { max-width: 60ch; margin-bottom: clamp(2rem, 4vw, 3rem); }
.crumbs { margin: 0 0 clamp(1.5rem, 3vw, 2.5rem); font-size: 0.875rem; animation: fade-up 700ms var(--ease-expo) both; }
.crumbs a { display: inline-flex; gap: 0.5rem; align-items: baseline; color: var(--ink-quiet); text-decoration: none; font-weight: 500; transition: color var(--dur); }
.crumbs a:hover { color: var(--accent); }
.crumbs a:hover .arrow { transform: translateX(-4px); }
.page-kicker { font-size: 0.8125rem; font-weight: 600; color: var(--accent); margin: 0 0 0.8rem; animation: fade-up 800ms var(--ease-expo) 60ms both; }
.page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.6rem, 7vw, 5.6rem);
    line-height: 1;
    letter-spacing: -0.034em;
    margin: 0 0 1rem;
    animation: fade-up 900ms var(--ease-expo) 120ms both;
}
.page-line { font-size: clamp(1.15rem, 1.8vw, 1.5rem); line-height: 1.4; color: var(--ink-soft); margin: 0 0 1.5rem; max-width: 36ch; animation: fade-up 900ms var(--ease-expo) 220ms both; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; animation: fade-up 900ms var(--ease-expo) 320ms both; }

.frame-hero { margin: 0 0 clamp(3rem, 6vw, 5rem); animation: frame-in 1300ms var(--ease-expo) 260ms both; }
@keyframes frame-in {
    from { opacity: 0; translate: 0 40px; }
    to   { opacity: 1; translate: 0 0; }
}

.page-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(2rem, 6vw, 6rem); align-items: start; }
.page-aside { position: sticky; top: 6rem; }
.toc-title { font-size: 0.75rem; font-weight: 600; color: var(--ink-quiet); margin: 0 0 0.75rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a {
    display: block;
    padding: 0.4rem 0 0.4rem 1rem;
    margin-left: -1px;
    border-left: 1px solid transparent;
    color: var(--ink-quiet);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--dur), border-color var(--dur), padding-left 400ms var(--ease-expo);
}
.toc a:hover { color: var(--ink); }
.toc a.is-current { color: var(--accent); border-left-color: var(--accent); padding-left: 1.3rem; font-weight: 600; }

.page-body { max-width: var(--measure); min-width: 0; }

.facts { margin-bottom: clamp(3rem, 6vw, 4.5rem); padding: clamp(1.5rem, 3vw, 2.25rem); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.facts-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin: 0 0 1.25rem; color: var(--ink-quiet); letter-spacing: -0.01em; }
.facts-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem 2rem; margin: 0; }
.fact dt { font-size: 0.75rem; font-weight: 600; color: var(--accent); margin-bottom: 0.25rem; }
.fact dd { margin: 0; font-size: 0.9375rem; line-height: 1.5; color: var(--ink); }

.prose-section { margin-bottom: clamp(3.5rem, 7vw, 5.5rem); scroll-margin-top: 6rem; }
.prose-section h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    letter-spacing: -0.022em;
    line-height: 1.1;
    margin: 0 0 1.25rem;
}
.prose-section p { margin: 0 0 1.25rem; font-size: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem); line-height: 1.68; color: var(--ink-soft); }
.prose-section strong { color: var(--ink); font-weight: 600; }

.steps { list-style: none; margin: 0 0 1.5rem; padding: 0; counter-reset: step; }
.steps li { position: relative; padding: 1rem 0 1rem 3.25rem; border-top: 1px solid var(--line); color: var(--ink-soft); line-height: 1.62; counter-increment: step; }
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before {
    content: counter(step, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 1.1rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.bullets { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.bullets li { position: relative; padding: 0.5rem 0 0.5rem 1.4rem; color: var(--ink-soft); line-height: 1.62; }
.bullets li::before { content: ''; position: absolute; left: 0; top: 1.05rem; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { text-align: left; padding: 0.8rem 1rem; vertical-align: top; border-bottom: 1px solid var(--line); line-height: 1.5; }
th { font-size: 0.75rem; font-weight: 600; color: var(--ink-quiet); background: color-mix(in oklab, var(--surface-2) 60%, transparent); }
tbody tr:last-child td { border-bottom: none; }
td:first-child { font-weight: 600; color: var(--ink); white-space: nowrap; }

.fig { margin: clamp(2rem, 4vw, 2.75rem) 0; }
.fig .frame-img { aspect-ratio: auto; height: auto; object-fit: fill; }
.fig figcaption { margin-top: 0.75rem; font-size: 0.875rem; color: var(--ink-quiet); line-height: 1.5; }

.page-next { margin: clamp(3rem, 7vw, 6rem) 0 0; border-top: 1px solid var(--line); }
.next-link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
    gap: 2rem;
    align-items: center;
    padding: clamp(2.5rem, 5vw, 4rem) 0;
    text-decoration: none;
    color: inherit;
}
.next-kicker { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--accent); margin-bottom: 0.6rem; }
.next-name { display: inline-flex; gap: 0.6rem; align-items: baseline; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 4.6vw, 3.4rem); letter-spacing: -0.028em; line-height: 1.02; }
.next-line { display: block; margin-top: 0.6rem; color: var(--ink-quiet); }
.next-figure { display: block; overflow: hidden; border-radius: 6px; border: 1px solid var(--line-strong); transform: perspective(1200px) rotateY(-8deg); transition: transform 800ms var(--ease-expo), box-shadow 500ms var(--ease); }
.next-figure img { aspect-ratio: 16 / 10; object-fit: cover; object-position: top center; }
.next-link:hover .next-figure { transform: perspective(1200px) rotateY(0); box-shadow: 0 30px 60px -30px var(--shadow); }
.next-link:hover .next-name { color: var(--accent); }
.next-link:hover .arrow { transform: translateX(8px); }

/* ---------- Reveals and parallax ------------------------------------------ */

html.js [data-reveal] {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 900ms var(--ease-expo), transform 1000ms var(--ease-expo);
}
html.js [data-reveal].in-view { opacity: 1; transform: none; }
html.js .product.in-view .frame-link { animation: frame-reveal 1200ms var(--ease-expo) both; }
@keyframes frame-reveal {
    from { clip-path: inset(0 0 18% 0 round 6px); transform: translateY(20px); }
    to   { clip-path: inset(0 round 6px); transform: none; }
}

[data-parallax] { will-change: transform; }
.frame-par { display: block; will-change: transform; }

/* ---------- Cross-document view transitions -------------------------------- */

@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
    ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 340ms; animation-timing-function: var(--ease-expo); }
    ::view-transition-group(*) { animation-duration: 620ms; animation-timing-function: var(--ease-expo); }
}

/* ---------- Reduced motion ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    html.js [data-reveal] { opacity: 1; transform: none; transition: none; }
    html.js .product.in-view .frame-link { animation: none; }
    .wallpaper-img, .wallpaper-sweep, .hero-sigil, .hero-overline, .hero-lede, .hero-actions, .hero-index, .w, .stage, .stage-fallback, .hero-bg-map, .hero-bg-glow, .crumbs, .page-kicker, .page-title, .page-line, .page-actions, .frame-hero { animation: none !important; }
    .status-dot { animation: none; }
    .wallpaper-dust { display: none; }
    .stage-card { transition: opacity 300ms var(--ease); }
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Responsive ----------------------------------------------------- */

@media (max-width: 1100px) {
    .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .page-grid { grid-template-columns: 190px minmax(0, 1fr); }
}

@media (max-width: 980px) {
    .hero { grid-template-columns: 1fr; grid-template-rows: auto; min-height: 0; padding-top: clamp(1.5rem, 4vw, 3rem); }
    html.js [data-reveal] { transform: translateY(14px); transition-duration: 600ms; }
    html.js .product.in-view .frame-link { animation: none; }
    .stage-fallback { transform: rotateY(-7deg) rotateX(3deg); }
    .stage-card { left: 3%; top: 4%; width: 92%; transform: none; opacity: 0; filter: none; transition: opacity 500ms var(--ease); pointer-events: none; }
    .stage-card.is-active { pointer-events: auto; }
    .hero-bg-glow { width: 90vw; right: -30%; top: -10%; }
    .stage-card.is-active { opacity: 1; }
    .stage-canvas { display: none; }
    .stage { overflow: hidden; }
    .work, .method, .founder, .page { overflow-x: clip; }
    .hero-index { grid-template-columns: 1fr 1fr; }
    .stage { order: -1; min-height: 0; aspect-ratio: 16 / 11; perspective-origin: 50% 50%; margin-bottom: 0.5rem; }
    .product, .founder-row { grid-template-columns: 1fr; gap: 1.75rem; }
    .product:nth-of-type(even) .product-text { order: 2; }
    .product:nth-of-type(even) .frame-link { order: 1; }
    .product .frame-link { order: 1; }
    .product .product-text { order: 2; }
    .page-grid { grid-template-columns: 1fr; }
    .page-aside { position: static; }
    .toc { display: none; }
    .next-link { grid-template-columns: 1fr; }
    .next-figure { transform: none; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
    .masthead { flex-wrap: wrap; row-gap: 0.5rem; }
    .primary-nav { width: 100%; justify-content: space-between; padding-top: 0.25rem; }
    .nav-list { gap: 1.1rem; }
    .nav-divider { display: none; }
    .hero-index { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .brand-mark { font-size: 1rem; }
    .nav-list a { font-size: 0.8125rem; }
    .hero-title { font-size: clamp(2.2rem, 11vw, 3rem); }
    .btn { padding: 0.8rem 1.1rem; font-size: 0.875rem; }
}
