/* ═══════════════════════════════════════════════════════════════════
   yourguyfor.ai
   Signature: attention weight is rendered as type width.
   Every typeface here has a width axis, because width encodes weight.
   ═══════════════════════════════════════════════════════════════════ */

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

/* ── Fonts ──────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Archivo';
  src: url('/assets/fonts/archivo-var.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Martian';
  src: url('/assets/fonts/martianmono-var.woff2') format('woff2');
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-style: normal;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body, h1, h2, h3, p, figure { margin: 0; }
  button { font: inherit; color: inherit; background: none; border: 0; }
  a { color: inherit; }
  canvas { display: block; }
  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 4px;
    border-radius: 2px;
  }
}

@layer base {
  :root {
    /* ground — deep blue-black with a violet cast, never pure #000 */
    --void:    #08070E;
    --void-2:  #0C0A14;
    --rule:    #1C1829;
    --rule-2:  #14111E;

    /* ink */
    --ink:     #F1ECE3;   /* bone, not white */
    --ink-2:   #948DA8;
    --ink-3:   #5F5975;

    /* the hot end of the attention ramp, reused for accents */
    --hot:     #FFC978;
    --focus:   #FFC978;

    --pad:  clamp(1.25rem, 5.5vw, 4rem);
    --maxw: 74rem;

    --ease: cubic-bezier(.22, 1, .36, 1);
    --ease-io: cubic-bezier(.65, 0, .35, 1);

    color-scheme: dark;
  }

  body {
    background: var(--void);
    color: var(--ink);
    font-family: 'Archivo', ui-sans-serif, system-ui, sans-serif;
    font-variation-settings: 'wght' 400, 'wdth' 100;
    font-size: clamp(1rem, 0.94rem + 0.3vw, 1.125rem);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
  }

  /* A single ambient wash so the void has depth without a gradient cliché */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(120vw 90vh at 50% -18%, #191036 0%, transparent 62%),
      radial-gradient(80vw 60vh at 88% 8%, #2a0f2c 0%, transparent 58%);
    opacity: .85;
  }

  .skip {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: .75rem 1.25rem;
    background: var(--ink);
    color: var(--void);
    font-family: 'Martian', ui-monospace, monospace;
    font-size: .75rem;
  }
  .skip:focus { left: 0; }
}

@layer layout {
  .topbar {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(1rem, 3vw, 1.75rem) var(--pad);
  }

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

  .work, .stance, .contact {
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: var(--pad);
  }

  .work    { padding-block: clamp(4.5rem, 14vw, 9rem); }
  .stance  { padding-block: clamp(4rem, 12vw, 8rem); }
  .contact { padding-block: clamp(4.5rem, 14vw, 9rem) clamp(3rem, 9vw, 6rem); }
}

@layer components {

  /* ── wordmark ─────────────────────────────────────────────────── */
  .wordmark, .foot-mark {
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 600, 'wdth' 90;
    font-size: .8125rem;
    letter-spacing: -.02em;
    text-decoration: none;
    color: var(--ink);
  }
  .wordmark-dot { color: var(--hot); }

  .topbar-mail {
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 300, 'wdth' 82;
    font-size: .6875rem;
    letter-spacing: .01em;
    color: var(--ink-2);
    text-decoration: none;
    padding: .5rem .75rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    transition: color 200ms var(--ease), border-color 200ms var(--ease);
  }
  .topbar-mail:hover { color: var(--ink); border-color: var(--ink-3); }

  /* ── hero ─────────────────────────────────────────────────────── */
  /* Eyebrow pinned to the top, statement dropped to the bottom of the
     free space. The air between them is the composition, not leftovers. */
  .hero {
    position: relative;
    min-height: calc(100svh - 5rem);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas: "eyebrow" "matrix" "main" "instrument";
    padding: clamp(1.5rem, 6vw, 3rem) var(--pad) clamp(1.25rem, 4vw, 2.5rem);
    max-width: var(--maxw);
    margin-inline: auto;
    width: 100%;
  }

  .field {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
  }

  .hero-inner {
    grid-area: main;
    align-self: end;
    position: relative;
    z-index: 1;
    padding-top: clamp(1rem, 4svh, 3.5rem);
  }

  .eyebrow {
    grid-area: eyebrow;
    position: relative;
    z-index: 1;
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 400, 'wdth' 80;
    font-size: .625rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--ink-3);
  }

  /* The matrix is the same numbers the headline is made of, shown whole:
     ten queries down, ten keys across, the live row picked out. */
  .matrix {
    grid-area: matrix;
    align-self: center;
    justify-self: start;
    width: clamp(96px, 33vw, 168px);
    position: relative;
    z-index: 1;
  }
  .matrix-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    cursor: crosshair;
  }
  .matrix-cap {
    margin-top: .75rem;
    white-space: nowrap;
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 300, 'wdth' 78;
    font-size: .5625rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
    opacity: .7;
  }

  /* The headline: a softmax distribution rendered as type.
     `contain` keeps the per-frame width animation off the rest of the page. */
  /* Line breaks are authored, not wrapped. Automatic wrapping re-breaks
     the headline every time a glyph width changes, which reads as a
     glitch rather than an animation. Each line is its own nowrap block;
     the script scales widths so the longest one always fits. */
  .headline {
    contain: layout style;
    /* Five authored lines have to fit the viewport, so the display size
       is bounded by height as well as width. On phones the width term
       always wins; on short laptops the height term takes over. */
    font-size: clamp(2.1rem, min(11.6vw, 10svh), 6.5rem);
    line-height: .96;
    letter-spacing: -.035em;
    font-variation-settings: 'wght' 500, 'wdth' 100;
    margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
  }
  .ln {
    display: block;
    white-space: nowrap;
  }

  .tok {
    display: inline-block;
    color: var(--ink-3);
    font-variation-settings: 'wght' 400, 'wdth' 88;
    /* No CSS transition: JS interpolates every frame so the canvas arcs
       and the glyph widths stay locked to the same value. */
    will-change: font-variation-settings;
  }
  .tok.is-query { color: var(--ink); }

  .lede {
    max-width: 34ch;
    color: var(--ink-2);
    font-variation-settings: 'wght' 400, 'wdth' 96;
    text-wrap: pretty;
  }

  /* ── instrument readout ───────────────────────────────────────── */
  .instrument {
    grid-area: instrument;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule-2);
  }

  .readout, .hint {
    font-family: 'Martian', ui-monospace, monospace;
    font-size: .625rem;
    letter-spacing: .04em;
  }
  .readout {
    font-variation-settings: 'wght' 400, 'wdth' 78;
    color: var(--ink-3);
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
  }
  .ro-sep { color: var(--rule); }
  .ro-name { color: var(--hot); font-variation-settings: 'wght' 600, 'wdth' 78; }
  .hint {
    font-variation-settings: 'wght' 300, 'wdth' 78;
    color: var(--ink-3);
    opacity: .65;
    line-height: 1.5;
    max-width: 46ch;
  }

  /* ── section label ────────────────────────────────────────────── */
  .section-label {
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 400, 'wdth' 80;
    font-size: .625rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: clamp(2rem, 6vw, 3.5rem);
  }

  /* ── the work ─────────────────────────────────────────────────── */
  .row {
    display: grid;
    gap: .75rem;
    padding-block: clamp(1.75rem, 5vw, 2.75rem);
    border-top: 1px solid var(--rule-2);
  }
  .row:last-child { border-bottom: 1px solid var(--rule-2); }

  .row-tag {
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 500, 'wdth' 80;
    font-size: .625rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--hot);
  }
  .row-title {
    font-size: clamp(1.5rem, 5.4vw, 2.5rem);
    line-height: 1.08;
    letter-spacing: -.025em;
    font-variation-settings: 'wght' 500, 'wdth' 108;
    text-wrap: balance;
  }
  .row-note {
    color: var(--ink-2);
    max-width: 48ch;
    font-variation-settings: 'wght' 400, 'wdth' 94;
    text-wrap: pretty;
  }
  .row-body { display: grid; gap: .625rem; }

  /* ── stance ───────────────────────────────────────────────────── */
  .stance-line {
    font-size: clamp(1.75rem, 7vw, 4rem);
    line-height: 1.04;
    letter-spacing: -.03em;
    text-wrap: balance;
    max-width: 20ch;
  }
  .sw {
    display: inline-block;
    font-variation-settings: 'wght' 300, 'wdth' 70;
    color: var(--ink-3);
    transition:
      font-variation-settings 900ms var(--ease),
      color 900ms var(--ease);
    transition-delay: calc(var(--i, 0) * 55ms);
  }
  .stance.is-in .sw {
    font-variation-settings: 'wght' 560, 'wdth' 112;
    color: var(--ink);
  }
  .stance-note {
    margin-top: clamp(1.5rem, 4vw, 2rem);
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 300, 'wdth' 80;
    font-size: .6875rem;
    letter-spacing: .04em;
    color: var(--ink-3);
  }

  /* ── contact ──────────────────────────────────────────────────── */
  .contact { border-top: 1px solid var(--rule-2); }

  .contact-title {
    font-size: clamp(1.5rem, 5.4vw, 2.5rem);
    line-height: 1.08;
    letter-spacing: -.025em;
    font-variation-settings: 'wght' 500, 'wdth' 106;
    text-wrap: balance;
    max-width: 18ch;
    margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
  }

  .mail {
    display: inline-flex;
    align-items: baseline;
    gap: .5em;
    font-family: 'Martian', ui-monospace, monospace;
    font-size: clamp(1.05rem, 5.2vw, 2.25rem);
    font-variation-settings: 'wght' 500, 'wdth' 78;
    letter-spacing: -.03em;
    color: var(--ink);
    text-decoration: none;
    padding-bottom: .2em;
    border-bottom: 1px solid var(--rule);
    transition:
      font-variation-settings 420ms var(--ease),
      border-color 420ms var(--ease),
      color 420ms var(--ease);
  }
  .mail:hover, .mail:focus-visible {
    font-variation-settings: 'wght' 620, 'wdth' 100;
    border-color: var(--hot);
    color: var(--hot);
  }
  .mail-arrow {
    font-family: 'Archivo', sans-serif;
    transition: transform 420ms var(--ease);
  }
  .mail:hover .mail-arrow { transform: translateX(.25em); }

  .copy {
    display: block;
    margin-top: 1.5rem;
    padding: .55rem .9rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 400, 'wdth' 80;
    font-size: .625rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-3);
    cursor: pointer;
    transition: color 200ms var(--ease), border-color 200ms var(--ease);
  }
  .copy:hover { color: var(--ink); border-color: var(--ink-3); }

  .contact-note {
    margin-top: 1.75rem;
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 300, 'wdth' 80;
    font-size: .6875rem;
    color: var(--ink-3);
  }

  /* ── footer ───────────────────────────────────────────────────── */
  .footer {
    max-width: var(--maxw);
    margin-inline: auto;
    padding: 2rem var(--pad) 3rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    border-top: 1px solid var(--rule-2);
  }
  .foot-meta {
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 300, 'wdth' 80;
    font-size: .625rem;
    color: var(--ink-3);
  }

  /* ── toast ────────────────────────────────────────────────────── */
  .toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    translate: -50% 0;
    z-index: 50;
    padding: .6rem 1rem;
    background: var(--ink);
    color: var(--void);
    border-radius: 999px;
    font-family: 'Martian', ui-monospace, monospace;
    font-variation-settings: 'wght' 500, 'wdth' 82;
    font-size: .625rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    display: none;
  }
  .toast.is-on {
    display: block;
    animation: toast-in 220ms var(--ease);
  }
  @starting-style { .toast.is-on { opacity: 0; } }
}

@layer motion {
  /* Page-load: tokens decode left to right, then the first head resolves.
     Everything that starts hidden is gated behind `.js`, which is set
     synchronously in <head> — so with scripting off nothing disappears. */
  .js .tok {
    opacity: 0;
    transform: translateY(.14em);
    animation: tok-in 620ms var(--ease) forwards;
    animation-delay: calc(var(--t) * 42ms + 120ms);
  }

  @keyframes tok-in {
    from { opacity: 0; transform: translateY(.14em); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes toast-in {
    from { opacity: 0; transform: translateY(.5rem); }
    to   { opacity: 1; transform: none; }
  }

  /* Scroll reveals — native scroll-driven where supported, IO fallback. */
  .js .reveal {
    opacity: 0;
    transform: translateY(1.25rem);
    transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  }
  .js .reveal.is-in { opacity: 1; transform: none; }

  @supports (animation-timeline: view()) {
    .js .reveal {
      opacity: 1;
      transform: none;
      transition: none;
      animation: reveal-up linear both;
      animation-timeline: view();
      animation-range: entry 5% cover 26%;
    }
  }
  @keyframes reveal-up {
    from { opacity: 0; transform: translateY(1.25rem); }
    to   { opacity: 1; transform: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
      scroll-behavior: auto !important;
    }
    .js .tok { opacity: 1; transform: none; }
    .js .reveal { opacity: 1; transform: none; }
    .stance .sw { font-variation-settings: 'wght' 560, 'wdth' 112; color: var(--ink); }
  }
}

/* ── wider viewports ───────────────────────────────────────────── */
@media (min-width: 48rem) {
  @layer components {
    /* `ch` resolves against the headline's own (very large) font-size,
       which is the point — the measure scales with the display type. */
    .headline { max-width: 11ch; letter-spacing: -.04em; }
    .lede { font-size: 1.0625rem; }
    .row {
      grid-template-columns: 9rem 1fr;
      gap: 2rem;
      align-items: start;
    }
    .instrument { flex-direction: row; align-items: baseline; gap: 2rem; }
    .hint { margin-left: auto; text-align: right; }
  }
}

@media (min-width: 64rem) {
  @layer components {
    .headline { max-width: 10.5ch; }
    .hero {
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-rows: auto 1fr auto;
      grid-template-areas:
        "eyebrow    matrix"
        "main       matrix"
        "instrument instrument";
      column-gap: clamp(2rem, 5vw, 5rem);
    }
    .matrix {
      justify-self: end;
      width: 168px;
      padding-bottom: clamp(1rem, 4vw, 3rem);
    }
  }
}
