/* Hanken Grotesk (SIL Open Font License), served from this site so no browser contacts a third party. */
@font-face {
  font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/hanken-grotesk-latin.woff2") format("woff2");
}

/* Layout: one quiet column on a pale ground. The assistant speaks in plain text, the patient's
   replies sit in soft grey pills, and one spruce accent marks what can be pressed. No decoration. */
:root {
  --ground: #F6F7F6;
  --surface: #FFFFFF;
  --ink: #1B2325;
  --muted: #687576;
  --line: #E1E6E5;
  --accent: #2B5C5A;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EEED;
  --me: #EAEEED;
  --stop: #B3261E;
  --stop-ink: #FFFFFF;
  --stop-soft: #FBE9E7;
  --ok: #2B5C5A;
  --font: "Hanken Grotesk", "Helvetica Neue", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #14191A; --surface: #1B2223; --ink: #E7ECEB; --muted: #8F9B9C; --line: #2A3335;
    --accent: #8CC2BC; --accent-ink: #0F1B1B; --accent-soft: #213032; --me: #252E30;
    --stop: #D9453C; --stop-ink: #FFFFFF; --stop-soft: #3A1E1C; --ok: #8CC2BC;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #14191A; --surface: #1B2223; --ink: #E7ECEB; --muted: #8F9B9C; --line: #2A3335;
  --accent: #8CC2BC; --accent-ink: #0F1B1B; --accent-soft: #213032; --me: #252E30;
  --stop: #D9453C; --stop-ink: #FFFFFF; --stop-soft: #3A1E1C; --ok: #8CC2BC;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font); font-size: 19px; line-height: 1.5; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  /* Pinned to the part of the screen that is actually visible: app.js keeps height and top in step
     with the on-screen keyboard, so the question and the answer box are never underneath it. */
  position: fixed; top: 0; left: 0; right: 0; height: 100dvh; max-width: 780px; margin-inline: auto; padding-inline: 20px;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; flex-direction: column;
}

/* Header */
.top { display: flex; align-items: center; gap: 12px; padding-block: 16px 12px; }
.mark { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.35); opacity: .7; } }
.who { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 10px; }
.who b { font-weight: 600; font-size: 1.02rem; letter-spacing: -.005em; }
.who span { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill { flex: none; display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill.closed::before { background: var(--muted); }

/* Stage line */
.stage { display: flex; flex-direction: column-reverse; gap: 8px; padding-bottom: 6px; font-size: .68rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 500; }
.stage .bar { height: 1px; background: var(--line); overflow: visible; }
.stage .bar i { display: block; height: 2px; margin-top: -1px; width: 0; background: var(--accent); transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* Conversation */
.chat { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-block: 18px 20px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }
.msg { overflow-wrap: anywhere; animation: rise .35s cubic-bezier(.2,.8,.2,1) both; }
.msg.bot { align-self: flex-start; max-width: 92%; }
.msg.me { align-self: flex-end; max-width: 80%; background: var(--me); padding: 9px 15px; border-radius: 20px; }
.msg .tag { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; color: var(--muted); margin-bottom: 2px; }
.msg .sub { display: block; color: var(--muted); font-size: .92rem; margin-top: 4px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.typing { align-self: flex-start; display: flex; gap: 5px; padding: 8px 0; animation: rise .2s both; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bob 1.1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* Cards inside the conversation */
.card { align-self: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; animation: rise .35s both; }
.card h2 { font-size: 1.08rem; font-weight: 600; margin: 0 0 12px; letter-spacing: -.005em; text-wrap: balance; }
.card dl { margin: 0; display: grid; grid-template-columns: minmax(0, 10em) minmax(0, 1fr); gap: 8px 16px; font-size: .95rem; }
.card dt { color: var(--muted); } .card dd { margin: 0; overflow-wrap: anywhere; }
.card p { margin: 8px 0 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list li:last-child { padding-bottom: 0; }
.list b { display: block; font-weight: 600; font-size: .98rem; line-height: 1.3; }
.list small { display: block; color: var(--muted); font-size: .86rem; line-height: 1.35; margin-top: 1px; }
.tick { width: 40px; height: 40px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; margin-bottom: 14px; animation: pop .4s cubic-bezier(.2,1.3,.4,1) both; }
.tick svg { width: 20px; height: 20px; fill: none; stroke: var(--accent-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .45s .25s ease-out forwards; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.net { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: .93rem; color: var(--muted); }
.net ul { margin: 6px 0 0; padding-left: 1.1em; } .net li { margin-top: 3px; }
.num { color: var(--ink); font-weight: 600; user-select: all; white-space: nowrap; }

/* What to include: shown in the conversation so it stays in view while typing */
.prompts { align-self: stretch; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; padding: 14px 18px; animation: rise .35s both; }
.prompts b { display: block; font-weight: 600; margin-bottom: 6px; }
.prompts ul { margin: 0; padding-left: 1.1em; } .prompts li { margin-top: 4px; }

/* Composer */
.composer { padding-block: 6px 14px; display: flex; flex-direction: column; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.hint { font-size: .9rem; color: var(--muted); margin: 0; text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 11px 22px; font-weight: 500; cursor: pointer; min-height: 50px;
  transition: background .15s, border-color .15s, transform .15s; animation: rise .3s both;
}
.chip:nth-child(2) { animation-delay: .04s; } .chip:nth-child(3) { animation-delay: .08s; } .chip:nth-child(4) { animation-delay: .12s; }
.chip:hover { background: var(--accent-soft); border-color: var(--accent); } .chip:active { transform: scale(.97); }
.chip.wide { flex: 1 1 40%; }
.chip.yes:hover { background: var(--stop-soft); border-color: var(--stop); }
.chip.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .chip.go:hover { background: var(--accent); filter: brightness(1.08); }
.chip.quiet { color: var(--muted); }
.entry { display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 6px 6px 6px 18px; box-shadow: 0 1px 2px rgba(27,35,37,.04), 0 4px 16px rgba(27,35,37,.04); transition: border-color .2s; animation: rise .3s both; }
.entry:focus-within { border-color: var(--muted); }
.entry input, .entry textarea { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; padding: 9px 0; font-size: 19px; resize: none; max-height: 9em; }
.entry ::placeholder { color: var(--muted); opacity: .8; }
.entry.dob { align-items: center; gap: 6px; }
.entry.dob label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; display: flex; flex-direction: column; flex: 1; min-width: 0; }
.entry.dob label:last-of-type { flex: 1.5; }
.entry.dob input { width: 100%; padding: 2px 0 6px; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--ground); cursor: pointer; display: grid; place-items: center; transition: transform .15s, opacity .15s; }
.send:hover { opacity: .85; } .send:active { transform: scale(.94); }
.send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.err { color: var(--stop); font-size: .88rem; margin: 0; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .7rem; color: var(--muted); }
.foot button { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: inherit; }

/* 999 takeover: the one place the page raises its voice */
.stop { position: fixed; inset: 0; z-index: 5; background: var(--stop); color: var(--stop-ink); display: grid; place-items: center; padding: 24px 20px; overflow-y: auto; animation: flood .3s ease-out both; }
@keyframes flood { from { opacity: 0; } }
.stop div { max-width: 520px; }
.stop .big { font-weight: 600; font-size: clamp(3.2rem, 16vw, 5.6rem); line-height: 1; letter-spacing: -.03em; margin: 0 0 16px; }
.stop h2 { font-size: 1.4rem; font-weight: 600; margin: 0 0 12px; text-wrap: balance; }
.stop p { margin: 0 0 12px; font-size: 1.05rem; }
.stop .said { background: rgba(255,255,255,.14); border-radius: 12px; padding: 12px 14px; }
.stop button { margin-top: 10px; background: transparent; color: var(--stop-ink); border: 1px solid rgba(255,255,255,.7); border-radius: 999px; padding: 11px 18px; cursor: pointer; font-weight: 500; min-height: 46px; }

@media (max-width: 480px) { .who span { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}

/* The emergency list: red is kept for this and the 999 screen only */
.card.danger { border-color: var(--stop); border-top-width: 4px; padding-top: 16px; }
.card.danger h2 { color: var(--stop); }
.card.danger .list li { display: grid; grid-template-columns: 10px minmax(0, 1fr); column-gap: 12px; align-items: start; }
.card.danger .list li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--stop); margin-top: .42em; }
.card.danger .list li > * { grid-column: 2; }
.card.danger .list small { color: var(--ink); opacity: .72; }

/* Phones: smaller type and controls, two answers side by side */
@media (max-width: 600px) {
  body { font-size: 17px; }
  .app { padding-inline: 16px; }
  .top { padding-block: 10px 8px; }
  .chat { gap: 11px; padding-block: 12px 12px; }
  .entry input, .entry textarea { font-size: 17px; padding: 7px 0; }
  .send { width: 36px; height: 36px; }
  .chip { padding: 8px 14px; min-height: 42px; font-size: .94rem; }
  .chip.wide { flex: 1 1 0; min-width: 0; padding-inline: 8px; }
  .card { padding: 14px; border-radius: 14px; }
  .card h2 { font-size: 1rem; margin-bottom: 8px; }
  .list li { padding: 7px 0; }
  .list b { font-size: .94rem; }
  .list small { font-size: .8rem; }
  .prompts { padding: 10px 14px; font-size: .94rem; }
  .composer { padding-block: 4px 8px; gap: 6px; }
  .hint { font-size: .8rem; }
  .foot { font-size: .64rem; }
  .card dl { grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr); font-size: .9rem; }
}
