/* ------------------------------------------------------------------
   Storylab engine styles.

   The tokens are lifted verbatim from the product surface's design system
   (storylab-prototype/app/globals.css) so the engine and the marketing site
   are recognisably one product. Plain CSS rather than Tailwind on purpose:
   the engine is a thin server with no build step, and a stylesheet is the
   smallest thing that keeps the two surfaces in step.

   Kept from the prototype and load-bearing, not decoration:
     · coach turns are SERIF, in a peach-bordered card with paper grain
     · learner turns are UNBORDERED and indented — the person's own voice,
       set plainly, never boxed like a system message
     · coral is action only, never a surface
   ------------------------------------------------------------------ */

:root {
  /* Light only. No dark variant and no OS-preference following — Richie's
     call, 6 Aug 2026. Do not reintroduce a toggle here without asking. */
  color-scheme: light;

  --ground: #f8f6f0;
  --surface: #fdfcf9;
  --surface-sunk: #f1ede4;

  --euc: #1c4a4e;
  --euc-deep: #133438;
  --peach: #f9c7a8;
  --peach-wash: #fdeee2;
  --coral: #e76f51;
  --coral-ink: #ffffff;

  --ink: #14282a;
  --ink-2: #3a5457;
  --muted: #5b7578;
  --faint: #879c9e;

  --line: color-mix(in oklab, #1c4a4e 14%, transparent);
  --line-strong: color-mix(in oklab, #1c4a4e 28%, transparent);

  --crit: #9e3b2a;

  --shadow-card: 0 1px 2px color-mix(in oklab, #1c4a4e 8%, transparent),
    0 8px 24px -16px color-mix(in oklab, #1c4a4e 22%, transparent);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif: "Source Serif 4", ui-serif, Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--peach); color: #14282a; }

:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Tracked uppercase micro-label — the product surface's `.label` */
.label {
  font-size: 0.6875rem;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Editorial paper warmth. Parent needs position: relative. */
.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.2;
  mix-blend-mode: multiply;
  pointer-events: none;
  border-radius: inherit;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
.rise { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

header.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--ground) 90%, transparent);
  backdrop-filter: blur(12px);
}

.chrome-inner {
  margin: 0 auto;
  max-width: 48rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
}
@media (min-width: 640px) { .chrome-inner { padding: 0 1.5rem; } }

/* The wordmark ends in a coral full stop — the voice charter's own rule is
   "a period where you want a comma", so the punctuation is the mark. */
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
}
.wordmark .stop { color: var(--coral); }

.chrome-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 9999px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: var(--ink);
  background: none;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s;
}
.pill:hover { border-color: var(--coral); }
.pill .dot {
  width: 0.375rem; height: 0.375rem;
  border-radius: 9999px; background: var(--coral);
}

/* --------------------------------- thread --------------------------------- */

.thread {
  margin: 0 auto;
  max-width: 48rem;
  padding: 2rem 1rem 11rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
@media (min-width: 640px) {
  .thread { padding: 2.5rem 1.5rem 11rem; gap: 2.25rem; }
}

/* Coach: serif, in a card. The register is the point — spare language in a
   typeface with some weight to it. */
.coach .card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--peach);
  border-radius: 0.75rem;
  background: var(--surface);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
@media (min-width: 640px) { .coach .card { padding: 1.5rem; } }

.coach .card p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  max-width: 34em;
}
@media (min-width: 640px) { .coach .card p { font-size: 1.375rem; } }

/* Learner: unbordered and indented. Never boxed — it is their own voice, not
   a system message. */
.user {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding-left: 1.5rem;
}
@media (min-width: 640px) { .user { padding-left: 2.5rem; } }

.user .label { color: var(--faint); margin: 0; }
.user p.says {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
}

.ended {
  margin: 0 auto;
  max-width: 48rem;
  padding: 0 1rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
}

/* -------------------------------- composer -------------------------------- */

.composer {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--ground) 95%, transparent);
  backdrop-filter: blur(12px);
}

.composer-inner {
  margin: 0 auto;
  max-width: 48rem;
  padding: 1rem;
}
@media (min-width: 640px) { .composer-inner { padding: 1rem 1.5rem; } }

.field {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.75rem;
  background: var(--surface);
  padding: 0.625rem 0.75rem;
  transition: border-color 0.15s;
}
.field:focus-within { border-color: var(--coral); }

.field textarea {
  flex: 1;
  resize: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  padding: 0.375rem 0.25rem;
  max-height: 8rem;
  min-height: 1.6rem;
  field-sizing: content;
}
.field textarea::placeholder { color: var(--faint); }
.field textarea:focus { outline: none; }

.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem; height: 2.25rem;
  flex-shrink: 0;
  border: 0; border-radius: 0.5rem;
  background: var(--coral);
  color: var(--coral-ink);
  cursor: pointer;
  transition: opacity 0.15s;
}
.send:disabled { opacity: 0.3; cursor: default; }

.under {
  margin: 0.625rem 0.25rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}
.under p { margin: 0; font-size: 0.75rem; color: var(--faint); }
.under a, .under button.link {
  font-size: 0.75rem;
  color: var(--muted);
  background: none; border: 0; padding: 0;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.under a:hover, .under button.link:hover { color: var(--coral); }

/* ---------------------------------- login ---------------------------------- */

body.centered {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth {
  width: 100%;
  max-width: 25rem;
}

.auth-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

.auth h1 {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.auth h1 .stop { color: var(--coral); }

.auth .sub {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--muted);
}

.auth label {
  display: block;
  color: var(--faint);
  margin-bottom: 0.5rem;
}

.auth input {
  width: 100%;
  font: inherit;
  padding: 0.6875rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.5rem;
  background: var(--ground);
  color: var(--ink);
  transition: border-color 0.15s;
}
.auth input::placeholder { color: var(--faint); }
.auth input:focus { outline: none; border-color: var(--coral); }

.auth button[type="submit"] {
  width: 100%;
  margin-top: 0.875rem;
  font: inherit;
  font-weight: 500;
  padding: 0.6875rem 0.75rem;
  border: 0; border-radius: 0.5rem;
  background: var(--coral);
  color: var(--coral-ink);
  cursor: pointer;
  transition: opacity 0.15s;
}
.auth button[type="submit"]:disabled { opacity: 0.45; cursor: default; }

.auth .note {
  margin: 1rem 0 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}
.auth .note.error { color: var(--crit); }

.auth .sent {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink);
}

.auth .privacy {
  margin: 1.25rem 0 0;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--faint);
  text-align: center;
}
