/* Memtell Legacy · tokens, base, the start screen and Tell (the person telling the stories).
   Light only. Cream page, paper surfaces, ink text, one deep teal. Fraunces for headlines and for people's words,
   Figtree for everything the interface says. */

:root {
  color-scheme: light;
  --cream: #FAF6F0;
  --paper: #F2EFE7;
  --line: #E7E1D5;
  --line-strong: #D6CEBF;
  --ink: #1F2B30;
  --teal: #1F4A4E;
  --teal-deep: #163739;
  --teal-wash: #E2EAE6;
  --muted: #5E6366;              /* the deck's #6B6F72, a touch darker so small text stays readable on cream */
  --error: #8C2F25;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 14px;
  --r-lg: 22px;
  --gutter: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--cream); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 50; background: var(--ink); color: var(--cream); padding: 12px 18px; border-radius: var(--r); text-decoration: none; }
.skip:focus { top: 12px; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; border-radius: 6px; }
.btn-primary:focus-visible { outline-color: var(--ink); }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

.view { min-height: 100vh; min-height: 100dvh; }
.view:focus { outline: none; }
.screen { min-height: 100vh; min-height: 100dvh; }

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

.display {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(38px, 6.4vw, 66px);
  line-height: 1.04;
  letter-spacing: -0.012em;
  font-variation-settings: "opsz" 40;
  max-width: 14ch;
}
.title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 36;
}
.dash { display: block; width: 36px; height: 3px; background: var(--teal); margin: 18px 0 22px; border-radius: 2px; }
.lede { font-size: 20px; line-height: 1.55; max-width: 36em; }
.fine { font-size: 16px; color: var(--muted); }
.link { color: var(--teal); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; font-weight: 600; }
.link:hover { color: var(--teal-deep); }
.said { font-family: var(--serif); font-weight: 500; font-variation-settings: "opsz" 36; }

/* ------------------------------------------------------------------ buttons and fields */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 26px;
  border-radius: var(--r);
  border: 2px solid transparent;
  font-weight: 600; font-size: 19px; line-height: 1.2;
  text-decoration: none; text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color .15s, color .15s, border-color .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--teal); color: var(--cream); }
.btn-primary:hover:not([disabled]) { background: var(--teal-deep); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-quiet:hover:not([disabled]) { background: var(--paper); }
.btn-soft { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
.btn-soft:hover:not([disabled]) { border-color: var(--ink); }
.btn-lg { min-height: 64px; font-size: 21px; }
.btn-xl { min-height: 64px; font-size: 22px; padding: 0 30px; }
.btn-xxl { min-height: 76px; font-size: 26px; padding: 0 30px; width: 100%; border-radius: 18px; }
.btn-sm { min-height: 48px; font-size: 17px; padding: 0 18px; }

.field { display: grid; gap: 8px; }
.field label, .label { font-weight: 600; font-size: 17px; }
.input, .select, .textarea {
  width: 100%; min-height: 56px; padding: 12px 16px;
  background: #fff; border: 2px solid var(--line-strong); border-radius: var(--r);
  font-size: 19px;
}
.textarea { min-height: 120px; line-height: 1.5; resize: vertical; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-wash); }
.hint { font-size: 15px; color: var(--muted); }
.form-err { color: var(--error); font-weight: 600; min-height: 1.5em; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); z-index: 60;
  transform: translate(-50%, 140%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--ink); color: var(--cream);
  padding: 14px 22px; border-radius: var(--r);
  font-size: 18px; line-height: 1.4;
  transition: transform .25s ease, visibility 0s linear .25s;
  pointer-events: none;
  visibility: hidden;
}
.toast.on { transform: translate(-50%, 0); visibility: visible; transition: transform .25s ease; }

/* ------------------------------------------------------------------ boot */

.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-dot, .breath {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--teal);
  animation: breathe 2.4s ease-in-out infinite;
}
.boot-fail { display: grid; place-content: center; gap: 24px; padding: 24px var(--gutter); text-align: center; justify-items: center; }
@keyframes breathe { 0%, 100% { transform: scale(.82); opacity: .55; } 50% { transform: scale(1); opacity: 1; } }

/* ------------------------------------------------------------------ start */

.start { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; max-width: 1180px; margin: 0 auto; padding: calc(18px + var(--safe-t)) var(--gutter) calc(18px + var(--safe-b)); }
.start-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 56px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.wordmark-light { font-weight: 500; color: var(--teal); }
.wordmark-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px var(--cream), 0 0 0 5px var(--line-strong); }
.lang-switch { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r); background: var(--paper); border: 1px solid var(--line); }
.lang-b { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; font-size: 16px; cursor: pointer; }
.lang-b.on { background: var(--ink); color: var(--cream); }

.start-body { display: grid; gap: 40px; align-content: center; padding: 32px 0; }
.start-hero { display: grid; justify-items: start; }
.start-actions { display: grid; gap: 14px; margin-top: 34px; width: min(100%, 420px); justify-items: stretch; }
.start-actions .fine { margin: -4px 0 10px; }
.start-actions .link { justify-self: start; min-height: 48px; display: inline-flex; align-items: center; font-size: 19px; }
.start-quote { margin: 0; padding: 28px 28px 24px; background: var(--paper); border-left: 3px solid var(--teal); border-radius: 0 var(--r-lg) var(--r-lg) 0; max-width: 34em; }
.start-quote blockquote { margin: 0; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.38; }
.start-quote figcaption { margin-top: 14px; font-size: 16px; color: var(--muted); }
.start-foot { color: var(--muted); font-size: 15px; padding-top: 8px; border-top: 1px solid var(--line); }
.start-foot p { padding-top: 12px; }

.auth { display: grid; justify-items: start; width: min(100%, 520px); }
.auth .lede { margin-bottom: 8px; }
.back-link { display: inline-flex; align-items: center; min-height: 48px; margin-bottom: 12px; font-weight: 600; color: var(--teal); text-decoration: underline; text-underline-offset: 4px; }
.back-link::before { content: "‹"; font-size: 28px; line-height: 1; margin-right: 8px; text-decoration: none; }
.auth-form { display: grid; gap: 18px; width: 100%; margin-top: 18px; }
.switch-line { margin-top: 22px; font-size: 18px; }
.code-box { font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: .06em; background: #fff; border: 2px dashed var(--line-strong); border-radius: var(--r); padding: 18px 22px; margin: 8px 0 24px; word-break: break-all; }
.demo-wait { display: grid; justify-items: center; gap: 24px; text-align: center; }

@media (min-width: 900px) {
  .start-body { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); align-items: center; gap: 64px; }
  .start-quote { align-self: center; }
}

/* ------------------------------------------------------------------ Tell: home */

.screen-tell { font-size: 24px; line-height: 1.45; }
.tell {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(28px + var(--safe-t)) var(--gutter) calc(18px + var(--safe-b));
  text-align: center;
}
.tell-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(28px, 6vh, 56px); width: 100%; }
.tell-name {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(52px, 13vw, 96px); line-height: 1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 48;
  min-height: 1em;
}
.tell-name::after { content: ""; display: block; width: 44px; height: 4px; margin: 22px auto 0; background: var(--teal); border-radius: 2px; }

/* The one big thing: a round button ringed like the growth rings of a tree, one ring per generation. */
.orb {
  --size: min(66vw, 46vh, 360px);
  position: relative;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  border: 0;
  background: var(--teal);
  color: var(--cream);
  cursor: pointer;
  display: grid; place-items: center;
  margin: calc(var(--size) * .14) 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .12s ease, background-color .15s;
}
.orb:hover { background: var(--teal-deep); }
.orb:active { transform: scale(.97); }
.orb:focus-visible { outline: 4px solid var(--ink); outline-offset: 6px; }
.orb-ring, .orb-ring::before, .orb-ring::after { position: absolute; border-radius: 50%; pointer-events: none; }
.orb-ring { inset: calc(var(--size) * -.05); border: 2px solid var(--line-strong); }
.orb-ring::before, .orb-ring::after { content: ""; border: 1.5px solid var(--line-strong); }
.orb-ring::before { inset: calc(var(--size) * -.05 - 2px); opacity: .75; }
.orb-ring::after { inset: calc(var(--size) * -.1 - 2px); opacity: .5; }
.orb-label {
  position: relative;
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(30px, calc(var(--size) * .13), 50px); line-height: 1.05;
  padding: 0 12%;
  letter-spacing: -0.01em;
}
.tell-family {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 64px; padding: 0 22px; margin-top: 12px;
  font-size: 22px; font-weight: 600; color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; text-decoration-color: var(--line-strong);
  border-radius: var(--r);
}
.tell-family:hover { text-decoration-color: var(--ink); }

/* ------------------------------------------------------------------ Tell: the microphone */

.mic { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 26px; max-width: 640px; margin: 0 auto; padding: calc(28px + var(--safe-t)) var(--gutter) calc(24px + var(--safe-b)); }
.mic-mark { width: 84px; height: 84px; border-radius: 50%; background: var(--teal-wash); color: var(--teal); display: grid; place-items: center; }
.mic-title { font-family: var(--serif); font-weight: 700; font-size: clamp(36px, 7vw, 52px); line-height: 1.08; }
.mic-text { font-size: clamp(22px, 4.4vw, 27px); line-height: 1.5; }
.mic-actions { display: grid; gap: 14px; margin-top: 8px; }

/* ------------------------------------------------------------------ Tell: the conversation */

.talk {
  min-height: 100dvh;
  display: grid; grid-template-rows: auto 1fr auto;
  gap: 12px;
  max-width: 1120px; margin: 0 auto;
  padding: calc(10px + var(--safe-t)) var(--gutter) calc(16px + var(--safe-b));
}
.talk-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.talk-stop { min-width: 140px; flex: 0 0 auto; }
.talk-stage { display: flex; flex-direction: column; justify-content: center; gap: 22px; min-height: 0; }
.talk-photo { margin: 0; display: grid; gap: 10px; justify-items: center; }
.talk-img {
  width: auto; max-width: 100%;
  max-height: 34vh; max-height: 34dvh;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 1px 0 var(--line-strong);
  object-fit: contain;
}
.talk-img:not([src]) { width: min(100%, 420px); aspect-ratio: 4 / 3; }
.talk-cap { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; align-items: baseline; font-size: 22px; }
.talk-cap-year { font-family: var(--serif); font-weight: 700; font-size: 26px; }
.talk-cap-names { color: var(--ink); }
.talk-words { display: grid; gap: 16px; }
.talk-q {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 6.6vw, 52px); line-height: 1.16;
  letter-spacing: -0.008em;
  font-variation-settings: "opsz" 30;
  max-width: 24ch;
  min-height: 1.2em;
}
.talk-caption {
  font-size: 22px; line-height: 1.45; color: var(--muted);
  max-width: 34em;
  min-height: 1.45em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.talk-write-box { display: grid; gap: 8px; }
.talk-write-box label { font-size: 22px; font-weight: 600; }
.talk-write { width: 100%; min-height: 112px; padding: 14px 16px; font-size: 24px; line-height: 1.45; border: 2px solid var(--ink); border-radius: var(--r); background: #fff; resize: vertical; }
.talk-write:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.talk-controls { display: grid; gap: 12px; }
.talk-status { display: flex; align-items: center; gap: 12px; min-height: 52px; min-width: 0; flex: 1 1 auto; font-size: 22px; font-weight: 600; line-height: 1.25; }
.talk-primary { display: grid; }
.talk-primary > .btn { grid-area: 1 / 1; }
.talk-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.talk-row .btn { width: 100%; padding: 0 12px; }

/* what each moment shows: the buttons keep their places, the ones that do not apply are hidden in place */
.talk .talk-resume, .talk .talk-retry { display: none; }
.talk .talk-done { visibility: hidden; }
.talk[data-phase="listening"] .talk-done { visibility: visible; }
.talk[data-phase="paused"] .talk-resume { display: inline-flex; }
.talk[data-phase="error"] .talk-retry { display: inline-flex; }
.talk[data-phase="paused"] .talk-done, .talk[data-phase="error"] .talk-done { display: none; }
.talk:not([data-phase="asking"]):not([data-phase="listening"]) .talk-another { visibility: hidden; }
.talk[data-phase="paused"] .talk-pause, .talk[data-phase="error"] .talk-pause { visibility: hidden; }
.talk[data-phase="paused"] .talk-stage { opacity: .72; }
.talk[data-phase="loading"] .talk-q:empty::before { content: ""; display: block; width: 60%; height: .9em; border-radius: 8px; background: var(--paper); }

/* The ear: a dot that breathes with the person's voice while listening. */
.ear { position: relative; width: 44px; height: 44px; flex: 0 0 44px; --level: 0; }
.ear-dot { position: absolute; inset: 12px; border-radius: 50%; background: var(--muted); transition: background-color .2s; }
.ear-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--teal); opacity: 0; transform: scale(.6); transition: transform .09s linear, opacity .2s; }
.talk[data-phase="listening"] .ear-dot { background: var(--teal); }
.talk[data-phase="listening"] .ear-ring { opacity: calc(.35 + var(--level) * 1.6); transform: scale(calc(.62 + var(--level) * 1.6)); }
.talk[data-phase="listening"] .ear.voiced .ear-dot { background: var(--teal-deep); }
.talk[data-phase="asking"] .ear-dot, .talk[data-phase="thinking"] .ear-dot, .talk[data-phase="loading"] .ear-dot { background: var(--teal); animation: breathe 2s ease-in-out infinite; }
.talk.no-mic .ear { display: none; }
.talk[data-phase="error"] .ear-dot { background: var(--error); }
.talk[data-phase="error"] .talk-status, .talk[data-phase="error"] .talk-caption { color: var(--error); }

@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .talk.has-photo .talk-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 48px; }
  .talk.has-photo .talk-img { max-height: 60vh; max-height: 60dvh; }
  .talk-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; column-gap: 24px; }
}
@media (min-width: 700px) {
  .talk-q { max-width: 22ch; }
}
@media (max-width: 520px) {
  .talk { gap: 10px; }
  .talk-stage { gap: 16px; }
  .talk-words { gap: 12px; }
  .talk-controls { gap: 10px; }
}
@media (max-height: 700px) {
  .talk-img { max-height: 28vh; max-height: 28dvh; }
  .talk-q { font-size: clamp(28px, 6vw, 44px); }
}

/* ------------------------------------------------------------------ Tell: thank you */

.thanks { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 20px; max-width: 680px; margin: 0 auto; padding: calc(28px + var(--safe-t)) var(--gutter) calc(24px + var(--safe-b)); }
.thanks-title { font-family: var(--serif); font-weight: 700; font-size: clamp(52px, 12vw, 88px); line-height: 1; letter-spacing: -0.02em; }
.thanks-title::after { content: ""; display: block; width: 44px; height: 4px; margin-top: 22px; background: var(--teal); border-radius: 2px; }
.thanks-kept { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 6vw, 42px); line-height: 1.2; }
.thanks-about { font-size: clamp(24px, 4.6vw, 30px); line-height: 1.4; }
.thanks-note { font-size: 20px; color: var(--muted); }
.thanks .btn { margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .talk[data-phase="listening"] .ear-ring { transform: scale(1); opacity: .8; }
}

/* "I wasn't finished": shown for a while after a long pause ended a turn on its own */
.talk-notdone { width: 100%; margin-bottom: 12px; background: var(--paper, #F2EFE7); color: var(--ink, #1F2B30);
  border: 3px solid var(--teal, #1F4A4E); font-weight: 700; }
.talk-notdone[hidden] { display: none; }
.talk.is-quiet .talk-done { outline: 4px solid var(--teal, #1F4A4E); outline-offset: 3px; }
