/* ───────────────────────── tokens ───────────────────────── */
:root {
  --paper: #e9e8e2;        /* light grey background */
  --paper-deep: #e0dfd8;
  --card: #ffffff;         /* the squares, as cards */
  --ink: #0e1116;
  --blue: #2257e6;
  --tracker: #ff7a1a;      /* spiral tracking ball (orange) */
  --blue-soft: #dbe3f8;
  --red: #d7263d;

  /* subtle diagram inks */
  --spiral-ink: rgba(14, 17, 22, 0.12);

  /* stroke widths, divided by camera scale each frame from JS */
  --sw-line: 1.4px;
  --sw-spiral: 2.6px;

  /* work-card accent colours (from the Figma reference) */
  --teal: #57a6a0;
  --purple: #a77fe3;
  --red-stat: #e8442e;

  --font-display: "Bricolage Grotesque", "Arial Black", sans-serif;
  --font-body: "Inter", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

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

html { scroll-behavior: auto; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* the scroll track is empty — height set from JS */
#track { width: 1px; }

/* ───────────────────────── stage & world ───────────────────────── */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  /* background-color is driven per-fold from JS; this is the resting tone */
  background-color: var(--paper);
}
/* constant soft highlight/vignette so any background tint keeps its depth */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 20% 10%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(140% 120% at 80% 100%, rgba(14, 17, 22, 0.035) 0%, rgba(14, 17, 22, 0) 55%);
}

#world {
  position: absolute;
  top: 0; left: 0;
  width: 1618.034px;
  height: 1000px;
  transform-origin: 0 0;
  will-change: transform;
}

#diagram {
  position: absolute;
  inset: 0;
  overflow: visible;
}

#diagram .card rect { fill: var(--card); }
/* the six main squares double as nav: click a square to jump to its fold */
#diagram .card rect[data-go] { cursor: pointer; }

/* tracking ball: hidden at rest, fades in while the user scrolls */
#diagram .tracker {
  opacity: 0;
  transition: opacity 0.45s ease;
}
#diagram .tracker.on { opacity: 1; }
#diagram .spiral-marker      { fill: var(--tracker); }
#diagram .spiral-marker-halo { fill: none; stroke: var(--tracker); stroke-width: var(--sw-line); opacity: 0.4; }

#diagram .spiral { stroke: var(--spiral-ink); stroke-width: var(--sw-spiral); stroke-linecap: round; }

/* ──────────────── INTRO SEQUENCE ────────────────
   On load: the diagram cards and golden spiral fade in together (the spiral
   starts a little heavier and relaxes — handled in main.js), the tracker ball
   rushes once along the spiral (main.js), then the hero content fades up
   (JS-gated), and finally — after a pause — the scroll cue fades in (JS). */
@keyframes intro-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* content stays hidden until JS takes over its opacity on the first frame */
.is-intro .fold { opacity: 0; }

/* cards + spiral arrive at the same moment */
.is-intro #diagram .card,
.is-intro #diagram .spiral {
  opacity: 0;
  animation: intro-appear 0.45s ease 0.1s forwards;
}

/* ───────────────────────── folds ───────────────────────── */
/* Every fold is authored at 1000×1000 and uniformly scaled down to
   its square from JS — type stays at sane authoring sizes and is
   never distorted. Editorial layout: every child is placed by hand,
   in corners and along edges. Whitespace is intentional. */
.fold {
  position: absolute;
  width: 1000px;
  height: 1000px;
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;
}

.fold > * { position: absolute; margin: 0; }

/* rotated edge text: vertical-rl reads top→bottom (rotated right),
   adding .up flips it to read bottom→top (rotated left) */
.v-edge { writing-mode: vertical-rl; }
.v-edge.up { transform: rotate(180deg); }

.side {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8a8f99;
  white-space: nowrap;
}

/* shared card elements (from the Figma reference) */
.card-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.bio {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  color: #3a4150;
}

.v-cta {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
}
.v-cta-work { color: var(--blue); }
.v-cta:hover { color: var(--blue); }

/* tool groups (stats card, right column) */
.tools { display: flex; flex-direction: column; gap: 18px; }
.tool-group .t-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8f99;
}
.tool-group p {
  margin: 0;
  font-family: var(--font-body);
  font-size: 12.5px;
  line-height: 1.65;
  color: #3a4150;
}

/* stats column */
.stats { display: flex; flex-direction: column; gap: 46px; }
.stat .num {
  display: block;
  font-family: var(--font-display);
  font-size: 60px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
}
.stat .cap {
  display: block;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.6;
  color: #8a8f99;
}

/* work cards */
.fold h2.work-title {
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}
.fold h2.work-title.big { font-size: 46px; line-height: 1.16; }

.work-caption {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  color: #3a4150;
}

.work-brand {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.work-stat {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  line-height: 1.18;
  text-align: right;
  white-space: nowrap;
}
.work-stat.teal   { color: var(--teal); }
.work-stat.purple { color: var(--purple); }
.work-stat.red    { color: var(--red-stat); }

.work-label {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* clickable areas on the work cards (name, visual, "selected work" line).
   display:contents keeps the wrapped element as the positioned .fold child,
   so the absolute-position coordinates below still apply unchanged. */
.work-hit {
  display: contents;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.work-hit > * {
  position: absolute;
  transition: color 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1),
              box-shadow 0.35s ease, opacity 0.25s ease;
}

/* visual: gentle lift + scale with a soft shadow */
.work-hit > .illo { border-radius: 16px; }
.work-hit:hover > .illo {
  transform: scale(1.025);
  box-shadow: 0 18px 40px -18px rgba(28, 26, 23, 0.45);
}

/* name + "selected work" label: warm to the accent and nudge over */
.work-hit:hover > .work-title,
.work-hit:hover > .work-brand,
.work-hit:hover > .work-label {
  color: var(--blue);
}
.work-hit:hover > .work-title,
.work-hit:hover > .work-brand { transform: translateX(6px); }
.work-hit:focus-visible > * { outline: 2px solid var(--blue); outline-offset: 6px; }

/* three-line vertical mono tag (reads in columns, left to right) */
.tri-tag {
  writing-mode: vertical-lr;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a8f99;
  line-height: 1.9;
}

.illo svg { display: block; width: 100%; height: 100%; }

/* contact card photo: treated like the illustrations — a rounded block */
.photo {
  border-radius: 12px;
  overflow: hidden;
  background: #e2e1dc;
}
.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1);
}

/* contact rows: mono label, ink value, hairline separators */
.contact-list { list-style: none; }
.contact-list li { border-top: 1px solid #e7e7e3; }
.contact-list li:last-child { border-bottom: 1px solid #e7e7e3; }
.contact-list a {
  display: flex;
  align-items: baseline;
  gap: 28px;
  padding: 15px 0;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.25s ease;
}
.contact-list a:hover { color: var(--blue); }
.contact-list a span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8f99;
  min-width: 110px;
}

.fold h1 {
  font-family: var(--font-display);
  font-size: 58px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.fold h1 em, .fold h2 em { font-style: normal; font-weight: inherit; color: var(--blue); }

.fold h2 {
  font-family: var(--font-display);
  font-size: 68px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 44px;
}

/* (legacy .lede / .mail styles removed — superseded by card layouts) */

/* ─────────────── card layouts, fold by fold (from Figma) ─────────────── */
/* The fold canvas IS the card. Groups pin to the card's outer edges on a
   consistent margin; the middle of each card stays deliberately empty. */

/* f1 · hero — name + headline hang from the top-left, vertical CTAs sit on
   the bottom-left, a full-height hairline carves the right column where the
   tag hangs from the top and the bio is pinned to the bottom-right corner */
.f1 .card-name  { top: 72px; left: 76px; }
.f1 h1          { top: 200px; left: 76px; width: 640px; }
.f1 .edge-tag   { right: 64px; top: 72px; }
.f1 .bio        { right: 72px; bottom: 72px; width: 232px; }
.f1 .v-cta-touch { left: 64px; bottom: 232px; }
.f1 .v-cta-work  { left: 64px; bottom: 72px; }
.f1 .edge-name  { left: -52px; top: 0; }
.f1 .edge-phi   { left: -52px; bottom: 0; }

/* f2 · stats — name and the stat column share the same left margin,
   right column mirrors the hero: tag top, bio pinned bottom-right */
.f2 .card-name { top: 72px; left: 76px; }
.f2 .stats     { left: 76px; top: 228px; }
.f2 .edge-tag  { right: 64px; top: 72px; }
.f2 .tools     { right: 72px; bottom: 72px; width: 240px; }

/* f3 · selected work 1 — title, radar and caption share the left margin
   in the top half; brand bottom-left and teal stat bottom-right sit on the
   same baseline band; mono tag hangs from the top of the right edge */
.f3 .work-title { top: 76px; left: 80px; }
.f3 .illo       { top: 206px; left: 80px; width: 531px; height: 347px; }
.f3 .work-caption { top: 601px; left: 80px; width: 590px; }
.f3 .work-brand { left: 80px; bottom: 72px; }
.f3 .work-stat  { right: 72px; bottom: 72px; }
.f3 .edge-tag   { right: 60px; top: 76px; }

/* f4 · selected work 2 — heading top-left, tri-line tag top-right,
   rotated label and purple stat aligned across the middle band, chart
   pinned to the bottom-right corner, caption to the bottom-left */
.f4 .work-title { top: 72px; left: 78px; width: 440px; }
.f4 .tri-tag    { right: 78px; top: 72px; }
.f4 .work-label { left: 100px; top: 390px; }
.f4 .work-stat  { right: 78px; top: 388px; }
.f4 .illo       { right: 78px; bottom: 88px; width: 517px; height: 347px; }
.f4 .work-caption { left: 78px; bottom: 88px; width: 226px; }

/* f5 · selected work 3 — red stat top-right, heading + caption + Pikachu
   stacked on the left margin toward the bottom, tags down the right edge,
   rotated label pinned to the bottom-right corner */
.f5 .work-stat  { right: 76px; top: 76px; }
.f5 .work-title { left: 80px; top: 390px; }
.f5 .work-caption { left: 80px; top: 475px; width: 520px; }
.f5 .illo       { left: 80px; bottom: 76px; width: 522px; height: 347px; }
.f5 .tri-tag    { right: 76px; top: 460px; }
.f5 .work-label { right: 76px; bottom: 88px; }

/* f6 · contact — name top-left, photo block top-right, greeting and
   intro on the left margin, contact rows pinned to the bottom-left,
   a vertical tag rising from the bottom of the right edge */
.f6 .card-name    { top: 72px; left: 76px; }
.f6 .photo        { top: 76px; right: 76px; width: 280px; height: 350px; }
.f6 .work-title   { left: 76px; top: 208px; }
.f6 .f6-intro     { left: 76px; top: 368px; width: 380px; }
.f6 .contact-list { left: 76px; bottom: 72px; width: 470px; }
.f6 .edge-eye     { right: 64px; bottom: 72px; }

/* ───────────────────────── HUD ───────────────────────── */
.hud {
  position: fixed;
  z-index: 10;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.hud-top { top: 0; left: 0; right: 0; padding: 26px 34px; justify-content: center; }

.nav {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  background: var(--card);
  border: 1px solid var(--blue-soft);
  border-radius: 999px;
  padding: 6px 8px;
  box-shadow: 0 2px 14px rgba(14, 17, 22, 0.05);
}
.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 999px;
  transition: color 0.25s ease, background 0.25s ease;
}
.nav a:hover { color: var(--blue); }
.nav a.active { color: var(--blue); background: rgba(34, 87, 230, 0.08); }
.nav a.ext span { display: inline-block; font-size: 11px; transform: translateY(-1px); }
.hud-bottom { bottom: 0; left: 0; right: 0; padding: 24px 34px; align-items: center; }
/* animated scroll cue: a "mouse" whose wheel-dot drops and fades on a loop.
   Hidden until JS reveals it after the intro + a short idle pause. */
#hint { opacity: 0; transition: opacity 0.6s ease; }
#hint.cue-on { opacity: 0.85; }
.scroll-cue { display: inline-flex; align-items: center; }
.scroll-cue .mouse {
  width: 21px;
  height: 33px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  position: relative;
}
.scroll-cue .wheel {
  position: absolute;
  left: 50%;
  top: 7px;
  width: 3px;
  height: 6px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--tracker);
  animation: scroll-wheel 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes scroll-wheel {
  0%   { opacity: 0; transform: translateY(0); }
  25%  { opacity: 1; }
  70%  { opacity: 1; transform: translateY(11px); }
  100% { opacity: 0; transform: translateY(11px); }
}
#counter { font-variant-numeric: tabular-nums; }

.hud-dots {
  top: 50%;
  right: 30px;
  transform: translateY(-50%);
  flex-direction: column;
  gap: 14px;
  pointer-events: auto;
}
.hud-dots button {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s ease, transform 0.3s ease;
}
.hud-dots button.active { background: var(--tracker); border-color: var(--tracker); transform: scale(1.3); }

/* ───────────────────────── grain ───────────────────────── */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 9;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 7s steps(8) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-2%,3%); }
  50% { transform: translate(3%,-2%); }
  75% { transform: translate(-3%,-3%); }
}

/* ───────────────────────── custom cursor ───────────────────────── */
/* enabled from JS only on fine-pointer devices */
html.custom-cursor, html.custom-cursor * { cursor: none !important; }

.cursor-ring, .cursor-dot {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cursor-ring::after {
  content: "";
  display: block;
  width: 34px; height: 34px;
  margin: -17px 0 0 -17px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.cursor-dot::after {
  content: "";
  display: block;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  background: var(--ink);
  border-radius: 50%;
  transition: transform 0.25s ease, background 0.25s ease;
}

/* treatment over clickables: ring swells & tints, dot shrinks */
.cursor-ring.is-hover::after {
  transform: scale(1.55);
  border-color: var(--blue);
  background: rgba(34, 87, 230, 0.07);
}
.cursor-dot.is-hover::after { transform: scale(0.4); background: var(--blue); }

/* pressed */
.cursor-ring.is-down::after { transform: scale(0.85); }
.cursor-ring.is-hover.is-down::after { transform: scale(1.25); }

@media (prefers-reduced-motion: reduce) {
  .grain, .cta-link .arrow { animation: none; }
  /* skip the intro entirely — show everything at rest */
  .is-intro .fold { opacity: 1; }
  .is-intro #diagram .card,
  .is-intro #diagram .spiral { animation: none; opacity: 1; }
  /* scroll cue still reveals (JS), but the wheel-dot sits still */
  .scroll-cue .wheel { animation: none; opacity: 0.85; top: 13px; }
}

/* ─────────────────────────────────────────────────────────────
   MOBILE — the golden-spiral camera is a desktop experience.
   On small screens we drop the camera/diagram and lay the six
   folds out as a simple vertical stack of cards. (JS disables the
   camera loop below this same breakpoint.)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html { scroll-behavior: smooth; }
  body { background: var(--paper) !important; overflow-x: hidden; }

  /* kill the camera rig */
  #track { display: none !important; }
  .stage { position: static !important; height: auto !important; overflow: visible !important; background: transparent !important; }
  #world { transform: none !important; position: static !important; width: 100% !important; }
  #diagram, .grain { display: none !important; }
  .hud-dots, .hud-bottom, .cursor-dot, .cursor-ring { display: none !important; }

  /* top nav: compact centred pill, fixed */
  .hud-top { padding: 12px 12px; justify-content: center; }
  .nav { gap: 0; padding: 5px 5px; font-size: 11px; letter-spacing: 0.06em;
         box-shadow: 0 2px 14px rgba(14, 17, 22, 0.06); }
  .nav a { padding: 8px 11px; }
  .nav a.ext span { font-size: 10px; }

  /* folds → stacked cards */
  #world { padding: 72px 14px 14px; box-sizing: border-box; }
  .fold {
    position: static !important;
    transform: none !important;
    left: auto !important; top: auto !important;
    width: auto !important; height: auto !important;
    opacity: 1 !important; pointer-events: auto !important;
    display: flex; flex-direction: column; align-items: flex-start;
    gap: 18px;
    margin: 0 0 14px 0;
    padding: 40px 24px;
    box-sizing: border-box;
    background: var(--card);
    border: 1px solid var(--blue-soft);
    border-radius: 18px;
  }
  .fold > *, .work-hit > * {
    position: static !important;
    transform: none !important;
    writing-mode: horizontal-tb !important;
    max-width: 100% !important;
    margin: 0;
    text-align: left !important;
    white-space: normal !important;
  }

  /* hide rotated edge labels / decorative side text */
  .side, .edge-tag, .edge-name, .edge-phi, .edge-eye, .tri-tag, .work-label { display: none !important; }

  /* typography */
  .card-name { font-size: 14px; color: var(--ink); margin-bottom: -2px; }
  .fold h1 { font-size: 29px; line-height: 1.24; }
  .fold h2.work-title { font-size: 27px; line-height: 1.22; }
  .fold h2.work-title.big { font-size: 32px; line-height: 1.15; }
  .bio, .work-caption { font-size: 15px; line-height: 1.62; color: #3a4150; }
  .work-brand { font-size: 38px; }
  .work-stat { font-size: 20px; line-height: 1.3; text-align: left !important; }
  .v-cta { display: inline-block; font-size: 15px; font-weight: 600; }

  /* stats card */
  .stats { gap: 26px; width: 100%; }
  .stat .num { font-size: 42px; }
  .stat .cap { font-size: 11px; }
  .tools { gap: 16px; width: 100%; }

  /* work-card visuals: full-width, keep aspect via viewBox */
  .illo { width: 100% !important; border-radius: 16px; overflow: hidden; }
  .illo svg { width: 100%; height: auto; display: block; }

  /* contact fold */
  .photo { width: 96px !important; height: 96px !important; border-radius: 50%; overflow: hidden; }
  .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .contact-list { list-style: none; padding: 0; width: 100%; }
  .contact-list li { width: 100%; }
  .contact-list a { display: flex; justify-content: space-between; align-items: baseline;
                    gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--blue-soft);
                    font-size: 15px; text-decoration: none; color: var(--ink); }
  .contact-list a span { color: #8a8f99; font-family: var(--font-mono); font-size: 11px;
                         letter-spacing: 0.1em; text-transform: uppercase; }
}
