/* ==========================================================================
   家味 · Daily Table — Apple Design System Tokens (Light & Dark + Frosted Glass)
   ========================================================================== */

:root {
  color-scheme: light;

  /* Apple Light System Surfaces */
  --bg-canvas: #F5F5F7;
  --bg-surface: #FFFFFF;
  --bg-surface-secondary: #F5F5F8;
  --bg-seg-track: rgba(118, 118, 128, 0.10);
  --bg-thumb: #FFFFFF;
  --bg-fill-subtle: rgba(118, 118, 128, 0.09);
  --bg-fill-hover: rgba(118, 118, 128, 0.14);
  --bg-fill-active: rgba(118, 118, 128, 0.20);

  /* Translucent Frosted Materials (apple-design §12) */
  --glass-chrome: rgba(245, 245, 247, 0.72);
  --glass-sheet-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.76) 0%, rgba(246, 246, 251, 0.62) 100%);
  --glass-sheet-border: rgba(255, 255, 255, 0.78);
  --glass-sheet-rim: inset 0 1px 0 rgba(255, 255, 255, 0.92), inset 0 0 0 0.5px rgba(255, 255, 255, 0.45);
  --glass-block-bg: rgba(255, 255, 255, 0.54);
  --glass-block-border: rgba(255, 255, 255, 0.72);
  --glass-block-inner: rgba(255, 255, 255, 0.48);
  --glass-footer-bg: rgba(255, 255, 255, 0.42);
  --scrim-rgb: 15, 15, 20;
  --scrim-max: 0.24;

  /* Ink Hierarchy */
  --ink-primary: #1D1D1F;
  --ink-secondary: #6E6E73;
  --ink-tertiary: #86868B;
  --hairline: rgba(0, 0, 0, 0.075);
  --hairline-strong: rgba(0, 0, 0, 0.13);
  --header-fade: rgba(0, 0, 0, 0.07);
  --grabber-bg: rgba(0, 0, 0, 0.18);

  /* Apple System Accents (Light Mode) */
  --apple-blue: #0071E3;
  --apple-blue-hover: #0077ED;
  --apple-blue-soft: rgba(0, 113, 227, 0.11);

  --apple-green: #1E7E34;
  --apple-green-vivid: #28C840;
  --apple-green-soft: rgba(40, 200, 64, 0.13);

  --apple-orange: #B85D00;
  --apple-orange-vivid: #FF9500;
  --apple-orange-soft: rgba(255, 149, 0, 0.13);

  --apple-red: #D70015;
  --apple-red-vivid: #FF5F57;
  --apple-red-soft: rgba(255, 59, 48, 0.12);

  /* Authentic macOS / Apple Traffic Lights */
  --tl-red: #FF5F57;
  --tl-red-ring: #E0443E;
  --tl-red-glow: rgba(255, 95, 87, 0.42);

  --tl-yellow: #FEBC2E;
  --tl-yellow-ring: #DEA123;
  --tl-yellow-glow: rgba(254, 188, 46, 0.46);

  --tl-green: #28C840;
  --tl-green-ring: #1AAB29;
  --tl-green-glow: rgba(40, 200, 64, 0.42);

  --tl-off: rgba(0, 0, 0, 0.11);
  --tl-capsule-bg: rgba(0, 0, 0, 0.045);
  --tl-capsule-border: rgba(0, 0, 0, 0.06);

  /* Native System Typography */
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 9999px;

  /* Elevation */
  --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.036), 0 0 0 0.5px rgba(0, 0, 0, 0.055);
  --shadow-card-hover: 0 8px 26px rgba(0, 0, 0, 0.065), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  --shadow-thumb: 0 2px 8px rgba(0, 0, 0, 0.09), 0 0.5px 1px rgba(0, 0, 0, 0.06);
  --shadow-sheet: 0 28px 70px rgba(0, 0, 0, 0.20), 0 6px 20px rgba(0, 0, 0, 0.08);

  /* Toast */
  --toast-bg: rgba(29, 29, 31, 0.88);
  --toast-ink: #FFFFFF;

  /* Brand mark */
  --brand-bg: #1D1D1F;
  --brand-ink: #FFFFFF;
  --day-active-bg: #1D1D1F;
  --day-active-ink: #FFFFFF;

  /* Z-index layers */
  --z-sticky: 20;
  --z-header: 40;
  --z-sheet: 100;
  --z-toast: 200;
}

/* ==========================================================================
   Apple Official Dark Mode System Tokens (Elevated Dark Surfaces, Never Inverted)
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-canvas: #0B0B0D;
  --bg-surface: #1C1C1E;
  --bg-surface-secondary: #262629;
  --bg-seg-track: rgba(118, 118, 128, 0.24);
  --bg-thumb: #3A3A3C;
  --bg-fill-subtle: rgba(255, 255, 255, 0.08);
  --bg-fill-hover: rgba(255, 255, 255, 0.13);
  --bg-fill-active: rgba(255, 255, 255, 0.19);

  /* Premium Dark Frosted Glass */
  --glass-chrome: rgba(18, 18, 21, 0.72);
  --glass-sheet-bg: linear-gradient(160deg, rgba(48, 48, 54, 0.74) 0%, rgba(26, 26, 30, 0.64) 100%);
  --glass-sheet-border: rgba(255, 255, 255, 0.18);
  --glass-sheet-rim: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --glass-block-bg: rgba(255, 255, 255, 0.065);
  --glass-block-border: rgba(255, 255, 255, 0.10);
  --glass-block-inner: rgba(255, 255, 255, 0.055);
  --glass-footer-bg: rgba(20, 20, 24, 0.42);
  --scrim-rgb: 0, 0, 0;
  --scrim-max: 0.52;

  /* Dark Ink Hierarchy */
  --ink-primary: #F5F5F7;
  --ink-secondary: #A1A1A6;
  --ink-tertiary: #75757A;
  --hairline: rgba(255, 255, 255, 0.085);
  --hairline-strong: rgba(255, 255, 255, 0.15);
  --header-fade: rgba(255, 255, 255, 0.10);
  --grabber-bg: rgba(255, 255, 255, 0.28);

  /* Dark Mode Apple Accents (HIG brightened luminance) */
  --apple-blue: #0A84FF;
  --apple-blue-hover: #3399FF;
  --apple-blue-soft: rgba(10, 132, 255, 0.18);

  --apple-green: #32D74B;
  --apple-green-vivid: #30D158;
  --apple-green-soft: rgba(48, 209, 88, 0.16);

  --apple-orange: #FF9F0A;
  --apple-orange-vivid: #FF9F0A;
  --apple-orange-soft: rgba(255, 159, 10, 0.17);

  --apple-red: #FF6961;
  --apple-red-vivid: #FF453A;
  --apple-red-soft: rgba(255, 69, 58, 0.17);

  /* Dark Mode Traffic Lights (luminous against dark elevated surfaces) */
  --tl-red-glow: rgba(255, 95, 87, 0.55);
  --tl-yellow-glow: rgba(254, 188, 46, 0.55);
  --tl-green-glow: rgba(40, 200, 64, 0.55);
  --tl-off: rgba(255, 255, 255, 0.12);
  --tl-capsule-bg: rgba(255, 255, 255, 0.055);
  --tl-capsule-border: rgba(255, 255, 255, 0.09);

  /* Dark Elevation */
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.32), 0 0 0 0.5px rgba(255, 255, 255, 0.09);
  --shadow-card-hover: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 0 0.5px rgba(255, 255, 255, 0.14);
  --shadow-thumb: 0 2px 8px rgba(0, 0, 0, 0.36), 0 0 0 0.5px rgba(255, 255, 255, 0.10);
  --shadow-sheet: 0 32px 80px rgba(0, 0, 0, 0.62), 0 8px 24px rgba(0, 0, 0, 0.38);

  --toast-bg: rgba(44, 44, 48, 0.90);
  --toast-ink: #F5F5F7;

  --brand-bg: #F5F5F7;
  --brand-ink: #1D1D1F;
  --day-active-bg: #F5F5F7;
  --day-active-ink: #1D1D1F;
}

/* Reduced Transparency Support (apple-design §14) */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --glass-chrome: var(--bg-canvas);
    --glass-sheet-bg: var(--bg-surface);
    --glass-block-bg: var(--bg-surface-secondary);
    --glass-footer-bg: var(--bg-surface);
  }
}

/* Higher Contrast Support */
@media (prefers-contrast: more) {
  :root {
    --hairline: rgba(0, 0, 0, 0.24);
    --ink-secondary: #3A3A3C;
  }
  :root[data-theme="dark"] {
    --hairline: rgba(255, 255, 255, 0.26);
    --ink-secondary: #D1D1D6;
  }
}
