/* ==========================================================================
   PulseGrid — Design Tokens (Light Liquid Glass + High Contrast + Okabe-Ito)
   Zero external fonts, zero SVGs, local-first PWA
   ========================================================================== */

:root {
  color-scheme: light;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas,
    "Liberation Mono", Menlo, monospace;

  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.375rem;    /* 22px */
  --text-2xl: 1.75rem;    /* 28px */
  --text-3xl: 2.25rem;    /* 36px */

  /* Luminous Light Liquid Glass Canvas */
  --bg-base: #eef4fc;
  --bg-gradient:
    radial-gradient(62% 52% at 10% 6%, rgba(160, 212, 255, 0.56) 0%, rgba(160, 212, 255, 0) 70%),
    radial-gradient(54% 48% at 92% 10%, rgba(196, 181, 253, 0.44) 0%, rgba(196, 181, 253, 0) 68%),
    radial-gradient(58% 54% at 78% 92%, rgba(134, 239, 172, 0.36) 0%, rgba(134, 239, 172, 0) 72%),
    radial-gradient(52% 48% at 16% 88%, rgba(253, 224, 171, 0.34) 0%, rgba(253, 224, 171, 0) 70%),
    linear-gradient(155deg, #f6f9ff 0%, #eaf2fb 50%, #f1f7f5 100%);

  /* Translucent Glass Surfaces */
  --glass-bg: rgba(255, 255, 255, 0.66);
  --glass-bg-strong: rgba(255, 255, 255, 0.82);
  --glass-bg-subtle: rgba(255, 255, 255, 0.44);
  --glass-bg-inset: rgba(226, 236, 248, 0.52);
  --glass-bg-hover: rgba(255, 255, 255, 0.86);

  --glass-border-width: 1px;
  --glass-border: rgba(255, 255, 255, 0.82);
  --glass-border-outer: rgba(148, 169, 198, 0.28);
  --glass-border-strong: rgba(100, 128, 166, 0.38);
  --glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 -1px 0 rgba(148, 169, 198, 0.14);

  --glass-blur: 18px;
  --glass-saturate: 165%;

  /* Layered Liquid Depth Shadows */
  --shadow-xs: 0 2px 6px rgba(18, 38, 68, 0.05);
  --shadow-sm: 0 6px 18px rgba(18, 38, 68, 0.07),
    0 1px 2px rgba(18, 38, 68, 0.04);
  --shadow-md: 0 14px 34px rgba(18, 38, 68, 0.10),
    0 3px 10px rgba(18, 38, 68, 0.05);
  --shadow-lg: 0 24px 56px rgba(18, 38, 68, 0.16),
    0 6px 18px rgba(18, 38, 68, 0.08);
  --shadow-inset: inset 0 1px 3px rgba(18, 38, 68, 0.08);

  /* Ink Hierarchy */
  --ink-primary: #0f1b2d;
  --ink-secondary: #3b4f6b;
  --ink-muted: #5d7290;
  --ink-inverse: #ffffff;

  /* Brand & Semantic Accents */
  --accent-primary: #1a66f5;
  --accent-primary-hover: #1353cf;
  --accent-primary-soft: rgba(26, 102, 245, 0.12);
  --accent-primary-border: rgba(26, 102, 245, 0.32);

  --semantic-success: #0d9668;
  --semantic-success-soft: rgba(13, 150, 104, 0.13);
  --semantic-warning: #c97a08;
  --semantic-warning-soft: rgba(201, 122, 8, 0.14);
  --semantic-danger: #cf3547;
  --semantic-danger-soft: rgba(207, 53, 71, 0.12);

  /* Anti-Abandonment Semantic Colors */
  --shield-color: #1f6feb;
  --shield-bg: rgba(31, 111, 235, 0.13);
  --shield-border: rgba(31, 111, 235, 0.45);

  --vacation-color: #0e8296;
  --vacation-bg: rgba(14, 130, 150, 0.13);
  --vacation-border: rgba(14, 130, 150, 0.42);

  --discreet-color: #5b47c2;
  --discreet-bg: rgba(91, 71, 194, 0.12);

  /* Consistency Cell Levels (Default Light Palette) */
  --cell-0-bg: rgba(216, 228, 243, 0.52);
  --cell-0-border: rgba(140, 162, 192, 0.30);

  --cell-1-bg: #a9e6c9;
  --cell-1-border: #55bd8d;
  --cell-1-marker: #0c6244;

  --cell-2-bg: #3bc28c;
  --cell-2-border: #179464;
  --cell-2-marker: #ffffff;

  --cell-3-bg: #0c7e59;
  --cell-3-border: #06573d;
  --cell-3-ring: rgba(255, 255, 255, 0.88);
  --cell-3-marker: #fef08a;

  /* Momentum Gradient */
  --momentum-track: rgba(148, 169, 198, 0.24);
  --momentum-fill: linear-gradient(90deg, #38bdf8 0%, #1a66f5 52%, #0d9668 100%);

  /* Focus Ring */
  --focus-ring: 0 0 0 3px rgba(26, 102, 245, 0.38);

  /* Radii & Spacing */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --radius-pill: 9999px;
  --radius-squircle: 30%;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Layout Constraints */
  --app-max-width: 980px;
  --header-height: 68px;
  --tabbar-height: 70px;

  /* Z-index Layers */
  --z-sticky: 20;
  --z-tabbar: 30;
  --z-modal: 60;
  --z-tutorial: 80;
  --z-pin: 100;
  --z-toast: 120;

  /* Motion */
  --ease-fluid: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 340ms;
}

/* ==========================================================================
   Colorblind-Safe Palette: Okabe-Ito (data-colorblind="okabe-ito")
   Scientifically validated for Deuteranopia, Protanopia & Tritanopia
   ========================================================================== */
:root[data-colorblind="okabe-ito"] {
  --accent-primary: #0072b2;
  --accent-primary-hover: #005587;
  --accent-primary-soft: rgba(0, 114, 178, 0.14);
  --accent-primary-border: rgba(0, 114, 178, 0.42);

  --semantic-success: #009e73;
  --semantic-success-soft: rgba(0, 158, 115, 0.15);
  --semantic-warning: #e69f00;
  --semantic-warning-soft: rgba(230, 159, 0, 0.18);
  --semantic-danger: #d55e00;
  --semantic-danger-soft: rgba(213, 94, 0, 0.15);

  --shield-color: #b87800;
  --shield-bg: rgba(230, 159, 0, 0.18);
  --shield-border: rgba(213, 94, 0, 0.55);

  --vacation-color: #8f426f;
  --vacation-bg: rgba(204, 121, 167, 0.22);
  --vacation-border: rgba(143, 66, 111, 0.52);

  /* Okabe-Ito Distinct Cell Progression */
  --cell-1-bg: #8fd3f4;
  --cell-1-border: #3a96c9;
  --cell-1-marker: #003b5c;

  --cell-2-bg: #009e73;
  --cell-2-border: #006e50;
  --cell-2-marker: #ffffff;

  --cell-3-bg: #0072b2;
  --cell-3-border: #00466e;
  --cell-3-ring: #ffffff;
  --cell-3-marker: #f0e442;

  --momentum-fill: linear-gradient(90deg, #56b4e9 0%, #009e73 52%, #0072b2 100%);
  --focus-ring: 0 0 0 3px rgba(0, 114, 178, 0.45);
}

/* ==========================================================================
   High Contrast Mode (data-contrast="high") — WCAG AAA Solid Surfaces
   ========================================================================== */
:root[data-contrast="high"] {
  --bg-base: #f4f6f9;
  --bg-gradient: linear-gradient(180deg, #f7f9fc 0%, #eef1f6 100%);

  --glass-bg: #ffffff;
  --glass-bg-strong: #ffffff;
  --glass-bg-subtle: #f5f7fa;
  --glass-bg-inset: #e9edf3;
  --glass-bg-hover: #edf2f8;

  --glass-border-width: 2px;
  --glass-border: #111827;
  --glass-border-outer: #111827;
  --glass-border-strong: #000000;
  --glass-specular: none;

  --glass-blur: 0px;
  --glass-saturate: 100%;

  --shadow-xs: 0 1px 0 #111827;
  --shadow-sm: 0 2px 0 #111827;
  --shadow-md: 0 4px 0 #111827;
  --shadow-lg: 0 6px 0 #000000;
  --shadow-inset: none;

  --ink-primary: #000000;
  --ink-secondary: #111827;
  --ink-muted: #273244;
  --ink-inverse: #ffffff;

  --accent-primary: #0044cc;
  --accent-primary-hover: #002e8a;
  --accent-primary-soft: #e0ebff;
  --accent-primary-border: #0044cc;

  --semantic-success: #006b44;
  --semantic-success-soft: #d6f5e8;
  --semantic-warning: #8f4f00;
  --semantic-warning-soft: #fff0cc;
  --semantic-danger: #a8001f;
  --semantic-danger-soft: #ffe0e6;

  --shield-color: #003c9e;
  --shield-bg: #dbe9ff;
  --shield-border: #003c9e;

  --vacation-color: #005a6b;
  --vacation-bg: #d4f1f6;
  --vacation-border: #005a6b;

  --discreet-color: #3d1fa8;
  --discreet-bg: #e7e1ff;

  --cell-0-bg: #ffffff;
  --cell-0-border: #1f2937;

  --cell-1-bg: #b8f0d4;
  --cell-1-border: #005737;
  --cell-1-marker: #000000;

  --cell-2-bg: #008055;
  --cell-2-border: #000000;
  --cell-2-marker: #ffffff;

  --cell-3-bg: #00422b;
  --cell-3-border: #000000;
  --cell-3-ring: #ffffff;
  --cell-3-marker: #ffee33;

  --momentum-track: #d1d9e6;
  --momentum-fill: #0044cc;

  --focus-ring: 0 0 0 3px #ffffff, 0 0 0 6px #000000;
}

/* High Contrast + Okabe-Ito Composition */
:root[data-contrast="high"][data-colorblind="okabe-ito"] {
  --accent-primary: #005387;
  --accent-primary-hover: #00385c;
  --accent-primary-soft: #d9f0ff;
  --accent-primary-border: #005387;

  --semantic-danger: #9c3d00;
  --semantic-danger-soft: #ffe7d6;

  --shield-color: #7d4f00;
  --shield-bg: #fff0c2;
  --shield-border: #7d4f00;

  --vacation-color: #6b244f;
  --vacation-bg: #f7dfee;
  --vacation-border: #6b244f;

  --cell-1-bg: #b5e4fb;
  --cell-1-border: #004c75;
  --cell-1-marker: #000000;

  --cell-2-bg: #007a58;
  --cell-2-border: #000000;
  --cell-2-marker: #ffffff;

  --cell-3-bg: #004b78;
  --cell-3-border: #000000;
  --cell-3-ring: #ffffff;
  --cell-3-marker: #f0e442;

  --momentum-fill: #005387;
}

/* Reduced Motion Respect */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 1ms;
    --dur-base: 1ms;
    --dur-slow: 1ms;
  }
}
