/**
 * MechCore Theme — single source of truth for visual tokens.
 * Load first in HTML. Other stylesheets may @import this file.
 */

:root {
  /* BACKGROUNDS */
  --bg:           #0f0e0c;
  --surface:      #1c1a17;
  --surface-2:    #242118;
  --surface-3:    #2a2825;

  /* BORDERS */
  --border:       rgba(255,255,255,0.06);
  --border-gold:  rgba(200,169,110,0.25);
  --border-hover: rgba(200,169,110,0.5);

  /* GOLD — THE ONLY ACCENT COLOR */
  --gold:         #c8a96e;
  --gold-bright:  #d4b87a;
  --gold-deep:    #b89058;
  --gold-dim:     rgba(200,169,110,0.12);
  --gold-glow:    rgba(200,169,110,0.25);

  /* TEXT */
  --text:         #f0ede8;
  --text-muted:   #9c9a92;
  --text-dim:     #6b6963;

  /* STATUS */
  --critical:       #e05555;
  --critical-dim:   rgba(224,85,85,0.12);
  --critical-glow:  rgba(224,85,85,0.3);
  --high:           #e07a35;
  --high-dim:       rgba(224,122,53,0.12);
  --medium:         #c8a96e;
  --low:            #9c9a92;
  --ok:             #4ade80;
  --ok-dim:         rgba(74,222,128,0.12);
  --ok-glow:        rgba(74,222,128,0.25);

  /* SPACING — 4px base grid */
  --s1: 4px;   --s2: 8px;   --s3: 12px;  --s4: 16px;
  --s5: 24px;  --s6: 32px;  --s7: 48px;  --s8: 64px;

  /* RADII */
  --r-sm: 6px;   --r-md: 10px;
  --r-lg: 16px;  --r-xl: 24px;

  /* SHADOWS */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-gold: 0 4px 24px rgba(200,169,110,0.2);
  --shadow-critical: 0 4px 24px rgba(224,85,85,0.2);

  /* TRANSITIONS */
  --t-fast: 0.1s ease;
  --t-base: 0.2s ease;
  --t-slow: 0.3s ease;

  /* TYPOGRAPHY */
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', monospace;

  /* App-wide extras */
  --h: 18px;
  --b: 15px;
  --l: 13px;
  --border-strong: rgba(255,255,255,0.12);
  --border-sub: rgba(240,237,232,0.07);
  --gold-border: var(--border-hover);
  --critical-border: rgba(224,85,85,0.3);
  --ok-border: rgba(74,222,128,0.25);
  --amber: #f59e0b;
  --amber-dim: rgba(245,158,11,0.1);
  --amber-border: rgba(245,158,11,0.3);
  --blue: #2563eb;
  --blue-dim: rgba(37,99,235,0.08);
  --blue-border: rgba(37,99,235,0.28);
  --risk-orange: #ea580c;
  --risk-orange-dim: rgba(234,88,12,0.12);
  --risk-orange-border: rgba(234,88,12,0.35);

  --muted: var(--text-muted);
  --muted-2: var(--text-dim);
  --red: var(--critical);
  --green: var(--ok);
  --red-dim: var(--critical-dim);
  --red-border: var(--critical-glow);
  --green-dim: var(--ok-dim);
  --green-border: var(--ok-glow);
  --surface2: var(--surface-2);
  --surface3: var(--surface-3);

  --card-white: #ffffff;
  --card-fg: #111111;
  --card-fg-muted: #4c4a46;
  --card-fg-muted-2: #797470;
  --card-surface-2: #f3f3f1;
  --card-surface-3: #e8e8e5;
  --chrome-muted: #b0aea6;
  --gold-on-card: #9a7535;
  --status-red-on-card: #c42020;
  --status-green-on-card: #1a8c44;
  --status-amber-on-card: #a86400;
  --pill-green-fg: #0d4020;
  --pill-amber-fg: #4a2c00;
  --pill-red-fg: #5c0a0a;
  --pill-blue-fg: #0f2a6e;
  --light-ink: #1a1916;
}

/* GOLD — warm brown chrome; accent gold unchanged */
[data-theme="gold"] {
  --bg:        #1a1408;
  --surface:   #2a1f0a;
  --surface-2: #3a2d10;
  --surface-3: #4a3a18;
  --border:    rgba(200,169,110,0.2);
  --border-gold: rgba(200,169,110,0.5);
  --gold:        #c8a96e;
  --gold-bright: #e0c080;
  --text:      #f5e6c8;
  --text-muted:#b09060;
  --text-dim:  #806840;
  --shadow-gold: 0 4px 24px rgba(200,169,110,0.3);
  --muted: var(--text-muted);
  --muted-2: var(--text-dim);
  --surface2: var(--surface-2);
  --surface3: var(--surface-3);
  --gold-border: var(--border-gold);
  --gold-dim: rgba(200,169,110,0.14);
  --gold-deep: #b89058;
}

/* BRIGHT — light UI ([data-theme="light"] alias until storage migrates) */
[data-theme="bright"],
[data-theme="light"] {
  --bg:        #f7f6f3;
  --surface:   #ffffff;
  --surface-2: #f0efe9;
  --surface-3: #e8e6df;
  --border:    rgba(0,0,0,0.08);
  --border-gold: rgba(200,169,110,0.42);
  --gold:        #c8a96e;
  --gold-bright: #d4b87a;
  --gold-deep:   #b89058;
  --gold-dim:    rgba(200,169,110,0.14);
  --gold-glow:   rgba(200,169,110,0.28);
  --text:      #1a1917;
  --text-muted:#5c5a54;
  --text-dim:  #8a8880;
  --muted: var(--text-muted);
  --muted-2: var(--text-dim);
  --surface2: var(--surface-2);
  --surface3: var(--surface-3);
  --critical:     #c0392b;
  --critical-dim: rgba(192,57,43,0.08);
  --ok:           #1e8449;
  --ok-dim:       rgba(30,132,73,0.08);
  --high:         #d35400;
  --high-dim:     rgba(211,84,0,0.08);
  --red: var(--critical);
  --green: var(--ok);
  --red-dim: var(--critical-dim);
  --green-dim: var(--ok-dim);
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.14);
  --shadow-gold: 0 4px 24px rgba(200,169,110,0.2);
}

/* GLOBAL RESETS */
html {
  transition: background-color 0.2s ease, color 0.2s ease;
}
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.t-page    { font-size:24px; font-weight:600; letter-spacing:-0.02em; line-height:1.2; }
.t-section { font-size:18px; font-weight:600; letter-spacing:-0.01em; line-height:1.3; }
.t-card    { font-size:15px; font-weight:600; line-height:1.4; }
.t-body    { font-size:15px; font-weight:400; line-height:1.5; }
.t-label   { font-size:13px; font-weight:400; color:var(--text-muted); line-height:1.4; }
.t-badge   { font-size:11px; font-weight:600; letter-spacing:0.06em; text-transform:uppercase; }
.t-mono    { font-family:var(--font-mono); font-size:14px; font-weight:400; }
.t-mono-lg { font-family:var(--font-mono); font-size:24px; font-weight:500; }

/* --- Theme pills (Dark | Gold | Bright) --- */
.theme-switcher.theme-switcher--pills,
.theme-switcher--pills {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: transparent;
  border: none;
}
.theme-pill {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.theme-pill:hover { color: var(--text); }
.theme-pill.active {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 0 1px rgba(200, 169, 110, 0.35);
}
.theme-pill:active { transform: scale(0.97); }

[data-theme="bright"] .nav,
[data-theme="bright"] .hdr,
[data-theme="light"] .nav,
[data-theme="light"] .hdr {
  background: rgba(247, 246, 243, 0.95) !important;
}
[data-theme="bright"] nav,
[data-theme="light"] nav {
  background: rgba(247, 246, 243, 0.92) !important;
}
[data-theme="bright"] .carousel-wrap::after,
[data-theme="bright"] .def-carousel-wrap::after,
[data-theme="light"] .carousel-wrap::after,
[data-theme="light"] .def-carousel-wrap::after {
  background: linear-gradient(to left, #f7f6f3, transparent) !important;
}
[data-theme="bright"] .cc-card-wrap,
[data-theme="light"] .cc-card-wrap,
[data-theme="bright"] .def-card-wrap,
[data-theme="light"] .def-card-wrap {
  border-color: rgba(26, 25, 22, 0.1) !important;
  box-shadow: 0 2px 12px rgba(26, 25, 22, 0.07), 0 1px 3px rgba(26, 25, 22, 0.04) !important;
}
[data-theme="bright"] .cc-card-wrap:hover,
[data-theme="light"] .cc-card-wrap:hover,
[data-theme="bright"] .def-card-wrap:hover,
[data-theme="light"] .def-card-wrap:hover {
  border-color: var(--gold) !important;
}

[data-theme="gold"] .nav,
[data-theme="gold"] .hdr {
  background: color-mix(in srgb, var(--bg) 97%, transparent) !important;
  border-bottom-color: var(--border) !important;
}
[data-theme="gold"] nav {
  background: color-mix(in srgb, var(--bg) 95%, transparent) !important;
  border-bottom-color: var(--border) !important;
}
[data-theme="gold"] .carousel-wrap::after {
  background: linear-gradient(to left, var(--bg), transparent) !important;
}
[data-theme="gold"] .carousel-wrap::before {
  background: linear-gradient(to right, var(--bg), transparent) !important;
}
[data-theme="gold"] .cc-card,
[data-theme="gold"] .def-card,
[data-theme="gold"] .pblock,
[data-theme="gold"] .panel,
[data-theme="gold"] .search-dropdown,
[data-theme="gold"] .psearch-dropdown,
[data-theme="gold"] .user-menu {
  --surface-2: var(--card-surface-2);
  --surface-3: var(--card-surface-3);
  --text: var(--card-fg);
  --muted: var(--card-fg-muted);
  --muted-2: var(--card-fg-muted-2);
  --border: rgba(17, 17, 17, 0.1);
  --gold: var(--gold-on-card);
  --gold-dim: rgba(154, 117, 53, 0.1);
  --gold-border: rgba(154, 117, 53, 0.38);
  color: var(--card-fg);
}
[data-theme="gold"] .cc-card-wrap,
[data-theme="gold"] .def-card-wrap {
  border-color: rgba(17, 17, 17, 0.1) !important;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.24), 0 2px 6px rgba(0, 0, 0, 0.12) !important;
}

.conf-flag {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  position: relative;
  cursor: help;
  vertical-align: middle;
  flex-shrink: 0;
}
.conf-flag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  opacity: 0.8;
}
.conf-flag-tip {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--amber-border);
  border-radius: 5px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--amber);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 500;
  box-shadow: var(--shadow-md);
}
.conf-flag:hover .conf-flag-tip { opacity: 1; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  top: -120px;
  left: 12px;
  z-index: 10000;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--gold-border);
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 12px;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="tab"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--gold) !important;
  outline-offset: 2px !important;
}
.bottom-nav .bn-item {
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  box-sizing: border-box;
}
.theme-switcher:not(.theme-switcher--pills) {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
  flex-shrink: 0;
}
.theme-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  opacity: 0.35;
  transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease;
  border: none;
  background: transparent;
}
.theme-icon.active {
  opacity: 1;
  color: var(--gold);
  background: var(--gold-dim);
}
