/*
 * Chạm Loa Design System V1 — tokens
 * Source: computed styles of public/demo-v2@399d25b (32 routes × 360/390/840/1440),
 * normalised per Owner decision OD-1104-08 ("gom khác biệt nhỏ, không đổi thiết kế").
 * Spec: docs/design/public-v2/foundation/14_DESIGN_SYSTEM_V1.md
 * Old demo hex → token map: apps/web/src/design-system/color-source-map.json
 * Served as a static asset; reference it ONLY through src/public-ui/assets.ts (versioned URL).
 *
 * Layer order: tokens < base < legacy (pre-Design-System CSS, e.g. s304-product.css,
 * wrapped in @layer legacy) < demo (CSS ported verbatim from Demo V2, DEMO_V2_PARITY_RULES §4)
 * < components < families < utilities. Ported
 * components therefore always win over legacy CSS without !important.
 * Layers: primitives (--cl-*) are raw values and are NEVER used by components
 * directly. Components use semantic tokens. Page families may override
 * semantic tokens under [data-family="…"] only (no second theme).
 * Breakpoints (OD-1104-04, mobile-first): base < 761px, tablet ≥ 761px, desktop ≥ 1100px.
 * CSS custom properties cannot be used inside @media; use:
 *   @media (min-width: 761px)  { … }   tablet
 *   @media (min-width: 1100px) { … }   desktop
 */
@layer upgrade, tokens, base, legacy, demo, components, families, utilities;

@layer tokens {
:root {
  /* ── Stacking scale (GĐ15.1, OD-1109-01 (8)): one ladder for everything that floats over the page.
     Values are the ones the shell already used; Welcome Popup (160) and the deal card (66) slot into it. ── */
  --z-top: 32;            /* announcement bar / poster banner */
  --z-card: 66;           /* deal card (below the menu scrim, above page content) */
  --z-float: 67;          /* floating consult button */
  --z-scrim: 70;          /* mobile menu scrim */
  --z-panel: 71;          /* mobile menu drawer */
  --z-toast-low: 90;
  --z-drawer-scrim: 155;  /* consultation drawer scrim */
  --z-drawer: 156;        /* consultation drawer */
  --z-search-scrim: 110;
  --z-search: 111;        /* search and Saved panels */
  --z-toast-mid: 140;
  --z-modal: 160;         /* Welcome Popup */
  --z-consent: 165;       /* cookie notice */
  --z-privacy-scrim: 175;
  --z-privacy: 176;
  --z-toast-top: 200;
  --z-portals: 210;
  /* ── Primitive colours: name = hue family + CIE L* lightness (0 dark … 100 light) ── */
  --cl-neutral-100: #FFFFFF; /* 8.6% */
  --cl-neutral-94: #EFEFEF; /* 0.5% */
  --cl-neutral-95: #F0F1ED; /* 1.1% */
  --cl-neutral-98: #FAFAF7; /* canvas body (28/32 routes) */
  --cl-neutral-98a: #F7FAFB; /* header glass base */
  --cl-ocean-09: #101A20; /* 12.2% */
  --cl-ocean-15: #102932; /* 4.3% */
  --cl-ocean-21: #07364B; /* 1.0% */
  --cl-ocean-21a: #07384A; /* 3.3% */
  --cl-ocean-29: #2B4855; /* 0.6% */
  --cl-ocean-38: #415F6B; /* 0.8% */
  --cl-ocean-42: #526773; /* 1.8% */
  --cl-ocean-46: #527280; /* 5.5% */
  --cl-ocean-51: #07819C; /* 6.1% — demo #0785A1 (4.30:1 on white) darkened ΔE2000 1.5 to reach WCAG AA 4.54:1 */
  --cl-ocean-53: #6B8188; /* 0.4% */
  --cl-ocean-54: #5B8798; /* 1.3% */
  --cl-ocean-56: #3E91A6; /* 0.3% */
  --cl-ocean-82: #BCD0D8; /* 0.4% */
  --cl-ocean-84: #B6D8E2; /* 2.4% */
  --cl-ocean-89: #D5E2E8; /* 4.1% */
  --cl-ocean-95: #EAF3F6; /* 1.6% */
  --cl-sage-55: #71887D; /* 0.5% */
  --cl-sage-59: #78938B; /* 0.7% */
  --cl-sage-62: #87998E; /* 0.5% */
  --cl-sage-77: #B0C1B9; /* 2.5% */
  --cl-sage-88: #D6DFD8; /* 10.2% */
  --cl-sage-96: #EEF4EE; /* 3.2% */
  --cl-teal-15: #1C2929; /* 5.1% */
  --cl-teal-18: #173034; /* 0.4% */
  --cl-teal-21: #233537; /* 1.1% */
  --cl-teal-21a: #173838; /* 1.2% */
  --cl-teal-28: #364546; /* 0.3% */
  --cl-teal-33: #395352; /* 0.3% */
  --cl-teal-34: #15595C; /* 0.3% */
  --cl-teal-45: #52706E; /* 0.4% */
  --cl-teal-47: #087C88; /* 2.9% */
  --cl-teal-67: #8CA8A8; /* 1.5% */
  --cl-teal-76: #91C7BF; /* 0.6% */
  --cl-teal-77: #45D0D3; /* 0.6% */
  --cl-teal-78: #6ED1D2; /* 1.3% */
  --cl-teal-83: #81DBEA; /* 0.2% */
  --cl-teal-83a: #C3D3D1; /* 0.9% */
  --cl-teal-90: #BCE9F1; /* 1.2% */
  --cl-teal-91: #DCE8EA; /* 0.3% */
  --cl-teal-95: #D8F5F7; /* 0.7% */
  /* ── Semantic: surfaces ── */
  --surface-canvas: var(--cl-neutral-98);          /* page background */
  --surface-canvas-cool: var(--cl-neutral-98a);    /* header bar base (used at 97% opacity) */
  --surface-raised: var(--cl-neutral-100);         /* cards, panels, drawers */
  --surface-quiet: var(--cl-sage-96);              /* soft section band (warm) */
  --surface-quiet-cool: var(--cl-ocean-95);        /* soft section band (cool) */
  --surface-editorial: var(--cl-neutral-95);       /* editorial paper */
  --surface-muted: var(--cl-neutral-94);           /* media placeholder */
  --surface-tint: var(--cl-teal-95);               /* highlight tint */
  --surface-inverse: var(--cl-ocean-09);           /* dark band / footer */
  --surface-inverse-ocean: var(--cl-ocean-21);
  --surface-inverse-teal: var(--cl-teal-21a);
  --surface-inverse-deep: var(--cl-teal-18);
  --surface-scrim: rgb(16 26 32 / 0.56);           /* overlay behind dialogs/drawers */

  /* ── Semantic: text ── */
  --text-primary: var(--cl-ocean-09);
  --text-strong: var(--cl-ocean-15);
  --text-editorial: var(--cl-teal-15);
  --text-secondary: var(--cl-ocean-42);
  --text-muted: var(--cl-ocean-46);
  --text-subtle: var(--cl-teal-67);                /* OD-1104-11: decorative / ≥24px text ONLY (2.42:1); readable text uses --text-muted */
  --text-on-inverse: var(--cl-neutral-100);
  --text-on-inverse-soft: var(--cl-sage-96);       /* footer headings / body on dark */
  --text-on-inverse-muted: var(--cl-sage-88);
  --text-on-inverse-subtle: var(--cl-sage-77);
  --text-on-inverse-accent: var(--cl-teal-78);

  /* ── Semantic: actions / accent ── */
  --action-primary: var(--cl-ocean-51);            /* links, primary buttons on light */
  --action-editorial: var(--cl-teal-47);           /* editorial links on paper */
  --action-strong: var(--cl-ocean-21a);            /* solid button background */
  --accent-cyan: var(--cl-teal-77);                /* decoration, never body text on white */
  --accent-cyan-soft: var(--cl-teal-90);
  --focus-ring: var(--cl-ocean-51);

  /* ── Semantic: borders ── */
  --border-subtle: var(--cl-ocean-89);
  --border-default: var(--cl-teal-83a);
  --border-strong: var(--cl-ocean-46);
  --border-on-inverse: var(--cl-teal-28);
  --border-accent: var(--cl-ocean-56);

  /* ── Semantic: commerce (Deal / price / badges) ── */
  --price-text: var(--text-primary);
  --deal-signal-bg: var(--cl-teal-95);
  --deal-signal-text: var(--cl-teal-34);
  --badge-bg: var(--cl-ocean-09);                  /* Spotlight / Phổ biến / Hấp dẫn on image */
  --badge-text: var(--cl-neutral-100);

  /* ── Semantic: status (OD-1104-11 approved; WCAG AA on white and canvas: 6.57 / 4.87 / 5.32) ── */
  --status-danger: #B42318;
  --status-warning: #9A6700;
  --status-success: #1F7A4D;

  /* ── Typography ── */
  --font-sans: "Inter", "Helvetica Neue", Arial, sans-serif;  /* self-hosted Inter (base.css), OD-1104-11 */
  --font-serif: Georgia, "Times New Roman", serif;
  /* OD-1104-11 (Q-DS-02): no text below 12px; interactive labels ≥ 14px (--fs-ui).
     --fs-3xs/--fs-2xs keep their names for demo mapping but resolve to the 12px floor. */
  --fs-3xs: 12px;
  --fs-2xs: 12px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-ui: 14px;    /* minimum for interactive labels */
  --fs-md: 15px;
  --fs-base: 16px;  /* body text on mobile */
  --fs-lg: 18px;
  --fs-xl: 20px;
  --fs-2xl: 22px;
  --fs-3xl: clamp(23px, 1.6vw + 17px, 28px);
  --fs-4xl: clamp(28px, 2.2vw + 20px, 34px);
  --fs-5xl: clamp(32px, 3vw + 21px, 42px);
  --fs-display: clamp(38px, 5vw + 18px, 72px);
  --fs-display-xl: clamp(44px, 7vw + 16px, 100px); /* hero only */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 650;
  --fw-bold: 750;
  --fw-black: 800;
  --lh-tight: 1.05;
  --lh-heading: 1.15;
  --lh-snug: 1.35;
  --lh-body: 1.55;
  --ls-display: -0.03em;
  --ls-heading: -0.015em;
  --ls-eyebrow: 0.12em;

  /* ── Spacing: 4px grid (+2/6 for fine detail). Demo values within ±2px snap here. ── */
  --sp-0: 0;
  --sp-1: 2px;
  --sp-2: 4px;
  --sp-3: 6px;
  --sp-4: 8px;
  --sp-5: 12px;
  --sp-6: 16px;
  --sp-7: 20px;
  --sp-8: 24px;
  --sp-9: 28px;
  --sp-10: 32px;
  --sp-11: 40px;
  --sp-12: 48px;
  --sp-13: 56px;
  --sp-14: 64px;
  --sp-15: 80px;
  --sp-16: 96px;
  --sp-17: 128px;
  --section-y: clamp(48px, 6vw + 24px, 120px);   /* vertical rhythm between sections */
  --gutter: clamp(14px, 4.7vw, 76px);            /* page side padding (demo --pad) */

  /* ── Radius ── */
  --r-xs: 2px;
  --r-sm: 4px;      /* default for cards / inputs (most used in demo) */
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 14px;
  --r-2xl: 18px;
  --r-pill: 999px;
  --r-circle: 50%;

  /* ── Elevation (32 demo shadows → 6 roles) ── */
  --shadow-subtle: 0 2px 8px rgb(15 48 48 / 0.045);
  --shadow-card: 0 12px 30px rgb(6 30 44 / 0.22);
  --shadow-menu: 0 7px 25px rgb(0 0 0 / 0.2);
  --shadow-panel: 0 14px 40px rgb(0 0 0 / 0.133);
  --shadow-dialog: 0 15px 45px rgb(0 0 0 / 0.2);
  --shadow-drawer: -20px 0 40px rgb(0 0 0 / 0.2);
  --shadow-inset-accent: inset 4px 0 0 var(--action-editorial);

  /* ── Motion (76 demo durations → 4) ── */
  --dur-fast: 160ms;
  --dur-base: 200ms;
  --dur-slow: 260ms;
  --dur-reveal: 600ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-standard: cubic-bezier(.22, .68, .26, 1);

  /* ── Layout ── */
  --container-global: 1360px;   /* header/footer and most pages */
  --container-wide: 1480px;     /* family heroes / galleries */
  --container-reading: 820px;   /* article / policy body */
  --container-text: 720px;
  --header-height: 65px;
  --z-header: 50;
  --z-overlay: 80;
  --z-dialog: 90;
  --z-toast: 100;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur-base: 0ms; --dur-slow: 0ms; --dur-reveal: 0ms; }
}

/* ── Public standard OD-1111-08 (L0, 11/11) ─────────────────────────────────
 * One source for every upgraded part (OD-1111-25(4)). New variables only: parts not yet
 * rebuilt keep the Demo tokens above until their slice moves them here.
 * Mobile-first: the phone value is the default; ≥ 1100 px overrides (breakpoints OD-1104).
 * Story pages (Home, About, Campaign) have their own hero sizes (OD-1111-02(1), OD-1111-14(2)). */
:root {
  /* (1) Type scale — page / block / feature / card title, body, button & small, label. Never < 12px. */
  --std-fs-page: 36px;      /* 52 PC */
  --std-fs-block: 32px;     /* 46 PC */
  --std-fs-feature: 24px;   /* 32 PC */
  --std-fs-card: 20px;
  --std-fs-body: 15px;      /* 16 PC */
  --std-fs-small: 14px;     /* 15 PC — buttons and secondary text */
  --std-fs-label: 12px;     /* uppercase, letter-spaced */
  --std-ls-label: .08em;
  --std-fw-regular: 400;
  --std-fw-semibold: 600;
  --std-fw-bold: 700;
  --std-font-accent: Georgia, "Times New Roman", serif;  /* italic accent, weight 400 */
  --std-fs-input: 16px;     /* inputs/selects on phones: no iPhone zoom (5) */

  /* (2) Colour — every text ≥ 4.5:1 (≥ 3:1 from 18px). Copper only for offer / saving / ending soon. */
  --std-accent: #1d6b72;
  --std-ink: #13232a;
  --std-body: #3f524e;
  --std-muted: #5b6e6a;
  --std-line: #d6dfdb;
  --std-dark: #0f2a2e;
  --std-on-dark-accent: #9fd6cf;
  --std-copper: #a4502e;

  /* (3) Buttons and touch targets */
  --std-btn-main: 52px;
  --std-btn-card: 40px;
  --std-control: 44px;      /* chip, tab, input */
  --std-arrow-box: 40px;    /* square arrow with chevron */
  --std-touch: 44px;

  /* (4) Frame and rhythm */
  --std-frame: 1480px;
  --std-gutter: 20px;       /* 32 at 761–1099, 64 at ≥ 1100 */
  --std-block-gap: 64px;    /* 96 PC */
  --std-hub-hero: 460px;    /* 520 PC */
}
@media (min-width: 761px) {
  :root { --std-gutter: 32px; }
}
@media (min-width: 1100px) {
  :root {
    --std-fs-page: 52px; --std-fs-block: 46px; --std-fs-feature: 32px;
    --std-fs-body: 16px; --std-fs-small: 15px;
    --std-gutter: 64px; --std-block-gap: 96px; --std-hub-hero: 520px;
  }
}
}
