/*
 * RAGEX-ENHANCEMENTS.CSS — v1.0
 * Elite interface refinements for RAGE X Intelligence
 * Decode. Dominate. Deliver.
 *
 * Load order: After style.css via wp_enqueue_style().
 * This file is purely additive — zero regressions to existing markup.
 *
 * SECTIONS:
 *   1. SPACING SYSTEM — 8-pt scale tokens
 *   2. MOBILE NAV FIX — @media wrapper (CRITICAL BUG FIX)
 *   3. TYPOGRAPHY HIERARCHY — hierarchy, contrast, rhythm
 *   4. COMPONENT CONSISTENCY — cards, buttons, borders
 *   5. VISUAL CRISPNESS — rendering, overlays, depth
 *   6. DEPTH & LAYERING — dark mode backgrounds
 *   7. GRID & ALIGNMENT — alignment validation
 *   8. LIGHT MODE REFINEMENT — true light mode
 *   9. PERFORMANCE HELPERS — GPU hints, paint containment
 */

/* =============================================================
   1. SPACING SYSTEM — Strict 8-pt scale
   ============================================================= */

:root {
  /* 8-pt scale tokens — use these everywhere */
  --sp-1:  8px;
  --sp-2:  16px;
  --sp-3:  24px;
  --sp-4:  32px;
  --sp-5:  40px;
  --sp-6:  48px;
  --sp-7:  56px;
  --sp-8:  64px;

  /* Component-level tokens (derived from scale) */
  --card-padding-v:    16px;
  --card-padding-h:    16px;
  --card-gap:          8px;
  --section-gap:       32px;
  --widget-padding:    16px;

  /* Border system */
  --border-radius-ui:  2px;   /* Tactical: sharp with just a hint of finish */
  --border-w:          1px;
  --border-w-accent:   2px;
  --border-w-strong:   3px;

  /* Type scale tokens */
  --text-label:    10px;   /* mono labels, timestamps, metadata */
  --text-micro:    11px;   /* secondary metadata */
  --text-caption:  12px;   /* captions, tags */
  --text-sm:       13px;   /* auxiliary body */
  --text-body:     15px;   /* primary body */
  --text-body-lg:  16px;   /* article body */
  --text-h4:       14px;
  --text-h3:       18px;
  --text-h2:       22px;
  --text-h1:       clamp(26px, 3.5vw, 42px);

  /* Transitions */
  --t-fast:   0.12s ease;
  --t-base:   0.18s ease;
  --t-slow:   0.28s ease;
}

/* =============================================================
   2. MOBILE NAV — CRITICAL BUG FIX
   The @media (max-width:900px) block was accidentally placed
   inside a CSS comment in style.css, causing the mobile nav
   rules to be stripped entirely. This block is the authoritative
   replacement. Desktop nav is fully restored. Mobile gets a
   proper off-canvas panel with overlay backdrop.
   ============================================================= */

/* --- GLOBAL: sub-toggle hidden on desktop --- */
.sub-toggle {
  display: none;
}

/* --- GLOBAL: Reset any position:fixed leak from the bugged block --- */
.nav-primary__menu {
  position: static;
  transform: none;
  overflow: visible;
  overscroll-behavior: auto;
}

/* --- MOBILE NAV OVERLAY BACKDROP --- */
.rx-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 99990;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-slow), visibility var(--t-slow);
  pointer-events: none;
}
.rx-nav-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ─── MOBILE BREAKPOINT ─────────────────────────────────────── */
@media (max-width: 900px) {

  /* Show hamburger */
  .header-toggle {
    display: flex;
  }

  /* Hide desktop-only search */
  .header-search--desktop {
    display: none !important;
  }

  /* Show mobile search toggle */
  .header-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-ui);
    color: var(--text-p);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--t-base), color var(--t-base);
  }
  .header-search-toggle:hover {
    border-color: var(--rage-red);
    color: var(--text-p);
  }

  /* ── Off-canvas slide-in menu ── */
  .nav-primary {
    position: static;
    border-bottom: none;
  }

  .nav-primary__wrap {
    padding: 0;
    overflow: visible;
  }

  .nav-primary__menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-body) !important;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 99999;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    will-change: transform;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
    padding-top: 0;
  }

  .nav-primary__menu.is-open {
    transform: translateX(0);
  }

  /* Panel header label */
  .nav-primary__menu::before {
    content: "INTELLIGENCE";
    display: block;
    flex-shrink: 0;
    padding: 20px 22px 16px;
    margin-top: 0;
    background: var(--bg-body);
    border-bottom: 1px solid rgba(154, 0, 0, 0.5);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.22em;
    color: var(--rage-red);
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 3;
  }

  /* Top-level nav items */
  .nav-primary__menu > li {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    flex-shrink: 0;
  }

  .nav-primary__menu > li > a {
    width: 100%;
    justify-content: flex-start;
    min-height: 52px;
    padding: 0 22px;
    padding-right: 56px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    border-bottom-color: var(--border) !important; /* override the 2px red underline */
    color: var(--text-p) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--t-base), border-left-color var(--t-base);
  }

  .nav-primary__menu > li > a:hover,
  .nav-primary__menu > li.current-menu-item > a,
  .nav-primary__menu > li.current-menu-ancestor > a {
    background: var(--bg-s2);
    border-left-color: var(--rage-red);
  }

  /* Hide CSS-only dropdown arrow on mobile */
  .nav-primary__menu > li.menu-item-has-children > a::after {
    display: none !important;
  }

  /* Sub-toggle button */
  .sub-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 52px;
    min-height: 52px;
    border: 0;
    border-left: 1px solid var(--border);
    background: none;
    color: var(--text-m);
    cursor: pointer;
    z-index: 4;
    transition: background var(--t-base), color var(--t-base);
  }

  .sub-toggle:hover {
    background: var(--bg-s2);
    color: var(--text-p);
  }

  .sub-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
  }

  .sub-toggle.is-open svg {
    transform: rotate(180deg);
  }

  /* Sub-menu accordion */
  .nav-primary__menu .sub-menu {
    position: static;
    min-width: 0;
    width: 100%;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    background: var(--bg-s2);
    border: 0;
    border-top: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: max-height 0.26s ease, padding-bottom 0.26s ease;
    order: 10; /* push below parent link */
    flex-basis: 100%;
  }

  .nav-primary__menu .sub-menu.is-open {
    padding-bottom: 4px;
  }

  .nav-primary__menu .sub-menu li a {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 22px 0 40px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    color: var(--text-s) !important;
    transition: background var(--t-base), color var(--t-base), border-left-color var(--t-base);
  }

  .nav-primary__menu .sub-menu li a:hover {
    background: var(--bg-s3);
    color: var(--text-p) !important;
    border-left-color: var(--rage-red);
  }

  .nav-primary__menu .sub-menu .sub-menu li a {
    padding-left: 56px;
  }

  /* Body lock when menu open */
  body.menu-open {
    overflow: hidden;
    overflow-y: scroll; /* prevent layout shift */
  }

  body.menu-open .site-header {
    z-index: 100000 !important;
  }

  .nav-primary.menu-elevated {
    z-index: 99998 !important;
  }
}

/* ─── LIGHT / AUTO MOBILE OVERRIDES ───────────────────────── */
@media (max-width: 900px) {
  [data-theme="light"] .nav-primary__menu,
  [data-theme="auto"] .nav-primary__menu {
    background: #ffffff !important;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.18);
  }

  [data-theme="light"] .nav-primary__menu::before,
  [data-theme="auto"] .nav-primary__menu::before {
    background: #fff;
    border-bottom-color: rgba(154, 0, 0, 0.25);
    color: var(--rage-red);
  }

  [data-theme="light"] .nav-primary__menu > li > a,
  [data-theme="auto"] .nav-primary__menu > li > a {
    color: #1a1a1a !important;
    border-bottom-color: rgba(0, 0, 0, 0.07) !important;
  }

  [data-theme="light"] .nav-primary__menu > li > a:hover,
  [data-theme="auto"] .nav-primary__menu > li > a:hover {
    background: #f5f5f5;
    color: #111 !important;
  }

  [data-theme="light"] .nav-primary__menu .sub-menu,
  [data-theme="auto"] .nav-primary__menu .sub-menu {
    background: #f0f2f5;
  }

  [data-theme="light"] .nav-primary__menu .sub-menu li a,
  [data-theme="auto"] .nav-primary__menu .sub-menu li a {
    color: #444 !important;
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
  }

  [data-theme="light"] .sub-toggle,
  [data-theme="auto"] .sub-toggle {
    color: #666;
    border-left-color: rgba(0, 0, 0, 0.08);
  }

  [data-theme="light"] .header-toggle span,
  [data-theme="auto"] .header-toggle span {
    background: #333;
  }
}

/* =============================================================
   3. TYPOGRAPHY HIERARCHY
   Clear weight differentiation at every level.
   ============================================================= */

/* Sharpen rendering on all heading-class text */
.article-card__title,
.article-card__title a,
.hero-main__title,
.hero-main__title a,
.hero-side__title,
.section-header__title,
.homepage-cat-section__title,
.archive-header__title,
.widget .widget-title,
.alert-panel__header-label,
.site-logo__name {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* HEADLINE — primary article title on cards */
.article-card__title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.015em;
}

/* METADATA — consistent mono treatment */
.article-card__time,
.article-card__author,
.article-card__readtime,
.article-list-item__time,
.post-meta__date,
.post-meta__readtime {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-m);
  text-transform: uppercase;
}

/* BODY TEXT — improved reading comfort */
.article-body {
  font-size: 16px;
  line-height: 1.82;
  letter-spacing: 0.01em;
}

/* Section headers — stronger label differentiation */
.section-header__title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.24em;
}

/* Widget titles — consistent uppercase tracking */
.widget .widget-title {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.24em;
}

/* Archive title — scaled, not cramped */
.archive-header__title {
  font-size: clamp(28px, 4.5vw, 44px);
  line-height: 1.0;
  letter-spacing: 0.02em;
}

/* Hero main title — commanding presence */
.hero-main__title {
  font-size: clamp(20px, 2.6vw, 36px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: 0.01em;
}

/* Hero side — readable at smaller size */
.hero-side__title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

/* Article H2 — proper visual hierarchy over body */
.article-body h2 {
  font-size: clamp(20px, 2.2vw, 26px);
  margin-top: 2.2em;
  margin-bottom: 0.6em;
}

/* Article H3 — subordinate to H2 */
.article-body h3 {
  font-size: 18px;
  letter-spacing: 0.03em;
}

/* Footer tagline — subtle */
.site-logo__tagline,
.footer-brand__tagline {
  font-size: 9px;
  letter-spacing: 0.24em;
  opacity: 0.7;
}

/* =============================================================
   4. COMPONENT CONSISTENCY
   Unified padding, border weight, interaction states.
   ============================================================= */

/* ── Article Cards ────────────────────────────── */
.article-card {
  border-width: 1px;
  border-style: solid;
  border-color: var(--card-border);
  border-radius: var(--border-radius-ui);
  /* Remove the `transform: none` override that blocks the hover lift */
}

/* Re-enable hover lift (the last block in style.css disabled it) */
.article-card:hover {
  border-color: var(--card-hover-border) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="light"] .article-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10) !important;
}

.article-card:hover .article-card__thumb img {
  transform: scale(1.04) !important;
}

.article-card__body {
  padding: var(--card-padding-v) var(--card-padding-h);
  gap: var(--card-gap);
}

.article-card__footer {
  padding: 8px var(--card-padding-h);
  border-top: 1px solid var(--border);
}

/* ── Buttons — primary / secondary / ghost ───── */

/* Primary CTA */
.nl-submit,
.comment-form .submit,
.rx-search-btn,
.mobile-search-bar__btn {
  border-radius: var(--border-radius-ui);
  font-size: 12px;
  letter-spacing: 0.16em;
  padding: 11px 22px;
  transition: background var(--t-base), transform 0.1s ease, box-shadow var(--t-base);
}

.nl-submit:hover,
.comment-form .submit:hover {
  background: var(--rage-red-light);
  box-shadow: 0 4px 12px rgba(154, 0, 0, 0.3);
}

/* Ghost button (share, nav links) */
.share-btn {
  border-radius: var(--border-radius-ui);
  font-size: 11px;
  padding: 7px 13px;
  gap: 5px;
}

/* Pill-shaped read-more */
.homepage-cat-section__footer-link {
  letter-spacing: 0.16em;
  padding: 9px 22px;
  transition: all var(--t-base);
}

/* ── Widgets ──────────────────────────────────── */
.widget {
  border-radius: var(--border-radius-ui);
  border-width: 1px;
  border-style: solid;
  margin-bottom: var(--sp-3);  /* 24px — consistent rhythm */
  overflow: hidden;
}

.widget .widget-body {
  padding: var(--widget-padding);
}

.widget .widget-title {
  padding: 10px var(--widget-padding);
}

/* ── Alert panel ─────────────────────────────── */
.alert-panel {
  border-radius: var(--border-radius-ui);
  border-width: 1px;
  border-left-width: 4px;
}

.alert-panel__item {
  padding: 10px var(--widget-padding);
  gap: 12px;
}

/* ── Nav primary (desktop) ───────────────────── */
.nav-primary__menu > li > a {
  padding: 0 16px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  min-height: 44px;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

/* Consistent sub-menu radius */
.nav-primary__menu .sub-menu {
  border-radius: 0 0 var(--border-radius-ui) var(--border-radius-ui);
}

/* ── Section header accent line ──────────────── */
.section-header {
  margin-bottom: var(--sp-3);
  padding-bottom: 14px;
}

.section-header::after {
  width: 48px;
  height: 2px;
}

.homepage-cat-section__header {
  margin-bottom: var(--sp-3);
}

/* =============================================================
   5. VISUAL CRISPNESS
   Sharp borders, controlled contrast, no blur noise.
   ============================================================= */

/* Hard edge borders — no border-radius on tactical UI elements */
.article-card,
.article-card__thumb,
.alert-panel,
.widget,
.analysis-label,
.article-tag,
.share-btn,
.nl-submit,
.nl-input,
.comment-form input,
.comment-form textarea {
  border-radius: var(--border-radius-ui);
}

/* Input focus rings — crisp red glow */
.nl-input:focus,
.header-search__input:focus,
.comment-form input:focus,
.comment-form textarea:focus {
  box-shadow: 0 0 0 2px rgba(154, 0, 0, 0.2);
  outline: none;
}

/* Thumbnail images — GPU-composited for smooth hover */
.article-card__thumb img,
.hero-main__img,
.hero-side__img {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Logo: maximum clarity */
.site-logo img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  filter: none;
  opacity: 1;
}

/* Ticker badge — stronger contrast */
.rx-ticker__badge {
  background: var(--rage-red);
}

/* Category badges — consistent sizing */
.cat-badge {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  padding: 3px 7px;
  line-height: 1.5;
}

/* Reading progress — crisp gradient */
.reading-progress {
  height: 2px;
  background: var(--rage-red);
}

/* Scroll to top — crisp, no border-radius */
.scroll-top {
  border-radius: 2px;
  width: 36px;
  height: 36px;
}

/* =============================================================
   6. DEPTH & LAYERING — Dark Mode
   Replace flat black with structured tone layers.
   ============================================================= */

/* Layered header: deepest level */
.site-header {
  background: linear-gradient(180deg, #000000 0%, #060606 100%);
  border-bottom: 1px solid rgba(154, 0, 0, 0.35);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.site-header.is-scrolled {
  box-shadow: 0 2px 24px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Navigation bar — one notch above header */
.nav-primary {
  background: #0d0d0d;
  border-bottom-color: rgba(154, 0, 0, 0.5);
}

/* Homepage body — banded depth */
.homepage-cat-section:nth-child(even) {
  background: rgba(255, 255, 255, 0.012);
}

/* Card depth — subtle lift from body */
.article-card {
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* Sidebar widgets — panel feel */
.widget {
  background: var(--widget-bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Widget title — slightly elevated */
.widget .widget-title {
  background: linear-gradient(90deg, var(--widget-title-bg) 0%, var(--bg-s3) 100%);
  border-bottom: var(--border-w-accent) solid var(--rage-red);
}

/* Intel strip — subtle top glow */
.intel-strip {
  background: linear-gradient(180deg, var(--bg-s1) 0%, var(--bg-body) 100%);
}

.intel-strip__value {
  font-size: 18px;
  font-weight: 900;
}

/* Footer — three-layer separation */
.site-footer {
  background: #000;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-top {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

/* =============================================================
   7. GRID & ALIGNMENT VALIDATION
   Enforce strict container gutter + alignment across breakpoints.
   ============================================================= */

/* Universal container guard */
.container,
.container--lg,
.container--md,
.container--read,
.header-inner,
.nav-primary__wrap,
.footer-grid,
.intel-strip__inner,
.homepage-body,
.homepage-body__inner,
.homepage-sections,
.archive-header__inner {
  box-sizing: border-box;
  max-width: 100%;
}

/* Layout gutter: 24px desktop, 16px mobile (enforced via variables) */
.layout-with-sidebar {
  padding: var(--sp-4) var(--sp-3) var(--sp-8);
  gap: var(--sp-5);
  align-items: start;
}

.layout-full {
  padding: var(--sp-4) var(--sp-3) var(--sp-8);
}

/* Hero grid — zero gap between panels for seamless editorial feel */
.hero-grid {
  gap: 2px;
}

/* Card grids — consistent gap */
.article-grid {
  gap: 2px;
}

/* Article card: aligned footer */
.article-card__footer {
  margin-top: auto;
}

/* Hero side: fixed gap */
.hero-side {
  gap: 2px;
}

/* Breadcrumb: tight mono tracking */
.breadcrumb {
  font-size: 10px;
  letter-spacing: 0.08em;
  gap: 4px;
}

/* Archive header: consistent top/bottom spacing */
.archive-header {
  padding: var(--sp-4) 0 var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* Section padding alignment */
.homepage-cat-section {
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-4);
}

/* Author box alignment */
.author-box {
  padding: var(--sp-3);
}

/* Sidebar sticky — precision offset */
.sidebar__sticky {
  position: sticky;
  top: var(--sidebar-top);
}

/* =============================================================
   8. LIGHT MODE REFINEMENT
   True editorial light mode — not inverted dark.
   ============================================================= */

[data-theme="light"],
[data-theme="light"] body {
  background-color: #f4f4f4 !important;
}

/* Header: clean white — not a dark artifact */
[data-theme="light"] .site-header {
  background: #ffffff !important;
  border-bottom: 1px solid rgba(154, 0, 0, 0.25) !important;
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06) !important;
}

[data-theme="light"] .site-header.is-scrolled {
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.10) !important;
}

/* Nav: white bar with light separator */
[data-theme="light"] .nav-primary {
  background: #ffffff !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .nav-primary::after {
  content: '';
  display: block;
  height: 2px;
  background: var(--rage-red, #9A0000);
  margin-top: -2px;
}

/* Cards: clean white surfaces */
[data-theme="light"] .article-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .article-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10) !important;
}

/* Widgets: white panels */
[data-theme="light"] .widget {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .widget .widget-title {
  background: linear-gradient(90deg, #f6f6f6 0%, #f0f0f0 100%);
  color: #1a1a1a;
  border-bottom-color: #9A0000;
}

/* Alert panel: very subtle red tint */
[data-theme="light"] .alert-panel {
  background: rgba(154, 0, 0, 0.03);
  border-color: rgba(154, 0, 0, 0.18);
}

/* Intel strip: gray surface */
[data-theme="light"] .intel-strip {
  background: #f0f0f0;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

/* Section header accent */
[data-theme="light"] .section-header {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Author box */
[data-theme="light"] .author-box {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

/* Post nav */
[data-theme="light"] .post-nav__item {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .post-nav__item:hover {
  border-color: #9A0000;
  background: #fafafa;
}

/* Breadcrumb */
[data-theme="light"] .breadcrumb {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Tags */
[data-theme="light"] .article-tag {
  border-color: rgba(0, 0, 0, 0.12);
  color: #555;
}

[data-theme="light"] .article-tag:hover {
  color: #111;
  border-color: rgba(0, 0, 0, 0.22);
}

/* Share buttons */
[data-theme="light"] .share-btn {
  border-color: rgba(0, 0, 0, 0.12);
  color: #444;
}

/* Article body links */
[data-theme="light"] .article-body a {
  color: #1B365D;
}

/* Site logo name — red X accent */
[data-theme="light"] .site-logo__name em,
[data-theme="auto"] .site-logo__name em {
  color: #9A0000;
}

/* Footer stays dark in light mode — intentional brand decision */
[data-theme="light"] .site-footer {
  background: #0a0a0a;
}

/* Light mode: auto media sync */
@media (prefers-color-scheme: light) {
  [data-theme="auto"],
  [data-theme="auto"] body {
    background-color: #f4f4f4 !important;
  }

  [data-theme="auto"] .site-header {
    background: #ffffff !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.06) !important;
  }

  [data-theme="auto"] .nav-primary {
    background: #ffffff !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
  }

  [data-theme="auto"] .article-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  }

  [data-theme="auto"] .widget {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  }

  [data-theme="auto"] .intel-strip {
    background: #f0f0f0;
  }
}

/* =============================================================
   9. MOBILE REFINEMENTS — typography + layout
   ============================================================= */

@media (max-width: 767px) {
  /* Container padding */
  .container,
  .container--lg,
  .container--read {
    padding-left: 16px;
    padding-right: 16px;
  }

  .layout-with-sidebar,
  .layout-full {
    padding: 20px 16px 48px;
  }

  /* Card body — tighter on mobile */
  .article-card__body {
    padding: 12px 14px;
    gap: 7px;
  }

  .article-card__footer {
    padding: 7px 14px;
  }

  .article-card__title {
    font-size: 14px;
    line-height: 1.3;
  }

  /* Hero title — readable at mobile */
  .hero-main__title {
    font-size: clamp(18px, 5.5vw, 24px);
    line-height: 1.1;
  }

  .hero-main__body {
    padding: 16px 18px;
  }

  /* Archive header */
  .archive-header__title {
    font-size: clamp(24px, 7vw, 32px);
  }

  /* Article body — optimized for small screens */
  .article-body {
    font-size: 15px;
    line-height: 1.78;
  }

  .article-body h2 {
    font-size: 20px;
  }

  .article-body h3 {
    font-size: 17px;
  }

  /* Footer — stacked */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 0 16px;
  }

  .footer-bottom__inner {
    padding: 14px 16px;
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }

  /* Section header smaller */
  .section-header__title {
    font-size: 10px;
    letter-spacing: 0.2em;
  }

  /* Ticker mobile */
  .rx-ticker {
    height: var(--ticker-h-mobile);
  }

  .site-header {
    top: var(--ticker-h-mobile);
  }
}

@media (max-width: 480px) {
  .article-card__body {
    padding: 10px 12px;
    gap: 6px;
  }

  .article-card__title {
    font-size: 13.5px;
  }

  .article-card__excerpt {
    font-size: 12px;
    line-height: 1.5;
  }
}

/* =============================================================
   PERFORMANCE — paint containment + GPU hints
   ============================================================= */

.article-card {
  contain: layout style;
}
.article-card:hover {
  will-change: transform;
}

.widget {
  contain: layout;
}

.breaking-ticker__track,
.rx-ticker__track {
  transform: translateZ(0);
  will-change: transform;
}

/* Smooth font rendering globally */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* =============================================================
   v21.9 — ELITE POLISH: 6-STEP SYSTEM REFINEMENT
   Applied: April 2026 | Decode. Dominate. Deliver.
   Rules: Additive only. No HTML changes. No JS changes.
         No layout redesign. All regressions must be reverted.
   ============================================================= */

/* ─────────────────────────────────────────────────────────────
   STEP 1 — GLOBAL SPACING SYSTEM (4px base grid)
   Complements existing 8pt --sp-* scale.
   Use --space-* at component level for sub-8px precision.
   ───────────────────────────────────────────────────────────── */

:root {
  /* 4px base grid — 6-stop scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --space-8: 48px;
}

/* Before → After: hero body padding was 28px 28px 28px 32px (off-grid)
   After → 32px 32px 32px 40px (on 4px grid, same visual rhythm) */
.hero-main__body {
  padding: var(--space-6) var(--space-6) var(--space-6) var(--space-7);
}

/* Before → After: article-header padding was 28px 0 20px (both off-grid)
   After → 32px 0 24px */
.article-header {
  padding: var(--space-6) 0 var(--space-5);
  margin-bottom: var(--space-6);
}

/* ─────────────────────────────────────────────────────────────
   STEP 2 — HEADER & NAV PRECISION LOCK
   Header: 60px via --header-h (changed in style.css root).
   Nav bar: enforce 44px item height with exact flex centering.
   ───────────────────────────────────────────────────────────── */

/* Verify header flexbox stays perfectly centered at 60px */
.header-inner {
  height: var(--header-h); /* 60px — cascades from :root */
  align-items: center;
}

/* Logo: scale to 60px header (was 44px img height — keep, now has 8px breathing room) */
.site-logo img {
  height: 40px; /* precisely centered in 60px with 10px top/bottom */
}

/* Nav bar: strict 44px item height, no vertical drift */
.nav-primary__menu > li > a {
  min-height: 44px;
  height: 44px;
  padding: 0 var(--space-4) !important; /* 0 16px — removes the 13px/15px arbitrary values */
  display: flex;
  align-items: center;
}

/* Kill the margin-bottom: -2px shift that causes 1px vertical drift on non-active items.
   The active indicator is re-delivered via border-bottom on the anchor itself. */
.nav-primary__menu > li > a {
  margin-bottom: 0 !important;
  border-bottom: 3px solid transparent;
  /* The 3px border is inside the 44px flex container — no drift */
}

/* Active/hover indicator — flush and intentional */
.nav-primary__menu > li > a:hover,
.nav-primary__menu > li.current-menu-item > a,
.nav-primary__menu > li.current-menu-ancestor > a,
.nav-primary__menu > li.current-category-ancestor > a {
  border-bottom-color: var(--rage-red);
}

/* ─────────────────────────────────────────────────────────────
   STEP 3 — TYPOGRAPHY SYSTEM REFINEMENT
   Scale: 10 / 11 / 12 / 14 / 16 / 18 / 24 / 32
   All elements map to this scale. No in-between values.
   ───────────────────────────────────────────────────────────── */

/* NAV: 12px uniform (was 11.5px — not on scale) */
.nav-primary__menu > li > a {
  font-size: 12px;
  letter-spacing: 0.09em; /* uniform across all items */
  line-height: 1;
}

/* Sub-menu: matching scale baseline */
.nav-primary__menu .sub-menu li a {
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* Card title: 16px (on scale, one step above 14px body) */
.article-card__title {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

/* Card excerpt: 13px → 14px (on scale) */
.article-card__excerpt {
  font-size: 14px;
  line-height: 1.55;
}

/* Metadata: locked to 10px across all card contexts */
.article-card__time,
.article-card__author,
.article-card__readtime,
.article-list-item__time,
.alert-panel__item-time,
.trending-item__time {
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1;
}

/* Category badges: uniform 10px */
.cat-badge {
  font-size: 10px;
  letter-spacing: 0.12em;
  line-height: 1.4;
}

/* Widget title: 11px (was 10px — slightly more readable at this weight) */
.widget .widget-title {
  font-size: 11px;
  letter-spacing: 0.2em;
}

/* Section header: 11px label */
.section-header__title {
  font-size: 11px;
  letter-spacing: 0.22em;
}

/* ─────────────────────────────────────────────────────────────
   STEP 4 — COMPONENT CONSISTENCY
   Every component: same padding logic, same border weight,
   same hover behavior. No one-offs.
   ───────────────────────────────────────────────────────────── */

/* ── Cards: unified padding system ─── */
.article-card__body {
  padding: var(--space-4); /* 16px all sides — was 15px top (off-grid) */
  gap: var(--space-2);     /* 8px */
}

.article-card__footer {
  padding: var(--space-2) var(--space-4); /* 8px 16px */
}

/* ── Buttons: unified height + padding ─── */
/* All primary actions: 40px height, 24px side padding, 12px label */
.nl-submit,
.rx-search-btn,
.mobile-search-bar__btn {
  height: 40px;
  min-height: 40px;
  padding: 0 var(--space-5); /* 0 24px */
  font-size: 12px;
  letter-spacing: 0.14em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Ghost / secondary: 36px height, 16px side padding */
.share-btn,
.report-filter-link,
.homepage-cat-section__footer-link {
  height: 36px;
  min-height: 36px;
  padding: 0 var(--space-4); /* 0 16px */
  font-size: 11px;
  letter-spacing: 0.12em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Widgets: identical structure ─── */
.widget .widget-body {
  padding: var(--space-4); /* 16px */
}

.widget .widget-title {
  padding: var(--space-2) var(--space-4); /* 8px 16px — tighter label */
}

/* ── Alert panel items: consistent density ─── */
.alert-panel__item {
  padding: var(--space-3) var(--space-4); /* 12px 16px */
  gap: var(--space-3); /* 12px */
}

/* ── List items: uniform baseline ─── */
.article-list-item {
  padding: var(--space-3) 0; /* 12px 0 */
  gap: var(--space-3);       /* 12px */
}

/* ─────────────────────────────────────────────────────────────
   STEP 5 — LIGHT MODE DEPTH
   Replace flat white surfaces with premium layered elevation.
   Hierarchy: page (#f4f4f4) → card (#fff) → header (#fff elevated)
   Border system: #e5e7eb (soft, not stark)
   ───────────────────────────────────────────────────────────── */

/* Page: very subtle gradient to break pure flat */
[data-theme="light"],
[data-theme="light"] body {
  background: #f2f3f5 !important;
}

/* Header: pure white — highest surface, slight bottom shadow */
[data-theme="light"] .site-header {
  background: #ffffff !important;
  border-bottom: 1px solid #e5e7eb !important;
  box-shadow: 0 1px 0 #e5e7eb, 0 2px 12px rgba(0,0,0,0.05) !important;
}

[data-theme="light"] .site-header.is-scrolled {
  box-shadow: 0 1px 0 #e5e7eb, 0 4px 20px rgba(0,0,0,0.08) !important;
}

/* Nav bar: fractionally off-white — creates visible separation from header */
[data-theme="light"] .nav-primary {
  background: #fafafa !important;
  border-bottom: 2px solid #9A0000 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
}

/* Cards: white panels elevated off the page */
[data-theme="light"] .article-card {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04) !important;
}

[data-theme="light"] .article-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05) !important;
  border-color: #9A0000 !important;
}

/* Widgets: same white surface as cards */
[data-theme="light"] .widget {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
}

[data-theme="light"] .widget .widget-title {
  background: linear-gradient(90deg, #f8f8f8 0%, #f3f3f3 100%) !important;
  color: #1a1a1a !important;
  border-bottom: 2px solid #9A0000 !important;
}

/* Intel strip: mid-tone to bridge header and cards */
[data-theme="light"] .intel-strip {
  background: linear-gradient(180deg, #efefef 0%, #e8e9ec 100%) !important;
  border-top: 1px solid #e0e0e0 !important;
  border-bottom: 1px solid #e0e0e0 !important;
}

/* Alert panel: warm tint — visually distinct from neutral cards */
[data-theme="light"] .alert-panel {
  background: rgba(154, 0, 0, 0.025) !important;
  border-color: rgba(154, 0, 0, 0.18) !important;
}

/* Section alternation: even sections get a whisper of depth */
[data-theme="light"] .homepage-cat-section:nth-child(even) {
  background: rgba(0, 0, 0, 0.018);
}

/* Post nav items: card-consistent elevation */
[data-theme="light"] .post-nav__item {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
}

[data-theme="light"] .post-nav__item:hover {
  border-color: #9A0000 !important;
  background: #fafafa !important;
}

/* Author box: white panel */
[data-theme="light"] .author-box {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
}

/* ── Auto mode sync ─── */
@media (prefers-color-scheme: light) {
  [data-theme="auto"],
  [data-theme="auto"] body {
    background: #f2f3f5 !important;
  }

  [data-theme="auto"] .site-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 0 #e5e7eb, 0 2px 12px rgba(0,0,0,0.05) !important;
  }

  [data-theme="auto"] .nav-primary {
    background: #fafafa !important;
    border-bottom: 2px solid #9A0000 !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
  }

  [data-theme="auto"] .article-card {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04) !important;
  }

  [data-theme="auto"] .widget {
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
  }

  [data-theme="auto"] .intel-strip {
    background: linear-gradient(180deg, #efefef 0%, #e8e9ec 100%) !important;
    border-top: 1px solid #e0e0e0 !important;
    border-bottom: 1px solid #e0e0e0 !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   STEP 6 — MICRO-ALIGNMENT PASS
   Pixel-perfect grid snap. Every element intentional.
   ───────────────────────────────────────────────────────────── */

/* Section header: on-grid spacing */
.section-header {
  padding-bottom: var(--space-3);  /* 12px — border needs breathing room */
  margin-bottom: var(--space-5);   /* 24px */
}

/* Section header accent line: precise 48px width */
.section-header::after {
  width: 48px;
  height: 2px;
  bottom: -1px; /* flush with border */
}

/* Widget margin rhythm: uniform 24px gap between panels */
.widget {
  margin-bottom: var(--space-5); /* 24px */
}

/* Article tag: 4px 12px — grid-aligned */
.article-tag {
  padding: var(--space-1) var(--space-3); /* 4px 12px */
  font-size: 11px;
}

/* Breadcrumb: on-grid */
.breadcrumb {
  padding: var(--space-3) 0;  /* 12px 0 */
  margin-bottom: var(--space-5); /* 24px */
}

/* Post nav: tight gap between prev/next */
.post-nav {
  gap: var(--space-1); /* 4px — near-seamless join */
  margin-top: var(--space-7); /* 40px */
}

/* Post nav item padding: on-grid */
.post-nav__item {
  padding: var(--space-4); /* 16px */
}

/* Article share: on-grid margins */
.article-share {
  padding: var(--space-4) 0; /* 16px */
  margin-top: var(--space-6); /* 32px */
  gap: var(--space-2);        /* 8px */
}

/* Article tags block: on-grid */
.article-tags {
  margin-top: var(--space-7);  /* 40px */
  padding-top: var(--space-4); /* 16px */
  gap: var(--space-2);         /* 8px */
}

/* Intel strip items: uniform density */
.intel-strip__item {
  padding: 0 var(--space-7); /* 0 40px — was 0 28px (off-grid) */
}

.intel-strip__item:first-child {
  padding-left: 0;
}

/* Hero side items: exact 2px gap (already set — lock it) */
.hero-side {
  gap: 2px;
}

/* Card grids: 2px gap (lock) */
.article-grid {
  gap: 2px;
}

/* Hero grid: 2px gap (lock) */
.hero-grid {
  gap: 2px;
}

/* Analysis label: on-grid padding */
.analysis-label {
  padding: var(--space-3) var(--space-4); /* 12px 16px */
  margin-bottom: var(--space-6);          /* 32px */
  gap: var(--space-3);                    /* 12px */
}

/* Archive header: grid-aligned */
.archive-header {
  padding: var(--space-7) 0 var(--space-5); /* 40px 0 24px */
  margin-bottom: var(--space-6);             /* 32px */
}

/* ── Final: suppress sub-pixel rendering artifacts ─── */
.nav-primary__menu > li > a,
.article-card,
.widget,
.section-header::after,
.reading-progress {
  transform: translateZ(0); /* promote to own compositor layer — eliminates sub-pixel border drift */
}
