/* The look is the deck's: paper, map ink, one red. Red is for the drift and for what is mine. */
@font-face { font-family: Fraunces; src: url(fonts/fraunces.woff2) format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: Fraunces; src: url(fonts/fraunces-italic.woff2) format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fonts/plex-sans.woff2) format("woff2"); font-weight: 100 450; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fonts/plex-sans-semibold.woff2) format("woff2"); font-weight: 451 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/plex-mono.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --paper: #f4f1ea;
  --ink: #17233b;
  --soft: #4d5669;
  --rule: #cfc9bb;
  --red: #c8351f;
  --red-on-ink: #f0745c;
  --on-ink: #b9c0cf;
  --pad: 20px;
  --serif: Fraunces, Georgia, serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; color: var(--ink); }
body { background: var(--paper); transition: background-color 0.4s ease; -webkit-tap-highlight-color: transparent; }
body[data-ground="ink"] { background: var(--ink); }
body { font: 400 16px/1.45 var(--sans); -webkit-text-size-adjust: 100%; touch-action: manipulation; }

/* every view is one window tall; only a region marked .scroll may scroll */
.view {
  height: 100dvh;
  max-width: 480px; margin-inline: auto; /* a phone-width column on a wide screen */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) max(var(--pad), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--pad), env(safe-area-inset-left));
}
.body { min-height: 0; display: flex; flex-direction: column; gap: 12px; padding-top: 16px; }
.scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.body > .scroll { flex: 1 1 0; }

.bar {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0 8px; border-bottom: 2px solid var(--ink);
  font: 400 12px/1.3 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--soft);
}

h1 { font: 500 clamp(1.6rem, 7.6vw, 2.1rem)/1.12 var(--serif); letter-spacing: -0.01em; }
h1.wordmark { font-size: clamp(2.2rem, 11vw, 3rem); font-weight: 400; }
h2 { font: 400 12px/1.3 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--soft); padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
em { font-family: var(--serif); font-style: italic; }
.say { font: italic 400 clamp(1.15rem, 5.4vw, 1.4rem)/1.3 var(--serif); }
.note { font-size: 14px; line-height: 1.45; color: var(--soft); }
.note + .note { margin-top: 6px; }
blockquote { font: 400 1.05rem/1.4 var(--serif); }
.body.scroll { gap: 14px; display: flex; }

/* what is mine, as in the deck */
.mine { border-left: 5px solid var(--red); padding: 2px 0 2px 14px; }
.mine::before { content: "MINE"; display: block; font: 400 12px/1.3 var(--mono); letter-spacing: 0.18em; color: var(--red); margin-bottom: 4px; }
.mine ul { padding-left: 1.1em; margin: 6px 0; }
.mine p + p { margin-top: 6px; }

.actions { display: grid; gap: 8px; padding: 10px 0 max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); }
.pair { display: flex; gap: 8px; }
.pair button { flex: 1; }

button {
  font: 600 16px/1 var(--sans); color: var(--ink); background: transparent;
  min-height: 48px; padding: 0 16px; border: 1.5px solid var(--ink); border-radius: 0; cursor: pointer;
}
button.primary { background: var(--ink); color: var(--paper); }
button.plain { border-color: transparent; text-decoration: underline; text-underline-offset: 4px; font-weight: 400; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 8px; }

.status { display: grid; gap: 2px; font: 400 13px/1.4 var(--mono); }
.status div { display: flex; gap: 12px; }
.status dt { width: 5.5em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--soft); }
.readout { font: 400 1.5rem/1.2 var(--serif); }

.drifts { list-style: none; padding: 0; }
.drifts button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--rule); min-height: 52px; padding: 8px 0; font-weight: 400; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.drifts .when { font: 400 14px/1.3 var(--mono); }
.drifts .what { font: 400 13px/1.3 var(--mono); color: var(--soft); text-align: right; }

textarea {
  flex: 0 1 auto; height: calc(1.7em * 6); min-height: 3.4em; width: 100%; resize: none; padding: 0; border: 0; background: transparent; color: var(--ink);
  font: 400 18px/1.7 var(--sans);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.7em - 1px), var(--rule) calc(1.7em - 1px), var(--rule) 1.7em);
  background-attachment: local;
}

#map { flex: 1 1 0; min-height: 0; width: 100%; display: block; border: 1px solid var(--rule); }
.notes { list-style: none; padding: 0; max-height: clamp(64px, 22dvh, 170px); flex: 0 1 auto !important; }
.notes { padding-bottom: 6px; }
.notes li { display: grid; grid-template-columns: 2.2em 1fr; font-size: 15px; line-height: 1.4; padding: 3px 0; white-space: pre-wrap; }
.notes li::before { content: attr(data-n); font: 400 13px/1.6 var(--mono); color: var(--soft); }

/* the drift: the screen is the light at the feet. No text. */
#drift { grid-template-rows: minmax(0, 1fr) auto; }
#field { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 0; }
#say { color: var(--on-ink); font: 400 14px/1 var(--mono); letter-spacing: 0.18em; text-transform: uppercase; }
#brief { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: center; gap: 20px; max-width: 480px; margin-inline: auto; padding: 32px max(var(--pad), env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left)); background: var(--ink); color: var(--paper); animation: fade 0.3s ease; }
#brief[hidden] { display: none; }
#brief .kicker { color: var(--on-ink); }
#brief ol { padding-left: 1.3em; display: grid; gap: 12px; font: 400 clamp(1.1rem, 5vw, 1.3rem)/1.35 var(--serif); }
#brief li::marker { color: var(--red-on-ink); font-family: var(--mono); font-size: 0.8em; }
#brief .primary { background: var(--paper); color: var(--ink); }
#signal { width: min(68vw, 50dvh); height: auto; max-height: 100%; fill: var(--red-on-ink); stroke: var(--red-on-ink); stroke-width: 9; stroke-linecap: square; stroke-linejoin: miter; }
#signal polygon { stroke: none; }
#arrow, #stop { transform-origin: 50px 50px; transition: opacity 0.25s ease, transform 0.25s ease; }
#stop { opacity: 0; transform: scaleY(0.7); }
#signal[data-state="look"] #arrow { opacity: 0; }
#signal[data-state="look"] #stop { opacity: 1; transform: none; animation: breathe 2.4s ease-in-out infinite; }
#signal.roll { animation: roll 0.3s ease; }
@keyframes roll { 40% { opacity: 0.15; transform: scale(0.94); } }
@keyframes breathe { 50% { opacity: 0.55; } }
.strip { display: flex; justify-content: space-between; padding: 4px 0 max(8px, env(safe-area-inset-bottom)); }
.strip button { border: 0; color: var(--on-ink); font: 400 13px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; min-width: 64px; }

#tape { width: 100%; height: 52px; display: block; }

/* finish: views rise in, press is felt, nothing moves when motion is reduced */
.view { animation: fade 0.3s ease; }
.view.out { opacity: 0; transform: translateY(-6px); transition: opacity 0.14s ease, transform 0.14s ease; }
.view:not(#drift) .body > *, .view:not(#drift) .actions > * { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
.body > :nth-child(2) { animation-delay: 0.05s; }
.body > :nth-child(3) { animation-delay: 0.1s; }
.body > :nth-child(4) { animation-delay: 0.15s; }
.body > :nth-child(n+5) { animation-delay: 0.2s; }
.actions > * { animation-delay: 0.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade { from { opacity: 0; } }
button { transition: transform 0.1s ease, opacity 0.1s ease; }
button:active { transform: scale(0.97); opacity: 0.82; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-height: 640px) {
  #tape { height: 44px; }
  .body { gap: 8px; padding-top: 10px; }
  h1 { font-size: 1.45rem; }
  h1.wordmark { font-size: 2rem; }
  .say { font-size: 1.1rem; }
  button { min-height: 44px; }
}
/* home: the name centred, the second word wandering off, a drift drawing itself beneath */
#home { grid-template-rows: minmax(0, 1fr) auto; }
#home .body { padding-top: max(16px, env(safe-area-inset-top)); }
#home .body > .scroll { flex: 0 1 auto; max-height: 28dvh; }
.hero { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.kicker { font: 400 12px/1.3 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--soft); }
h1.wordmark { display: flex; flex-direction: column; align-items: center; font-size: clamp(3.4rem, 21vw, 6rem); font-weight: 400; line-height: 0.9; letter-spacing: -0.02em; }
h1.wordmark span { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
h1.wordmark span:last-child { font-style: italic; translate: 0.32em 0; rotate: -4deg; animation-delay: 0.18s; }
.wander { width: min(80vw, 340px); height: auto; overflow: visible; margin: -0.2em 0 2px; }
.wander path { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.5s 0.45s cubic-bezier(0.6, 0, 0.2, 1) forwards; }
.wander polygon { fill: var(--red); opacity: 0; animation: show 0.25s 1.9s forwards; }
.hero .say { margin-top: 4px; }
.hero .sub { max-width: 30ch; color: var(--soft); font-size: 15px; }
#home #no-drifts { text-align: center; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes show { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .wander path { stroke-dashoffset: 0; }
  .wander polygon { opacity: 1; }
}
@media (max-height: 640px) {
  h1.wordmark { font-size: clamp(2.8rem, 17vw, 4rem); }
  .wander { width: min(64vw, 260px); }
  .hero { gap: 6px; }
}

.area { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 8px; }
.area label { display: grid; gap: 4px; font: 400 11px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); }
.area input { font: 400 16px/1.2 var(--sans); color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--rule); padding: 6px 0; min-width: 0; }
#about a { color: inherit; }

@media print { .actions, .strip { display: none; } }
