/*
 * AVMELIO Business design tokens — the unified KoreaHisob system (architecture 11 §5.1, ADR-0013, ADR-0021,
 * audit 04 §2 and §7). Seeded from YukHisob's :root; semantic --avb-* names, legacy short names as aliases.
 *
 * This is the ONLY stylesheet allowed to contain colour literals (tests/web/tokens-lint.test.mjs).
 * Theme: auto (no attribute, follows the device) / light / dark via data-theme on <html>; any element may
 * carry data-theme to scope a theme (component gallery).
 *
 * Breakpoints (CSS cannot read custom properties in media queries; keep in sync with web/ui/breakpoints.js):
 *   720px  — bottom sheet becomes a centred dialog; phone bottom bar becomes top navigation
 *   1010px — wider header and the status line (ADR-0021: no sidebar on any device); card lists become column tables
 */

/* Manrope variable (weight 200–800), self-hosted from vendor/ (OFL-1.1, see vendor/NOTICE.md). */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/vendor/fonts/manrope/manrope-cyrillic-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/vendor/fonts/manrope/manrope-cyrillic-wght-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/vendor/fonts/manrope/manrope-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/vendor/fonts/manrope/manrope-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------- theme-independent scales */
:root {
  /* typography */
  --avb-font-body: 'Manrope', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --avb-font-display: 'Manrope', 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --avb-font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --avb-tracking: -0.01em;
  --avb-tracking-tight: -0.02em;
  --avb-tracking-title: -0.04em;
  --avb-text-2xs: 10.5px; /* phone nav label */
  --avb-text-xs: 11.5px; /* badge, status pill */
  --avb-text-sm: 13px; /* field label, hint, muted */
  --avb-text-button-sm: 13.5px;
  --avb-text-nav: 14px;
  --avb-text-toast: 14.5px;
  --avb-text-md: 15px; /* body, button */
  --avb-text-row: 15.5px; /* list row title */
  --avb-text-field: 16px; /* never below 16px: iOS focus zoom */
  --avb-text-lg: 17px; /* card title, confirm title */
  --avb-text-h2: 18px;
  --avb-text-xl: 19px; /* sheet title */
  --avb-text-brand: 20px;
  --avb-text-kpi: 20px; /* 24px from 720px */
  --avb-text-h1: 28px; /* 30px from 720px */
  --avb-weight-regular: 500; /* Manrope axis starts low; 500 matches the reference's effective weight */
  --avb-weight-label: 590;
  --avb-weight-strong: 650;
  --avb-weight-bold: 700;
  --avb-weight-heavy: 800;
  --avb-leading: 1.47;
  --avb-leading-tight: 1.15;

  /* spacing scale (4-8-12-16-20-28 plus the half steps the reference uses) */
  --avb-space-0: 2px;
  --avb-space-1: 4px;
  --avb-space-1h: 6px;
  --avb-space-2: 8px;
  --avb-space-2h: 10px;
  --avb-space-3: 12px;
  --avb-space-3h: 14px;
  --avb-space-4: 16px;
  --avb-space-5: 20px;
  --avb-space-6: 28px;
  --avb-space-7: 40px;
  --avb-gutter: 16px; /* 28px from 720px */
  --avb-content-max: 1440px;
  --avb-topnav-height: 60px;

  /* control heights */
  --avb-control-sm: 40px;
  --avb-control-md: 44px;
  --avb-control-field: 46px;
  --avb-control-lg: 48px;
  --avb-nav-bar-height: 64px;

  /* radii */
  --avb-radius-xs: 8px;
  --avb-radius-sm: 10px;
  --avb-radius-md: 12px;
  --avb-radius-control: 14px;
  --avb-radius-nav: 16px;
  --avb-radius-card: 18px;
  --avb-radius-tile: 16px;
  --avb-radius-panel: 20px;
  --avb-radius-sheet: 22px;
  --avb-radius-pill: 999px;
  --avb-radius-round: 50%;

  /* blur */
  --avb-blur-card: blur(14px);
  --avb-blur-header: blur(16px);
  --avb-blur-glass: saturate(180%) blur(20px);

  /* motion */
  --avb-ease-standard: cubic-bezier(0.2, 0.8, 0.2, 1);
  --avb-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --avb-duration-press: 120ms;
  --avb-duration-fast: 150ms;
  --avb-duration-base: 200ms;
  --avb-duration-screen: 260ms;
  --avb-duration-dialog: 280ms;
  --avb-duration-sheet: 340ms;
  --avb-duration-spin: 800ms;
  --avb-press-scale: 0.97;
  --avb-press-scale-icon: 0.92;

  /* z-index layers */
  --avb-z-sticky: 2;
  --avb-z-header: 20;
  --avb-z-nav: 25;
  --avb-z-sheet: 30;
  --avb-z-overlay: 40;
  --avb-z-confirm: 60;
  --avb-z-viewer: 80;
  --avb-z-toast: 90;

  /* safe areas */
  --avb-safe-top: env(safe-area-inset-top, 0px);
  --avb-safe-right: env(safe-area-inset-right, 0px);
  --avb-safe-bottom: env(safe-area-inset-bottom, 0px);
  --avb-safe-left: env(safe-area-inset-left, 0px);

  /* adhesive labels (architecture 17): always black on white, whatever the theme */
  --avb-label-ink: #000000;
  --avb-label-paper: #ffffff;
}

@media (min-width: 720px) {
  :root {
    --avb-gutter: 28px;
    --avb-text-h1: 30px;
    --avb-text-kpi: 24px;
  }
}

/* ---------------------------------------------------------------- light (default)
 * Phase 5 (ADR-0021): the KoreaHisob release-8 Apple palette — neutral greys, white cards, one blue accent.
 * Contrast (WCAG 2.1): text 15.9:1, muted 5.9:1 on --avb-surface; white on --avb-accent-solid 4.7:1. */
:root,
[data-theme='light'] {
  color-scheme: light;
  --avb-bg: #f3f5f9;
  --avb-bg-aurora: radial-gradient(1100px 560px at 100% -12%, rgba(0, 113, 227, 0.07), transparent 62%);
  --avb-surface: #ffffff;
  --avb-surface-2: #f5f7fb;
  --avb-surface-3: rgba(16, 32, 72, 0.07);
  --avb-surface-sheet: #ffffff;
  --avb-glass: rgba(255, 255, 255, 0.86);
  --avb-glass-border: rgba(16, 32, 72, 0.09);
  --avb-header: rgba(255, 255, 255, 0.84);
  --avb-nav: rgba(255, 255, 255, 0.9);
  --avb-nav-active: #0071e3;
  --avb-nav-active-text: #ffffff;
  --avb-field: #ffffff;
  --avb-menu: #ffffff;
  --avb-scrim: rgba(9, 16, 34, 0.36);

  --avb-text: #111827;
  --avb-text-2: #1f2a44;
  --avb-text-muted: #5b6478;
  --avb-figure: #0b1220;

  --avb-accent: #0071e3;
  --avb-accent-solid: #0066d6;
  --avb-accent-text: #0058b9;
  --avb-accent-soft: rgba(0, 113, 227, 0.1);
  --avb-button: #0071e3;
  --avb-button-text: #ffffff;
  --avb-button-shadow: 0 6px 18px rgba(0, 113, 227, 0.24);

  --avb-success: #11703a;
  --avb-success-soft: rgba(52, 199, 89, 0.15);
  --avb-danger: #c4141f;
  --avb-danger-soft: rgba(255, 59, 48, 0.11);
  --avb-warning: #965000;
  --avb-warning-soft: rgba(255, 149, 0, 0.15);
  --avb-info: #3a3fb0;
  --avb-info-soft: rgba(88, 86, 214, 0.12);

  --avb-border: rgba(16, 32, 72, 0.09);
  --avb-border-strong: rgba(16, 32, 72, 0.16);
  --avb-border-input: #7b8396;
  --avb-border-focus: #0071e3;
  --avb-focus-ring: rgba(0, 113, 227, 0.45);
  --avb-swatch-border: rgba(17, 24, 39, 0.42);

  --avb-shadow-1: 0 1px 2px rgba(16, 32, 72, 0.05), 0 1px 1px rgba(16, 32, 72, 0.03);
  --avb-shadow-2: 0 10px 30px rgba(16, 32, 72, 0.1), 0 1px 3px rgba(16, 32, 72, 0.06);
  --avb-shadow-3: 0 28px 72px rgba(9, 16, 34, 0.24);
  --avb-shadow-segment: 0 1px 3px rgba(16, 32, 72, 0.14);

  /* data visualisation: five categorical hues, distinguishable for common colour-vision deficiencies */
  --avb-chart-1: #0071e3;
  --avb-chart-2: #8e44ec;
  --avb-chart-3: #12a594;
  --avb-chart-4: #f5a524;
  --avb-chart-5: #8f98aa;
  --avb-chart-fill: rgba(0, 113, 227, 0.16);
  --avb-chart-grid: rgba(16, 32, 72, 0.08);
  --avb-hero: linear-gradient(135deg, #0a5bd8 0%, #0071e3 55%, #3c9bff 100%);
  --avb-hero-text: #ffffff;
}

/* ---------------------------------------------------------------- dark: device preference (auto)
 * Navy dark (ADR-0021, approved MobiCore reference). Contrast: text 16.2:1, muted 7.1:1 on --avb-surface. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --avb-bg: #070b16;
    --avb-bg-aurora: radial-gradient(1100px 560px at 100% -12%, rgba(10, 132, 255, 0.12), transparent 62%);
    --avb-surface: #0f1626;
    --avb-surface-2: #151e33;
    --avb-surface-3: rgba(255, 255, 255, 0.09);
    --avb-surface-sheet: #121a2d;
    --avb-glass: rgba(12, 18, 32, 0.88);
    --avb-glass-border: rgba(255, 255, 255, 0.08);
    --avb-header: rgba(8, 12, 24, 0.82);
    --avb-nav: rgba(18, 26, 45, 0.92);
    --avb-nav-active: #0a6fe0; /* white text 4.8:1 (was #0a84ff: 3.6:1, below WCAG AA) */
    --avb-nav-active-text: #ffffff;
    --avb-field: #0c1322;
    --avb-menu: #151e33;
    --avb-scrim: rgba(0, 0, 0, 0.6);
    --avb-text: #f2f5fc;
    --avb-text-2: #d7deee;
    --avb-text-muted: #9aa5bf;
    --avb-figure: #ffffff;
    --avb-accent: #3d9bff;
    --avb-accent-solid: #0a6fe0;
    --avb-accent-text: #6cb4ff;
    --avb-accent-soft: rgba(10, 132, 255, 0.18);
    --avb-button: #0a6fe0;
    --avb-button-text: #ffffff;
    --avb-button-shadow: 0 8px 22px rgba(10, 132, 255, 0.28);
    --avb-success: #4ade80;
    --avb-success-soft: rgba(48, 209, 88, 0.16);
    --avb-danger: #ff7b72;
    --avb-danger-soft: rgba(255, 69, 58, 0.17);
    --avb-warning: #ffb547;
    --avb-warning-soft: rgba(255, 159, 10, 0.17);
    --avb-info: #b7b9ff;
    --avb-info-soft: rgba(94, 92, 230, 0.2);
    --avb-border: rgba(255, 255, 255, 0.08);
    --avb-border-strong: rgba(255, 255, 255, 0.15);
    --avb-border-input: #6f7a95;
    --avb-border-focus: #3d9bff;
    --avb-focus-ring: rgba(61, 155, 255, 0.75);
    --avb-swatch-border: rgba(200, 208, 232, 0.6);
    --avb-shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.02);
    --avb-shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 14px 36px rgba(0, 0, 0, 0.45);
    --avb-shadow-3: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.65);
    --avb-shadow-segment: 0 1px 3px rgba(0, 0, 0, 0.4);
    --avb-chart-1: #3d9bff;
    --avb-chart-2: #b07cff;
    --avb-chart-3: #2dd4bf;
    --avb-chart-4: #fbbf24;
    --avb-chart-5: #8b95ab;
    --avb-chart-fill: rgba(61, 155, 255, 0.22);
    --avb-chart-grid: rgba(255, 255, 255, 0.07);
    --avb-hero: linear-gradient(135deg, #0b2a66 0%, #0a4fb8 60%, #1679f0 100%);
    --avb-hero-text: #ffffff;
  }
}

/* ---------------------------------------------------------------- dark: forced (same values as above) */
:root[data-theme='dark'],
[data-theme='dark'] {
  color-scheme: dark;
  --avb-bg: #070b16;
  --avb-bg-aurora: radial-gradient(1100px 560px at 100% -12%, rgba(10, 132, 255, 0.12), transparent 62%);
  --avb-surface: #0f1626;
  --avb-surface-2: #151e33;
  --avb-surface-3: rgba(255, 255, 255, 0.09);
  --avb-surface-sheet: #121a2d;
  --avb-glass: rgba(12, 18, 32, 0.88);
  --avb-glass-border: rgba(255, 255, 255, 0.08);
  --avb-header: rgba(8, 12, 24, 0.82);
  --avb-nav: rgba(18, 26, 45, 0.92);
  --avb-nav-active: #0a6fe0; /* white text 4.8:1 (was #0a84ff: 3.6:1, below WCAG AA) */
  --avb-nav-active-text: #ffffff;
  --avb-field: #0c1322;
  --avb-menu: #151e33;
  --avb-scrim: rgba(0, 0, 0, 0.6);
  --avb-text: #f2f5fc;
  --avb-text-2: #d7deee;
  --avb-text-muted: #9aa5bf;
  --avb-figure: #ffffff;
  --avb-accent: #3d9bff;
  --avb-accent-solid: #0a6fe0;
  --avb-accent-text: #6cb4ff;
  --avb-accent-soft: rgba(10, 132, 255, 0.18);
  --avb-button: #0a6fe0;
  --avb-button-text: #ffffff;
  --avb-button-shadow: 0 8px 22px rgba(10, 132, 255, 0.28);
  --avb-success: #4ade80;
  --avb-success-soft: rgba(48, 209, 88, 0.16);
  --avb-danger: #ff7b72;
  --avb-danger-soft: rgba(255, 69, 58, 0.17);
  --avb-warning: #ffb547;
  --avb-warning-soft: rgba(255, 159, 10, 0.17);
  --avb-info: #b7b9ff;
  --avb-info-soft: rgba(94, 92, 230, 0.2);
  --avb-border: rgba(255, 255, 255, 0.08);
  --avb-border-strong: rgba(255, 255, 255, 0.15);
  --avb-border-input: #6f7a95;
  --avb-border-focus: #3d9bff;
  --avb-focus-ring: rgba(61, 155, 255, 0.75);
  --avb-swatch-border: rgba(200, 208, 232, 0.6);
  --avb-shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.02);
  --avb-shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 14px 36px rgba(0, 0, 0, 0.45);
  --avb-shadow-3: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.65);
  --avb-shadow-segment: 0 1px 3px rgba(0, 0, 0, 0.4);
  --avb-chart-1: #3d9bff;
  --avb-chart-2: #b07cff;
  --avb-chart-3: #2dd4bf;
  --avb-chart-4: #fbbf24;
  --avb-chart-5: #8b95ab;
  --avb-chart-fill: rgba(61, 155, 255, 0.22);
  --avb-chart-grid: rgba(255, 255, 255, 0.07);
  --avb-hero: linear-gradient(135deg, #0b2a66 0%, #0a4fb8 60%, #1679f0 100%);
  --avb-hero-text: #ffffff;
}

/* ---------------------------------------------------------------- legacy aliases (port period only) */
:root,
[data-theme] {
  --bg: var(--avb-bg);
  --aBg: var(--avb-bg-aurora);
  --card: var(--avb-surface);
  --surface-2: var(--avb-surface-2);
  --surface-3: var(--avb-surface-3);
  --sheet: var(--avb-surface-sheet);
  --glass: var(--avb-glass);
  --glassBd: var(--avb-glass-border);
  --topBg: var(--avb-header);
  --navBg: var(--avb-nav);
  --navOn: var(--avb-nav-active);
  --inp: var(--avb-field);
  --optBg: var(--avb-menu);
  --scrim: var(--avb-scrim);
  --tx: var(--avb-text);
  --tx2: var(--avb-text-2);
  --mu: var(--avb-text-muted);
  --kTx: var(--avb-figure);
  --pr: var(--avb-accent);
  --prSolid: var(--avb-accent-solid);
  --prText: var(--avb-accent-text);
  --prSoft: var(--avb-accent-soft);
  --btn: var(--avb-button);
  --btnTx: var(--avb-button-text);
  --btnSh: var(--avb-button-shadow);
  --ok: var(--avb-success);
  --okBg: var(--avb-success-soft);
  --bad: var(--avb-danger);
  --badBg: var(--avb-danger-soft);
  --warn: var(--avb-warning);
  --warnBg: var(--avb-warning-soft);
  --bd: var(--avb-border);
  --bd2: var(--avb-border-strong);
  --inpBd: var(--avb-border-input);
  --focusBd: var(--avb-border-focus);
  --ring: var(--avb-focus-ring);
  --dotBd: var(--avb-swatch-border);
  --sh1: var(--avb-shadow-1);
  --sh2: var(--avb-shadow-2);
  --sh3: var(--avb-shadow-3);
  --body: var(--avb-font-body);
  --display: var(--avb-font-display);
  --mono: var(--avb-font-mono);
  --ease: var(--avb-ease-standard);
  --out: var(--avb-ease-out);
  --gut: var(--avb-gutter);
}
