/* BrainHealth Coach — shared styles
   Tokens come from The BrainHealth Project Design System (tokens.json, Figma sync 2026-10-17).
   Museo Sans is licensed: Nunito Sans is a stand-in until licensed files are wired in. */

@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;500;700&display=swap");

:root {
  /* color */
  --primary-900: #037DBA;   /* the only action color */
  --primary-700: #039BE5;
  --primary-500: #68C3EF;
  --primary-300: #CDEBFA;
  --primary-100: #F2FAFE;
  --neutral-900: #231F20;
  --neutral-700: #4F4C4D;
  --neutral-500: #7B7979;   /* disabled / decorative only */
  --neutral-300: #D3D2D2;
  --neutral-100: #F5F6FA;
  --neutral-0:   #FFFFFF;
  --error-900: #D11111;
  --error-illustration: #FFDCDC;
  --clarity-900: #7B1FA2;        --clarity-100: #7B1FA233;
  --emotional-900: #E91E7F;      --emotional-100: #E91E7F33;
  --connectedness-900: #1FA2A2;  --connectedness-100: #1FA2A233;
  --emerging-900: #FFCA28;       --emerging-100: #FFCA2833;
  --success-900: var(--connectedness-900);
  --training-flower: #F5A950;
  --habit-fruit: #F68179;
  --pulse-primary: #FF9797;

  /* type */
  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: "Museo Sans", "Nunito Sans", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* shape + depth */
  --radius-pill: 64px;
  --radius-card: 4px;
  --shadow-card: 0 4px 4px 0 #0000000d;
  --shadow-modal: 0 4px 28px 0 #0000001a;
  --shadow-scrolling: 0 -2px 28px 0 #00000026;

  /* layout */
  --space-gutter: 16px;
  --space-margin-small: 24px;
  --space-margin-large: 40px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--neutral-100);
  color: var(--neutral-900);
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 16px;
  line-height: 24px;
}
a { color: var(--primary-900); font-weight: 500; }
a:hover { color: #025f8e; }
:focus-visible { outline: 2px solid var(--primary-900); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- type ---------- */
.serif { font-family: var(--font-serif); font-weight: 400; }
.display-01 { font-size: 40px; line-height: 60px; margin: 0; }
.display-02 { font-size: 34px; line-height: 51px; margin: 0; }
.heading-01 { font-size: 28px; line-height: 42px; margin: 0; }
.heading-02 { font-size: 22px; line-height: 33px; margin: 0; }
.heading-03 { font-size: 20px; line-height: 30px; margin: 0; }
.sub-01 { font-size: 18px; line-height: 27px; font-weight: 700; margin: 0; }
.sub-02 { font-size: 16px; line-height: 24px; font-weight: 500; margin: 0; }
.body-02 { font-size: 14px; line-height: 22px; }
.foot { font-size: 12px; line-height: 18px; }
.muted { color: var(--neutral-700); }
.eyebrow { margin: 0; font-size: 14px; line-height: 22px; font-weight: 500; color: var(--primary-900); }
.mono { font-family: var(--font-mono); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 16px var(--space-margin-large);
  background: var(--neutral-0); border-bottom: 1px solid var(--neutral-300);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wordmark { font-family: var(--font-serif); font-size: 22px; line-height: 33px; font-weight: 700; }
.avatar {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  background: var(--primary-900); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
@media (max-width: 672px) { .topbar { padding: 12px var(--space-margin-small); } }

/* ---------- tags + chips ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 12px; border-radius: var(--radius-pill);
  font-size: 12px; line-height: 18px; font-weight: 500;
  background: var(--primary-300); color: var(--neutral-900);
}
.tag-outline { background: var(--neutral-100); border: 1px solid var(--neutral-300); color: var(--neutral-700); }
.tag-test { background: var(--emerging-100); border: 1px dashed var(--training-flower); }
.tag-success { background: var(--connectedness-100); }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--neutral-0); border: 1px solid var(--neutral-300);
  font-size: 14px; line-height: 22px; font-weight: 500;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px; border-radius: var(--radius-pill);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  text-decoration: none; cursor: pointer; border: 1px solid transparent; white-space: nowrap;
}
.btn-lg { height: 48px; padding: 0 32px; font-size: 18px; font-weight: 700; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary-900); color: #fff; }
.btn-primary:hover { color: #fff; }
.btn-primary:active { background: var(--primary-700); }
.btn-secondary { background: var(--neutral-0); color: var(--primary-900); border-color: var(--primary-900); }
.btn-secondary:active, .btn-text:active { background: var(--primary-100); }
.btn-text { background: transparent; color: var(--primary-900); }
.btn-quiet { background: var(--neutral-0); color: var(--neutral-700); border-color: var(--neutral-300); }
.btn-danger { background: var(--error-900); color: #fff; font-weight: 700; }
.btn-danger:hover { color: #fff; }
.btn:disabled { background: var(--neutral-300); color: var(--neutral-500); border-color: var(--neutral-300); cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; padding: 0; }
.btn svg, .icon svg { flex: none; }

/* segmented control */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px;
  background: var(--neutral-100); border: 1px solid var(--neutral-300); border-radius: var(--radius-pill);
}
.seg button {
  height: 40px; border: none; border-radius: var(--radius-pill); background: transparent;
  color: var(--neutral-700); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--primary-900); color: #fff; }

/* ---------- cards + forms ---------- */
.card { background: var(--neutral-0); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 24px; }
.card-modal { box-shadow: var(--shadow-modal); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 14px; line-height: 22px; font-weight: 500; }
.input, .select {
  height: 48px; padding: 0 14px; width: 100%;
  border: 1px solid var(--neutral-300); border-radius: var(--radius-card);
  background: var(--neutral-0); color: var(--neutral-900); font: inherit; font-size: 16px;
}
.input[aria-invalid="true"] { border-color: var(--error-900); }
.error-text { color: var(--error-900); }
input[type="range"], input[type="checkbox"] { accent-color: var(--primary-900); }
input[type="checkbox"] { width: 20px; height: 20px; }

.choice {
  display: flex; gap: 16px; align-items: flex-start; width: 100%; text-align: left;
  padding: 20px; border-radius: var(--radius-card);
  background: var(--neutral-0); border: 1px solid var(--neutral-300); box-shadow: var(--shadow-card);
  font: inherit; color: var(--neutral-900); cursor: pointer;
}
.choice[aria-pressed="true"] { background: var(--primary-100); border-color: var(--primary-900); }
.radio-dot {
  flex: none; width: 20px; height: 20px; margin-top: 3px; border-radius: 50%;
  border: 2px solid var(--neutral-300); display: inline-flex; align-items: center; justify-content: center;
}
.choice[aria-pressed="true"] .radio-dot { border-color: var(--primary-900); }
.choice[aria-pressed="true"] .radio-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary-900); }

.icon-circle {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-100); color: var(--primary-900);
  display: inline-flex; align-items: center; justify-content: center;
}

.alert-error { display: flex; gap: 12px; padding: 16px; border-radius: var(--radius-card); background: var(--error-illustration); border: 1px solid var(--error-900); }
.test-panel { padding: 20px; border-radius: var(--radius-card); background: var(--neutral-0); border: 2px dashed var(--training-flower); }
.record-card { padding: 14px 16px; border-radius: var(--radius-card); background: var(--primary-100); border: 1px solid var(--primary-300); }
.record-card dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; line-height: 22px; }
.record-card dt { color: var(--neutral-700); }
.record-card dd { margin: 0; font-weight: 500; }

/* page layout */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1 1 auto; display: flex; justify-content: center; padding: 40px var(--space-margin-small); }
.container { width: 100%; max-width: 1120px; }
.split { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.split > .main { flex: 999 1 560px; min-width: 0; }
.split > .side { flex: 1 1 340px; min-width: 0; }

/* ---------- voice orb ---------- */
@keyframes orb-ring { 0% { transform: scale(.62); opacity: .9; } 100% { transform: scale(1.08); opacity: 0; } }
@keyframes orb-talk { 0%, 100% { height: 14px; } 50% { height: 58px; } }
@keyframes orb-listen { 0%, 100% { height: 10px; } 50% { height: 26px; } }
@keyframes orb-think { 0%, 100% { transform: translateY(0); opacity: .45; } 50% { transform: translateY(-10px); opacity: 1; } }
@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.orb { --orb: 240px; --core: 150px; position: relative; width: var(--orb); height: var(--orb); display: flex; align-items: center; justify-content: center; }
.orb-sm { --orb: 180px; --core: 112px; }
.orb-md { --orb: 220px; --core: 136px; }
.orb .ring { position: absolute; inset: 0; border-radius: 50%; opacity: 0; }
.orb .core {
  position: relative; z-index: 1; width: var(--core); height: var(--core); border-radius: 50%;
  background: var(--primary-900); display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .3s, border-color .3s;
}
.orb .bar { width: 9px; height: 16px; border-radius: 9px; background: #fff; }
.orb .bar:nth-child(2) { animation-delay: .15s; } .orb .bar:nth-child(3) { animation-delay: .3s; }
.orb .bar:nth-child(4) { animation-delay: .45s; } .orb .bar:nth-child(5) { animation-delay: .6s; }
.orb .mic-off { display: none; }

.orb[data-state="speaking"] .ring { background: var(--primary-300); animation: orb-ring 2.1s ease-out infinite; }
.orb[data-state="speaking"] .r2 { animation-delay: .7s; } .orb[data-state="speaking"] .r3 { animation-delay: 1.4s; }
.orb[data-state="speaking"] .bar { animation: orb-talk .9s ease-in-out infinite; }

.orb[data-state="listening"] .ring { border: 2px solid var(--primary-500); animation: orb-ring 2.8s ease-out infinite; }
.orb[data-state="listening"] .r2 { animation-delay: 1.4s; } .orb[data-state="listening"] .r3 { display: none; }
.orb[data-state="listening"] .core { background: #fff; border: 3px solid var(--primary-900); }
.orb[data-state="listening"] .bar { background: var(--primary-900); animation: orb-listen 1.2s ease-in-out infinite; }

.orb[data-state="thinking"] .r1 { opacity: 1; inset: 30px; border: 3px dashed var(--primary-500); animation: orb-spin 7s linear infinite; }
.orb[data-state="thinking"] .bar { width: 12px; height: 12px; animation: orb-think 1s ease-in-out infinite; }
.orb[data-state="thinking"] .bar:nth-child(4), .orb[data-state="thinking"] .bar:nth-child(5) { display: none; }

.orb[data-state="muted"] .core { background: var(--neutral-100); border: 3px solid var(--neutral-300); }
.orb[data-state="muted"] .bar { display: none; }
.orb[data-state="muted"] .mic-off { display: block; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--error-900); animation: blink 1.6s ease-in-out infinite; }
.meter { height: 12px; border-radius: var(--radius-pill); background: var(--neutral-100); border: 1px solid var(--neutral-300); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: var(--radius-pill); background: var(--primary-900); transition: width .08s linear; }
.progress-sweep { height: 6px; border-radius: var(--radius-pill); background: var(--primary-100); overflow: hidden; }
.progress-sweep > span { display: block; width: 40%; height: 100%; border-radius: var(--radius-pill); background: var(--primary-900); animation: sweep 1.6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .orb[data-state="speaking"] .r1, .orb[data-state="listening"] .r1 { opacity: .6; }
}
