/* =========================================================================
   takingcare.app — THEME SYSTEM (shared)
   Two independent axes:
     • colour / hue  → html[data-palette]  : sage(default) | ocean | clay | lavender
     • mode          → html[data-mode]      : light | dark   (System resolves to one)
   Pair with theme.js, which renders the toolbar and persists the choice.

   Pages already define the SAGE-LIGHT defaults in their own :root
   (--bg-*, --text-*, --accent-*, --success-*, --warning-*). This file only
   ADDS: scene tokens, the ink button pair, mood modifiers, every palette /
   dark override, the no-anim guard, and the toolbar UI.
   ========================================================================= */

:root {
  /* solid "ink" button pair (inverts in dark) */
  --ink: hsl(40 6% 14%); --ink-soft: hsl(40 7% 35%); --ink-inv: hsl(40 36% 95%);
  /* animated-scene tokens (used by the client card weather scene) */
  --sky-1: #F8D6B5; --sky-2: #FBE7C7; --sky-3: #D5E2EC; --sky-4: #B4CFDB;
  --wave-1: #9DC3CE; --wave-2: #7EA9B4; --wave-3: #5C8896;
  --sun-1: #F9D589; --sun-2: #FCE6B3; --horizon: #9CB7BE;
  /* shared mood modifiers — weather states mix the sky toward these */
  --mood-overcast: hsl(40 8% 72%);
  --mood-warn:     hsl(32 65% 62%);
  --mood-cool:     hsl(210 20% 60%);
  --mood-storm:    hsl(214 16% 40%);
}

/* ---- 2 · Ocean / Mist ---------------------------------------------------- */
[data-palette="ocean"] {
  --bg-primary: hsl(200 33% 95%); --bg-secondary: hsl(200 40% 97.5%); --bg-tertiary: hsl(200 26% 88%);
  --text-primary: hsl(208 24% 16%); --text-secondary: hsl(208 16% 34%); --text-soft: hsl(205 14% 52%);
  --border-color: hsla(208, 30%, 16%, 0.10); --hairline: hsla(208, 30%, 16%, 0.07);
  --accent-color: hsl(196 42% 40%); --accent-light: hsl(196 38% 89%); --accent-hover: hsl(196 46% 32%);
  --success-color: hsl(168 38% 36%); --success-light: hsl(168 34% 90%);
  --warning-color: hsl(28 42% 50%); --warning-light: hsl(30 55% 93%);
  --sky-1:#BAD7E9; --sky-2:#CFE6F1; --sky-3:#B6D0E0; --sky-4:#8FB6CF;
  --wave-1:#88B7D2; --wave-2:#5793B6; --wave-3:#356C92;
  --sun-1:#EAE6B8; --sun-2:#F5F0D6; --horizon:#8FB0C0;
}

/* ---- 3 · Terracotta / Clay ---------------------------------------------- */
[data-palette="clay"] {
  --bg-primary: hsl(28 42% 94%); --bg-secondary: hsl(30 48% 96.5%); --bg-tertiary: hsl(26 34% 87%);
  --text-primary: hsl(20 18% 16%); --text-secondary: hsl(20 14% 34%); --text-soft: hsl(22 12% 52%);
  --border-color: hsla(20, 25%, 16%, 0.10); --hairline: hsla(20, 25%, 16%, 0.07);
  --accent-color: hsl(16 48% 50%); --accent-light: hsl(18 52% 90%); --accent-hover: hsl(14 50% 42%);
  --success-color: hsl(130 26% 40%); --success-light: hsl(120 28% 90%);
  --warning-color: hsl(32 55% 48%); --warning-light: hsl(34 60% 92%);
  --sky-1:#F4C49A; --sky-2:#F8DAB6; --sky-3:#EBD2BE; --sky-4:#D7B59C;
  --wave-1:#A7C6BE; --wave-2:#74A39B; --wave-3:#4E7D75;
  --sun-1:#F6C57A; --sun-2:#FBDFA9; --horizon:#C2A98F;
}

/* ---- 4 · Lavender / Dusk ------------------------------------------------- */
[data-palette="lavender"] {
  --bg-primary: hsl(282 24% 96%); --bg-secondary: hsl(288 30% 97.5%); --bg-tertiary: hsl(282 20% 90%);
  --text-primary: hsl(280 16% 18%); --text-secondary: hsl(280 12% 36%); --text-soft: hsl(278 10% 54%);
  --border-color: hsla(280, 22%, 18%, 0.10); --hairline: hsla(280, 22%, 18%, 0.07);
  --accent-color: hsl(265 32% 55%); --accent-light: hsl(270 32% 91%); --accent-hover: hsl(265 34% 45%);
  --success-color: hsl(155 28% 40%); --success-light: hsl(150 26% 91%);
  --warning-color: hsl(338 42% 54%); --warning-light: hsl(338 48% 93%);
  --sky-1:#E7D2E0; --sky-2:#F0DEEA; --sky-3:#DAD0EA; --sky-4:#C2B4DE;
  --wave-1:#BBAAD8; --wave-2:#9382C4; --wave-3:#6E5CA6;
  --sun-1:#F2C9D7; --sun-2:#F9E1E9; --horizon:#B8A8D0;
}

/* =========================================================================
   DARK MODE — neutral dark shell for every hue; each hue then tints only the
   accent + scene. (html[...] keeps these higher-specificity than the light
   [data-palette] blocks above, so dark always wins for bg/text.)
   ========================================================================= */
html[data-mode="dark"] {
  --bg-primary: hsl(226 24% 12%); --bg-secondary: hsl(226 22% 16%); --bg-tertiary: hsl(226 18% 23%);
  --text-primary: hsl(40 28% 92%); --text-secondary: hsl(220 14% 74%); --text-soft: hsl(220 10% 56%);
  --border-color: hsla(220, 40%, 80%, 0.14); --hairline: hsla(220, 40%, 80%, 0.09);
  --ink: hsl(40 28% 92%); --ink-soft: hsl(40 18% 80%); --ink-inv: hsl(226 24% 12%);
  --success-color: hsl(150 42% 56%); --success-light: hsl(150 30% 22%);
  --warning-color: hsl(35 58% 60%); --warning-light: hsl(33 36% 26%);
  --mood-overcast: hsl(220 12% 40%); --mood-cool: hsl(212 22% 46%); --mood-storm: hsl(216 18% 28%);
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.35);
  --shadow-md: 0 4px 14px -2px rgba(0,0,0,0.45), 0 2px 6px -1px rgba(0,0,0,0.32);
  --shadow-lg: 0 20px 30px -8px rgba(0,0,0,0.55), 0 10px 12px -6px rgba(0,0,0,0.38);
  /* default (sage) dark accent + scene */
  --accent-color: hsl(150 30% 52%); --accent-light: hsl(150 26% 24%); --accent-hover: hsl(150 36% 62%);
  --sky-1:#1C2A2C; --sky-2:#24373A; --sky-3:#2E464A; --sky-4:#3A585C;
  --wave-1:#3C5C5C; --wave-2:#2B4848; --wave-3:#1C3636;
  --sun-1:#CBD9D2; --sun-2:#E6EFEA; --horizon:#2E4A48;
}
html[data-mode="dark"][data-palette="ocean"] {
  --accent-color: hsl(200 48% 60%); --accent-light: hsl(200 38% 26%); --accent-hover: hsl(200 54% 70%);
  --sky-1:#222C46; --sky-2:#2C3754; --sky-3:#3A4868; --sky-4:#4D5E80;
  --wave-1:#41597A; --wave-2:#2F4768; --wave-3:#203552;
  --sun-1:#CBD8EA; --sun-2:#E6EDF7; --horizon:#3A4A66;
}
html[data-mode="dark"][data-palette="clay"] {
  --accent-color: hsl(20 55% 60%); --accent-light: hsl(20 38% 25%); --accent-hover: hsl(18 58% 68%);
  --sky-1:#2A211C; --sky-2:#352A22; --sky-3:#45362B; --sky-4:#564537;
  --wave-1:#3E5A52; --wave-2:#2E4840; --wave-3:#203530;
  --sun-1:#E8D5BC; --sun-2:#F4E7D2; --horizon:#4A3A30;
}
html[data-mode="dark"][data-palette="lavender"] {
  --accent-color: hsl(265 45% 68%); --accent-light: hsl(265 34% 30%); --accent-hover: hsl(265 50% 75%);
  --sky-1:#241E33; --sky-2:#2E2742; --sky-3:#3A3154; --sky-4:#4A406B;
  --wave-1:#4A3E70; --wave-2:#382C5A; --wave-3:#261E40;
  --sun-1:#D8CBE8; --sun-2:#ECE4F5; --horizon:#3A3155;
}
/* dark: client-card components that hard-code a near-white background */
html[data-mode="dark"] .ditem.warm  { background: hsl(28 26% 21%); border-color: hsl(28 22% 30%); }
html[data-mode="dark"] .ditem.alert { background: hsl(14 32% 22%); border-color: hsl(14 34% 34%); }
html[data-mode="dark"] .di-amount.warm { color: hsl(28 55% 66%); }
html[data-mode="dark"] .axis.wait .axis-amount { color: hsl(28 55% 66%); }

/* suppress transitions during a theme switch so var()-backed backgrounds
   recompute instantly (avoids Chromium's stuck-transition quirk). */
html.no-anim, html.no-anim * { transition: none !important; }

/* =========================================================================
   TOOLBAR  (rendered by theme.js into [data-theme-toolbar], else floated)
   ========================================================================= */
.theme-toolbar-float {
  position: fixed; top: 14px; inset-inline-start: 14px; z-index: 200;
  background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 5px 7px; box-shadow: var(--shadow-md);
}
.toolbar { display: inline-flex; align-items: center; gap: 8px; }
.tb-group {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-secondary); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 3px;
}
.tb-group button {
  width: 30px; height: 30px; border-radius: 999px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: none; color: var(--text-soft);
  transition: background var(--transition-base), color var(--transition-base);
}
.tb-group button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tb-group button:hover { color: var(--text-primary); }
.tb-group button.active { background: var(--bg-primary); color: var(--accent-hover); box-shadow: var(--shadow-sm); }

.color-pick { position: relative; }
.cp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-secondary); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 6px 12px 6px 10px; cursor: pointer;
  font: 500 12.5px/1 var(--font-family); color: var(--text-secondary);
  transition: border-color var(--transition-base), color var(--transition-base);
}
.cp-btn:hover { color: var(--text-primary); border-color: var(--border-color); }
.cp-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 1px var(--border-color) inset; flex-shrink: 0; }
.cp-name { white-space: nowrap; }
.cp-btn .chev { width: 14px; height: 14px; stroke: var(--text-soft); fill: none; stroke-width: 2; transition: transform var(--transition-base); }
.color-pick.open .cp-btn .chev { transform: rotate(180deg); }
.cp-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 41;
  min-width: 184px; background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; flex-direction: column; gap: 2px;
}
.color-pick.open .cp-menu { display: flex; }
.cp-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  background: transparent; border: none; border-radius: var(--radius-sm);
  padding: 9px 10px; cursor: pointer; font: 500 13px/1.2 var(--font-family); color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base);
}
.cp-opt:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.cp-opt .cp-dot { width: 16px; height: 16px; }
.cp-opt .cp-check { margin-inline-start: auto; width: 15px; height: 15px; stroke: var(--accent-color); fill: none; stroke-width: 2.2; opacity: 0; }
.cp-opt.sel { color: var(--text-primary); }
.cp-opt.sel .cp-check { opacity: 1; }

.a11y-btn {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; position: relative;
  background: var(--bg-secondary); border: 1px solid var(--hairline); color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.a11y-btn:hover { color: var(--text-primary); border-color: var(--border-color); }
.a11y-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.a11y-pop {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 41;
  width: 210px; background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 14px; display: none;
  text-align: start;
}
.a11y-wrap { position: relative; display: inline-flex; }
.a11y-wrap.open .a11y-pop { display: block; }
.a11y-pop .ap-title { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 7px; }
.a11y-pop .ap-soon { font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--accent-hover); background: var(--accent-light); padding: 2px 7px; border-radius: 999px; }
.a11y-pop .ap-text { font-size: 12px; color: var(--text-soft); line-height: 1.5; margin-top: 7px; }
/* ---- font pairs (all Hebrew-capable; html[data-font] beats [dir="rtl"]) ---- */
html[data-font="modern"]   { --font-family: 'Assistant', 'Rubik', system-ui, -apple-system, sans-serif; }
html[data-font="humanist"] { --font-family: 'Rubik', 'Assistant', system-ui, -apple-system, sans-serif; }
html[data-font="rounded"]  { --font-family: 'Varela Round', 'Assistant', system-ui, sans-serif; }
html[data-font="classic"]  { --font-family: 'Frank Ruhl Libre', 'Assistant', Georgia, serif; }
html[data-font="system"]   { --font-family: system-ui, -apple-system, 'Segoe UI', 'Assistant', sans-serif; }

/* ---- picker section heading + font "Aa" swatch (reuses .cp-* dropdown) ---- */
.cp-head { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-soft); padding: 3px 10px 6px; }
.fp-aa {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 18px; font-size: 14px; font-weight: 700; line-height: 1;
  color: var(--text-secondary); flex-shrink: 0;
}
.cp-btn.fp-btn { padding-inline: 11px 12px; }
.cp-btn.fp-btn .fp-aa-cur { font-size: 15px; }
.fp-opt .fp-aa { min-width: 26px; font-size: 16px; }

/* ---- accessibility popover controls (replaces the old placeholder text) ---- */
.a11y-pop { width: 244px; padding: 14px 15px 15px; }
.a11y-pop .ap-title { font-size: 13px; font-weight: 700; color: var(--text-primary); display: block; }
.ap-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 13px; }
.ap-lbl { font-size: 12.5px; color: var(--text-secondary); }
.ap-scale { display: inline-flex; gap: 3px; background: var(--bg-tertiary); border: 1px solid var(--hairline); border-radius: 999px; padding: 3px; }
.ap-step {
  min-width: 32px; height: 26px; padding: 0 9px; border: none; background: transparent; cursor: pointer;
  border-radius: 999px; font: 600 12px/1 var(--font-family); color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base);
}
.ap-step:hover { color: var(--text-primary); }
.ap-step:active { background: var(--bg-primary); }
.ap-reset.is-on { background: var(--accent-light); color: var(--accent-hover); }
.ap-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; cursor: pointer; font-size: 12.5px; color: var(--text-secondary); position: relative;
}
.ap-toggle input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.ap-sw {
  width: 38px; height: 22px; border-radius: 999px; flex-shrink: 0; position: relative;
  background: var(--bg-tertiary); border: 1px solid var(--hairline);
  transition: background var(--transition-base);
}
.ap-sw::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg-primary); box-shadow: var(--shadow-sm);
  transition: inset-inline-start var(--transition-base);
}
.ap-toggle input:checked + .ap-sw { background: var(--accent-color); border-color: transparent; }
.ap-toggle input:checked + .ap-sw::after { inset-inline-start: calc(100% - 18px); background: #fff; }
.ap-toggle:hover > span:first-child { color: var(--text-primary); }
.ap-clear {
  display: block; width: 100%; margin-top: 15px; padding: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font: 600 12px/1 var(--font-family); color: var(--text-secondary);
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.ap-clear:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--text-soft); }

/* ---- accessibility EFFECTS applied to the whole app ---- */
html[data-contrast="high"] {
  --text-soft: var(--text-secondary);
  --hairline: var(--border-color);
  --border-color: color-mix(in srgb, var(--text-primary) 42%, transparent);
}
html[data-contrast="high"] .cp-btn,
html[data-contrast="high"] .a11y-btn,
html[data-contrast="high"] .tb-group { border-color: var(--border-color); }

html[data-focus="on"] :focus-visible {
  outline: 3px solid var(--accent-color) !important;
  outline-offset: 2px !important; border-radius: 3px;
}

html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

@media (max-width: 560px) { .cp-name { display: none; } }

/* =========================================================================
   Sidebar-mounted appearance toolbar — used when index.html provides a
   [data-theme-toolbar] mount (.side-appearance) in the sidebar footer, so the
   controls live IN the layout instead of floating a pill over the page header.
   ========================================================================= */
.side-appearance { margin-block-end: 12px; }
.side-appearance .toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center;
}
/* compact in the narrow sidebar: show the swatch/Aa + chevron, drop the labels */
.side-appearance .cp-name { display: none; }
.side-appearance .cp-btn { padding: 6px 9px; }
/* the sidebar footer sits at the bottom of the viewport, so menus open UPWARD */
.side-appearance .cp-menu  { top: auto; bottom: calc(100% + 6px); }
.side-appearance .a11y-pop { top: auto; bottom: calc(100% + 8px); }
