/* ============================================================
   rarysh.github.io — design system
   Hand-written. No framework, no build step.
   ============================================================ */

/* Self-hosted variable fonts — no third-party request, no FOUT dependency
   on someone else's CDN. Latin subset only; Portuguese sits inside U+00FF. */
@font-face {
  font-family: "Inter var";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Grotesk var";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@layer reset, tokens, base, layout, components, motion, utils;

/* ---------- reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
  img, picture, svg, video { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  p, h1, h2, h3, h4 { overflow-wrap: break-word; }
  main ul { list-style: none; padding: 0; }
  a { color: inherit; }
}

/* ---------- tokens ---------- */
@layer tokens {
  :root {
    /* palette — deliberate dark. Near-black base, cool grey ramp, one accent. */
    --bg:            #08090b;
    --bg-elevated:   #0e1014;
    --bg-sunken:     #050607;
    --surface:       #12151a;
    --border:        #1e2229;
    --border-strong: #2c323b;

    --text:          #e8eaed;
    --text-muted:    #9aa2ad;
    --text-faint:    #646c78;

    --accent:        #7dd3a0;
    --accent-dim:    #4c9c72;
    --accent-glow:   color-mix(in oklab, var(--accent) 18%, transparent);

    /* fluid type — 320px → 1440px */
    --step--1: clamp(0.83rem, 0.80rem + 0.14vw, 0.90rem);
    --step-0:  clamp(0.95rem, 0.90rem + 0.24vw, 1.06rem);
    --step-1:  clamp(1.15rem, 1.05rem + 0.45vw, 1.40rem);
    --step-2:  clamp(1.45rem, 1.25rem + 0.95vw, 2.00rem);
    --step-3:  clamp(1.85rem, 1.45rem + 1.90vw, 2.90rem);
    --step-4:  clamp(2.35rem, 1.60rem + 3.60vw, 4.40rem);
    --step-5:  clamp(2.90rem, 1.60rem + 6.20vw, 6.40rem);

    --font-sans: "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: "Grotesk var", "Inter var", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

    /* spacing — 4px base */
    --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
    --sp-6: 1.5rem;  --sp-8: 2rem;    --sp-12: 3rem;   --sp-16: 4rem;
    --sp-24: 6rem;   --sp-32: 8rem;

    --radius:    10px;
    --radius-lg: 16px;

    --measure: 62ch;
    --gutter: clamp(1.25rem, 4vw, 3rem);
    --wrap: 68rem;

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* ---------- base ---------- */
@layer base {
  html { scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--step-0);
    line-height: 1.65;
    letter-spacing: -0.005em;
    min-height: 100svh;
  }

  /* ambient light — a single soft bloom behind the hero, nothing more */
  body::before {
    content: "";
    position: fixed;
    inset: -20% 0 auto;
    height: 70vh;
    background: radial-gradient(60% 60% at 50% 0%, var(--accent-glow), transparent 70%);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
  }

  h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.08;
    letter-spacing: -0.03em;
    font-weight: 600;
    text-wrap: balance;
  }
  /* Space Grotesk sits wide at display sizes — pull it in as it grows */
  .hero__title { letter-spacing: -0.05em; }
  .section__title, .case__title, .modal__title { letter-spacing: -0.035em; }
  p { text-wrap: pretty; }

  a { text-decoration-thickness: 1px; text-underline-offset: 0.25em; }

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

  ::selection { background: var(--accent); color: var(--bg); }
}

/* ---------- layout ---------- */
@layer layout {
  .wrap {
    width: min(100% - var(--gutter) * 2, var(--wrap));
    margin-inline: auto;
  }

  main { position: relative; z-index: 1; }

  .section { padding-block: clamp(var(--sp-12), 8vw, var(--sp-24)); }

  .section__head {
    display: flex;
    align-items: baseline;
    gap: var(--sp-4);
    margin-bottom: var(--sp-12);
  }
  .section__num {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent-dim);
    letter-spacing: 0.08em;
  }
  .section__title {
    font-size: var(--step-2);
  }
  .section__rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-strong), transparent);
  }

  .skip {
    position: absolute;
    left: var(--sp-4);
    top: var(--sp-4);
    padding: var(--sp-2) var(--sp-4);
    background: var(--accent);
    color: var(--bg);
    border-radius: var(--radius);
    font-weight: 600;
    transform: translateY(-200%);
    z-index: 100;
  }
  .skip:focus-visible { transform: none; }
}

/* ---------- components ---------- */
@layer components {

  /* --- nav --- */
  .nav {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px) saturate(160%);
    background: color-mix(in oklab, var(--bg) 72%, transparent);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
  }
  .nav[data-scrolled="true"] {
    border-bottom-color: var(--border);
    background: color-mix(in oklab, var(--bg) 88%, transparent);
  }
  .nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-6);
    padding-block: var(--sp-4);
  }
  .nav__brand {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.02em;
    text-decoration: none;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
  }
  .nav__dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent);
    animation: pulse 3s var(--ease) infinite;
  }
  .nav__links {
    display: flex;
    gap: clamp(var(--sp-4), 3vw, var(--sp-8));
    font-size: var(--step--1);
  }
  .nav__links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s var(--ease);
  }
  .nav__links a:hover,
  .nav__links a[aria-current="true"] { color: var(--text); }
  /* Never hide the nav on small screens — shrink it instead. */
  @media (max-width: 34rem) {
    .nav__links { gap: var(--sp-4); font-size: 0.8rem; }
    .nav__links a[href="#skills"] { display: none; }
  }

  /* --- reading progress: fills as you move down the page --- */
  .progress {
    position: fixed;
    inset: 0 0 auto;
    height: 2px;
    z-index: 60;
    background: transparent;
    transform-origin: left;
    transform: scaleX(var(--p, 0));
    background-image: linear-gradient(90deg, var(--accent-dim), var(--accent));
    pointer-events: none;
  }

  /* --- film grain: kills banding on the dark gradients, adds depth --- */
  .grain {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    opacity: 0.028;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  /* --- hero --- */
  .hero {
    position: relative;
    padding-block: clamp(var(--sp-12), 11vh, var(--sp-24)) clamp(var(--sp-12), 9vw, var(--sp-24));
    overflow: hidden;
  }
  .hero__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
    gap: clamp(var(--sp-8), 5vw, var(--sp-16));
    align-items: center;
  }
  @media (max-width: 62rem) {
    .hero__grid { grid-template-columns: 1fr; }
    .pipeline { order: 2; max-width: 34rem; }
  }
  .hero__inner { position: relative; z-index: 1; }

  .hero__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: 999px;
    padding: var(--sp-1) var(--sp-3);
    margin-bottom: var(--sp-6);
  }
  .hero__eyebrow .nav__dot { animation-duration: 4s; }

  .hero__title {
    font-size: var(--step-5);
    letter-spacing: -0.05em;
    font-weight: 600;
    max-width: 13ch;
  }
  /* Solid colour is the base: without JS there are no .word spans to paint. */
  .hero__title em {
    font-style: normal;
    color: var(--accent);
  }
  /* With the split in place, gradient each word — clipping text on the <em>
     itself paints nothing, because its text lives inside the spans. */
  .hero__title .word {
    background: linear-gradient(180deg, #ffffff 0%, #c9ced6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .hero__title em .word {
    font-style: normal;
    background: linear-gradient(120deg, #a8e6c0 0%, var(--accent) 55%, var(--accent-dim) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .hero__lede {
    margin-top: var(--sp-6);
    font-size: var(--step-1);
    color: var(--text-muted);
    max-width: 40ch;
    line-height: 1.55;
  }
  .hero__actions {
    margin-top: var(--sp-8);
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
  }

  /* --- live pipeline diagram: the signature object of the page --- */
  .pipeline {
    position: relative;
    margin: 0;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background:
      radial-gradient(120% 90% at 50% 0%, color-mix(in oklab, var(--accent) 7%, transparent), transparent 60%),
      linear-gradient(165deg, var(--bg-elevated), var(--bg-sunken));
    overflow: hidden;
    box-shadow: 0 40px 80px -40px rgb(0 0 0 / 0.9);
  }
  /* faint engineering grid behind the graph */
  .pipeline::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
      linear-gradient(var(--border) 1px, transparent 1px),
      linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 34px 34px;
    opacity: 0.35;
    mask-image: radial-gradient(75% 75% at 50% 45%, #000, transparent 78%);
  }
  .pipeline__canvas {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
  }
  .pipeline__cap {
    position: absolute;
    right: var(--sp-4);
    top: var(--sp-4);
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: color-mix(in oklab, var(--bg) 70%, transparent);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: var(--sp-1) var(--sp-3);
  }
  .pipeline__dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2.4s var(--ease) infinite;
  }

  /* --- buttons --- */
  .btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-6);
    background: var(--btn-bg);
    color: var(--btn-fg);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    text-decoration: none;
    font-size: var(--step--1);
    font-weight: 500;
    transition: transform 0.2s var(--ease-out), background 0.2s var(--ease), border-color 0.2s var(--ease);
  }
  .btn:hover { transform: translateY(-2px); border-color: var(--text-faint); }
  .btn:active { transform: translateY(0); }
  .btn--primary {
    --btn-bg: var(--accent);
    --btn-fg: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
  }
  .btn--primary:hover { background: color-mix(in oklab, var(--accent) 88%, #fff); }
  .btn svg { width: 1em; height: 1em; }

  /* --- experience timeline --- */
  .roles { display: grid; gap: var(--sp-4); }
  .role {
    display: grid;
    grid-template-columns: minmax(0, 12rem) minmax(0, 1fr);
    gap: var(--sp-6);
    padding: var(--sp-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-sunken));
    transition: border-color 0.3s var(--ease), transform 0.3s var(--ease-out);
  }
  .role:hover { border-color: var(--border-strong); }
  @media (max-width: 44rem) {
    .role { grid-template-columns: 1fr; gap: var(--sp-3); }
  }
  .role__period {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-faint);
    letter-spacing: 0.02em;
    padding-top: 0.2em;
  }
  .role__title { font-size: var(--step-1); }
  .role__org {
    color: var(--accent);
    font-size: var(--step-0);
    margin-top: var(--sp-1);
  }
  .role__points {
    margin-top: var(--sp-4);
    display: grid;
    gap: var(--sp-2);
    color: var(--text-muted);
    max-width: var(--measure);
  }
  .role__points li {
    position: relative;
    padding-left: var(--sp-6);
  }
  .role__points li::before {
    content: "";
    position: absolute;
    left: 0; top: 0.72em;
    width: var(--sp-3); height: 1px;
    background: var(--border-strong);
  }
  .role__points strong { color: var(--text); font-weight: 600; }

  /* Timeline rail: a spine outside the cards, with each role hanging off it.
     Runs accent at the present and fades back through time. */
  .roles {
    position: relative;
    --rail: 2.75rem;
    padding-left: var(--rail);
  }
  .roles::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 10px;
    bottom: 22px;
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(180deg,
      var(--accent) 0%,
      var(--accent-dim) 18%,
      var(--border-strong) 55%,
      var(--border) 100%);
  }
  /* arrowhead closing the spine */
  .roles::after {
    content: "";
    position: absolute;
    left: 3px;
    bottom: 6px;
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 10px solid var(--border);
  }

  .role { position: relative; }
  /* node sits on the spine, in the gutter — not inside the card */
  .role::before {
    content: "";
    position: absolute;
    left: calc(var(--rail) * -1 + 3px);
    top: calc(var(--sp-6) + 0.5em);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--border-strong);
    z-index: 2;
    transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
  }
  .role:first-child::before {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 5px color-mix(in oklab, var(--accent) 16%, transparent);
  }
  .role:hover::before { border-color: var(--accent); }

  @media (max-width: 44rem) {
    .roles { padding-left: 0; }
    .roles::before, .roles::after, .role::before { display: none; }
  }

  .role__meta { display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; }
  .role__badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
    background: color-mix(in oklab, var(--accent) 10%, transparent);
    border-radius: 999px;
    padding: 0.1rem var(--sp-2);
  }
  .role__blurb { color: var(--text-muted); margin-top: var(--sp-3); max-width: var(--measure); }
  .role__stack {
    display: flex; flex-wrap: wrap; gap: var(--sp-2);
    margin-top: var(--sp-4);
    font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint);
  }
  .role__stack li { border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem var(--sp-2); }

  /* --- stat row --- */
  .stats {
    margin-top: clamp(var(--sp-12), 8vw, var(--sp-16));
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
    gap: var(--sp-6);
    border-top: 1px solid var(--border);
    padding-top: var(--sp-8);
  }
  .stat dd {
    font-size: var(--step-3);
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--accent);
    margin: 0;
    font-variant-numeric: tabular-nums;
  }
  .stat dt {
    order: 2;
    font-size: var(--step--1);
    color: var(--text-faint);
    margin-top: var(--sp-1);
  }
  .stat { display: flex; flex-direction: column; }

  /* --- logo wall --- */
  .logos-section { padding-block: var(--sp-8) var(--sp-4); }
  .logos__label {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-faint);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: var(--sp-6);
  }
  .logos {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-6) clamp(var(--sp-6), 3.2vw, var(--sp-12));
    row-gap: var(--sp-6);
  }
  .logo--text { font-size: var(--step-0); }
  /* One dark chip for every mark. Brand colour is kept; only near-black ink was
     lifted to white in the asset itself, so each logo holds contrast here. */
  .logo {
    display: grid;
    place-items: center;
    background: #16181d;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-3) var(--sp-6);
    min-width: 8.5rem;
    min-height: 3.5rem;
    opacity: 0.86;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease-out), border-color 0.3s var(--ease);
  }
  .logo:hover { border-color: var(--border-strong); }
  .logo img {
    height: clamp(1.4rem, 2vw, 1.7rem);
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }
  /* Marks with stacked icon-over-text need more height to read at the same
     optical weight as a single-line wordmark. */
  .logo img.tall { height: clamp(2.2rem, 3.2vw, 2.8rem); }

  /* StopChurn only publishes a square icon, so the name is set alongside it. */
  .logo--lockup {
    grid-auto-flow: column;
    gap: var(--sp-3);
    align-items: center;
  }
  .logo--lockup img { height: clamp(1.7rem, 2.4vw, 2.1rem); border-radius: 6px; }
  .logo--lockup span {
    font-size: var(--step-0);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f4f5f7;
  }

  .logo--text {
    font-size: var(--step-0);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f4f5f7;
  }
  .logo:hover { opacity: 1; transform: translateY(-2px); }

  /* --- case studies --- */
  .cases { display: grid; gap: clamp(var(--sp-8), 6vw, var(--sp-16)); }
  .case {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(var(--sp-6), 4vw, var(--sp-12));
    align-items: center;
  }
  .case--flip .case__body { order: 2; }
  @media (max-width: 52rem) {
    .case, .case--flip .case__body { grid-template-columns: 1fr; order: 0; }
  }
  .case__kicker {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: var(--sp-2);
  }
  .case__title { font-size: var(--step-2); }
  .case__desc { color: var(--text-muted); margin-top: var(--sp-3); max-width: var(--measure); }
  .case__points {
    margin-top: var(--sp-4);
    display: grid; gap: var(--sp-2);
    color: var(--text-muted);
  }
  .case__points li { position: relative; padding-left: var(--sp-6); }
  .case__points li::before {
    content: "→";
    position: absolute; left: 0;
    color: var(--accent-dim);
  }
  .case .card__tags { margin-top: var(--sp-6); }

  /* --- portfolio grid --- */
  .section__lede {
    color: var(--text-muted);
    max-width: var(--measure);
    margin-top: calc(var(--sp-12) * -1 + var(--sp-4));
    margin-bottom: var(--sp-12);
  }

  /* Bento: a designed arrangement, not a uniform card wall. Two tiles lead at
     double width, the rest fill in — so the eye has somewhere to land first. */
  .folio {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--sp-4);
  }
  .folio__item { grid-column: span 2; }
  .folio__item:nth-child(1),
  .folio__item:nth-child(8) { grid-column: span 4; }
  .folio__item:nth-child(1) .folio__media,
  .folio__item:nth-child(8) .folio__media { aspect-ratio: 21 / 9; }
  .folio__item:nth-child(1) .folio__title,
  .folio__item:nth-child(8) .folio__title { font-size: var(--step-2); }

  @media (max-width: 68rem) {
    .folio { grid-template-columns: repeat(4, 1fr); }
    .folio__item { grid-column: span 2; }
    .folio__item:nth-child(1),
    .folio__item:nth-child(8) { grid-column: span 4; }
  }
  @media (max-width: 44rem) {
    .folio { grid-template-columns: 1fr; }
    .folio__item,
    .folio__item:nth-child(1),
    .folio__item:nth-child(8) { grid-column: span 1; }
    .folio__item:nth-child(1) .folio__media,
    .folio__item:nth-child(8) .folio__media { aspect-ratio: 16 / 10; }
  }
  .folio__item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-sunken));
    overflow: hidden;
    transition: border-color 0.3s var(--ease), transform 0.35s var(--ease-out);
  }
  .folio__item::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg, color-mix(in oklab, var(--accent) 55%, transparent), transparent 42%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s var(--ease);
    pointer-events: none;
    z-index: 1;
  }
  .folio__item { position: relative; }
  .folio__item:hover::before { opacity: 1; }
  .folio__item:hover { border-color: var(--border-strong); transform: translateY(-4px); }

  .folio__media {
    display: block;
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);
  }
  .folio__media img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-out), filter 0.4s var(--ease);
    filter: saturate(0.9);
  }
  .folio__item:hover .folio__media img { transform: scale(1.04); filter: saturate(1.05); }

  /* Scroll-driven parallax: the shot drifts inside its frame as the card
     crosses the viewport. Pure CSS, no scroll listener. */
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      .folio__media img {
        animation: drift linear both;
        animation-timeline: view();
        animation-range: entry 0% exit 100%;
      }
      .folio__item:hover .folio__media img { animation-play-state: paused; }
    }
  }

  .folio__body {
    padding: var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    flex: 1;
  }
  .folio__meta {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-faint);
    letter-spacing: 0.04em;
  }
  .folio__title { font-size: var(--step-1); font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; }
  .folio__desc { color: var(--text-muted); font-size: var(--step-0); flex: 1; }
  .folio__item .card__tags { margin: 0 var(--sp-6) var(--sp-6); }

  /* the whole card is the trigger — a button, not a link, since it opens a dialog */
  .folio__open {
    display: flex;
    flex-direction: column;
    background: none;
    border: 0;
    padding: 0;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    flex: 1;
  }
  .folio__cta {
    margin-top: var(--sp-4);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
  }
  .folio__cta::after {
    content: "→";
    transition: transform 0.3s var(--ease-out);
  }
  .folio__item:hover .folio__cta::after { transform: translateX(4px); }
  .folio__open:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

  /* full case copy lives in the DOM: readable with JS off, cloned into the dialog with it on */
  .folio__full { display: none; }
  .no-js .folio__full {
    display: block;
    padding: 0 var(--sp-6) var(--sp-6);
    color: var(--text-muted);
  }
  .folio__shots { display: none; }
  .no-js .folio__shots { display: grid; gap: var(--sp-3); margin-top: var(--sp-4); }
  .no-js .folio__shots img { border-radius: var(--radius); border: 1px solid var(--border); }

  /* --- modal --- */
  .modal[hidden] { display: none; }
  .modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: var(--gutter);
  }
  .modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / 0.72);
    backdrop-filter: blur(6px);
    animation: fade 0.25s var(--ease) both;
  }
  .modal__panel {
    position: relative;
    width: min(100%, 46rem);
    max-height: min(86svh, 52rem);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 40px 90px -30px rgb(0 0 0 / 0.9);
    overflow: hidden;
    animation: pop 0.32s var(--ease-out) both;
  }
  .modal__scroll {
    overflow-y: auto;
    max-height: inherit;
    padding: clamp(var(--sp-6), 4vw, var(--sp-12));
    overscroll-behavior: contain;
    /* scrollbar stays inside the panel and matches the page, not the OS */
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
  .modal__scroll::-webkit-scrollbar { width: 10px; }
  .modal__scroll::-webkit-scrollbar-track {
    background: transparent;
    margin-block: var(--sp-2);
  }
  .modal__scroll::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 3px solid var(--bg-elevated);
  }
  .modal__scroll::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

  /* --- modal gallery --- */
  .modal__gallery { margin-top: var(--sp-6); }
  .modal__main {
    width: 100%;
    aspect-ratio: 16 / 10;
    /* contain, not cover — a screenshot cropped at the edges stops being evidence */
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-sunken);
  }
  .modal__thumbs {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    overflow-x: auto;
    padding-bottom: var(--sp-2);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
  .modal__thumbs::-webkit-scrollbar { height: 8px; }
  .modal__thumbs::-webkit-scrollbar-track { background: transparent; }
  .modal__thumbs::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
  }
  .modal__thumb {
    flex: 0 0 auto;
    width: 5.5rem;
    aspect-ratio: 16 / 10;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s var(--ease), border-color 0.2s var(--ease);
  }
  .modal__thumb img { width: 100%; height: 100%; object-fit: cover; }
  .modal__thumb:hover { opacity: 0.85; }
  .modal__thumb[aria-current="true"] { opacity: 1; border-color: var(--accent); }

  /* image count badge on the card */
  .folio__count {
    position: absolute;
    right: var(--sp-3);
    bottom: var(--sp-3);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text);
    background: color-mix(in oklab, var(--bg) 78%, transparent);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.1rem var(--sp-2);
  }
  .modal__close {
    position: absolute;
    top: var(--sp-4);
    right: var(--sp-4);
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: color-mix(in oklab, var(--bg) 75%, transparent);
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  }
  .modal__close:hover { color: var(--text); border-color: var(--text-faint); }
  .modal__close svg { width: 1rem; height: 1rem; }

  .modal__meta {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent-dim);
    letter-spacing: 0.04em;
  }
  .modal__title { font-size: var(--step-2); margin-top: var(--sp-2); }
  .modal__shot {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: var(--sp-6);
  }
  .modal__body { margin-top: var(--sp-6); }
  .modal__body p {
    color: var(--text-muted);
    margin-bottom: var(--sp-4);
    max-width: var(--measure);
  }
  .modal__body .card__tags { margin: var(--sp-6) 0; }
  .folio__src {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
    padding-bottom: 2px;
  }
  .folio__src:hover { border-bottom-color: var(--accent); }

  body.is-locked { overflow: hidden; }

  /* --- metric panels: the proof, drawn rather than screenshotted --- */
  .metric {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--bg-elevated), var(--bg-sunken));
    padding: clamp(var(--sp-6), 3vw, var(--sp-8));
    box-shadow: 0 24px 60px -30px rgb(0 0 0 / 0.9);
    transition: border-color 0.3s var(--ease), transform 0.4s var(--ease-out);
  }
  .case:hover .metric { transform: translateY(-4px); border-color: var(--border-strong); }
  .metric__cap {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-faint);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .metric__note {
    margin-top: var(--sp-6);
    font-size: var(--step--1);
    color: var(--text-faint);
    border-top: 1px solid var(--border);
    padding-top: var(--sp-3);
  }

  .bars { display: grid; gap: var(--sp-4); margin-top: var(--sp-6); }
  .bar {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-3);
  }
  .bar__label, .bar__val {
    font-family: var(--font-mono);
    font-size: var(--step--1);
  }
  .bar__label { color: var(--text-faint); }
  .bar__val { color: var(--text); }
  .bar__track {
    height: 10px;
    border-radius: 999px;
    background: var(--surface);
    overflow: hidden;
  }
  .bar__fill {
    display: block;
    height: 100%;
    width: var(--w);
    border-radius: 999px;
    background: var(--accent);
    transform-origin: left;
    animation: grow 1.1s var(--ease-out) both;
  }
  .bar__fill--before { background: var(--border-strong); }

  .metric__big {
    font-size: var(--step-4);
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--accent);
    margin-top: var(--sp-4);
    line-height: 1;
  }
  .metric__big span {
    font-size: var(--step-0);
    color: var(--text-faint);
    font-weight: 400;
    margin-left: var(--sp-2);
    letter-spacing: 0;
  }

  .spark {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 5rem;
    margin-top: var(--sp-6);
  }
  .spark i {
    flex: 1;
    height: var(--h);
    border-radius: 2px 2px 0 0;
    background: linear-gradient(180deg, var(--accent), var(--accent-dim));
    opacity: 0.75;
    transform-origin: bottom;
    animation: grow-y 0.9s var(--ease-out) both;
  }
  .spark i:nth-child(n) { animation-delay: calc(var(--i, 0) * 0ms); }

  .tenants { margin-top: var(--sp-6); display: grid; gap: var(--sp-4); justify-items: center; }
  .tenants__core {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--bg);
    background: var(--accent);
    border-radius: 999px;
    padding: var(--sp-2) var(--sp-6);
    font-weight: 600;
  }
  .tenants__fan {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    justify-content: center;
    position: relative;
    padding-top: var(--sp-4);
  }
  .tenants__fan::before {
    content: "";
    position: absolute;
    top: 0; left: 50%;
    width: 1px; height: var(--sp-4);
    background: var(--border-strong);
  }
  .tenants__fan i {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-style: normal;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: var(--sp-1) var(--sp-3);
  }

  /* --- education / certs --- */
  .extras {
    margin-top: clamp(var(--sp-12), 8vw, var(--sp-16));
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: var(--sp-8);
    border-top: 1px solid var(--border);
    padding-top: var(--sp-8);
  }
  .extra h3 {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: var(--sp-3);
    font-weight: 500;
  }
  .extra p { color: var(--text-muted); }
  .extra strong { color: var(--text); font-weight: 600; }
  .certs { display: grid; gap: var(--sp-1); color: var(--text-muted); font-size: var(--step--1); }

  .yrs {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-faint);
    margin-left: var(--sp-2);
  }

  /* --- browser frame for screenshots --- */
  .case__shot { margin: 0; }
  .frame {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-elevated);
    box-shadow: 0 24px 60px -24px rgb(0 0 0 / 0.85);
    transition: transform 0.4s var(--ease-out), border-color 0.3s var(--ease);
  }
  .case:hover .frame { transform: translateY(-4px); border-color: var(--border-strong); }
  .frame__bar {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .frame__bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
  .frame__body { aspect-ratio: 16 / 10; }
  .frame__body img { width: 100%; height: 100%; object-fit: cover; }
  .frame__empty {
    display: grid; place-items: center;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-faint);
    background:
      repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in oklab, var(--border) 45%, transparent) 10px 11px),
      var(--bg-sunken);
    padding: var(--sp-4);
    text-align: center;
  }

  /* --- marquee --- */
  .marquee {
    overflow: hidden;
    border-block: 1px solid var(--border);
    padding-block: var(--sp-4);
    mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    user-select: none;
  }
  .marquee__track {
    display: flex;
    gap: var(--sp-12);
    width: max-content;
    animation: scroll 42s linear infinite;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-faint);
    letter-spacing: 0.04em;
  }
  .marquee:hover .marquee__track { animation-play-state: paused; }

  /* --- project cards --- */
  .projects {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
    gap: var(--sp-4);
  }
  .card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s var(--ease), transform 0.3s var(--ease-out);
  }
  .card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(30rem 20rem at var(--mx, 50%) var(--my, 0%), var(--accent-glow), transparent 60%);
    opacity: 0;
    transition: opacity 0.4s var(--ease);
    pointer-events: none;
  }
  .card:hover { border-color: var(--border-strong); transform: translateY(-3px); }
  .card:hover::after { opacity: 1; }
  .card__title {
    font-size: var(--step-1);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
  }
  .card__desc { color: var(--text-muted); font-size: var(--step-0); flex: 1; }
  .card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-faint);
  }
  .card__tags li {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem var(--sp-2);
  }

  /* --- skills --- */
  .skills {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
    gap: var(--sp-8) var(--sp-6);
  }
  .skills h3 {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--accent-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: var(--sp-3);
    font-weight: 500;
  }
  .skills ul { display: grid; gap: var(--sp-1); color: var(--text-muted); }

  /* --- contact --- */
  .contact {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, var(--bg-elevated), var(--bg-sunken));
    padding: clamp(var(--sp-8), 6vw, var(--sp-16));
    text-align: center;
  }
  .contact h2 { font-size: var(--step-3); }
  .contact p {
    margin: var(--sp-4) auto 0;
    color: var(--text-muted);
    max-width: 48ch;
  }
  .contact .hero__actions { justify-content: center; }

  /* --- footer --- */
  .footer {
    border-top: 1px solid var(--border);
    padding-block: var(--sp-8);
    margin-top: var(--sp-16);
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    justify-content: space-between;
    align-items: center;
    font-size: var(--step--1);
    color: var(--text-faint);
    font-family: var(--font-mono);
  }
  .footer a { color: var(--text-muted); text-decoration: none; }
  .footer a:hover { color: var(--accent); }
}

/* ---------- motion ---------- */
@layer motion {
  @keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50%      { box-shadow: 0 0 0 5px transparent; }
  }

  @keyframes rise {
    from { opacity: 0; transform: translateY(1.25rem); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes scroll { to { transform: translateX(-50%); } }

  @keyframes drift {
    from { transform: scale(1.12) translateY(-2.2%); }
    to   { transform: scale(1.12) translateY(2.2%); }
  }

  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes pop  {
    from { opacity: 0; transform: translateY(1rem) scale(0.985); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes grow   { from { transform: scaleX(0); } to { transform: none; } }
  @keyframes grow-y { from { transform: scaleY(0); } to { transform: none; } }

  /* hero headline: per-word rise, staggered by JS-set --i */
  @keyframes word-in {
    from { opacity: 0; transform: translateY(0.6em) rotate(2deg); }
    to   { opacity: 1; transform: none; }
  }
  [data-split] .word {
    display: inline-block;
    animation: word-in 0.85s var(--ease-out) both;
    animation-delay: calc(var(--i) * 45ms);
  }

  /* Progressive enhancement: scroll-driven where supported, IntersectionObserver
     fallback via [data-reveal] otherwise. Content is visible either way. */
  [data-reveal] { opacity: 0; }
  [data-reveal].is-visible { animation: rise 0.7s var(--ease-out) both; }

  @supports (animation-timeline: view()) {
    [data-reveal] {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 5% cover 22%;
    }
  }

  /* no-JS and reduced-motion safety net */
  .no-js [data-reveal] { opacity: 1; animation: none; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
    [data-reveal] { opacity: 1; animation: none; }
    [data-split] .word { animation: none; opacity: 1; transform: none; }
    .marquee__track { animation: none; }
  }
}

/* ---------- utils ---------- */
@layer utils {
  .visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .mono { font-family: var(--font-mono); }
}
