/* Tymira Care Finder design system. Tokens come from the Tymira Health brand kit;
   rules and rationale are in docs/design-system.md. Keep this the only stylesheet. */

@font-face {
  font-family: "Chillax";
  src: url("../fonts/Chillax-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Chillax";
  src: url("../fonts/Chillax-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* 1. Tokens ---------------------------------------------------------------------- */
:root {
  /* Brand */
  --phthalo: #1e1c85;      /* primary: headings, primary actions, dark surfaces */
  --sapphire: #0057c0;     /* links, focus, secondary emphasis */
  --aquamarine: #00f5c1;   /* accent fill only, never text on light backgrounds */
  --neon: #5e59fc;         /* data and highlights */
  --bittersweet: #ff715b;  /* alerts only: borders and icons, never text */

  /* Surfaces and text (light) */
  --bg: #ffffff;
  --bg-subtle: #f3f3f3;
  --bg-tint: #e0f2fe;
  --text: #353535;
  --text-secondary: #595959;
  --text-muted: #747474;   /* white backgrounds only (4.7:1); use --text-secondary on grey */
  --border: #cccccc;
  --border-strong: #939393;
  --ink: #08084b;          /* brand bg-inverted: deepest surface */
  --on-dark-muted: #d3d3d3; /* brand text-inverted: secondary text on Phthalo */
  --on-accent: #000000;    /* brand text-on-accent: text on Aquamarine */
  --heading: var(--phthalo);
  --link: var(--sapphire);
  --focus: var(--sapphire);
  --on-primary: #ffffff;
  --alert-bg: #fff1ee;
  --alert-text: #8a2a1c;
  --ok-bg: #e6fff8;
  --ok-text: #0b5d4b;

  /* Type: Chillax for headings, Campton for body (licensed webfont to be added). */
  --font-heading: "Chillax", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Campton", "Avenir Next", "Segoe UI", Roboto, system-ui, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;
  --step-4: 2.25rem;

  /* Space (4px base) and shape */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --tap: 44px;             /* minimum touch target (WCAG 2.5.5) */
  --measure: 40rem;        /* comfortable reading width */
  --shadow: 0 1px 2px rgb(8 8 75 / 6%), 0 4px 16px rgb(8 8 75 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08084b;
    --bg-subtle: #201e26;
    --bg-tint: #2b2830;
    --text: #d3d3d3;
    --text-secondary: #a2a2a2;
    --text-muted: #a2a2a2;
    --border: #3a3a3a;
    --border-strong: #626262;
    --heading: #e0f2fe;
    --link: #e0f2fe;
    --focus: var(--aquamarine);
    --alert-bg: #3a1d19;
    --alert-text: #ffd2ca;
    --ok-bg: #0d3b33;
    --ok-text: #b8ffef;
    --shadow: none;
  }
}

/* 2. Base ------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--heading);
  line-height: 1.2;
  margin: var(--space-5) 0 var(--space-3);
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p, li { max-width: var(--measure); }
a { color: var(--link); text-underline-offset: 0.15em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 3. Layout ---------------------------------------------------------------------- */
.skip-link { position: absolute; left: var(--space-4); top: -4rem; background: var(--bg); padding: var(--space-2) var(--space-3); z-index: 10; }
.skip-link:focus { top: var(--space-2); }
.container { max-width: 48rem; margin: 0 auto; padding: 0 var(--space-4); }
.site-header { background: var(--phthalo); color: var(--on-primary); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 60px; }
.brand { color: var(--on-primary); text-decoration: none; font-family: var(--font-heading); font-weight: 600; font-size: var(--step-1); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); }
.brand img { border-radius: 6px; }
.brand span { font-weight: 500; opacity: 0.85; }
.site-nav { display: flex; gap: var(--space-4); }
.site-nav a { color: var(--on-primary); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }
.site-nav a:hover { text-decoration: underline; }
main { padding-bottom: var(--space-7); }
.site-footer { border-top: 1px solid var(--border); color: var(--text-secondary); font-size: var(--step--1); padding: var(--space-5) 0; }
.made-by { font-family: var(--font-heading); font-weight: 500; color: var(--heading); }

/* 4. Crisis support: always visible, calm not alarming --------------------------- */
.crisis { background: var(--bg-tint); border-bottom: 1px solid var(--border); font-size: var(--step--1); }
.crisis .container { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.crisis strong { color: var(--heading); }

/* 5. Components ------------------------------------------------------------------ */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); margin: var(--space-4) 0; box-shadow: var(--shadow); }
.card > :first-child { margin-top: 0; }
.lead { font-size: var(--step-1); color: var(--text-secondary); }
.hint { color: var(--text-secondary); font-size: var(--step--1); margin: var(--space-1) 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-pill); border: 2px solid var(--phthalo);
  background: var(--bg); color: var(--phthalo);
  font: 600 var(--step-0) / 1.2 var(--font-body); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--bg-tint); }
.btn-primary { background: var(--phthalo); color: var(--on-primary); }
.btn-primary:hover { background: #15136a; }
.btn-block { width: 100%; }
.btn-quiet { border-color: transparent; text-decoration: underline; padding-inline: var(--space-2); }
.btn-danger { border-color: var(--alert-text); color: var(--alert-text); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }
@media (prefers-color-scheme: dark) {
  .btn { background: transparent; color: var(--heading); border-color: var(--heading); }
  .btn-primary { background: var(--aquamarine); color: #08084b; border-color: var(--aquamarine); }
  .btn-primary:hover { background: #7dffe0; }
}

/* Forms: labels above fields, one question per line, generous targets */
.field { margin: var(--space-5) 0 0; }
.field > label, fieldset > legend { display: block; font-weight: 600; color: var(--heading); margin-bottom: var(--space-2); }
.optional { font-weight: 400; color: var(--text-secondary); }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="time"], select, textarea {
  width: 100%; min-height: var(--tap); padding: var(--space-2) var(--space-3);
  font: inherit; color: var(--text); background: var(--bg);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
}
input.code { font-size: var(--step-3); letter-spacing: 0.4em; text-align: center; max-width: 12rem; }
fieldset { border: 0; padding: 0; margin: var(--space-5) 0 0; min-width: 0; }
.check { display: flex; gap: var(--space-3); align-items: flex-start; min-height: var(--tap); padding: var(--space-2) 0; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; accent-color: var(--phthalo); flex: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* Chips: multi-choice answers that read like buttons */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--bg);
}
.chip input:checked + span { background: var(--phthalo); border-color: var(--phthalo); color: var(--on-primary); }
.chip input:checked + span::before { content: "✓ "; white-space: pre; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  .chip input:checked + span { background: var(--aquamarine); border-color: var(--aquamarine); color: #08084b; }
}

/* Feedback */
.alert { background: var(--alert-bg); color: var(--alert-text); border-left: 4px solid var(--bittersweet); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin: var(--space-4) 0; }
.alert ul { margin: var(--space-1) 0 0; padding-left: var(--space-5); }
.notice { background: var(--ok-bg); color: var(--ok-text); border-left: 4px solid var(--aquamarine); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin: var(--space-4) 0; }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0; padding: 0; list-style: none; }
.badge { display: inline-block; font-size: var(--step--1); line-height: 1.4; padding: 2px var(--space-3); border-radius: var(--radius-pill); background: var(--bg-subtle); color: var(--text-secondary); }
.badge-verified { background: var(--aquamarine); color: var(--phthalo); font-weight: 600; }
.badge-cover { background: var(--bg-tint); color: var(--phthalo); }
.badge-open { background: var(--ok-bg); color: var(--ok-text); }
.badge-sample { background: #fff4d6; color: #6b4b00; }
@media (prefers-color-scheme: dark) { .badge-sample { background: #3d3115; color: #ffe3a3; } }

/* Provider and match cards */
.results { list-style: none; padding: 0; margin: 0; }
.provider-card h2 { margin: 0; font-size: var(--step-1); }
.provider-card .meta { color: var(--text-secondary); margin: var(--space-1) 0; font-size: var(--step--1); }
.provider-card .head { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; }
.distance { color: var(--text-secondary); white-space: nowrap; font-size: var(--step--1); }
.why { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); background: var(--bg-subtle); border-radius: var(--radius-sm); }
.why h3 { margin: 0 0 var(--space-1); font-size: var(--step-0); }
.why ul { margin: 0; padding-left: var(--space-5); }
.fit { font-weight: 600; color: var(--heading); }

/* Questionnaire progress */
.steps { display: flex; gap: var(--space-2); list-style: none; padding: 0; margin: var(--space-4) 0; }
.steps li { flex: 1; height: 6px; border-radius: var(--radius-pill); background: var(--border); }
.steps li[aria-current="step"], .steps li.done { background: var(--phthalo); }
@media (prefers-color-scheme: dark) { .steps li[aria-current="step"], .steps li.done { background: var(--aquamarine); } }

/* Slots */
.day { margin: var(--space-4) 0; }
.slots { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.slot { min-width: 5.5rem; }

/* Map */
.map { height: 300px; border-radius: var(--radius); border: 1px solid var(--border); margin: var(--space-4) 0; }

/* Tables (provider and admin views) */
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th, td { text-align: left; padding: var(--space-2); border-bottom: 1px solid var(--border); vertical-align: top; }
@media (max-width: 36rem) {
  .row { grid-template-columns: 1fr; }
  table thead { display: none; }
  table tr { display: block; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
  table td { display: block; border: 0; padding: 2px 0; }
  h1 { font-size: var(--step-3); }
}

/* Places from Google Maps: listed, never drawn on our map (ADR 0023) */
.live-place { border-top: 1px solid var(--border); padding: var(--space-3) 0; }
.live-place h3 { margin: 0; font-size: var(--step-0); }
.attribution { font-size: var(--step--1); color: var(--text-secondary); text-align: right; margin: var(--space-2) 0 0; }

/* Lists of links to need-and-place pages: large, easy tap targets. */
.link-list { list-style: none; padding: 0; margin: var(--space-3) 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.link-list a { display: inline-block; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); min-height: 44px; line-height: 1.6; }

/* Navigator conversation: plain text, line breaks kept. */
.chat { list-style: none; padding: 0; margin: var(--space-4) 0; display: grid; gap: var(--space-3); }
.chat li { padding: var(--space-3) var(--space-4); border-radius: var(--radius); white-space: pre-line; max-width: 46rem; }
.chat-user { background: var(--bg-tint); justify-self: end; }
.chat-assistant { border: 1px solid var(--border); }

/* Breadcrumbs: where this page sits, for people and search engines. */
.breadcrumb ol { list-style: none; padding: 0; margin: 0 0 var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--step--1); }
.breadcrumb li + li::before { content: "›"; margin-right: var(--space-2); color: var(--text-secondary); }

/* Lean MVP (ADR 0044): brand hero, quick choices and result summary. Phthalo carries the
   brand; Aquamarine is an accent fill only (text on it is black); Neon marks data. */
.hero { background: var(--phthalo); color: var(--on-primary); padding: var(--space-7) 0 calc(var(--space-7) + 2.5rem); }
.hero h1 { color: var(--on-primary); margin-top: 0; max-width: 18ch; }
.hero h1::after { content: ""; display: block; width: 3.5rem; height: 4px; margin-top: var(--space-4); border-radius: var(--radius-pill); background: var(--aquamarine); }
.hero .lead { color: var(--on-dark-muted); }
.trust { list-style: none; padding: 0; margin: var(--space-5) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--step--1); }
.trust li::before { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: var(--space-2); border-radius: 50%; background: var(--aquamarine); }
.card-raised { position: relative; margin-top: -2.5rem; }
.alert-raised { position: relative; margin-top: -2.5rem; margin-bottom: 3rem; }
.card-raised > fieldset:first-child { margin-top: 0; }
.search-btn { margin-top: var(--space-6); }

.results-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--space-4); }
.results-head h1 { margin-bottom: 0; }
.results-summary { font-family: var(--font-heading); font-weight: 500; color: var(--heading); margin: var(--space-4) 0 0; }
.filters .chips { list-style: none; padding: 0; margin: var(--space-4) 0 0; }
.chip-link {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-pill); color: var(--text); text-decoration: none;
}
.chip-link:hover { border-color: var(--phthalo); }
.chip-link[aria-current="page"] { background: var(--phthalo); border-color: var(--phthalo); color: var(--on-primary); }
.badge-rating { background: var(--bg-tint); color: var(--phthalo); font-weight: 600; }
.badge-rating .star { color: var(--neon); }
.badge-rating .count { font-weight: 400; }
.badge-kind { background: var(--bg-tint); color: var(--phthalo); }
.badge-open { background: var(--aquamarine); color: var(--on-accent); font-weight: 600; }
.card-support { border-left: 4px solid var(--aquamarine); }
.providers-cta { text-align: center; }
@media (prefers-color-scheme: dark) {
  .hero { background: var(--bg-tint); }
  .chip-link[aria-current="page"] { background: var(--aquamarine); border-color: var(--aquamarine); color: var(--ink); }
  .badge-rating, .badge-kind { background: var(--bg-subtle); color: var(--heading); }
  .badge-rating .star { color: var(--aquamarine); }
}
@media (max-width: 36rem) {
  .hero { padding: var(--space-6) 0 calc(var(--space-6) + 2.5rem); }
  .hero h1 { font-size: var(--step-3); }
}

/* Language menu: a globe and a small dropdown; works without JavaScript (<details>). */
.lang-menu { position: relative; }
.lang-menu summary {
  list-style: none; display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-pill);
  border: 1.5px solid rgb(255 255 255 / 35%); cursor: pointer; color: var(--on-primary);
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: "▾"; font-size: 0.8em; }
.lang-menu summary:hover { border-color: var(--aquamarine); }
.lang-menu .icon { flex: none; }
.lang-menu ul {
  position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: 20; min-width: 10rem;
  list-style: none; margin: 0; padding: var(--space-2); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.lang-menu ul a { display: flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-3); border-radius: 6px; color: var(--text); text-decoration: none; }
.lang-menu ul a:hover { background: var(--bg-tint); }
.lang-menu ul a[aria-current="true"] { font-weight: 600; color: var(--heading); }
.lang-menu ul a[aria-current="true"]::after { content: "✓"; margin-left: auto; color: var(--heading); }
.brand { white-space: nowrap; }
@media (max-width: 36rem) {
  .site-header .container { gap: var(--space-2); }
  .site-nav { gap: var(--space-3); align-items: center; font-size: var(--step--1); }
  .lang-menu summary { padding: 0 var(--space-2); }
  .lang-menu summary span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.site-nav a { white-space: nowrap; }
@media (max-width: 36rem) { .brand { font-size: var(--step-0); } }

/* Navigation: the current page is marked; on phones the two search links drop out of the
   header (the home page is one tap away on the brand) to keep one tidy row. */
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--aquamarine); text-decoration-thickness: 3px; text-underline-offset: 0.5em; }
@media (max-width: 36rem) { .nav-wide { display: none !important; } }

/* Own-words search (ADR 0045) */
.stack > :first-child { position: relative; margin-top: -2.5rem; }
.own-words-label { display: block; font-family: var(--font-heading); font-weight: 600; font-size: var(--step-2); color: var(--heading); margin-bottom: var(--space-3); }
.own-words textarea { margin-bottom: var(--space-2); }
.own-words .btn { margin-top: var(--space-3); }
.or { display: flex; align-items: center; gap: var(--space-3); color: var(--text-secondary); max-width: none; margin: var(--space-5) 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.understood { margin: var(--space-4) 0 0; padding: var(--space-4); border-radius: var(--radius); background: var(--bg-tint); }
.understood h2 { margin: 0 0 var(--space-2); font-size: var(--step-0); }
.understood .hint { margin: 0; }
.why-line { margin: var(--space-2) 0 0; font-size: var(--step--1); font-weight: 600; color: var(--heading); }
.crisis-now { border-left: 4px solid var(--bittersweet); }
