/*
  TRF color system (better-colors)
  Tier 1 — primitives, named by hue. Never used in components.
  Tier 2 — semantic tokens, named by role. The only tier components read.

  Brand pins: #164A78 = oklch(0.40 0.0945 249.33) → --navy-600
              #FF6915 = oklch(0.70 0.2001 43.18) → --orange-500
  Neutral is tinted toward the navy hue (chroma 0.007–0.018) and holds H 249.33.
  Every primitive below is consumed by at least one role; values are inside sRGB.
*/
:root {
  color-scheme: light;

  /* ---------- Primitives ---------- */
  --gray-50:  oklch(0.985 0.007 249.33); /* #f7fbff */
  --gray-100: oklch(0.968 0.008 249.33); /* #f0f5fa */
  --gray-200: oklch(0.905 0.010 249.33); /* #dbe0e6 */
  --gray-300: oklch(0.835 0.012 249.33); /* #c3cad1 */
  --gray-500: oklch(0.600 0.018 249.33); /* #78818b */
  --gray-600: oklch(0.470 0.018 249.33); /* #535c65 */
  --gray-900: oklch(0.220 0.018 249.33); /* #141b23 */
  --white:    oklch(1 0 0);

  --navy-300: oklch(0.775 0.061 249.33);  /* #98badc */
  --navy-500: oklch(0.470 0.080 249.33);  /* #355e86 */
  --navy-600: oklch(0.400 0.0945 249.33); /* #164a78 brand */
  --navy-900: oklch(0.250 0.060 249.33);  /* #06233d */
  --navy-950: oklch(0.200 0.049 249.33);  /* #02172b */

  --orange-50:  oklch(0.968 0.016 43.18);  /* #fff1ec */
  --orange-200: oklch(0.835 0.096 43.18);  /* #ffb597 */
  --orange-500: oklch(0.700 0.2001 43.18); /* #ff6915 brand */
  --orange-600: oklch(0.645 0.190 43.18);  /* #e75b01 */
  --orange-700: oklch(0.560 0.165 43.18);  /* #bf4a01 */

  --red-50:  oklch(0.960 0.020 22.2); /* #ffedec */
  --red-600: oklch(0.520 0.190 22.2); /* #be2132 — 21° from accent hue */

  /* ---------- Semantic: surfaces ---------- */
  --color-bg-page:          var(--gray-50);
  --color-bg-subtle:        var(--gray-100);
  --color-bg-surface:       var(--white);
  --color-bg-sunken:        var(--white);
  --color-bg-inverse:       var(--navy-950);
  --color-bg-inverse-raised: var(--navy-900);
  --color-bg-brand:         var(--navy-600);
  --color-bg-overlay:       oklch(0.200 0.049 249.33 / 0.62);

  /* ---------- Semantic: text ---------- */
  --color-text-primary:   var(--gray-900);  /* 16.7:1 on page */
  --color-text-secondary: var(--gray-600);  /* 6.5:1 on page, 6.2:1 on subtle */
  --color-text-inverse:   var(--white);
  --color-text-on-accent: var(--gray-900);  /* 6.0:1 on accent-solid; white would be 2.9:1 */

  /* ---------- Semantic: borders ---------- */
  --color-border-separator: var(--gray-200);
  --color-border:           var(--gray-300);
  --color-border-strong:    var(--gray-500); /* inputs: 3.95:1 on white */
  --color-focus-ring:       var(--navy-600); /* 9.2:1 on white */

  /* ---------- Semantic: accent (orange = action) ---------- */
  --color-accent-subtle:     var(--orange-50);
  --color-accent-border:     var(--orange-200);
  --color-accent-solid:      var(--orange-500);
  --color-accent-solid-hover: var(--orange-600); /* text-on-accent 4.9:1 */
  --color-accent-text:       var(--orange-700); /* 5.0:1 on white, 4.5:1 on accent-subtle */

  /* ---------- Semantic: status ---------- */
  --color-danger-subtle: var(--red-50);
  --color-danger-text:   var(--red-600); /* 6.1:1 on white */

  /* ---------- Motion (emil-design-eng) ---------- */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  /* ---------- Type & shape ---------- */
  --font-display: "Montserrat", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-raised: 0 1px 2px oklch(0.22 0.018 249.33 / 0.06), 0 8px 24px -8px oklch(0.22 0.018 249.33 / 0.14);
  --shadow-dialog: 0 24px 64px -16px oklch(0.2 0.049 249.33 / 0.45);
}

/*
  Inverse context: dark navy sections repoint the same roles,
  so components inside them need no special-casing.
*/
.theme-inverse {
  --color-bg-surface:       var(--navy-900);
  --color-bg-sunken:        var(--navy-950);
  --color-text-primary:     var(--white);     /* 18.1:1 on navy-950 */
  --color-text-secondary:   var(--navy-300);  /* 9.0:1 on navy-950, 7.9:1 on navy-900 */
  --color-border-separator: var(--navy-900);
  --color-border:           var(--navy-500);  /* decorative only */
  --color-border-strong:    var(--navy-300);
  --color-focus-ring:       var(--orange-500); /* 6.3:1 on navy-950 */
  --color-accent-text:      var(--orange-500); /* 6.3:1 on navy-950, 5.5:1 on navy-900 */
  color: var(--color-text-primary);
}

@media (prefers-contrast: more) {
  :root {
    --color-text-secondary: var(--gray-900);
    --color-border-strong:  var(--gray-600);
  }
  .theme-inverse {
    --color-text-secondary: var(--white);
    --color-border-strong:  var(--white);
  }
}
