/* static/css/main.css — Carrie's Brain, the one stylesheet.
   Adapted from CareIQ's static/css/main.css (Cbright133/portola-v2 main at
   45da9db, 2026-11-23): the :root OAC brand tokens, the status colours and
   the loading overlay are CareIQ's. The layout is the Brain's own: a small,
   phone-first sheet with no sidebar (PROJECT_RULES 7). No <style> blocks or
   style= anywhere else. */

:root {
  /* OAC brand palette (CareIQ) */
  --oac-sage:       #88CD6A;
  --oac-forest:     #5FA344;
  --oac-periwinkle: #8FB4F5;
  --oac-violet:     #7A68D6;
  --oac-slate:      #303642;
  --oac-cream:      #F5F3DE;

  /* Gradient bar: Forest → Sage → Periwinkle → Violet (CareIQ) */
  --oac-gradient: linear-gradient(90deg, #5FA344 0%, #88CD6A 25%, #8FB4F5 65%, #7A68D6 100%);

  /* Semantic aliases (CareIQ) */
  --primary:     var(--oac-violet);
  --primary-dim: rgba(122,104,214,0.15);
  --accent:      var(--oac-sage);
  --link:        var(--oac-forest);
  --text:        var(--oac-slate);
  --muted:       rgba(48,54,66,0.55);
  --border:      rgba(48,54,66,0.15);
  --border-mid:  rgba(48,54,66,0.22);
  --bg:          #f0f2f5;
  --surface:     #ffffff;

  /* Status colours (CareIQ) */
  --green:    #16a34a;  --green-bg:  #dcfce7;
  --amber:    #d97706;  --amber-bg:  #fef3c7;
  --red:      #dc2626;  --red-bg:    #fee2e2;
  --gray:     #6b7280;  --gray-bg:   #f3f4f6;

  /* Layout */
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --page-w:    720px;
}

/* ── Base, phone first ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a { color: var(--link); }

h1 { font-size: 1.4rem; line-height: 1.25; margin: 0 0 .5rem; }

.brand-bar { height: 4px; background: var(--oac-gradient); }

.page {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
}

.muted { color: var(--muted); }

@media (min-width: 600px) {
  .page { padding: 32px 24px; }
  .card { padding: 28px 24px; }
}

/* ── Loading overlay (CareIQ) ───────────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 20, 0.72);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#loading-overlay.active { display: flex; }

.loading-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 240px;
}

.loading-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid var(--border-mid);
  border-top-color: var(--oac-violet);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-message {
  font-size: 15px;
  font-weight: 500;
  color: var(--oac-slate);
}

/* ── Stage 1 part B: sign-in, My account, Activity ──────────────────────── */
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }

.card + .card, h1 + .card, .muted + .card, .filters + .card { margin-top: 16px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-home { font-weight: 600; color: var(--text); text-decoration: none; }
.topbar-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

.inline-form { display: inline; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }

input[type="text"], input[type="password"], input[type="email"], input[type="date"], select {
  font: inherit;
  font-size: 17px;            /* 16px or more: iPhone doesn't zoom in */
  padding: 10px 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  margin-top: 8px;
}
.button:disabled { opacity: .6; cursor: default; }
.button-quiet { background: var(--primary-dim); color: var(--oac-violet); }
.button-danger { background: var(--red); }
.button-small { padding: 6px 12px; font-size: 15px; margin-top: 0; }

.link-button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}

.flash {
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 12px;
}

.error { color: var(--red); font-weight: 500; }
.error[hidden] { display: none; }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
}
.banner-red { background: var(--red-bg); color: var(--red); border-bottom: 2px solid var(--red); }

.card-alert { border-color: var(--red); background: var(--red-bg); }

.menu { list-style: none; padding: 0; margin: 12px 0 0; }
.menu li + li { margin-top: 10px; }
.menu a { font-size: 1.1rem; }

.rows { list-style: none; padding: 0; margin: 0 0 12px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }

.tag {
  font-size: 13px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
}

.codes { font-size: 1.2rem; line-height: 2; padding-left: 1.5em; }
.codes code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; }

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0;
}
@media (min-width: 600px) {
  .filters { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }
}

/* ── Stage 1 part C: chat, marks, Open questions ────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

input[type="search"], textarea {
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; min-height: 4.5em; }

.search-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 12px 0; }
.search-form label { flex: 1 1 220px; }

.chat { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }

.msg {
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.msg-person { align-self: flex-end; background: var(--primary-dim); border-color: transparent; max-width: 90%; }
.msg-brain { align-self: stretch; }
.msg-note { align-self: center; font-size: 15px; color: var(--muted); background: var(--gray-bg); }
.msg-text { white-space: pre-wrap; }
.msg-meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
.msg-failed { margin-top: 8px; }

.statements { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.statement-text { white-space: pre-wrap; }

.mark {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.mark-checked { background: var(--green-bg); color: var(--green); }
.mark-not { background: var(--gray-bg); color: var(--gray); }
.mark-guess { background: var(--amber-bg); color: var(--amber); }

.settle { font-size: 15px; margin-top: 4px; color: var(--amber); }
.site-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.not-marked { font-weight: 600; color: var(--red); margin: 0 0 6px; }
.limits { margin-top: 10px; font-size: 15px; }
.limits ul { margin: 4px 0 0; padding-left: 1.2em; }

.thinking { color: var(--muted); font-style: italic; }

.composer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: flex-end; }
.composer-row .button { margin-top: 0; }
.mic {
  flex: 1 1 auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.mic-on { background: var(--red); color: #fff; }
.switch { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; font-size: 15px; }
.voice-words[hidden] { display: none; }

.title-edit { margin: 0 0 8px; font-size: 15px; }
.hide-form { margin: 16px 0; font-size: 15px; }

.snippet mark { background: var(--amber-bg); color: inherit; padding: 0 2px; }
.tag-gray { background: var(--gray-bg); color: var(--gray); }

.tabs { display: flex; gap: 16px; margin: 8px 0 0; }
.tabs a[aria-current="page"] { font-weight: 700; color: var(--text); text-decoration: none; }

.row-block { flex-direction: column; align-items: stretch; }

@media print {
  .topbar, .banner, .brand-bar, .button, .flash, #loading-overlay, .composer, .hide-form, .title-edit { display: none !important; }
  .card { border: 0; box-shadow: none; }
}

/* ── Stage 1 part D: promises and projects ──────────────────────────────── */
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-ai { background: var(--primary-dim); color: var(--oac-violet); }
.tag + .tag, .tag + a { margin-left: 6px; }
.promise-facts, .entry-meta { font-size: 15px; }
.facts { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px 16px; }
.facts dt { font-weight: 600; margin-top: 8px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 600px) {
  .facts { grid-template-columns: max-content 1fr; }
  .facts dt { margin-top: 0; }
}
.history { margin-top: 12px; }
details summary { cursor: pointer; }
