/* BRAIN COOLER · design system v2
   Temperature is the system: pages set colors via JS, tokens follow.
   Type: Instrument Serif (display, editorial warmth) + Instrument Sans (UI rigor). */

:root {
  --bg: #FCDDD6;
  --ink: #2B1B12;
  --hot: #D25734;
  --orange: #E99735;
  --sky: #71B1ED;
  --teal: #008670;
  --yellow: #F8D003;
  --hairline: color-mix(in oklab, var(--ink) 16%, transparent);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: background-color 1.2s linear, color 1.2s linear;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

canvas.field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;      /* gestures belong to the experience, never to browser zoom/scroll */
}

/* ---------- layout shell ---------- */

.page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 20px) 24px calc(env(safe-area-inset-bottom) + 20px);
  pointer-events: none;              /* canvas below stays touchable */
}
.page > * { pointer-events: auto; }

header.bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.wordmark { width: 118px; color: var(--ink); display: block; }
.wordmark svg { width: 100%; height: auto; display: block; }

a { color: inherit; }

/* ---------- type ---------- */

.serif, h1, h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.01em;
}
h2 { font-size: clamp(2rem, 8.5vw, 3.2rem); line-height: 1.08; max-width: 15ch; }
em { font-style: italic; }

.label {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
}
.body {
  font-size: 0.92rem;
  line-height: 1.55;
  font-weight: 400;
  max-width: 36ch;
  opacity: 0.85;
}

/* header controls: pill chips, full-contrast ink on a veil of the current bg,
   so they stay legible on top of the living canvas at any temperature */
.close {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid color-mix(in oklab, var(--ink) 30%, transparent);
  border-radius: 999px;
  padding: 10px 16px;
  transition: transform 0.25s var(--ease), background-color 0.25s var(--ease);
}
.close:active { transform: scale(0.96); }

.hint {
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  opacity: 0.7;
  text-align: center;
  max-width: 32ch;
  line-height: 1.5;
}
.hint .serif { font-size: 1.35rem; display: block; margin-bottom: 6px; opacity: 0.95; }

/* ---------- veils (arrival / return) ---------- */

.veil {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  text-align: center;
  padding: 32px;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 1;
  transition: opacity 0.45s var(--ease);
  z-index: 30;
}
.veil.gone { opacity: 0; pointer-events: none; }
/* intro typesetting rules:
   - line (h2): exactly 2 lines on mobile (the authored <br> is the break),
     exactly 1 line on desktop (the <br> is hidden). Never rewraps on its own.
   - body: exactly 1 line, mobile and desktop. */
.veil h2 {
  animation: rise 0.55s var(--ease) both;
  font-size: clamp(1.2rem, 5.1vw, 1.92rem);   /* 60% of the display scale: a whisper, not a shout */
  max-width: none;
  white-space: nowrap;
}
.veil .label { animation: rise 0.55s 0.06s var(--ease) both; }
.veil .body {
  animation: rise 0.55s 0.1s var(--ease) both;
  max-width: none;
  white-space: nowrap;
  font-size: clamp(0.6rem, 2.8vw, 0.8rem);
  opacity: 0.7;
}
@media (min-width: 700px) {
  .veil h2 br { display: none; }                /* one line: shell.js leaves a space after each <br> */
  .veil h2 { font-size: clamp(1.5rem, 2.7vw, 1.92rem); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- location chooser (rise) ---------- */
/* sits on the veil; input pinned high so the iOS keyboard never covers it */
.veil.loc { justify-content: flex-start; padding-top: calc(env(safe-area-inset-top) + 12vh); gap: 16px; }
.loc-in {
  animation: rise 0.55s var(--ease) both;
  font-family: var(--serif);
  font-size: clamp(1.4rem, 6vw, 2rem);
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid color-mix(in oklab, var(--ink) 34%, transparent);
  padding: 8px 4px;
  width: min(78vw, 20ch);
  outline: none;
}
.loc-in::placeholder { color: var(--ink); opacity: 0.32; }
.loc-list { list-style: none; width: min(80vw, 26ch); display: flex; flex-direction: column; }
.loc-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 11px 2px;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
  animation: rise 0.4s var(--ease) both;
}
.loc-list li:active { opacity: 0.55; }
.loc-list b { font-family: var(--serif); font-size: 1.18rem; font-weight: 400; letter-spacing: -0.01em; }
.loc-list span { font-size: 0.72rem; opacity: 0.6; text-align: right; white-space: nowrap; }
.loc-mine {
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink); background: none; border: none; opacity: 0.6; cursor: pointer;
}
.loc-mine:active { opacity: 0.3; }

/* ---------- science sheet ---------- */

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 74dvh;
  overflow-y: auto;
  background: var(--bg);
  color: var(--ink);
  border-top: 1px solid var(--hairline);
  border-radius: 24px 24px 0 0;
  padding: 28px 26px calc(env(safe-area-inset-bottom) + 32px);
  transform: translateY(103%);
  transition: transform 0.55s var(--ease);
  z-index: 40;
}
.sheet.open { transform: translateY(0); }
.sheet h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  margin: 6px 0 14px;
}
.sheet p { font-size: 0.92rem; line-height: 1.6; margin-bottom: 12px; max-width: 58ch; opacity: 0.9; }
.sheet sup { font-size: 0.62em; opacity: 0.55; margin-left: 1px; }
/* catalogue: names in serif, science in whisper caps, hairline rows */
.sheet .cat { list-style: none; margin: 6px 0 16px; }
.sheet .cat li { border-top: 1px solid var(--hairline); }
.sheet .cat a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.sheet .cat a:active { opacity: 0.6; }
.sheet .cat .name {
  font-family: var(--serif);
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}
.sheet .cat .meta {
  /* one line, always: rows stay equal-height. Size follows viewport so the
     longest description fits next to the name on a phone */
  font-size: clamp(0.6rem, 2.6vw, 0.8rem);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.55;
  text-align: right;
  flex: 1 1 auto;
  white-space: nowrap;
}

.sheet .bib {
  list-style-position: inside;
  margin: 0 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}
.sheet .bib li { font-size: 0.72rem; opacity: 0.6; line-height: 1.7; }
.sheet .cite { font-size: 0.72rem; opacity: 0.6; line-height: 1.55; }
.sheet .label { display: inline-block; margin-bottom: 2px; }
.scrim {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--ink) 28%, transparent);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s;
  z-index: 39;
}
.scrim.on { opacity: 1; pointer-events: auto; }

/* ---------- session chrome ---------- */

.phase {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  letter-spacing: 0.01em;
  text-align: center;
  transition: opacity 0.5s;
}
.ticks { display: flex; gap: 7px; justify-content: center; }
.ticks i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.2;
  transition: opacity 0.4s;
}
.ticks i.on { opacity: 0.85; }

.progress {
  position: fixed;
  left: 0; bottom: 0;
  width: 100%; height: 2px;
  z-index: 10;
}
.progress i {
  display: block; height: 100%;
  background: var(--ink);
  opacity: 0.4;
  transform-origin: left;
  transform: scaleX(0);
}

/* breathing guide: the phase word sits in the middle, the runner orbits it
   on an invisible rounded-square path */
.boxwrap {
  position: relative;
  width: min(58vw, 250px);
  aspect-ratio: 1;
}
.boxwrap .boxguide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.boxwrap .track { fill: none; stroke: none; }
.boxwrap .phase {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01s !important; animation-duration: 0.01s !important; }
}
