/* rossteixeira.com/mnemonics */

@font-face {
  font-family: "EB Garamond";
  src: url("/assets/fonts/eb-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("/assets/fonts/eb-garamond-italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/ibm-plex-mono.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("/assets/fonts/open-sans.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --night: #0b0a0d;
  --paper: #ece6dc;
  --muted: #8f887e;
  --faint: rgba(236, 230, 220, 0.12);
  --amber: #f1bd7c;

  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Open Sans", "Helvetica Neue", Arial, sans-serif;

  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);
  color-scheme: dark;
}

/* Each constant's world. */
[data-world="pi"]    { --bg: #120d12; --bg2: #2c1912; --ink: #f7eee3; --accent: #f4bf7a; --accent2: #e47a62; }
[data-world="e"]     { --bg: #0a0e18; --bg2: #1c1a33; --ink: #eceef8; --accent: #b9c4ff; --accent2: #8fd3e0; }
[data-world="phi"]   { --bg: #0e1109; --bg2: #2b2610; --ink: #f6f1df; --accent: #f4c430; --accent2: #a3c45e; }
[data-world="sqrt2"] { --bg: #06111b; --bg2: #0f2539; --ink: #e8f3f7; --accent: #9edcf0; --accent2: #f3b49c; }
[data-world="robin"] { --bg: #0c0a14; --bg2: #241838; --ink: #f1ecf8; --accent: #d6b6ff; --accent2: #ff9fb2; }

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--night);
}
html.locked { overflow: hidden; }

/* No visible scrollbars: the rail and ticker show where you are. */
html, .world { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, .world::-webkit-scrollbar { display: none; width: 0; height: 0; }

body {
  margin: 0;
  background: var(--night);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent, var(--amber)); outline-offset: 4px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 10;
  background: var(--paper); color: var(--night); padding: 0.5rem 0.9rem; border-radius: 6px;
  font-family: var(--sans); font-size: 0.875rem;
}
.skip-link:focus { top: 1rem; }

/* ---------------------------------------------------------------- Index */

.index {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(60rem 40rem at 15% -10%, rgba(241, 189, 124, 0.09), transparent 70%),
    radial-gradient(50rem 40rem at 100% 30%, rgba(158, 220, 240, 0.05), transparent 70%),
    var(--night);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem var(--gutter);
  font-family: var(--sans);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}
.masthead nav { display: flex; gap: 1.25rem; }
.masthead a { color: var(--muted); transition: color 0.2s; }
.masthead a:hover, .masthead a[aria-current="page"] { color: var(--paper); }
.masthead .home { color: var(--paper); font-weight: 600; letter-spacing: 0.02em; }
@media (max-width: 30rem) { .masthead nav a:not([aria-current]) { display: none; } }

.intro {
  max-width: 64rem;
  margin: 0 auto;
  padding: clamp(3rem, 2rem + 6vw, 8rem) var(--gutter) clamp(2.5rem, 2rem + 3vw, 4.5rem);
  text-align: center;
}
.kicker {
  margin: 0 0 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}
.intro h1 {
  margin: 0;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(3.6rem, 1.5rem + 10vw, 10.5rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  color: var(--paper);
  text-wrap: balance;
}
.lede {
  margin: 1rem 0 0;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 2rem);
  color: var(--paper);
  opacity: 0.85;
}
.how {
  max-width: 34rem;
  margin: 2.25rem auto 0;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 2.3;
  text-wrap: balance;
}
.demo { color: var(--paper); font-style: italic; white-space: nowrap; }
.demo span { position: relative; display: inline-block; margin: 0 0.06em; }
.demo span::before {
  content: attr(data-n);
  position: absolute;
  left: 50%;
  top: -1.05em;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.6em;
  color: var(--amber);
  opacity: 0;
  animation: digit-in 0.6s ease forwards;
}
.demo span:nth-child(1)::before { animation-delay: 0.6s; }
.demo span:nth-child(2)::before { animation-delay: 0.9s; }
.demo span:nth-child(3)::before { animation-delay: 1.2s; }
.demo span:nth-child(4)::before { animation-delay: 1.5s; }
.demo span:nth-child(5)::before { animation-delay: 1.8s; }
@keyframes digit-in { from { opacity: 0; transform: translate(-50%, 0.4em); } to { opacity: 1; transform: translate(-50%, 0); } }

.constants { padding: 0 var(--gutter) clamp(3rem, 2rem + 4vw, 6rem); }
.cards {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 82rem;
  display: grid;
  gap: clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
  grid-template-columns: 1fr;
}
@media (min-width: 34rem) and (max-width: 55.99rem) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards li:last-child { grid-column: span 2; }
  .cards li:last-child .card { aspect-ratio: 2 / 1.25; }
}
@media (min-width: 56rem) { .cards { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 56rem) { .card .card-glyph { font-size: clamp(4.5rem, 2rem + 3.5vw, 6.5rem); } .card-name { font-size: 1.2rem; } }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 1.4rem 1.4rem 1.3rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  background: radial-gradient(120% 90% at 50% 25%, var(--bg2), var(--bg) 70%);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.4s, box-shadow 0.5s;
}
@media (max-width: 34rem) { .card { aspect-ratio: 4 / 3.6; } }
.card canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.75;
  transition: opacity 0.5s;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, var(--bg) 8%, transparent 55%);
}
.card:hover, .card:focus-visible {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 30px 60px -30px color-mix(in srgb, var(--accent) 45%, transparent);
}
.card:hover canvas, .card:focus-visible canvas { opacity: 1; }
.card .card-glyph {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -62%);
  font-style: italic;
  font-size: clamp(5rem, 3rem + 5vw, 7.5rem);
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 40px color-mix(in srgb, var(--accent) 50%, transparent);
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
  white-space: nowrap;
}
.card:hover .card-glyph { transform: translate(-50%, -66%) scale(1.05); }
.card-name {
  display: block;
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}
.card-line {
  display: block;
  margin: 0.35rem 0 0;
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.4;
  opacity: 0.72;
}

.colophon {
  max-width: 38rem;
  margin: 0 auto;
  padding: 0 var(--gutter) 4rem;
  color: var(--muted);
  font-size: 1.125rem;
  text-align: center;
  text-wrap: pretty;
}
.colophon p { margin: 0 0 1rem; }

.foot {
  padding: 2rem var(--gutter) 3rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.foot a:hover { color: var(--paper); }

/* The index fits one screen: the cards take whatever height is left. */
.index {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  min-height: 0;
}
.index main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.masthead { padding-top: clamp(0.75rem, 2vh, 1.25rem); padding-bottom: clamp(0.5rem, 1.5vh, 1rem); }
.intro { padding: clamp(0.5rem, 3vh, 3rem) var(--gutter) clamp(1rem, 3.5vh, 2.75rem); }
.kicker { margin-bottom: clamp(0.5rem, 1.6vh, 1.25rem); }
.intro h1 { font-size: clamp(3rem, min(10vw, 12vh), 9rem); }
.lede { margin-top: clamp(0.25rem, 1vh, 0.9rem); font-size: clamp(1.15rem, min(1rem + 1vw, 3.4vh), 1.85rem); }
.how { margin-top: clamp(0.75rem, 2.2vh, 1.75rem); line-height: 2.1; font-size: clamp(1rem, 2.3vh, 1.125rem); }
.constants { flex: 1; min-height: 0; padding: 0 var(--gutter); }
.cards { height: 100%; grid-auto-rows: 1fr; }
.cards li { min-height: 0; }
.card, .cards li:last-child .card { aspect-ratio: auto; height: 100%; container-type: size; }
.card .card-glyph { font-size: clamp(3rem, 42cqh, 7rem); }
@media (min-width: 56rem) { .card .card-glyph { font-size: clamp(3rem, min(40cqh, 55cqw), 6.5rem); } }
@container (max-height: 13rem) {
  .card-line { display: none; }
  .card .card-glyph { transform: translate(-50%, -70%); }
}
@container (max-height: 9rem) {
  .card { padding: 0.9rem 1rem; }
}
.colophon {
  max-width: 52rem;
  padding: clamp(0.75rem, 2.2vh, 1.5rem) var(--gutter) max(clamp(0.75rem, 2.4vh, 1.75rem), env(safe-area-inset-bottom));
  font-size: clamp(0.85rem, 1.9vh, 0.98rem);
  line-height: 1.5;
}
.colophon p { margin: 0; }
@media (max-width: 34rem) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards li:last-child { grid-column: span 2; }
  .card { padding: 0.9rem 1rem; border-radius: 16px; }
  .card-name { font-size: 1.1rem; }
  .card-line { font-size: 0.9rem; }
  .how { max-width: 21rem; }
}
/* Too short to fit (a phone on its side): let the page scroll instead. */
@media (max-height: 34rem) {
  .index { height: auto; min-height: 100svh; }
  .constants { flex: none; }
  .cards { height: auto; grid-auto-rows: 15rem; }
}

/* Sound */
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.7rem 0.35rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--ink, var(--paper)) 16%, transparent);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.sound-toggle:hover { color: var(--ink, var(--paper)); border-color: var(--accent, var(--amber)); }
.sound-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.sound-bars i {
  display: block;
  width: 2px;
  height: 3px;
  border-radius: 1px;
  background: var(--accent, var(--amber));
  transition: height 0.4s;
}
.sound-toggle[data-state="on"] .sound-bars i { animation: sound-bar 1.6s ease-in-out infinite; }
.sound-toggle[data-state="on"] .sound-bars i:nth-child(2) { animation-delay: -0.4s; animation-duration: 1.3s; }
.sound-toggle[data-state="on"] .sound-bars i:nth-child(3) { animation-delay: -0.9s; animation-duration: 1.9s; }
.sound-toggle[data-state="on"] .sound-bars i:nth-child(4) { animation-delay: -0.2s; animation-duration: 1.5s; }
.sound-toggle[data-state="waiting"] { color: var(--ink, var(--paper)); animation: breathe 2.4s ease-in-out infinite; }
.sound-toggle[data-state="off"] .sound-bars i { height: 2px; opacity: 0.5; }
@keyframes sound-bar { 0%, 100% { height: 3px; } 50% { height: 12px; } }
.masthead nav { align-items: center; }
.world-bar-end { display: flex; align-items: center; gap: 1rem; }
.world-bar .sound-toggle {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: color-mix(in srgb, var(--ink) 75%, transparent);
}
@media (max-width: 30rem) {
  .world-name { display: none; }
  .masthead .sound-toggle .sound-label { display: none; }
}

/* ---------------------------------------------------------------- World */

.world {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: radial-gradient(120% 80% at 50% 100%, var(--bg2), var(--bg) 65%) fixed, var(--bg);
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
}
.world[hidden] { display: none; }

.world-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  pointer-events: none;
}

.stream-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(42rem 70% at 50% 50%, color-mix(in srgb, var(--bg) 82%, transparent), transparent 100%);
}

.world-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.9rem, env(safe-area-inset-top)) var(--gutter) 0.9rem;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 85%, transparent), transparent);
  pointer-events: none;
}
.world-bar > * { pointer-events: auto; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-family: var(--sans);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
}
.back:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.world-name {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0.6;
}

.world-scroll { position: relative; z-index: 2; }

.world-intro {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem var(--gutter) 4rem;
  text-align: center;
}
.glyph {
  margin: 0;
  font-style: italic;
  font-size: clamp(7rem, 4rem + 14vw, 15rem);
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 80px color-mix(in srgb, var(--accent) 45%, transparent);
}
.world-title {
  margin: 1.25rem 0 0;
  font-weight: 400;
  font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.4rem);
  font-style: italic;
}
.world-epigraph {
  max-width: 32rem;
  margin: 1rem 0 0;
  font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem);
  line-height: 1.6;
  opacity: 0.72;
  text-wrap: balance;
}
.begin {
  margin: 3.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.55;
  animation: breathe 3.2s ease-in-out infinite;
}
.begin::after { content: ""; display: block; width: 1px; height: 3rem; margin: 1rem auto 0; background: linear-gradient(var(--ink), transparent); }
@keyframes breathe { 50% { opacity: 0.2; } }

/* The poem. Lines arrive as plain text and become word spans near the viewport. */
.loading {
  margin: 0;
  min-height: 1px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.6;
}
.loading:empty { display: none; }
.poem {
  max-width: 44rem;
  margin: 0 auto;
  padding: 18vh var(--gutter) 46vh;
  letter-spacing: 0.003em;
}
@media (max-width: 48rem) { .poem, .seam { padding-right: calc(var(--gutter) + 1.5rem); } }
.line {
  margin: 0;
  opacity: 0.2;
  text-wrap: pretty;
  transition: opacity 0.9s ease;
}
.line.hand {
  margin-bottom: 0.3em;
  font-size: clamp(1.6rem, 1.05rem + 2.1vw, 2.75rem);
  line-height: 1.85;
}
.line.gen {
  font-size: clamp(1.15rem, 1rem + 0.55vw, 1.45rem);
  line-height: 2.3;
}
.line.gap { margin-top: 1.4em; }
.line.past, .line.cur { opacity: 1; }
.line.past { opacity: 0.82; }
.line.cur .t { opacity: 0.22; transition: opacity 0.9s ease; }
.line.cur .t.lit { opacity: 1; }
.w {
  position: relative;
  transition: color 0.9s ease, text-shadow 0.9s ease;
}
.w .d {
  position: absolute;
  left: 50%;
  bottom: 98%;
  transform: translate(-50%, 0.3em);
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.34em;
  line-height: 1;
  letter-spacing: 0;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
  user-select: none;
  pointer-events: none;
}
.line.gen .w .d { font-size: 0.5em; }
.t.lit .d { opacity: 0.5; transform: translate(-50%, 0); }
.line.past .t.lit .d { opacity: 0.32; }
.w.now { color: var(--accent); text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 55%, transparent); }
.w.now .d { opacity: 1; }

.seam {
  max-width: 30rem;
  margin: 5rem auto 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.9;
  letter-spacing: 0.06em;
  text-align: center;
  opacity: 0.6;
  text-wrap: balance;
}

/* Jump anywhere in the poem. */
.rail {
  position: fixed;
  right: max(0.4rem, env(safe-area-inset-right));
  top: 22vh;
  bottom: 22vh;
  z-index: 4;
  width: 2rem;
  cursor: pointer;
  touch-action: none;
}
.rail-track, .rail-fill {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
}
.rail-fill {
  width: 2px;
  margin-left: -0.5px;
  background: var(--accent);
  transform-origin: top;
  transform: scaleY(0);
}
.rail-thumb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}
.rail-label {
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}
.rail:hover .rail-label, .rail:focus-visible .rail-label, .rail.dragging .rail-label { opacity: 1; }
.rail:focus-visible { outline: none; }
.rail:focus-visible .rail-thumb { outline: 2px solid var(--accent); outline-offset: 3px; }

/* After the poem */
.finale {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 var(--gutter) 12rem;
  text-align: center;
}
.finale-count {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.finale-line {
  margin: 1rem 0 0;
  font-style: italic;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.5rem);
  line-height: 1.3;
  text-wrap: balance;
}

.compose {
  margin: 7rem 0 0;
  padding: 2rem clamp(1.25rem, 1rem + 2vw, 2.25rem);
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: left;
}
.compose h3 { margin: 0; font-weight: 400; font-size: 1.6rem; font-style: italic; }
.compose-hint { margin: 0.4rem 0 1.25rem; opacity: 0.72; font-size: 1.05rem; }
.next-digits { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.next-digits span {
  display: grid;
  place-items: center;
  min-width: 1.9rem;
  height: 2.1rem;
  padding: 0 0.3rem;
  border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 0.875rem;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.next-digits span.ok { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.next-digits span.bad { border-color: var(--accent2); color: var(--accent2); }
.next-digits span.cur { border-color: var(--accent); }
.compose textarea {
  display: block;
  width: 100%;
  min-height: 5.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 60%, black 10%);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.4;
  resize: vertical;
}
.compose textarea:focus { outline: none; border-color: var(--accent); }
.compose textarea::placeholder { color: color-mix(in srgb, var(--ink) 40%, transparent); font-style: italic; }
.compose-status { min-height: 1.5em; margin: 0.75rem 0 0; font-size: 1.02rem; opacity: 0.85; }

.keep { margin: 3.5rem 0 0; }
.keep p { margin: 0.75rem auto 0; max-width: 24rem; font-size: 1rem; opacity: 0.6; }
.keep-button {
  padding: 0.95rem 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 16px 40px -16px var(--accent);
  transition: transform 0.25s, box-shadow 0.25s;
}
.keep-button:hover { transform: translateY(-2px); box-shadow: 0 22px 50px -16px var(--accent); }
.back-bottom { margin-top: 3.5rem; }

.ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 1.1rem var(--gutter) max(1rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 90%, transparent), transparent);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  pointer-events: none;
  white-space: nowrap;
}
.ticker-glyph { font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--accent); letter-spacing: 0; }
.ticker-digits { flex: 1; min-width: 0; display: flex; justify-content: flex-end; overflow: hidden; opacity: 0.85; }
.ticker-digits > span { flex: none; }
.ticker-digits b { font-weight: 400; color: var(--accent); }
.ticker-digits i { font-style: normal; opacity: 0.28; }
.ticker-count { opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .line.cur .t { opacity: 1; }
  .t.lit .d, .w .d { transform: translate(-50%, 0); }
  .demo span::before { opacity: 1; }
}

/* Wide, short cards: the glyph moves aside so it never sits on the title. */
@container (min-aspect-ratio: 2 / 1) {
  .card .card-glyph { left: auto; right: 9%; transform: translateY(-50%); font-size: clamp(3rem, 55cqh, 6rem); }
  .card:hover .card-glyph { transform: translateY(-52%) scale(1.05); }
}

/* Keep each glyph clear of its title. */
.card .card-glyph { top: 31%; transform: translate(-50%, -50%); }
.card:hover .card-glyph { transform: translate(-50%, -54%) scale(1.05); }
@container (max-height: 13rem) {
  .card .card-glyph { top: 0.55rem; right: 0.8rem; left: auto; transform: none; font-size: clamp(2rem, 40cqh, 3.4rem); }
  .card:hover .card-glyph { transform: translateY(-3px) scale(1.05); }
}
@container (min-aspect-ratio: 2 / 1) and (min-height: 13.01rem) {
  .card .card-glyph { top: 50%; left: auto; right: 9%; transform: translateY(-50%); }
  .card:hover .card-glyph { transform: translateY(-52%) scale(1.05); }
}

/* ---------------------------------------------------------------- The whole poem */

.world-bar { z-index: 7; }
.zoom-out, .see-shape {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem 0.35rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: color-mix(in srgb, var(--ink) 80%, transparent);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.zoom-out svg { width: 14px; height: 14px; }
.zoom-out:hover, .see-shape:hover { color: var(--ink); border-color: var(--accent); }
.world.zoomed-out .zoom-out { border-color: var(--accent); color: var(--accent); }
.see-shape { margin: 3.5rem auto 0; padding: 0.8rem 1.3rem; font-size: 0.875rem; }
@media (max-width: 30rem) { .zoom-out span { display: none; } .zoom-out { padding: 0.45rem; } }

.world-scroll, .rail, .ticker { transition: opacity 0.6s ease; }
.world.zoomed-out .world-scroll, .world.zoomed-out .rail, .world.zoomed-out .ticker { opacity: 0; pointer-events: none; }
.world { touch-action: pan-y; }

.map {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--bg2) 70%, transparent), color-mix(in srgb, var(--bg) 94%, transparent) 70%);
  opacity: 0;
  transition: opacity 0.5s ease;
  outline: none;
}
.map.open { opacity: 1; }
.map[hidden] { display: none; }
.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.map-canvas:active { cursor: grabbing; }
.map-caption {
  position: absolute;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(40rem, calc(100% - 2 * var(--gutter)));
  text-align: center;
  pointer-events: none;
}
.map-title {
  margin: 0;
  font-style: italic;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem);
  color: var(--accent);
}
.map-text {
  margin: 0.35rem 0 0;
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
  line-height: 1.45;
  opacity: 0.8;
  text-wrap: balance;
}
.map-hint {
  margin: 0.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  opacity: 0.45;
}
.map-actions {
  position: absolute;
  top: calc(max(0.9rem, env(safe-area-inset-top)) + 2.9rem);
  right: var(--gutter);
  display: flex;
  gap: 0.5rem;
}
.map-actions button {
  padding: 0.45rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-family: var(--sans);
  font-size: 0.75rem;
  cursor: pointer;
}
.map-actions .map-back { border-color: var(--accent); color: var(--accent); }
.map-actions button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.map-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  max-width: 16rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  pointer-events: none;
}
.map-tip b { font-weight: 400; font-size: 1.15rem; font-style: italic; }
.map-tip span { font-family: var(--mono); color: var(--accent); }
.map-tip em { flex-basis: 100%; font-style: normal; font-family: var(--mono); font-size: 0.6875rem; opacity: 0.6; }
@media (max-width: 34rem) { .map-hint { display: none; } .map-text { font-size: 0.9rem; } }
.map-caption { transition: opacity 0.5s ease; }
.map.deep .map-caption { opacity: 0; }

/* The poem's shape, painted behind the text as you read. */
.shape-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.45s ease;
}
.world.zoomed-out .shape-canvas { opacity: 0; }
.map { transition: opacity 0.45s ease; }
.world-scroll, .rail, .ticker { transition: opacity 0.45s ease; }
.map-gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
