/* ============================================================
   Contour prototype — design system
   ============================================================ */

:root {
  --paper: #faf7f2;
  --paper-raised: #ffffff;
  --ink: #232019;
  --ink-soft: #5f594d;
  --ink-faint: #948c7c;
  --accent: #b4552d;          /* terracotta */
  --accent-soft: #f3e2d8;
  --line: #e6dfd3;
  --safe: #3d6b4f;
  --warn: #a97b1f;
  --danger: #a3352b;
  --danger-soft: #f7e6e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35,32,25,.05), 0 8px 28px rgba(35,32,25,.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Topographic backdrop */
#topo {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
}

.screen {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px;
}
.screen.active { display: flex; }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 620px; width: 100%;
  padding: 44px 48px;
}

/* ---------- Type ---------- */
.wordmark {
  font-family: var(--serif); font-size: 15px; letter-spacing: .35em;
  text-transform: uppercase; color: var(--accent);
}
h1 { font-family: var(--serif); font-weight: 500; font-size: 42px; line-height: 1.15; margin: 14px 0 18px; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; margin-bottom: 14px; }
.lede { font-size: 17px; color: var(--ink-soft); max-width: 46ch; }
.small { font-size: 13px; color: var(--ink-faint); }

/* ---------- Buttons ---------- */
.btn {
  font: 600 15px var(--sans); border: 0; border-radius: 999px;
  padding: 13px 30px; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(35,32,25,.25); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-choice {
  background: var(--paper-raised); border: 1.5px solid var(--line); color: var(--ink);
  font-size: 16px; padding: 16px 44px; border-radius: var(--radius); min-width: 130px;
}
.btn-choice:hover { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- Landing ---------- */
.proto-badge {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 5; font: 600 11px var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--paper-raised); border: 1px solid var(--line);
  padding: 4px 14px; border-radius: 999px;
}
#gear {
  position: fixed; top: 12px; right: 14px; z-index: 60;
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 50%;
  width: 38px; height: 38px; cursor: pointer; font-size: 17px; color: var(--ink-soft);
}

/* ---------- Screener ---------- */
.progress { display: flex; gap: 7px; margin-bottom: 30px; }
.progress i { width: 26px; height: 3px; border-radius: 2px; background: var(--line); }
.progress i.done { background: var(--accent); }
.screener-q { font-family: var(--serif); font-size: 26px; line-height: 1.3; margin-bottom: 34px; min-height: 3.2em; }
.choices { display: flex; gap: 14px; }
.note {
  margin-top: 22px; padding: 14px 18px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0; font-size: 14.5px; color: var(--ink-soft);
}

/* ---------- Resources card (code-rendered, fixed strings) ---------- */
.resources { margin-top: 24px; border: 1.5px solid var(--danger); border-radius: var(--radius); overflow: hidden; }
.resources header { background: var(--danger); color: #fff; font: 600 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; padding: 9px 16px; }
.resources ul { list-style: none; }
.resources li { padding: 12px 16px; border-top: 1px solid var(--line); }
.resources li:first-child { border-top: 0; }
.resources b { display: block; font-size: 15px; }
.resources span { font-size: 13.5px; color: var(--ink-soft); }

/* ---------- Consent ---------- */
.consent-list { list-style: none; margin: 20px 0 26px; }
.consent-list li { padding: 10px 0 10px 30px; position: relative; color: var(--ink-soft); font-size: 15px; border-bottom: 1px dashed var(--line); }
.consent-list li::before { content: "—"; position: absolute; left: 4px; color: var(--accent); }
.consent-check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; margin-bottom: 26px; cursor: pointer; }
.consent-check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--accent); }

/* ---------- Interview ---------- */
#screen-interview { justify-content: flex-start; padding: 0; }
.chat-shell { width: 100%; max-width: 760px; height: 100vh; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 14px; padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 4;
}
.chat-head .wordmark { font-size: 12px; }
#chunk-title { font-family: var(--serif); font-size: 16px; color: var(--ink-soft); flex: 1; }
.chunk-dots { display: flex; gap: 6px; }
.chunk-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.chunk-dots i.done { background: var(--accent); }
.chunk-dots i.now { background: var(--ink); }

.mode-badge {
  font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 999px; border: 1px solid;
}
.next-btn {
  font: 600 12px var(--sans); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; color: var(--ink-soft); background: var(--paper-raised);
  transition: background .15s, color .15s, border-color .15s;
}
.next-btn:hover:not(:disabled) { border-color: var(--ink); }
.next-btn:disabled { opacity: .4; cursor: default; }
.next-btn.ready { background: var(--accent); color: #fff; border-color: var(--accent); }
.next-btn.ready:hover { box-shadow: 0 3px 12px rgba(180,85,45,.3); }

.mode-SOCRATIC { color: var(--safe); border-color: var(--safe); background: #eaf2ec; }
.mode-SOFT     { color: var(--warn); border-color: var(--warn); background: #f8f0dd; }
.mode-SUPPORT  { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.mode-ENDED, .mode-PAUSED { color: var(--ink-faint); border-color: var(--line); background: var(--paper); }

#chat { flex: 1; overflow-y: auto; padding: 26px 22px; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 82%; padding: 14px 18px; border-radius: var(--radius); font-size: 15.5px; white-space: pre-wrap; }
.msg.ai { background: var(--paper-raised); border: 1px solid var(--line); align-self: flex-start; box-shadow: 0 1px 3px rgba(35,32,25,.05); }
.msg.me { background: var(--ink); color: var(--paper); align-self: flex-end; }
.msg.sys { align-self: center; background: transparent; color: var(--ink-faint); font-size: 13px; text-align: center; max-width: 90%; }

.typing { align-self: flex-start; display: flex; gap: 5px; padding: 16px 18px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25 } 40% { opacity: 1 } }

.chat-input { display: flex; gap: 10px; padding: 16px 22px 22px; border-top: 1px solid var(--line); background: var(--paper); }
.chat-input textarea {
  flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper-raised); font: 15.5px var(--sans); color: var(--ink);
  padding: 13px 16px; min-height: 52px; max-height: 160px; outline: none;
}
.chat-input textarea:focus { border-color: var(--ink-faint); }
.chat-input .btn-primary { align-self: flex-end; }

/* ---------- Map (sheet + internal build notes) ---------- */
#screen-map { justify-content: flex-start; padding: 0; overflow-y: auto; }
.map-wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 12px 24px 90px; }
.map-toolbar {
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 3;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(6px);
  padding: 16px 2px; margin-bottom: 10px; border-bottom: 1px solid var(--line);
}
.map-actions { display: flex; gap: 8px; }
.map-actions .btn { padding: 8px 16px; font-size: 13px; }
.map-sheet {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 40px 46px;
}
.map-sheet h1 { font-size: 30px; margin: 6px 0 16px; }
.map-sheet h2 { font-size: 21px; margin: 28px 0 10px; }
.map-sheet h3 { font-family: var(--serif); font-size: 17px; font-weight: 600; margin: 18px 0 6px; }
.map-sheet p  { margin: 10px 0; color: var(--ink-soft); font-size: 15.5px; }
.map-sheet strong { color: var(--ink); }
.map-sheet ul { margin: 10px 0 10px 22px; }
.map-sheet li { margin: 5px 0; color: var(--ink-soft); font-size: 15.5px; }
.map-sheet blockquote {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  margin: 12px 0; padding: 10px 16px; border-radius: 0 10px 10px 0; color: var(--ink); font-style: italic;
}
.map-sheet hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.map-loading { color: var(--ink-faint); font-style: italic; }
.map-audit {
  margin-top: 22px; background: #f4efe6; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 4px 20px 16px;
}
.map-audit > summary {
  cursor: pointer; padding: 14px 0; font: 600 12px var(--sans);
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint);
}
.map-audit h1 { font-size: 20px; } .map-audit h2 { font-size: 16px; } .map-audit h3 { font-size: 14px; }
.map-audit p, .map-audit li { font-size: 13.5px; }

/* ---------- Dev panel ---------- */
#dev {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(480px, 94vw); z-index: 50;
  background: #201d17; color: #e8e2d5; transform: translateX(100%);
  transition: transform .22s ease; display: flex; flex-direction: column;
  font-size: 13px;
}
#dev.open { transform: none; box-shadow: -12px 0 40px rgba(0,0,0,.3); }
#dev header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #3a352b; }
#dev header b { font: 600 13px var(--mono); letter-spacing: .1em; }
#dev-body { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
#dev section { margin-bottom: 26px; }
#dev h3 { font: 600 11px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #a89e8a; margin-bottom: 10px; }
#dev textarea, #dev input {
  width: 100%; background: #17150f; color: #e8e2d5; border: 1px solid #3a352b;
  border-radius: 8px; font: 12px var(--mono); padding: 10px;
}
#dev textarea { min-height: 120px; resize: vertical; }
#dev label { display: block; margin: 10px 0 4px; color: #a89e8a; }
#dev .btn { font-size: 12px; padding: 8px 16px; margin: 8px 8px 0 0; }
#dev .btn-primary { background: var(--accent); color: #fff; }
#dev .btn-ghost { color: #a89e8a; border-color: #3a352b; }
#dev-dossier {
  background: #17150f; color: #cfc8b8; border: 1px solid #3a352b; border-radius: 8px;
  padding: 10px; font: 11px var(--mono); white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto;
}
#dev table { width: 100%; border-collapse: collapse; font: 11.5px var(--mono); }
#dev td, #dev th { border-bottom: 1px solid #33302664; padding: 6px 4px; text-align: left; vertical-align: top; }
#dev .k-NONE { color: #7fae8e; } #dev .k-HEAVY { color: #d9b35d; }
#dev [class*="k-CRISIS"] { color: #e0715f; font-weight: 700; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid #3a352b; font: 10.5px var(--mono); margin: 1px 2px; }

/* ---------- End / decline states ---------- */
.state-icon { font-size: 34px; margin-bottom: 12px; }
.center { text-align: center; }

@media (max-width: 640px) {
  .card { padding: 30px 24px; }
  h1 { font-size: 32px; }
  .msg { max-width: 92%; }
}
