/* Step 10: visual polish, rebuilt against content/look_and_feel.md (the
   canonical spec) - not the earlier "warm lantern glow" pass, which was
   built without knowing that file existed and has been fully replaced.
   Six colour tokens, Baloo 2 (Archivo -> Inter -> Baloo 2, all 30 Aug 26
   - founder rulings, see content/look_and_feel.md §5's LOG), and the
   exact scale/spacing that file specifies. If something here looks like
   a judgement call rather than a direct read of that file, it's flagged
   in the handoff docs, not silently decided. */

:root {
  --ink: #15243f;
  --bone: #f5f2e9;
  --paper: #fffdf6;
  --text-c: #16223a;
  --line: #d9d5c8;
  --accent: #efd44a;

  /* Two grounds, one system (§2) - components read --ground/--on-ground
     rather than a fixed colour, so body.on-ink flips everything at once. */
  --ground: var(--bone);
  --on-ground: var(--text-c);
  --muted-body: rgba(22, 34, 58, 0.8);
  --muted-preamble: rgba(22, 34, 58, 0.62);
  --muted-counter: rgba(22, 34, 58, 0.5);
  --muted-placeholder: rgba(22, 34, 58, 0.42);

  --font: "Baloo 2", system-ui, "Helvetica Neue", Arial, sans-serif;

  --radius-btn: 8px;
  --radius-card: 10px;
  --radius-bubble: 14px;

  --h-primary: 66px;
  --h-option: 88px;
  --h-input: 58px;
}

body.on-ink {
  --ground: var(--ink);
  --on-ground: var(--bone);
  --muted-body: rgba(245, 242, 233, 0.8);
  --muted-preamble: rgba(245, 242, 233, 0.62);
  --muted-counter: rgba(245, 242, 233, 0.5);
  --muted-placeholder: rgba(245, 242, 233, 0.42);
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--ground);
  color: var(--on-ground);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--on-ground); }

/* --- Type scale (§3) --- */

.text-landing-headline {
  font-size: 35px;
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.025em;
  margin: 0 0 20px;
}

#screen h2 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
}

.text-section-lead { font-size: 19px; font-weight: 700; }

.text-option, .option { font-size: 17.5px; font-weight: 500; }

.text-message { font-size: 17.5px; font-weight: 400; }

body, .text-body { font-size: 16px; font-weight: 400; line-height: 1.5; }

.preamble {
  font-size: 15.5px;
  font-weight: 400;
  font-style: italic;
  color: var(--muted-preamble);
}

.progress {
  /* §5's Counter row specifies 12.5px, which contradicts §5's own "15px
     is the floor, no exceptions" rule two lines below it - the doc
     disagrees with itself here. Following the floor: it's the rule
     stated as load-bearing ("get exactly right"), not a role-specific
     number. Flagged, not silently picked. */
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-counter);
}

::placeholder { color: var(--muted-placeholder); }

/* Wordmark (§2/§5): bone on ink, text on bone - only ever "on-ground",
   never a fixed colour, since the mark appears on both grounds. */
.wordmark {
  font-family: var(--font);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.03em;
  color: var(--on-ground);
}

/* --- Buttons (§4) --- */

button {
  font-family: inherit;
  font-size: 17.5px;
  border: none;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: default; }

/* Option cards - the pressable answer surface. 4px bottom border in
   `line` is "the one piece of tactility in the system" (§4) - do not
   add a shadow alongside it. */
.option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--h-option);
  margin: 8px 0;
  padding: 16px 20px;
  text-align: left;
  background: var(--paper);
  color: var(--text-c);
  border-radius: var(--radius-card);
  border-bottom: 4px solid var(--line);
}

/* Selected = filled (ink), not a second accent use - accent is reserved
   for the one primary press per screen (§2, §6). */
.option.selected {
  background: var(--ink);
  color: var(--bone);
  border-bottom-color: var(--ink);
  font-weight: 700;
}

/* The one thing to press per screen (§2, §4). */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--h-primary);
  margin: 12px 0 0;
  padding: 0 24px;
  background: var(--accent);
  color: var(--ink);
  font-weight: 700;
  border-radius: var(--radius-btn);
}

/* A filled control that isn't the screen's one accent press - e.g. chat
   Send, which repeats every message rather than being a single per-screen
   CTA (§2's "filled controls" row). */
.btn-filled {
  background: var(--ink);
  color: var(--bone);
  font-weight: 700;
  border-radius: var(--radius-btn);
  min-height: var(--h-input);
  padding: 0 20px;
}

/* A secondary utility control - not filled, not a card, just bordered. */
.btn-utility {
  background: var(--paper);
  color: var(--text-c);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  min-height: var(--h-input);
  padding: 0 18px;
}

/* --- Inputs (§3, §4) --- */

input[type="text"], textarea {
  font-family: inherit;
  font-size: 16px;
  width: 100%;
  padding: 16px 18px;
  background: var(--paper);
  color: var(--text-c);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

input[type="text"] { min-height: var(--h-input); }
textarea { min-height: 90px; margin-bottom: 14px; }
input[type="text"]:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }

/* --- Progress: text + nine flat segments (§6) - a position indicator,
   never a score, nothing animated. --- */

#progress-segments { display: flex; gap: 4px; margin: 6px 0 18px; }
.progress-segment { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.progress-segment.filled { background: var(--on-ground); }

/* --- The lantern light (§3) - three states, all here, none in JS
   beyond toggling a class and a --lift custom property. §8: "the only
   two moving things in the product" are this pulse and the mirror's
   reveal - nothing else may animate. ---

   --metal defaults to bone, matching the SVG's own default (correct
   on ink ground, i.e. the landing). Anywhere the lantern sits on bone
   instead (the companion), add .lantern-on-bone to flip it to ink so
   the metalwork keeps contrast against its own ground. */

.lantern { --metal: var(--bone); display: block; }
.lantern-on-bone { --metal: var(--ink); }
.lantern svg { display: block; width: 100%; height: 100%; }

.lantern-glass { fill: var(--accent); }

/* Thinking: fill pulses toward paper, never opacity - fading opacity
   blends the flame into the tile behind it and reads as going out (§3,
   explicitly forbidden in §7). Stops the instant .thinking is removed -
   "when the reply lands". */
.lantern.thinking .lantern-glass {
  animation: lantern-thinking 1.7s ease-in-out infinite;
}
@keyframes lantern-thinking {
  0%, 100% { fill: var(--accent); }
  50% { fill: var(--paper); }
}

/* Lifted: a level, not a state - rendered straight from --lift (0-1,
   set by whoever places the lantern, from GET /api/light). Never
   negative, never past resting-and-up; the floor is enforced server-side
   (lib/light.js), this only ever renders whatever it's given. */
.lantern-halo-outer { opacity: calc(var(--lift, 0) * 0.13); transition: opacity 0.4s ease; }
.lantern-halo-inner { opacity: calc(var(--lift, 0) * 0.2); transition: opacity 0.4s ease; }

/* "Respect prefers-reduced-motion: no pulse, no halo transition. The
   thinking state still needs to be visible, so use a static lifted
   look rather than nothing" - a still glass plus a fixed full halo,
   no animation and no transition. */
@media (prefers-reduced-motion: reduce) {
  .lantern-halo-outer, .lantern-halo-inner { transition: none; }
  .lantern.thinking .lantern-glass { animation: none; fill: var(--accent); }
  .lantern.thinking .lantern-halo-outer { opacity: 0.13; }
  .lantern.thinking .lantern-halo-inner { opacity: 0.2; }
}
