/* ─── Apple-grade dark-mode refinement layer ────────────────────────────────
   Final override layer — loaded after responsive.css and control-bar.css.
   ADDITIVE ONLY: refines token values and visual polish.
   Does NOT change layout structure, class names, or JS-facing attributes.
   ──────────────────────────────────────────────────────────────────────── */

/* ─── 1. Token refinement ─────────────────────────────────── */
:root {
  /* Deep Charcoal surfaces — rich near-black with visible depth */
  --bg-app:      #010203;
  --bg-panel:    #06080c;
  --bg-elevated: #0b0e14;
  --bg-input:    #0f1219;

  /* Legacy aliases — kept for backward compat with JS and older CSS */
  --bg:          #010203;
  --bg-soft:     #06080c;
  --bg-card:     #06080c;
  --bg-elev:     #10141d;
  --bg-overlay:  rgba(1, 2, 3, 0.80);
  --surface:       var(--bg-app);
  --surface-raised:var(--bg-panel);
  --surface-hover: var(--bg-elevated);

  /* Borders — visible but not loud */
  --line:        #1b212c;
  --line-soft:   #111722;
  --line-strong: #333b4a;

  /* Text hierarchy */
  --text:        #f6f8fb;
  --text-muted:  #a0a8b6;
  --text-dim:    #858e9f;
  --text-faint:  #444c5c;

  /* Interactive — neutral glass accent */
  --accent:      #7f8fa8;
  --accent-hot:  #aeb8ca;
  --accent-soft: rgba(174, 184, 202, 0.14);
  --focus-ring:  rgba(174, 184, 202, 0.46);

  /* Stance */
  --anti:        #ff3b1f;
  --anti-soft:   rgba(255, 59, 31, 0.17);
  --anti-strong: #ff5a2f;
  --pro:         #2356d9;
  --pro-soft:    rgba(35, 86, 217, 0.18);
  --pro-strong:  #5d86ff;

  /* Status — redesigned palette */
  --accent-enacted:  #5fc8a1;
  --accent-symbolic: #9b6cd1;
  --accent-pending:  #f5b945;

  --enacted:         #5fc8a1;
  --enacted-soft:    rgba(95, 200, 161, 0.18);
  --symbolic:        #9b6cd1;
  --symbolic-soft:   rgba(155, 108, 209, 0.18);
  --pending:         #f5b945;
  --pending-soft:    rgba(245, 185, 69, 0.18);
  --dead:            #6b7280;
  --dead-soft:       rgba(107, 114, 128, 0.14);

  /* Geometry */
  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-pill: 999px;

  /* Depth — inner highlight + deep shadow for near-black surfaces */
  --shadow-panel: 0 1px 0 rgba(255,255,255,0.025) inset, 0 8px 28px rgba(0,0,0,0.68);
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow:       0 4px 16px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg:    0 24px 48px rgba(0, 0, 0, 0.75), 0 4px 12px rgba(0, 0, 0, 0.55);

  /* Motion — Apple standard */
  --ease:   cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 140ms var(--ease);
  --t-base: 180ms var(--ease);
  --t-slow: 280ms var(--ease);
}

/* ─── 2. Typography refinement ───────────────────────────── */
html {
  font-size: 16px; /* keeps rem base; body overrides display size */
}
body {
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.005em;
}
@media (max-width: 599px) {
  body { font-size: 14.5px; }
}
h1, h2, .v2-panel-title {
  letter-spacing: -0.01em;
  font-weight: 600;
}
.v2-panel-title { font-size: 1.05rem; }
.v2-panel-sub   { font-size: 0.78rem; }
.v2-brand-title { letter-spacing: -0.015em; font-weight: 600; }

/* ─── 3. Panel + card surfaces ───────────────────────────── */
.v2-panel {
  background: linear-gradient(180deg, rgba(9, 13, 20, 0.58), rgba(2, 5, 10, 0.64));
  border: 1px solid rgba(220, 230, 248, 0.12);
  border-radius: 10px;
  padding: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.055), 0 18px 42px rgba(0,0,0,0.22);
  backdrop-filter: blur(22px) saturate(185%);
  -webkit-backdrop-filter: blur(22px) saturate(185%);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.v2-panel:hover {
  border-color: rgba(185, 201, 230, 0.22);
}
.v2-kpi {
  background: linear-gradient(180deg, rgba(10, 16, 27, 0.64), rgba(3, 7, 13, 0.58));
  border: 1px solid rgba(185, 201, 230, 0.13);
  border-radius: 10px;
  padding: 13px 15px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.045), 0 10px 24px rgba(0,0,0,0.14);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
}
.v2-kpi-value {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ─── 4. Chip refinement (tactile) ──────────────────────── */
.v2-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  padding: 8px 14px;
  min-height: 36px;
  font-size: 0.79rem;
  letter-spacing: -0.005em;
  border-radius: var(--radius-pill);
  transition:
    background var(--t-fast),
    color var(--t-fast),
    border-color var(--t-fast),
    box-shadow var(--t-fast),
    transform var(--t-fast);
}
.v2-chip:hover {
  border-color: rgba(220, 230, 248, 0.22);
  background: rgba(255,255,255,0.055);
}
.v2-chip:active { transform: scale(0.97); }
.v2-chip[aria-pressed="true"],
.v2-chip.is-active {
  background: rgba(110, 122, 144, 0.18);
  color: #e6ebf3;
  border-color: rgba(220, 230, 248, 0.26);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 1px rgba(0,0,0,0.22);
}

/* ─── 5. Button refinement ───────────────────────────────── */
.v2-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: all var(--t-fast);
}
.v2-btn:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(220, 230, 248, 0.22);
}
.v2-btn:active { transform: scale(0.98); }
.v2-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), 0 0 0 1px rgba(0,0,0,0.22);
}
.v2-btn--primary:hover {
  background: var(--accent-hot);
  border-color: var(--accent-hot);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.5), 0 0 16px rgba(59,130,246,0.3);
}

/* ─── 6. Topbar — glass blur ─────────────────────────────── */
.v2-topbar {
  background:
    linear-gradient(180deg, rgba(12, 17, 27, 0.50), rgba(3, 6, 11, 0.30));
  backdrop-filter: blur(38px) saturate(225%);
  -webkit-backdrop-filter: blur(38px) saturate(225%);
  border-bottom: 1px solid rgba(190, 205, 230, 0.13);
}
.v2-brand-mark {
  background: rgba(255,255,255,0.05);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset, 0 5px 14px rgba(0,0,0,0.38);
  overflow: hidden;
}

/* ─── 7. Sidenav refinement ──────────────────────────────── */
.v2-sidenav {
  background: linear-gradient(180deg, rgba(9, 13, 21, 0.72), rgba(3, 5, 9, 0.88));
  border-right: 1px solid rgba(148, 163, 184, 0.12);
}
.v2-tab {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.v2-tab[aria-selected="true"],
.v2-tab.is-active {
  background: linear-gradient(180deg, rgba(105, 116, 136, 0.18), rgba(72, 82, 100, 0.09));
  color: #c7d0dd;
}

/* ─── 8. Modal — glass overlay + smooth open ─────────────── */
.v2-modal {
  background: rgba(5, 6, 8, 0.70);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: v2-modal-fade var(--t-slow) both;
}
@keyframes v2-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.v2-modal-inner {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: v2-modal-rise var(--t-slow) both;
}
/* keep sheet (bottom-attached) style on narrow viewports */
@media (max-width: 699px) {
  .v2-modal-inner {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
}
@keyframes v2-modal-rise {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.v2-modal-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}

/* ─── 9. Search palette ──────────────────────────────────── */
.v2-search-palette {
  background: rgba(5, 6, 8, 0.70);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.v2-search-palette-inner {
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* ─── 10. Filter drawer glass ───────────────────────────── */
.v2-filter-drawer {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.v2-filter-drawer-inner {
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
}
@media (min-width: 900px) {
  .v2-filter-drawer-inner {
    border-radius: var(--radius-lg);
  }
}

/* ─── 11. Pill refinement ───────────────────────────────── */
.v2-pill {
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: var(--radius-pill);
}

/* ─── 12. Form refinement ───────────────────────────────── */
.v2-select,
.v2-input {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.v2-select:focus,
.v2-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* ─── 13. Slice summary refinement ──────────────────────── */
.v2-slice-summary {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  letter-spacing: 0;
}

/* ─── 14. Bottom tabs glass ─────────────────────────────── */
.v2-bottom-tabs {
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--line-strong);
}
/* Active-tab top-bar indicator (refined in apple layer) */
.v2-bot-tab.is-active::before {
  left: 25%; right: 25%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(174,184,202,0.28);
}

/* ─── 15. Scrollbars ────────────────────────────────────── */
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  border: 2px solid var(--bg-app);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ─── 16. View fade-in ──────────────────────────────────── */
.v2-view {
  animation: v2-view-fade 160ms var(--ease) both;
}
@keyframes v2-view-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── 17. Empty / error state ───────────────────────────── */
.v2-empty-state,
.v2-empty {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ─── 18. Section headers (collapsible) ─────────────────── */
.v2-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 3px 3px 3px;
  cursor: pointer;
  user-select: none;
}
.v2-section-title {
  font-size: 0.94rem;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0;
}
.v2-section-sub {
  display: none;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 400;
}
.v2-section-toggle {
  font-size: 0.74rem;
  color: var(--text-muted);
  transition: transform var(--t-fast);
}
details[open] .v2-section-toggle {
  transform: rotate(180deg);
}

/* ─── Reduce-motion guard ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .v2-view,
  .v2-modal,
  .v2-modal-inner {
    animation: none !important;
  }
}

/* ─── Smoother view transitions (override §16 above) ────── */
.v2-view { animation: v2-view-fade 90ms ease-out both; }
@keyframes v2-view-fade { from { opacity: 0; } to { opacity: 1; } }

/* ─── Sidecar overlay colors (bright distinct accents) ───────── */
:root {
  --sidecar-firearms: #ff8a00;       /* bright orange */
  --sidecar-firearms-soft: rgba(255, 138, 0, 0.18);
  --sidecar-dei-ncs: #b96ff8;        /* bright purple */
  --sidecar-dei-ncs-soft: rgba(185, 111, 248, 0.18);
  --sidecar-fa: #4ade80;             /* bright green */
  --sidecar-fa-soft: rgba(74, 222, 128, 0.18);
}
