/* Design tokens. Everything visual reads from here, so a theme only touches this file.
   Source of truth: the PreçoVale design system (dark retail palette, price as the loudest element, one colour per chain).
   Two themes: DARK is the brand's own and the default; LIGHT is derived from it with the same emerald and amber, and every text
   pair is checked for WCAG AA (4.5:1 text, 3:1 large text and UI). The theme is picked by <html data-theme="dark|light"> (set by
   js/theme.js before the first paint); with no attribute it follows the device. */

/* ---------- Palette that does not change with the theme ---------- */
:root {
  --emerald-500: #10b981;   /* brand primary: economy and trust */
  --emerald-400: #34d399;   /* price and success on dark */
  --emerald-700: #047857;   /* price and links on light */
  --amber-500: #f59e0b;     /* offers and highlights */
  --focus-dark: #93c5fd;
  --focus-light: #1d4ed8;

  /* Store badges (flag colour of each chain): dark fill + light text, so they read the same on both themes. */
  --store-shibata-bg: #581c87;  --store-shibata-ink: #e9d5ff;
  --store-nagumo-bg: #7f1d1d;   --store-nagumo-ink: #fecaca;
  --store-assai-bg: #075985;    --store-assai-ink: #bae6fd;
  --store-atacadao-bg: #7c2d12; --store-atacadao-ink: #ffedd5;
  --store-maximo-bg: #14532d;   --store-maximo-ink: #bbf7d0;
  /* Chains the skill does not list yet: same recipe (dark fill, light text), hue kept from the first versions of the app. */
  --store-coop-bg: #1e3a8a;     --store-coop-ink: #dbeafe;
  --store-tenda-bg: #115e59;    --store-tenda-ink: #ccfbf1;
  --store-tauste-bg: #7c2d12;   --store-tauste-ink: #fed7aa;
  --store-barbosa-bg: #9f1239;  --store-barbosa-ink: #ffe4e6;
  --store-simpatia-bg: #3f6212; --store-simpatia-ink: #ecfccb;
  --store-other-bg: #14532d;    --store-other-ink: #bbf7d0;

  /* Typography: Inter when the device has it, otherwise its own system font. No web font is downloaded (first load stays light). */
  --font-sans: "Inter", "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-numeric: var(--font-sans);
}

/* ---------- DARK (default) ---------- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --page: #090d12;              /* canvas: bluish deep black, never pure #000 */
  --surface: #131b24;           /* elevation 1: cards, inputs */
  --surface-alt: #1a2430;       /* elevation 2: chips, touch states */
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: #7d8b99;
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;

  --primary: var(--emerald-500);
  --primary-hover: #34d399;
  --on-primary: #04130d;        /* dark text on the brand green: 7.5:1 (white would be 2.5:1) */
  --link: #6ee7b7;
  --link-hover: #a7f3d0;
  --ghost-hover-bg: #17302a;
  --text-price: var(--emerald-400);
  --accent: var(--amber-500);

  --success: #6ee7b7;
  --success-bg: #0f2e22;
  --warning-ink: #fde68a;
  --warning-bg: #2f2508;
  --warning-line: #8a7530;
  --danger: #fca5a5;
  --danger-bg: #381316;
  --danger-line: #7c3236;
  --info-bg: #15233d;
  --info-ink: #bfdbfe;
  --focus: var(--focus-dark);

  --backdrop: rgba(0, 0, 0, 0.6);
  --header-bg: #0c1a14;         /* header: a deeper green than the canvas, so the logo has a calm base */
  --header-ink: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 -8px 32px rgba(0, 0, 0, 0.6);
}

/* ---------- LIGHT ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f7f5;
  --surface: #ffffff;
  --surface-alt: #eaf2ee;
  --line: #d5dde0;
  --line-strong: #6b7782;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #475569;

  --primary: var(--emerald-500);
  --primary-hover: #0e9f6e;
  --on-primary: #04130d;
  --link: #047857;
  --link-hover: #065f46;
  --ghost-hover-bg: #dff3ea;
  --text-price: var(--emerald-700);   /* #34d399 would be 1.9:1 on white; #047857 is 5.5:1 */
  --accent: #b45309;

  --success: #146c43;
  --success-bg: #e3f4ea;
  --warning-ink: #6b4a00;
  --warning-bg: #fff4cc;
  --warning-line: #d9b84a;
  --danger: #a4161a;
  --danger-bg: #ffe1e1;
  --danger-line: #d98a8c;
  --info-bg: #e8f0fe;
  --info-ink: #1a3d7c;
  --focus: var(--focus-light);

  --backdrop: rgba(6, 32, 20, 0.45);
  --header-bg: #065f46;
  --header-ink: #ffffff;
  --shadow-sm: 0 1px 2px rgba(6, 32, 20, 0.08);
  --shadow-md: 0 4px 16px rgba(6, 32, 20, 0.12);
  --shadow-lg: 0 -8px 32px rgba(6, 32, 20, 0.18);
}

/* No explicit choice: follow the device. An explicit data-theme always wins over this block. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --page: #f3f7f5; --surface: #ffffff; --surface-alt: #eaf2ee; --line: #d5dde0; --line-strong: #6b7782;
    --ink: #0f172a; --ink-soft: #334155; --muted: #475569;
    --primary-hover: #0e9f6e; --link: #047857; --link-hover: #065f46; --ghost-hover-bg: #dff3ea;
    --text-price: var(--emerald-700); --accent: #b45309;
    --success: #146c43; --success-bg: #e3f4ea; --warning-ink: #6b4a00; --warning-bg: #fff4cc; --warning-line: #d9b84a;
    --danger: #a4161a; --danger-bg: #ffe1e1; --danger-line: #d98a8c; --info-bg: #e8f0fe; --info-ink: #1a3d7c;
    --focus: var(--focus-light); --backdrop: rgba(6, 32, 20, 0.45); --header-bg: #065f46; --header-ink: #ffffff;
    --shadow-sm: 0 1px 2px rgba(6, 32, 20, 0.08); --shadow-md: 0 4px 16px rgba(6, 32, 20, 0.12); --shadow-lg: 0 -8px 32px rgba(6, 32, 20, 0.18);
  }
}

/* ---------- Scales (same on both themes) ---------- */
:root {
  /* Spacing scale (4px base) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Typography */
  --text-xs: 0.78rem;
  --text-sm: 0.88rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.6rem;
  --text-3xl: 2rem;
  --leading-tight: 1.25;
  --leading: 1.5;


  /* Motion: interactions stay at 150-200ms and yield to reduced-motion. */
  --dur-fast: 150ms;
  --dur: 200ms;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);

  /* Layout */
  --container: 44rem;
  --tap: 44px;
  /* The rendered height of the sticky app header (52px). Pages that start under it read this, never a magic number. */
  --header-h: 52px;

  /* Layers */
  --z-header: 100;
  --z-nav: 200;
  --z-sheet: 300;
  --z-toast: 400;
}
