/* app.css — the ritual's screens.
   Every colour, space, radius and shadow comes from organic.css tokens.
   Nothing here hard-codes a hex except the one gradient stop the design
   handoff specifies literally. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--color-surface); }
body { font-family: var(--font-body); color: var(--color-text); }

/* Themed focus on every interactive element — never the browser default. */
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }

/* ---- the frame: one whole-page crossfade, 1.6s each direction ---------- */
.frame {
  min-height: 100vh;
  display: grid;
  background: radial-gradient(120% 90% at 12% 8%,
    var(--color-neutral-100) 0%, var(--color-surface) 62%, #e2d2b6 100%);
  color: var(--color-text);
  transition: opacity 1.6s ease;
}

/* ---- shared type ------------------------------------------------------- */
.display {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: clamp(34px, 5.6vh, 58px);
  line-height: 1.04;
  color: var(--color-accent-800);
  max-width: 620px;
}
.caption { margin: 0; font-size: 15px; color: var(--color-neutral-600); }

/* ---- pills ------------------------------------------------------------- */
.pill {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--color-neutral-100);
  background: var(--color-accent-500);
  border: none;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: background 0.6s ease, transform 0.6s ease;
}
.pill:hover { background: var(--color-accent-600); transform: translateY(-2px); }
.pill-sm { font-size: 19px; padding: var(--space-4) var(--space-8); }
.pill-md { font-size: 21px; padding: var(--space-4) 60px; box-shadow: var(--shadow-lg); }
.pill-lg { font-size: 22px; padding: var(--space-6) 52px; box-shadow: var(--shadow-lg); }

.ghost {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-neutral-600);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: 999px;
  transition: color 0.6s ease;
}
.ghost:hover { color: var(--color-accent-700); }

/* A dev/testing affordance that earns its place: it is also the only way
   back to the paper list once the single-paper skip kicks in. */
.restart {
  position: fixed; right: 24px; bottom: 20px;
  font-family: var(--font-body); font-size: 13px;
  color: var(--color-neutral-500);
  background: none; border: none; cursor: pointer;
  transition: color 0.6s ease;
}
.restart:hover { color: var(--color-accent-700); }

/* ---- the breath sphere: one 10s cycle, shared by two screens ----------- */
.sphere { position: relative; aspect-ratio: 1; }
.sphere-halo, .sphere-orb { position: absolute; border-radius: 999px; }
/* will-change promotes both shapes to their own compositor layers, so the
   10s cycle is a pure composite rather than a repaint every frame. Without
   it Firefox re-rasterizes the 28px blur on the halo continuously, which
   shows up as a low-framerate judder in the breath. */
.sphere-halo {
  inset: 10%;
  background: var(--color-accent-2-400);
  filter: blur(28px);
  animation: r-halo 10s cubic-bezier(0.4, 0, 0.4, 1) infinite;
  will-change: transform, opacity;
}
.sphere-orb {
  inset: 16%;
  background: radial-gradient(circle at 34% 30%,
    var(--color-accent-400) 0%, var(--color-accent-600) 74%);
  box-shadow: var(--shadow-md);
  animation: r-breathe 10s cubic-bezier(0.4, 0, 0.4, 1) infinite;
  will-change: transform, opacity;
}

@keyframes r-breathe {
  0%   { transform: scale(0.66); opacity: 0.74 }
  38%  { transform: scale(1);    opacity: 1 }
  50%  { transform: scale(1);    opacity: 1 }
  96%  { transform: scale(0.66); opacity: 0.74 }
  100% { transform: scale(0.66); opacity: 0.74 }
}
@keyframes r-halo {
  0%, 100% { transform: scale(0.82); opacity: 0.3 }
  44%      { transform: scale(1.16); opacity: 0.1 }
}
@keyframes r-bloom {
  0%   { transform: scale(0.2); opacity: 0.85 }
  100% { transform: scale(2.6); opacity: 0 }
}
@keyframes r-fill { from { transform: scale(0.1) } to { transform: scale(1) } }
@keyframes r-blink { 0%, 46% { opacity: 1 } 54%, 100% { opacity: 0 } }

/* ---- 1. papers --------------------------------------------------------- */
/* NOT pinned to a fixed height: the page must be free to grow and scroll
   when the add form opens. */
.s-papers {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  min-height: 100vh;
  padding: clamp(28px, 6vh, 72px) clamp(40px, 6vw, 80px);
  gap: clamp(24px, 5vh, 56px);
}

.paper-list {
  display: flex; flex-direction: column;
  gap: var(--space-2);
  width: 100%; max-width: 700px;
  /* The x-clip and right padding matter: without them the hover nudge and
     the trash icon push out a horizontal scrollbar. */
  overflow-x: hidden;
  padding-right: var(--space-4);
}

/* Wrapper animates max-height rather than grid-template-rows — the latter
   does not transition reliably from a measured value. */
.row-wrap {
  max-height: 160px; opacity: 1;
  overflow: hidden; flex: none;
  transition: max-height 0.9s ease, opacity 0.9s ease;
}
.row-wrap.is-collapsed { max-height: 0; opacity: 0; }

.paper-row {
  display: flex; align-items: center;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-6);
  border-radius: 999px;
  cursor: pointer; min-height: 0;
  transition: background 0.7s ease, transform 0.7s ease;
}
.paper-row:hover {
  background: color-mix(in srgb, var(--color-accent-300) 38%, transparent);
  transform: translateX(6px);
}
.paper-name { font-size: 30px; color: var(--color-neutral-900); }

.paper-trash {
  margin-left: auto;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 999px; flex: none;
  border: none; background: none; cursor: pointer;
  color: var(--color-accent-700);
  opacity: 0;
  transition: opacity 0.7s ease, background 0.5s ease;
}
.paper-row:hover .paper-trash { opacity: 1; }
.paper-trash:hover { background: color-mix(in srgb, var(--color-accent-300) 55%, transparent); }
.paper-trash svg { display: block; }

/* The add block sits outside the scrolling list so it can never be squeezed. */
.add-block { display: flex; flex-direction: column; width: 100%; max-width: 700px; }

.add-row {
  display: flex; align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-radius: 999px; cursor: pointer;
  transition: opacity 1.4s ease, background 0.7s ease;
}
.add-row:hover { background: color-mix(in srgb, var(--color-accent-300) 30%, transparent); }

/* Two drawn bars, not a "+" glyph — the glyph sits optically off-centre. */
.add-plus {
  position: relative;
  width: 32px; height: 32px; flex: none;
  border: 2px solid var(--color-accent-400);
  border-radius: 999px;
}
.add-plus i {
  position: absolute; top: 50%; left: 50%;
  background: var(--color-accent-700); border-radius: 2px;
}
.add-plus i:first-child { width: 14px; height: 2px; margin: -1px 0 0 -7px; }
.add-plus i:last-child  { width: 2px; height: 14px; margin: -7px 0 0 -1px; }
.add-label { font-size: 19px; color: var(--color-neutral-600); }

/* Collapses to exactly 0px when closed. All vertical padding lives on the
   wrapper, not inside the collapsing track, or the closed state reserves
   height. flex:none is required in a flex column — overflow:hidden makes the
   automatic minimum resolve to 0 and the form gets crushed. */
.add-form {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden; flex: none;
  padding-block: 0;
  opacity: 0;
  transition: grid-template-rows 1.4s ease, padding-block 1.4s ease, opacity 1.4s ease;
}
.add-form.is-open { grid-template-rows: 1fr; padding-block: 0 17.6px; opacity: 1; }
.add-form-inner {
  min-height: 0;
  display: flex; flex-direction: column;
  gap: var(--space-3);
  padding-left: var(--space-6);
}

.add-field {
  font-family: var(--font-body);
  background: color-mix(in srgb, var(--color-neutral-100) 76%, transparent);
  border: none; outline: none;
  border-radius: 999px;
  padding: var(--space-4) var(--space-6);
  color: var(--color-neutral-900);
  max-width: 620px;
}
.add-field-name { font-size: 24px; }
.add-field-link { font-size: 18px; }
.add-field::placeholder { color: var(--color-neutral-500); }

.add-actions { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-2); }

/* ---- 2. grounding ------------------------------------------------------ */
.s-ground {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 460px);
  align-items: center;
  gap: 60px;
  padding: clamp(28px, 6vh, 72px) clamp(40px, 6vw, 80px);
}
.ground-left {
  display: flex; flex-direction: column;
  gap: clamp(18px, 3.4vh, 35.2px);
  max-width: 540px;
}
.ground-left .display { line-height: 1.02; }
.acks { display: flex; flex-direction: column; }

/* Rows 2 and 3 are always mounted and hold their space, revealing by opacity
   only — this column is vertically centred, so mounting on demand made the
   whole frame jump. */
.ack {
  display: flex; align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.7s ease, opacity 1.8s ease;
}
.ack:hover { background: color-mix(in srgb, var(--color-accent-300) 34%, transparent); }
.ack-text { font-size: 22px; color: var(--color-neutral-800); transition: color 1.2s ease; }
.ack.is-done { cursor: default; }
.ack.is-done .ack-text { color: var(--color-accent-800); }

.mark {
  position: relative;
  width: 32px; height: 32px; flex: none;
  border-radius: 999px;
  border: 2px solid var(--color-accent-400);
}
.mark-dashed { border-style: dashed; border-color: var(--color-accent-300); }
.mark.is-filled {
  border-color: transparent;
  background: var(--color-accent-600);
  animation: r-fill 1.2s cubic-bezier(0.2, 0.9, 0.2, 1);
}
/* the ring that blooms outward on acknowledgment */
.mark.is-filled::after {
  content: ''; position: absolute; inset: -2px;
  border-radius: 999px;
  border: 2px solid var(--color-accent-600);
  animation: r-bloom 2.2s ease-out;
}

.ground-continue { transition: opacity 2.4s ease; margin-top: var(--space-2); }
.ground-right { display: grid; place-items: center; }

/* ---- 3. quote + typing gate -------------------------------------------- */
.s-gate {
  display: grid; place-items: center;
  padding: clamp(28px, 6vh, 72px) clamp(40px, 6vw, 80px);
}
.gate-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(26px, 6vh, 64px);
  max-width: 720px;
  text-align: center;
}
.haiku {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  font-size: 40px; line-height: 1.24;
  color: var(--color-accent-800);
  text-wrap: pretty;
}
.attribution { margin: -14px 0 0; font-size: 15px; color: var(--color-neutral-600); }
.instruction { margin: 0; font-size: 15px; color: var(--color-neutral-600); }

/* Deliberately no input box, border or fill: a mirror of the typed text with
   a hand-drawn caret, and the real input laid transparently over it. */
.type-field {
  position: relative;
  font-size: 26px; line-height: 1.4;
  min-height: 1.4em; min-width: 320px;
  cursor: text;
}
.type-mirror { display: flex; align-items: center; justify-content: center; }
.type-text { white-space: pre; color: var(--color-neutral-900); }
.caret {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--color-neutral-900);
  animation: r-blink 1.1s steps(1, end) infinite;
}
.type-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  font: inherit; text-align: center;
  color: transparent; caret-color: transparent;
  background: none; border: none; outline: none;
  padding: 0;
}

/* Always mounted so nothing reflows; fades in on opacity only. */
.gate-pill { transition: opacity 3.6s ease; }

/* ---- 4. land in the doc ------------------------------------------------ */
/* Everything clamps on viewport height so the button is never below the fold. */
.s-go {
  display: grid; place-items: center;
  align-content: center;
  justify-items: center;
  gap: clamp(22px, 4.4vh, 46px);
  padding: clamp(28px, 6vh, 64px) 48px;
  text-align: center;
}
.s-go .sphere-halo { inset: 8%; }
.s-go .sphere-orb  { inset: 22%; }
.display-go { font-size: clamp(30px, 4.6vh, 46px); line-height: 1.1; }

/* ---- 5. fade ----------------------------------------------------------- */
.s-fade { display: grid; place-items: center; }
.opening { margin: 0; font-size: 22px; color: var(--color-neutral-600); }
