/* Layout: one screen; the rose lives in a fixed full-bleed canvas, text sits on a paper sheet
   at the bottom like a note tucked under the flower. Palette and type follow the pilot deck. */
:root {
  --paper: #F4EFE6;        /* deck background paper */
  --paper-deep: #E6D9CD;   /* torn-paper edge */
  --sheet: rgba(255, 249, 240, 0.86);
  --ink: #43232E;          /* deep wine, deck titles */
  --ink-soft: #796866;     /* deck body grey-rose */
  --thread: #9B513F;       /* the copper thread */
  --line: rgba(67, 35, 46, 0.14);
  --focus: #9B513F;
  --serif: "Charis SIL", Charter, "Bitstream Charter", Georgia, serif;
  --sans: "Hanken Grotesk", "Nimbus Sans", "Helvetica Neue", Arial, sans-serif;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #241318;
    --paper-deep: #3A1F28;
    --sheet: rgba(46, 24, 31, 0.82);
    --ink: #F7EEE4;
    --ink-soft: #CDB9B2;
    --thread: #D08A6E;
    --line: rgba(247, 238, 228, 0.16);
    --focus: #E3A285;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #241318;
  --paper-deep: #3A1F28;
  --sheet: rgba(46, 24, 31, 0.82);
  --ink: #F7EEE4;
  --ink-soft: #CDB9B2;
  --thread: #D08A6E;
  --line: rgba(247, 238, 228, 0.16);
  --focus: #E3A285;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }

/* paper: soft vignette plus a faint fibre grain */
.paper {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 40%, transparent 0 45%, color-mix(in srgb, var(--paper-deep) 70%, transparent) 100%),
    var(--paper);
}
.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.42  0 0 0 0 0.38  0 0 0 0.28 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .paper::after { mix-blend-mode: screen; opacity: 0.12; } }
:root[data-theme="dark"] .paper::after { mix-blend-mode: screen; opacity: 0.12; }

.rose {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.rose-still {
  position: fixed;
  left: 50%;
  top: 38%;
  width: min(62vw, 36vh, 300px);   /* small and delicate, like the live rose */
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.rose-still img { display: block; width: 100%; height: auto; }

.app {
  position: relative;
  min-height: 100%;
  height: 100%;
  overflow-y: auto;          /* small phones and large text: the sheet scrolls instead of hiding */
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding-top: max(20px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: 34rem;
  margin: 0 auto;
  /* the panel must take touches itself, or phones never scroll it (pointer-events: none here made
     the review screen unscrollable). A sideways drag on its empty background turns the rose. */
  touch-action: pan-y;
}
.app > * { flex-shrink: 0; }
.app[data-view="talk"] { overflow: hidden; }

.masthead { display: grid; gap: 6px; }
.eyebrow {
  margin: 0;
  font: 600 0.72rem/1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--thread);
  display: flex;
  align-items: center;
  gap: 8px;
}
.mark { width: 22px; height: 22px; flex: none; margin-block: -6px; }
.wordmark {
  margin: 0;
  font: 400 var(--step-3)/0.95 var(--serif);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.app[data-view="talk"] .wordmark,
.app[data-view="consent"] .wordmark,
.app[data-view="write"] .wordmark,
.app[data-view="review"] .wordmark { font-size: var(--step-1); }
.app[data-view="talk"] .wordmark br,
.app[data-view="consent"] .wordmark br,
.app[data-view="write"] .wordmark br,
.app[data-view="review"] .wordmark br { display: none; }
.app[data-view="write"] { justify-content: flex-start; }

/* views */
.sheet, .talk { display: none; }
.app[data-view="welcome"] [data-for="welcome"],
.app[data-view="consent"] [data-for="consent"],
.app[data-view="write"] [data-for="write"],
.app[data-view="review"] [data-for="review"],
.app[data-view="done"] [data-for="done"] { display: grid; }
.app[data-view="talk"] [data-for="talk"] { display: grid; }

.sheet {
  gap: 14px;
  padding: 20px 20px 18px;
  background: var(--sheet);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(67, 35, 46, 0.45);
  animation: rise 700ms cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0.001; } }

.question {
  margin: 0;
  font: italic 400 var(--step-2)/1.22 var(--serif);
  text-wrap: balance;
  color: var(--ink);
}
.sheet-title {
  margin: 0;
  font: 400 var(--step-2)/1.15 var(--serif);
  text-wrap: balance;
}
.lede { margin: 0; color: var(--ink-soft); max-width: 60ch; }
.fine { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.fine:empty { display: none; }

.agreements {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}
.agreements li {
  position: relative;
  padding-left: 22px;
  color: var(--ink);
}
.agreements li::before {   /* a stitch of the copper thread */
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 11px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--thread);
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 20px;
  font: 600 1rem/1 var(--sans);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  transition: transform 120ms ease, background-color 200ms ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.quiet { border-color: var(--line); }
.btn.round {
  border-color: var(--line);
  background: var(--sheet);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 500;
  padding: 12px 16px;
}
.btn.round[aria-pressed="true"] { border-color: var(--thread); }
.btn.end { color: var(--thread); border-color: color-mix(in srgb, var(--thread) 45%, transparent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.link {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: 500 0.9rem/1.2 var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px;
  cursor: pointer;
  justify-self: center;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
/* headings and views receive focus from script only, to guide screen readers: no ring */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* conversation */
.talk { gap: 14px; justify-items: center; text-align: center; }
.status {
  margin: 0;
  font: 500 0.95rem/1.3 var(--sans);
  letter-spacing: 0.02em;
  color: var(--thread);
  min-height: 1.3em;
}
.caption {
  margin: 0;
  max-width: 30ch;
  height: 3.9em;            /* three lines; the newest words stay at the bottom */
  font: 400 var(--step-1)/1.3 var(--serif);
  color: var(--ink);
  text-wrap: balance;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.caption[data-speaker="user"] { font-style: italic; color: var(--ink-soft); }
.app[data-captions="off"] .caption { visibility: hidden; }
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* review */
.app[data-view="review"] { justify-content: flex-start; }
.review { flex-shrink: 0; }
.note { margin: 0; font-weight: 500; color: var(--thread); }
.note:empty { display: none; }
.browser-help { display: grid; gap: 8px; justify-items: start; }
.btn.small { min-height: 40px; padding: 9px 14px; font-size: 0.9rem; }
.transcript {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.turn {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.turn.assistant { border-color: transparent; padding-block: 4px; }
.turn .who {
  margin: 0;
  font: 600 0.7rem/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.turn .said { margin: 0; font: 400 var(--step-0)/1.45 var(--serif); white-space: pre-wrap; }
.turn.assistant .said { font: 400 0.95rem/1.45 var(--sans); color: var(--ink-soft); }
.turn .edited { font: 600 0.72rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.turn-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 500 0.85rem/1 var(--sans);
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--thread); color: var(--thread); }
.chip:disabled { opacity: 0.5; cursor: default; }
.turn.withdrawn { border-style: dashed; border-color: var(--thread); }
.turn.withdrawn .said { text-decoration: line-through; text-decoration-color: var(--thread); color: var(--ink-soft); }
.turn textarea { min-height: 6em; }
.empty { color: var(--ink-soft); font-style: italic; }
.naming {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.naming legend { font-weight: 600; margin-bottom: 6px; }
.naming label { display: flex; gap: 10px; align-items: center; }
.naming input[type="radio"], .naming input[type="checkbox"] { accent-color: var(--thread); width: 18px; height: 18px; flex-shrink: 0; }
.naming label { align-items: flex-start; }
.naming label:has(input:disabled) { color: var(--ink-soft); }
.field { display: grid; gap: 8px; }
.field-label { font-weight: 600; }
.field-label em, .naming em { font-style: normal; font-weight: 400; color: var(--ink-soft); }
.question.small { font-size: var(--step-1); }
textarea {
  font: 400 var(--step-0)/1.5 var(--serif);
  color: var(--ink);
  background: transparent;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.name-field { flex-direction: column; align-items: stretch !important; gap: 6px !important; }
.name-field input {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--sheet);
  border: 1px solid color-mix(in srgb, var(--thread) 50%, transparent);
  color: var(--ink);
  font-size: 0.95rem;
}

@media (min-height: 760px) {
  .wordmark { font-size: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}
