/* ==================================================================
   stastna.io — one line of type, taken apart and rebuilt by scroll,
   until the letters land on a name.
   ================================================================== */

:root {
  /* wine-black, not black: the ground already carries the hue */
  --ink:        #0E060B;
  --ink-deep:   #070407;
  --burgundy:   #74233D;
  --burgundy-l: #96304F;

  /* the collage palette, taken from the painted blocks Nikol likes and
     pulled down dark enough to sit under ivory type */
  --teal:       #0F2E37;
  --teal-d:     #081A20;
  --rust:       #6E2E10;
  --rust-d:     #361507;
  --ochre:      #6E5013;
  --ochre-d:    #392808;
  --brick:      #611A15;
  --brick-d:    #2E0D0A;
  --cream:      #E8DCC8;
  --ivory:      #F4F1EE;
  --muted:      #C6BABF;
  --dim:        #A5959C;
  --spark:      #D8ED83;

  --pad-x: clamp(1.375rem, 6vw, 6.5rem);
  --pad-y: clamp(1.375rem, 4vh, 2.75rem);

  --display: clamp(2rem, 4.4vw, 4rem);

  --font-display: "Archivo", ui-sans-serif, system-ui, -apple-system,
                  "Segoe UI", Roboto, sans-serif;
  --font-text:    "Instrument Sans", ui-sans-serif, system-ui, -apple-system,
                  "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body { margin: 0; overflow-x: clip; }

body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--spark); color: var(--ink); }

:focus-visible { outline: 2px solid var(--spark); outline-offset: 4px; border-radius: 2px; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--pad-x); top: 0;
  z-index: 60;
  transform: translateY(-140%);
  padding: 0.7rem 1.1rem;
  background: var(--ivory);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 0 0 3px 3px;
}

.skip:focus-visible { transform: translateY(0); }

/* ------------------------------------------------------------------
   Fixed furniture
   ------------------------------------------------------------------ */

.mark {
  position: fixed;
  top: var(--pad-y); left: var(--pad-x);
  z-index: 40;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.mark__link {
  color: inherit;
  text-decoration: none;
  padding: 0.35rem 0.4rem;
  margin: -0.35rem -0.4rem;
  border-radius: 3px;
  transition: color 0.2s ease;
}

.mark__link:hover { color: var(--ivory); }

.rail {
  position: fixed;
  top: 0; left: 0;
  z-index: 40;
  width: 100%; height: 1px;
  background: rgba(244, 241, 238, 0.06);
}

.rail__fill {
  display: block;
  height: 100%; width: 100%;
  background: var(--burgundy-l);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
}

/* ------------------------------------------------------------------
   The stage
   ------------------------------------------------------------------ */

.track { position: relative; height: 560svh; }

.scene {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 18% 12%, #140811 0%, var(--ink) 46%, var(--ink-deep) 100%);
}

/* ---- the line-work ---- */

/* Everything in the background is drawn with a line, a dot, or light.
   No blocks. */
.collage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.shape {
  position: absolute;
  left: var(--x, 0%);
  top: var(--y, 0%);
  width: var(--w, 10%);
  height: var(--h, 10%);
  opacity: var(--o, 0);
  transform: rotate(calc(var(--a, 0) * 1deg));
  transform-origin: 50% 50%;
  will-change: left, top, width, height, transform, opacity;
}

/* the ground: a wash with no edge anywhere */
.shape[data-kind="ground"] {
  background: linear-gradient(343deg, #431424 0%, #280D17 46%, #12070D 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 100%);
}

.shape[data-kind="ring"] {
  height: auto;
  aspect-ratio: 1;
  border: 1px solid rgba(232, 220, 200, 0.26);
  border-radius: 50%;
}

/* graph paper: the chaos is plotted, not spilled */
.shape[data-kind="dots"] {
  background-image: radial-gradient(rgba(232, 220, 200, 0.45) 1.1px, transparent 1.2px);
  background-size: 15px 15px;
}

/* the lines: one spine everything hangs from, two that cross it */
/* full-bleed, so the maths that hangs the map off the spine and the
   line that is drawn are in the same coordinate space */
.rules {
  pointer-events: none;   /* decoration must never catch a click meant for a word */
  position: absolute;
  inset: 0;
}

.rule {
  position: absolute;
  left: var(--x, 0%);
  top: var(--y, 50%);
  width: var(--w, 0%);
  height: 1px;
  background: rgba(232, 220, 200, 0.3);
  opacity: var(--o, 0);
  transform: rotate(calc(var(--a, 0) * 1deg));
  transform-origin: 0 50%;
  will-change: width, transform, opacity;
}

.rule--spine { background: var(--burgundy-l); height: 1.5px; }

/* ---- the brain map ---- */

.pieces { margin: 0; padding: 0; list-style: none; }

.piece {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: clamp(11px, 0.88vw, 14px);
  font-weight: 500;
  font-stretch: 104%;
  letter-spacing: -0.005em;
  color: var(--ivory);
  cursor: pointer;
  opacity: var(--o, 0);
  transform:
    translate(calc(var(--ax, -50) * 1%), -50%)
    rotate(calc(var(--r, 0) * 1deg))
    scale(var(--s, 1));
  transition: color 0.18s ease;
  will-change: left, top, transform, opacity;
}

/* a finger-sized target without changing the measured width of the word */
.piece::after {
  content: "";
  position: absolute;
  inset: -13px -10px;
}

.piece:hover { color: var(--spark); }

.piece[aria-pressed="true"] {
  color: var(--spark);
  font-weight: 600;
}

/* picked words get ticked off */
.piece[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  left: -0.7em;
  top: 50%;
  width: 0.34em;
  height: 0.34em;
  margin-top: -0.17em;
  border-radius: 50%;
  background: var(--spark);
}

.piece:focus-visible { outline: 2px solid var(--spark); outline-offset: 5px; }

/* the running tally while you pick */
.tray {
  position: absolute;
  left: var(--pad-x);
  bottom: calc(var(--pad-y) * 3.4);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(216, 237, 131, 0.45);
  border-radius: 999px;
  background: rgba(14, 6, 11, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 0.55rem 1rem;
  font-family: var(--font-text);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--spark);
  cursor: pointer;
  opacity: var(--o, 0);
  transition: background-color 0.2s ease, color 0.2s ease, opacity 0.25s ease;
}

.tray[data-quiet] { pointer-events: none; }
.tray:hover { background: var(--spark); color: var(--ink); }
.tray__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}

.picked {
  margin: 0.9rem 0 0;
  max-width: 40ch;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
}

.picked b { color: var(--spark); font-weight: 500; }

.links { position: absolute; inset: 0; pointer-events: none; }

.link {
  position: absolute;
  height: 1px;
  background: rgba(244, 241, 238, 0.2);
  transform-origin: 0 50%;
  opacity: var(--o, 0);
  will-change: left, top, width, transform, opacity;
}

/* Nothing has moved for a while: breathe, and say why. */
.cue {
  position: absolute;
  left: var(--pad-x);
  bottom: calc(var(--pad-y) * 1.6);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.cue__line {
  width: 2.25rem;
  height: 1px;
  background: var(--burgundy-l);
  transform-origin: 0 50%;
}

html[data-idle] .cue { opacity: 1; }

html[data-idle] .cue__line { animation: cue-pull 2.4s ease-in-out infinite; }

html[data-idle] .axis { animation: breathe 4.2s ease-in-out infinite; }

@keyframes cue-pull {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(1.7); }
}

@keyframes breathe {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-idle] .cue__line,
  html[data-idle] .axis { animation: none; }
}

html[data-mode="static"] .cue,
.no-js .cue { display: none; }

/* ---- the axis: the line, its note, and the end ---- */

.axis {
  position: absolute;
  pointer-events: none;
  left: var(--pad-x);
  right: var(--pad-x);
  top: 47%;
  transform: translate3d(calc(var(--indent, 0) * 1%),
                         calc(-50% + var(--shift, 0) * 1svh), 0);
}

.lines {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  font-family: var(--font-display);
  font-size: var(--display);
}

/* every line shares one cell, so the block is as tall as the longest of
   them and a long line can wrap without breaking the layout */
.line {
  grid-area: 1 / 1;
  margin: 0;
  max-width: 92%;
  font: inherit;
  font-weight: 700;
  font-stretch: 112%;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--ivory);
}

.word { display: inline-block; }

.ch {
  display: inline-block;
  opacity: var(--o, 1);
  transform:
    translate(calc(var(--dx, 0) * 1em), calc(var(--dy, 0) * 1em))
    rotate(calc(var(--r, 0) * 1deg))
    scale(var(--sx, 1), var(--sy, 1));
  will-change: transform, opacity;
}

.notes {
  position: absolute;
  left: 0;
  top: calc(100% + clamp(1.1rem, 2.4vh, 1.9rem));
  width: 100%;
}

.note {
  position: absolute;
  left: 0; top: 0;
  margin: 0;
  max-width: 52ch;
  font-size: clamp(1rem, 1.28vw, 1.25rem);
  font-weight: 400;
  line-height: 1.62;
  color: var(--muted);
  text-wrap: balance;
  opacity: var(--o, 0);
  transform: translate3d(0, calc(var(--ty, 0) * 1px), 0);
  will-change: opacity, transform;
}

/* ---- the end ---- */

.end {
  position: absolute;
  pointer-events: auto;
  left: 0;
  top: calc(100% + clamp(1.25rem, 3vh, 2.25rem));
  width: 100%;
  opacity: var(--o, 0);
  transform: translate3d(0, calc(var(--ty, 0) * 1px), 0);
  outline: none;
  will-change: opacity, transform;
}

.end[data-quiet] { pointer-events: none; }

.tagline {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--muted);
}

.areas {
  margin: clamp(1.1rem, 2.6vh, 1.75rem) 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.7em;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ivory);
}

.areas li:not(:last-child)::after {
  content: "·";
  margin-left: 0.7em;
  color: var(--muted);
}

.about {
  margin: 0;
  max-width: 46ch;
  font-size: clamp(1.0625rem, 1.25vw, 1.25rem);
  font-weight: 400;
  line-height: 1.6;
  color: var(--ivory);
  text-wrap: pretty;
}

.areas__more {
  margin: 0.5rem 0 0;
  font-size: clamp(0.9375rem, 1.05vw, 1.0625rem);
  color: var(--muted);
}

.contact {
  margin-top: clamp(1.25rem, 3vh, 2rem);
  padding-top: clamp(1rem, 2.2vh, 1.5rem);
  border-top: 1px solid rgba(150, 48, 79, 0.5);
  max-width: 46ch;
}

.contact__line {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 1.8vw, 1.5rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ivory);
}

a.contact__cta {
  color: inherit;
  text-decoration: none;
  /* at rest: a hairline. On hover: a highlighter that covers the whole
     line, so no part of a letter is ever left dark on a dark ground. */
  padding: 0.1em 0.26em;
  margin: 0 -0.26em;
  background-image: linear-gradient(var(--spark), var(--spark));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 2px;
  transition: background-size 0.28s cubic-bezier(0.22, 0.85, 0.3, 1),
              color 0.18s ease 0.06s;
}

a.contact__cta:hover,
a.contact__cta:focus-visible {
  background-size: 100% 100%;
  color: var(--ink);
}

a.contact__cta:focus-visible { outline-color: var(--ivory); }

.signature {
  margin-top: clamp(1.1rem, 2.6vh, 1.75rem);
}

.signature__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.0625rem, 1.3vw, 1.25rem);
  font-weight: 700;
  font-stretch: 108%;
  letter-spacing: -0.015em;
  color: var(--ivory);
}

.signature__links {
  margin: 0.55rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

.signature__links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(198, 186, 191, 0.4);
  padding-block: 0.35rem;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.signature__links a:hover { color: var(--ivory); border-color: var(--spark); }

/* ------------------------------------------------------------------
   Narrow
   ------------------------------------------------------------------ */

@media (max-width: 900px) {
  :root { --display: clamp(1.875rem, 8.6vw, 3.25rem); }

  .axis { top: 50%; }
  .note { font-size: 1rem; max-width: 34ch; }
  .line { max-width: 100%; }
  .about { max-width: 34ch; }
}

/* ------------------------------------------------------------------
   Static mode — reduced motion, a viewport too short for the stage,
   or no script. The same words, read straight down.
   ------------------------------------------------------------------ */

html[data-mode="static"] .track,
.no-js .track { height: auto; }

html[data-mode="static"] .scene,
.no-js .scene {
  position: static;
  height: auto;
  overflow: visible;
  padding: calc(var(--pad-y) * 3.5) var(--pad-x) calc(var(--pad-y) * 3);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* every block joins one column, in narrative order */
html[data-mode="static"] .axis,
html[data-mode="static"] .lines,
html[data-mode="static"] .notes,
.no-js .axis,
.no-js .lines,
.no-js .notes { display: contents; }

html[data-mode="static"] .mark,
.no-js .mark { position: absolute; }

/* nothing decorative survives into the stacked version */
html[data-mode="static"] .rules,
html[data-mode="static"] .rail,
html[data-mode="static"] .collage,
html[data-mode="static"] .links,
html[data-mode="static"] .cue,
html[data-mode="static"] .tray,
.no-js .rules,
.no-js .rail,
.no-js .collage,
.no-js .links,
.no-js .cue,
.no-js .tray { display: none; }

html[data-mode="static"] .scene,
.no-js .scene { background: none; }

/* but the fragments stay — as a row of pills you can still pick from */
html[data-mode="static"] .pieces,
.no-js .pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 clamp(2rem, 6vh, 3.5rem);
  padding: 0;
  max-width: 46rem;
}

html[data-mode="static"] .piece,
.no-js .piece {
  position: static;
  opacity: 1;
  transform: none;
  border: 1px solid rgba(198, 186, 191, 0.3);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}

html[data-mode="static"] .piece::after,
html[data-mode="static"] .piece[aria-pressed="true"]::before,
.no-js .piece::after,
.no-js .piece[aria-pressed="true"]::before { content: none; }

html[data-mode="static"] .piece[aria-pressed="true"],
.no-js .piece[aria-pressed="true"] {
  border-color: var(--spark);
  background: rgba(216, 237, 131, 0.1);
}

html[data-mode="static"] .line,
.no-js .line {
  position: static;
  white-space: normal;
  margin: 0 0 clamp(1.25rem, 3.5vh, 2rem);
  font-size: var(--display);
  max-width: 18ch;
}

html[data-mode="static"] .ch,
.no-js .ch { opacity: 1; transform: none; }

html[data-mode="static"] .note,
html[data-mode="static"] .end,
.no-js .note,
.no-js .end {
  position: static;
  opacity: 1;
  transform: none;
  width: auto;
}

html[data-mode="static"] .note,
.no-js .note {
  margin: 0 0 clamp(2.5rem, 7vh, 4rem);
  max-width: 46ch;
}

html[data-mode="static"] .end,
.no-js .end { margin-top: clamp(0.5rem, 2vh, 1.5rem); }

/* the narrative, straight down */
html[data-mode="static"] .line[data-line="0"], .no-js .line[data-line="0"] { order: 1; }
html[data-mode="static"] .note[data-note="0"], .no-js .note[data-note="0"] { order: 2; }
html[data-mode="static"] .line[data-line="1"], .no-js .line[data-line="1"] { order: 3; }
html[data-mode="static"] .note[data-note="1"], .no-js .note[data-note="1"] { order: 4; }
html[data-mode="static"] .line[data-line="2"], .no-js .line[data-line="2"] { order: 5; }
html[data-mode="static"] .note[data-note="2"], .no-js .note[data-note="2"] { order: 6; }
html[data-mode="static"] .pieces,              .no-js .pieces              { order: 7; }
html[data-mode="static"] .line[data-line="3"], .no-js .line[data-line="3"] { order: 8; }
html[data-mode="static"] .end,                 .no-js .end                 { order: 9; }
