/*
 * LimoMed v2 design tokens, emerald glass skin (2026-10-17).
 * The investors preferred the pre-v2 look, so the colors, glass surfaces and aurora background of
 * assets/css/glass.css and app-theme.css came back on top of the v2 components. The lemony values
 * are in git tag pre-emerald-skin.
 *
 * Three groups live here:
 *   1. Semantic colors (--bg, --ink, --brand ...) and the six service palettes (--p-<tone>-bg/fg/hd/hdi).
 *      Opaque hex values are what the contrast tests check; the glass tokens (--glass-card, --aurora) sit on top.
 *   2. Shape and motion tokens (--r-*, --dur-ms, --ease, --spring).
 *   3. Legacy RGB triplets (--color-*, --radius-*, --shadow-card) kept so app.css and the Tailwind
 *      colors canvas/surface/ink/muted/line/brand/on-brand/danger keep working. They mirror group 1.
 *
 * Theme switching: the OS preference applies by default; <html data-theme="light|dark"> forces a theme.
 * The dark block appears twice (media query and attribute) because CSS has no mixins; the tests assert
 * that both copies are identical.
 */
:root {
  color-scheme: light;
  --flip: 1;

  /* ---- surfaces and text ---- */
  --bg: #edf5f2;
  --surface: #fbfdfc;
  --card: #fbfdfc;
  --sheet: #fbfdfc;
  --field: #f8fbfa;
  --chip: #e2eee9;
  --chip-on: #d3efe3;
  --chip-on-ink: #064e3b;
  --ink: #0c231f;
  --muted: #415a55;
  --line: #dbe6e1;
  --line-strong: #c3d3cd;
  --field-line: #71877f;
  /* ---- brand: emerald, gradient primary button with a soft glow ---- */
  --brand: #047857;
  --on-brand: #ffffff;
  --btn-edge: #065f46;
  --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 22px -12px rgba(16, 185, 129, 0.55);
  --btn-grad: linear-gradient(135deg, #059669 0%, #065f46 100%);
  --brand-strong: #065f46;
  --accent: #10b981;
  --on-accent: #ffffff;
  --accent-strong: #059669;
  --ok: #047857;
  --danger: #be123c;
  --on-danger: #ffffff;
  /* ---- status tones (pills, calendar blocks): background + ink ---- */
  --tone-ok-bg: #cdeedb; --tone-ok-ink: #0b5a2b;
  --tone-warn-bg: #ffe9b0; --tone-warn-ink: #4d3a00;
  --tone-bad-bg: #f6d4d4; --tone-bad-ink: #7a1414;
  --tone-ref-bg: #e6dcff; --tone-ref-ink: #3d2a7a;
  --tone-visit-bg: #cfe3ff; --tone-visit-ink: #0b3a7a;
  --tone-rx-bg: #dfe6ff; --tone-rx-ink: #2a3a7a;
  --focus: rgba(5, 150, 105, 0.3);
  --focus-ring: #047857;
  --halo: rgba(16, 185, 129, 0.32);
  /* ---- glass surfaces and the aurora background (the pre-v2 look) ---- */
  --glass: rgba(255, 255, 255, 0.55);
  --glass-card: rgba(255, 255, 255, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.78);
  --glass-hi: rgba(255, 255, 255, 0.92);
  --tabbar: rgba(255, 255, 255, 0.6);
  --scrim: rgba(3, 26, 22, 0.32);
  --toast: #0b1f1b;
  --on-toast: #ffffff;
  --shadow-s: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 26px -18px rgba(4, 52, 44, 0.35);
  --shadow-m: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 22px 50px -26px rgba(4, 52, 44, 0.32);
  --a1: rgba(110, 231, 183, 0.55);
  --a2: rgba(125, 211, 252, 0.42);
  --a3: rgba(196, 181, 253, 0.32);
  --aurora: radial-gradient(38% 42% at 88% 8%, var(--a1), transparent 70%), radial-gradient(42% 40% at 8% 34%, var(--a2), transparent 70%), radial-gradient(52% 48% at 62% 100%, var(--a3), transparent 72%);
  /* ---- live order card, upcoming card, splash ---- */
  --live-bg: #0f3b33;
  --live-ink: #ffffff;
  --live-ecg: #34d399;
  --up-bg: #dcf3ea;
  --up-ink: #064e3b;
  --splash-bg: #edf5f2;
  --splash-ink: #064e3b;
  /* ---- tile decoration, loader (the --lemon* names are kept; the values are emerald now) ---- */
  --tile-ic-bg: rgba(255, 255, 255, 0.72);
  --tile-ic-rim: rgba(255, 255, 255, 0.85);
  --tile-ic-glow: 42%;
  --tile-deco: rgba(255, 255, 255, 0.35);
  /* glass service tiles: one frosted glass for every tile (white top, faint LimoMed mint bottom; the pictures carry the colour), a bright rim and a sheen on the upper half */
  --tile-glass-top: rgba(255, 255, 255, 0.9);
  --tile-glass-bottom: rgba(222, 246, 236, 0.72);
  --tile-glass-glow: rgba(4, 92, 70, 0.2);
  --tile-pic-shadow: rgba(15, 40, 35, 0.16);
  --tile-glass-edge: rgba(255, 255, 255, 0.95);
  --tile-glass-sheen: rgba(255, 255, 255, 0.8);
  --lemon: #10b981;
  --lemon-rind: #059669;
  --lemon-pith: #d1fae5;
  --on-lemon: #ffffff;
  --p-2: #ffffff;
  /* ---- map ---- */
  --map-bg: #eaf3ef;
  --map-park: #cdebd9;
  --map-block: #dde8e3;
  --map-road: #ffffff;
  --map-main: #e3f3ea;
  --map-water: #bfe0f5;
  --route: #0c231f;
  --route-base: #c3d3cd;
  /* ---- six service palettes (keys are stored in the catalog, so the names stay): bg = tile, fg = icon, hd = page header, hdi = text on header ---- */
  --p-lemon-bg: #fef3c7;
  --p-lemon-fg: #d97706;
  --p-lemon-hd: #b45309;
  --p-lemon-hdi: #ffffff;
  --p-mint-bg: #d1fae5;
  --p-mint-fg: #059669;
  --p-mint-hd: #047857;
  --p-mint-hdi: #ffffff;
  --p-sky-bg: #e0f2fe;
  --p-sky-fg: #0284c7;
  --p-sky-hd: #0369a1;
  --p-sky-hdi: #ffffff;
  --p-rose-bg: #ffe4e6;
  --p-rose-fg: #e11d48;
  --p-rose-hd: #be123c;
  --p-rose-hdi: #ffffff;
  --p-lilac-bg: #ede9fe;
  --p-lilac-fg: #7c3aed;
  --p-lilac-hd: #6d28d9;
  --p-lilac-hdi: #ffffff;
  --p-peach-bg: #ffedd5;
  --p-peach-fg: #ea580c;
  --p-peach-hd: #c2410c;
  --p-peach-hdi: #ffffff;
  --app-bg: var(--aurora), var(--bg);

  /* ---- shape ---- */
  --r-tile: 24px;
  --r-card: 24px;
  --r-btn: 14px;
  --r-ic: 20px;
  --r-sheet: 28px;
  --r-hd: 30px;
  --r-pill: 999px;

  /* ---- motion: --dur-ms is unitless so scripts can read it; reduced motion sets it to 0 ---- */
  --dur-ms: 320;
  --t: calc(var(--dur-ms) * 1ms);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --spring: cubic-bezier(0.22, 1.12, 0.36, 1);

  --font-ui: Vazirmatn, Tahoma, 'Segoe UI', system-ui, sans-serif;

  /* ---- legacy triplets (mirror of the values above, see tests) ---- */
  --color-canvas: 237 245 242;
  --color-surface: 251 253 252;
  --color-ink: 12 35 31;
  --color-muted: 65 90 85;
  --color-line: 219 230 225;
  --color-brand: 6 95 70;
  --color-on-brand: 255 255 255;
  --color-danger: 190 18 60;
  --radius-card: 24px;
  --radius-control: 14px;
  --shadow-card: 0 10px 26px -18px rgb(4 52 44 / 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #031210;
    --surface: #0a1c19;
    --card: #0c201c;
    --sheet: #0a1c19;
    --field: #0e231f;
    --chip: #112925;
    --chip-on: #0f3a2e;
    --chip-on-ink: #a7f3d0;
    --ink: #e5f3ef;
    --muted: #a2b9b3;
    --line: #18302b;
    --line-strong: #2a4842;
    --field-line: #5f7d76;
    --brand: #34d399;
    --on-brand: #03251b;
    --btn-edge: #059669;
    --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 10px 22px -12px rgba(16, 185, 129, 0.4);
    --btn-grad: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    --brand-strong: #34d399;
    --accent: #10b981;
    --on-accent: #03251b;
    --accent-strong: #6ee7b7;
    --ok: #34d399;
    --danger: #fda4af;
    --on-danger: #3a0508;
    --tone-ok-bg: #123d2b; --tone-ok-ink: #a7f3d0;
    --tone-warn-bg: #3d3212; --tone-warn-ink: #fde7a0;
    --tone-bad-bg: #4a1c20; --tone-bad-ink: #fecdd3;
    --tone-ref-bg: #2c2552; --tone-ref-ink: #ddd3ff;
    --tone-visit-bg: #12305a; --tone-visit-ink: #c3dcff;
    --tone-rx-bg: #1c2a55; --tone-rx-ink: #cdd8ff;
    --focus: rgba(52, 211, 153, 0.4);
    --focus-ring: #34d399;
    --halo: rgba(52, 211, 153, 0.28);
    --glass: rgba(7, 23, 20, 0.52);
    --glass-card: rgba(9, 26, 23, 0.72);
    --glass-edge: rgba(255, 255, 255, 0.08);
    --glass-hi: rgba(255, 255, 255, 0.1);
    --tabbar: rgba(7, 23, 20, 0.7);
    --scrim: rgba(0, 0, 0, 0.55);
    --toast: #e5f3ef;
    --on-toast: #0c231f;
    --shadow-s: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 30px -18px rgba(0, 0, 0, 0.7);
    --shadow-m: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 26px 60px -26px rgba(0, 0, 0, 0.75);
    --a1: rgba(110, 231, 183, 0.24);
    --a2: rgba(125, 211, 252, 0.18);
    --a3: rgba(196, 181, 253, 0.14);
    --live-bg: #0f3b33;
    --up-bg: #0f3a2e;
    --up-ink: #a7f3d0;
    --splash-bg: #031210;
    --splash-ink: #e5f3ef;
    --tile-ic-bg: rgba(255, 255, 255, 0.1);
    --tile-ic-rim: rgba(255, 255, 255, 0.1);
    --tile-ic-glow: 26%;
    --tile-deco: rgba(255, 255, 255, 0.06);
    --tile-glass-top: rgba(255, 255, 255, 0.13);
    --tile-glass-bottom: rgba(52, 211, 153, 0.07);
    --tile-glass-glow: rgba(0, 0, 0, 0.5);
    --tile-pic-shadow: rgba(0, 0, 0, 0.35);
    --tile-glass-edge: rgba(255, 255, 255, 0.18);
    --tile-glass-sheen: rgba(255, 255, 255, 0.16);
    --lemon: #34d399;
    --lemon-rind: #10b981;
    --lemon-pith: #0f3a2e;
    --on-lemon: #03251b;
    --map-bg: #0a1c19;
    --map-park: #0f2e24;
    --map-block: #0e231f;
    --map-road: #18302b;
    --map-main: #1f3f37;
    --map-water: #0f2f45;
    --route: #34d399;
    --route-base: #2a4842;
    --p-lemon-bg: #3a2a0a;
    --p-lemon-fg: #fbbf24;
    --p-lemon-hd: #b45309;
    --p-lemon-hdi: #ffffff;
    --p-mint-bg: #0c3a2c;
    --p-mint-fg: #34d399;
    --p-mint-hd: #047857;
    --p-mint-hdi: #ffffff;
    --p-sky-bg: #0c2d44;
    --p-sky-fg: #38bdf8;
    --p-sky-hd: #0369a1;
    --p-sky-hdi: #ffffff;
    --p-rose-bg: #3f1420;
    --p-rose-fg: #fb7185;
    --p-rose-hd: #be123c;
    --p-rose-hdi: #ffffff;
    --p-lilac-bg: #2a1f4f;
    --p-lilac-fg: #a78bfa;
    --p-lilac-hd: #6d28d9;
    --p-lilac-hdi: #ffffff;
    --p-peach-bg: #3d2210;
    --p-peach-fg: #fb923c;
    --p-peach-hd: #c2410c;
    --p-peach-hdi: #ffffff;
    --color-canvas: 3 18 16;
    --color-surface: 10 28 25;
    --color-ink: 229 243 239;
    --color-muted: 162 185 179;
    --color-line: 24 48 43;
    --color-brand: 52 211 153;
    --color-on-brand: 3 37 27;
    --color-danger: 253 164 175;
    --shadow-card: 0 12px 30px -18px rgb(0 0 0 / 0.7);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #031210;
  --surface: #0a1c19;
  --card: #0c201c;
  --sheet: #0a1c19;
  --field: #0e231f;
  --chip: #112925;
  --chip-on: #0f3a2e;
  --chip-on-ink: #a7f3d0;
  --ink: #e5f3ef;
  --muted: #a2b9b3;
  --line: #18302b;
  --line-strong: #2a4842;
  --field-line: #5f7d76;
  --brand: #34d399;
  --on-brand: #03251b;
  --btn-edge: #059669;
  --btn-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 10px 22px -12px rgba(16, 185, 129, 0.4);
  --btn-grad: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --brand-strong: #34d399;
  --accent: #10b981;
  --on-accent: #03251b;
  --accent-strong: #6ee7b7;
  --ok: #34d399;
  --danger: #fda4af;
  --on-danger: #3a0508;
  --tone-ok-bg: #123d2b; --tone-ok-ink: #a7f3d0;
  --tone-warn-bg: #3d3212; --tone-warn-ink: #fde7a0;
  --tone-bad-bg: #4a1c20; --tone-bad-ink: #fecdd3;
  --tone-ref-bg: #2c2552; --tone-ref-ink: #ddd3ff;
  --tone-visit-bg: #12305a; --tone-visit-ink: #c3dcff;
  --tone-rx-bg: #1c2a55; --tone-rx-ink: #cdd8ff;
  --focus: rgba(52, 211, 153, 0.4);
  --focus-ring: #34d399;
  --halo: rgba(52, 211, 153, 0.28);
  --glass: rgba(7, 23, 20, 0.52);
  --glass-card: rgba(9, 26, 23, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.08);
  --glass-hi: rgba(255, 255, 255, 0.1);
  --tabbar: rgba(7, 23, 20, 0.7);
  --scrim: rgba(0, 0, 0, 0.55);
  --toast: #e5f3ef;
  --on-toast: #0c231f;
  --shadow-s: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 30px -18px rgba(0, 0, 0, 0.7);
  --shadow-m: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 26px 60px -26px rgba(0, 0, 0, 0.75);
  --a1: rgba(110, 231, 183, 0.24);
  --a2: rgba(125, 211, 252, 0.18);
  --a3: rgba(196, 181, 253, 0.14);
  --live-bg: #0f3b33;
  --up-bg: #0f3a2e;
  --up-ink: #a7f3d0;
  --splash-bg: #031210;
  --splash-ink: #e5f3ef;
  --tile-ic-bg: rgba(255, 255, 255, 0.1);
  --tile-ic-rim: rgba(255, 255, 255, 0.1);
  --tile-ic-glow: 26%;
  --tile-deco: rgba(255, 255, 255, 0.06);
  --tile-glass-top: rgba(255, 255, 255, 0.13);
  --tile-glass-bottom: rgba(52, 211, 153, 0.07);
  --tile-glass-glow: rgba(0, 0, 0, 0.5);
  --tile-pic-shadow: rgba(0, 0, 0, 0.35);
  --tile-glass-edge: rgba(255, 255, 255, 0.18);
  --tile-glass-sheen: rgba(255, 255, 255, 0.16);
  --lemon: #34d399;
  --lemon-rind: #10b981;
  --lemon-pith: #0f3a2e;
  --on-lemon: #03251b;
  --map-bg: #0a1c19;
  --map-park: #0f2e24;
  --map-block: #0e231f;
  --map-road: #18302b;
  --map-main: #1f3f37;
  --map-water: #0f2f45;
  --route: #34d399;
  --route-base: #2a4842;
  --p-lemon-bg: #3a2a0a;
  --p-lemon-fg: #fbbf24;
  --p-lemon-hd: #b45309;
  --p-lemon-hdi: #ffffff;
  --p-mint-bg: #0c3a2c;
  --p-mint-fg: #34d399;
  --p-mint-hd: #047857;
  --p-mint-hdi: #ffffff;
  --p-sky-bg: #0c2d44;
  --p-sky-fg: #38bdf8;
  --p-sky-hd: #0369a1;
  --p-sky-hdi: #ffffff;
  --p-rose-bg: #3f1420;
  --p-rose-fg: #fb7185;
  --p-rose-hd: #be123c;
  --p-rose-hdi: #ffffff;
  --p-lilac-bg: #2a1f4f;
  --p-lilac-fg: #a78bfa;
  --p-lilac-hd: #6d28d9;
  --p-lilac-hdi: #ffffff;
  --p-peach-bg: #3d2210;
  --p-peach-fg: #fb923c;
  --p-peach-hd: #c2410c;
  --p-peach-hdi: #ffffff;
  --color-canvas: 3 18 16;
  --color-surface: 10 28 25;
  --color-ink: 229 243 239;
  --color-muted: 162 185 179;
  --color-line: 24 48 43;
  --color-brand: 52 211 153;
  --color-on-brand: 3 37 27;
  --color-danger: 253 164 175;
  --shadow-card: 0 12px 30px -18px rgb(0 0 0 / 0.7);
}

/* Text direction drives mirrored icons: --flip is 1 in RTL and -1 in LTR (nearest dir attribute wins). */
[dir='rtl'] { --flip: 1; }
[dir='ltr'] { --flip: -1; }

/* Reduced motion: the OS preference or the in-app switch (<html data-motion="reduced">, see lib/motion.ts). */
@media (prefers-reduced-motion: reduce) {
  :root { --dur-ms: 0; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
:root[data-motion='reduced'] { --dur-ms: 0; }
:root[data-motion='reduced'] *, :root[data-motion='reduced'] *::before, :root[data-motion='reduced'] *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
