/* ============================================================
   Nexus SecOps — Design System & Premium Styling
   One file enhances all 296 pages. Design tokens power both themes.
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS (Custom Properties)
   ============================================================ */
:root {
  /* Brand palette */
  --nx-purple:       #7c3aed;
  --nx-purple-light: #a78bfa;
  --nx-purple-dark:  #5b21b6;
  --nx-teal:         #0d9488;
  --nx-teal-light:   #34d399;
  --nx-teal-dark:    #0f766e;
  --nx-red:          #f85149;
  --nx-green:        #3fb950;

  /* Semantic — light mode */
  --nx-bg-primary:     #ffffff;
  --nx-bg-secondary:   #f8fafc;
  --nx-bg-tertiary:    #f1f5f9;
  --nx-bg-card:        #ffffff;
  --nx-bg-code:        #f6f8fa;
  --nx-text-primary:   #1e293b;
  --nx-text-secondary: #475569;
  --nx-text-muted:     #94a3b8;
  --nx-border:         rgba(124, 58, 237, 0.12);
  --nx-border-hover:   rgba(124, 58, 237, 0.35);
  --nx-shadow-sm:      0 1px 3px rgba(0,0,0,0.06);
  --nx-shadow-md:      0 4px 16px rgba(0,0,0,0.08);
  --nx-shadow-lg:      0 12px 40px rgba(0,0,0,0.1);
  --nx-glow:           0 0 20px rgba(124,58,237,0.12);
  --nx-glow-strong:    0 0 30px rgba(124,58,237,0.2);
  --nx-gradient:       linear-gradient(135deg, var(--nx-purple), var(--nx-teal));
  --nx-gradient-text:  linear-gradient(135deg, var(--nx-purple) 0%, var(--nx-teal) 100%);

  /* Spacing & Shape */
  --nx-radius-sm:   6px;
  --nx-radius-md:   12px;
  --nx-radius-lg:   16px;
  --nx-radius-pill:  9999px;

  /* Custom admonition icon */
  --md-admonition-icon--benchmark: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2zm-7 14H7v-2h5v2zm5-4H7v-2h10v2zm0-4H7V7h10v2z'/></svg>");
}

/* Dark mode overrides */
[data-md-color-scheme="slate"] {
  --nx-bg-primary:     #0d1117;
  --nx-bg-secondary:   #161b22;
  --nx-bg-tertiary:    #21262d;
  --nx-bg-card:        rgba(22, 27, 34, 0.7);
  --nx-bg-code:        #161b22;
  --nx-text-primary:   #e6edf3;
  --nx-text-secondary: #8b949e;
  --nx-text-muted:     #484f58;
  --nx-border:         rgba(124, 58, 237, 0.2);
  --nx-border-hover:   rgba(124, 58, 237, 0.5);
  --nx-shadow-sm:      0 1px 3px rgba(0,0,0,0.3);
  --nx-shadow-md:      0 4px 24px rgba(0,0,0,0.3);
  --nx-shadow-lg:      0 12px 40px rgba(0,0,0,0.4);
  --nx-glow:           0 0 20px rgba(124,58,237,0.3);
  --nx-glow-strong:    0 0 30px rgba(124,58,237,0.5);

  /* Material theme color overrides */
  --md-primary-fg-color: var(--nx-purple);
  --md-accent-fg-color:  var(--nx-teal);
}

/* ============================================================
   2. TYPOGRAPHY
   ============================================================ */
.md-typeset {
  font-size: 0.92rem;
  line-height: 1.7;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.md-typeset h1 {
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.md-typeset h2 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--nx-border);
}

.md-typeset h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Gradient h1 — dark mode */
[data-md-color-scheme="slate"] .md-typeset h1 {
  background: linear-gradient(135deg, var(--nx-purple-light) 0%, var(--nx-teal-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(167,139,250,0.25));
}

/* Gradient h1 — light mode */
[data-md-color-scheme="default"] .md-typeset h1 {
  background: var(--nx-gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* h2 tint — dark mode */
[data-md-color-scheme="slate"] .md-typeset h2 {
  color: #c4b5fd;
  border-bottom-color: rgba(124,58,237,0.25);
}

/* ============================================================
   3. LINK HOVER EFFECTS
   ============================================================ */
.md-typeset a:not(.md-button):not(.nexus-cta):not(.nexus-cta-outline):not(.md-nav__link):not(.md-footer__link):not(.md-source) {
  text-decoration: underline;
  text-decoration-color: rgba(124,58,237,0.25);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}
.md-typeset a:not(.md-button):not(.nexus-cta):not(.nexus-cta-outline):not(.md-nav__link):not(.md-footer__link):not(.md-source):hover {
  text-decoration-color: var(--nx-purple);
}

/* ============================================================
   4. CYBER GRID BACKGROUND (dark mode)
   ============================================================ */
[data-md-color-scheme="slate"] .md-main {
  background-image:
    linear-gradient(rgba(124,58,237,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center center;
}

/* Subtle texture — light mode */
[data-md-color-scheme="default"] .md-main {
  background-image:
    linear-gradient(rgba(124,58,237,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.015) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* ============================================================
   5. GLASSMORPHISM ADMONITIONS (both themes)
   ============================================================ */
.md-typeset .admonition,
.md-typeset details {
  border-radius: var(--nx-radius-md) !important;
  border: 1px solid var(--nx-border) !important;
  box-shadow: var(--nx-shadow-sm);
  overflow: hidden;
}

[data-md-color-scheme="slate"] .md-typeset .admonition,
[data-md-color-scheme="slate"] .md-typeset details {
  background: var(--nx-bg-card) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--nx-shadow-md), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Benchmark custom admonition */
.md-typeset .admonition.benchmark,
.md-typeset details.benchmark {
  border-left: 4px solid var(--nx-purple) !important;
}
.md-typeset .benchmark > .admonition-title,
.md-typeset .benchmark > summary {
  background-color: rgba(124,58,237,0.08) !important;
}
.md-typeset .benchmark > .admonition-title::before,
.md-typeset .benchmark > summary::before {
  background-color: var(--nx-purple) !important;
  -webkit-mask-image: var(--md-admonition-icon--benchmark);
  mask-image: var(--md-admonition-icon--benchmark);
}

/* ============================================================
   6. TABLE STYLING (both themes)
   ============================================================ */
.md-typeset table:not([class]) {
  border-radius: var(--nx-radius-md);
  overflow: hidden;
  border: 1px solid var(--nx-border);
  box-shadow: var(--nx-shadow-sm);
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.md-typeset table:not([class]) th {
  background: var(--nx-bg-tertiary);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--nx-text-secondary);
  border-bottom: 2px solid var(--nx-border);
}

.md-typeset table:not([class]) tr:nth-child(even) td {
  background: rgba(124,58,237,0.025);
}

.md-typeset table:not([class]) tr:hover td {
  background: rgba(124,58,237,0.05);
  transition: background 0.15s;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) th {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(13,148,136,0.1));
  color: #c4b5fd;
  border-bottom-color: rgba(124,58,237,0.3);
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) tr:nth-child(even) td {
  background: rgba(124,58,237,0.035);
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) tr:hover td {
  background: rgba(124,58,237,0.06);
}

/* ============================================================
   7. CODE BLOCKS — Terminal Chrome + Language Badge
   ============================================================ */
.md-typeset .highlight {
  position: relative;
  border-radius: var(--nx-radius-md);
  overflow: hidden;
  box-shadow: var(--nx-shadow-md);
}

.md-typeset > .highlight::before,
.md-typeset .tabbed-content .highlight::before {
  content: '\25CF  \25CF  \25CF';
  display: block;
  background: var(--nx-bg-tertiary);
  color: var(--nx-red);
  font-size: 0.65rem;
  letter-spacing: 2px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--nx-border);
}
.md-typeset .admonition .highlight::before,
.md-typeset details .highlight::before {
  display: none;
}

[data-md-color-scheme="slate"] .md-typeset .highlight::before {
  background: #21262d;
  border-bottom-color: rgba(255,255,255,0.06);
}

.md-typeset .highlight pre {
  border-left: 3px solid var(--nx-purple);
}

/* Language badge (injected by JS) */
.nx-code-lang {
  position: absolute;
  top: 5px;
  right: 12px;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--nx-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  z-index: 2;
  pointer-events: none;
}

/* ============================================================
   8. SECTION DIVIDERS (gradient hr)
   ============================================================ */
.md-typeset hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--nx-border-hover), transparent);
  margin: 2.5rem 0;
}

/* ============================================================
   9. NAVIGATION STYLING
   ============================================================ */

/* Active nav item */
.md-nav__item--active > .md-nav__link {
  background: rgba(124,58,237,0.08);
  border-left: 3px solid var(--nx-purple);
  border-radius: 0 var(--nx-radius-sm) var(--nx-radius-sm) 0;
  padding-left: calc(var(--md-nav-item-padding-x, 0.6rem) - 3px) !important;
}

/* Nav hover — dark mode */
[data-md-color-scheme="slate"] .md-nav__link:hover {
  color: var(--nx-purple-light) !important;
  text-shadow: 0 0 8px rgba(167,139,250,0.3);
}

/* Nav hover — light mode */
[data-md-color-scheme="default"] .md-nav__link:hover {
  color: var(--nx-purple) !important;
}

/* Chapter completion checkmark */
.chapter-complete::after {
  content: " \2713";
  color: var(--nx-teal);
  font-weight: 700;
  font-size: 0.85em;
}

/* Tabs */
.md-tabs {
  border-bottom: 1px solid var(--nx-border);
}
.md-tabs__link--active {
  border-bottom: 2px solid var(--nx-purple);
  font-weight: 600;
}

/* Navigation footer (prev/next) */
.md-footer__link {
  transition: background 0.2s;
  border-radius: var(--nx-radius-md);
  padding: 1rem;
}
.md-footer__link:hover {
  background: var(--nx-bg-secondary);
}

/* Scroll to top button */
.md-top {
  background: var(--nx-purple) !important;
  color: #fff !important;
  box-shadow: var(--nx-shadow-md);
  border-radius: var(--nx-radius-pill);
}

/* ============================================================
   10. SEARCH STYLING
   ============================================================ */
.md-search__form {
  border-radius: var(--nx-radius-pill);
  border: 1px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.md-search__form:focus-within {
  border-color: var(--nx-purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.md-search-result__meta {
  color: var(--nx-purple-light);
}

/* ============================================================
   11. HERO SECTION (landing page)
   ============================================================ */
.nx-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--nx-radius-lg);
  padding: 4.5rem 2rem 3.5rem;
  margin: -0.5rem -0.6rem 2.5rem;
  text-align: center;
  background: var(--nx-bg-secondary);
  border: 1px solid var(--nx-border);
}

[data-md-color-scheme="slate"] .nx-hero {
  background: linear-gradient(160deg, #0d0f1a 0%, #1a0d2e 50%, #0d1a1a 100%);
  border-color: rgba(124,58,237,0.15);
}

/* Animated gradient orbs */
.nx-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 500px 400px at 25% 50%, rgba(124,58,237,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 400px 350px at 75% 50%, rgba(13,148,136,0.10) 0%, transparent 70%);
  animation: nx-orb-drift 12s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes nx-orb-drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -20px) scale(1.05); }
}

/* Floating particles (dark mode) */
[data-md-color-scheme="slate"] .nx-hero::after {
  content: '';
  position: absolute;
  width: 2px; height: 2px;
  background: var(--nx-purple-light);
  border-radius: 50%;
  box-shadow:
    120px 40px 0 var(--nx-purple), 200px 80px 0 var(--nx-teal),
    350px 30px 0 var(--nx-purple-light), 50px 120px 0 var(--nx-teal),
    280px 150px 0 var(--nx-purple), 420px 90px 0 var(--nx-teal-light),
    80px 200px 0 var(--nx-purple), 320px 220px 0 var(--nx-purple-light),
    480px 60px 0 var(--nx-teal), 550px 140px 0 var(--nx-purple-light);
  opacity: 0.5;
  animation: nx-float 20s linear infinite;
  pointer-events: none;
}
@keyframes nx-float {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-300px); }
}

.nx-hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem) !important;
  font-weight: 800 !important;
  letter-spacing: -0.03em;
  line-height: 1.1 !important;
  margin-bottom: 1rem !important;
  animation: nx-fade-up 0.8s ease-out;
}

[data-md-color-scheme="slate"] .nx-hero h1 {
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 60%, #34d399 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  filter: none !important;
}

[data-md-color-scheme="default"] .nx-hero h1 {
  background: var(--nx-gradient) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

.nx-hero p {
  font-size: 1.1rem;
  color: var(--nx-text-secondary);
  max-width: 640px;
  margin: 0 auto 2rem;
  animation: nx-fade-up 0.8s ease-out 0.15s both;
}

[data-md-color-scheme="slate"] .nx-hero p {
  color: rgba(255,255,255,0.7);
}

.nx-hero .nx-hero__actions {
  animation: nx-fade-up 0.8s ease-out 0.3s both;
}

@keyframes nx-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   12. BUTTONS (CTA)
   ============================================================ */
.nexus-cta {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--nx-gradient);
  color: #fff !important;
  border-radius: var(--nx-radius-pill);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none !important;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin: 0.5rem 0.25rem;
}
.nexus-cta:hover {
  transform: translateY(-2px);
  box-shadow: var(--nx-glow-strong), 0 8px 32px rgba(124,58,237,0.4);
}

.nexus-cta-outline {
  display: inline-block;
  padding: 0.75rem 2rem;
  border: 2px solid var(--nx-purple);
  color: var(--nx-purple) !important;
  border-radius: var(--nx-radius-pill);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none !important;
  transition: transform 0.15s ease, background 0.2s ease;
  margin: 0.5rem 0.25rem;
}
.nexus-cta-outline:hover {
  background: rgba(124,58,237,0.08);
  transform: translateY(-2px);
}

[data-md-color-scheme="slate"] .nexus-cta-outline {
  color: var(--nx-purple-light) !important;
  border-color: var(--nx-purple-light);
}

/* Glowing button variant */
.nx-btn-glow {
  box-shadow: 0 0 20px rgba(124,58,237,0.4), 0 4px 16px rgba(0,0,0,0.2) !important;
}
.nx-btn-glow:hover {
  box-shadow: 0 0 30px rgba(124,58,237,0.6), 0 8px 24px rgba(0,0,0,0.3) !important;
}

/* ============================================================
   13. STAT CARDS (homepage)
   ============================================================ */
.stat-card {
  position: relative;
  z-index: 0;
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--nx-bg-card);
  border-radius: var(--nx-radius-md);
  border: 1px solid var(--nx-border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--nx-shadow-sm);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--nx-shadow-md);
}

/* Animated gradient border on hover */
.stat-card::before, .feature-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  background: var(--nx-gradient);
  background-size: 200% 200%;
  animation: nx-border-rotate 4s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
}
.stat-card:hover::before, .feature-card:hover::before { opacity: 1; }
@keyframes nx-border-rotate {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.stat-card .stat-number {
  display: block;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
  background: var(--nx-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nx-text-secondary);
  margin-top: 0.25rem;
}

/* ============================================================
   14. FEATURE CARDS (homepage)
   ============================================================ */
.feature-card {
  position: relative;
  z-index: 0;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 1.5rem; border-radius: var(--nx-radius-md);
  border: 1px solid var(--nx-border);
  background: var(--nx-bg-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  height: 100%;
  box-shadow: var(--nx-shadow-sm);
}
.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--nx-shadow-md);
  border-color: var(--nx-border-hover);
}
.feature-card .feature-icon {
  font-size: 2rem; margin-bottom: 0.75rem;
  background: var(--nx-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.feature-card h3 {
  font-size: 1rem; font-weight: 700; margin: 0 0 0.5rem !important;
}
.feature-card p {
  font-size: 0.88rem; color: var(--nx-text-secondary); margin: 0;
}

/* Card hover lift (grid cards) */
.md-typeset .grid .card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--nx-border);
}
.md-typeset .grid .card:hover {
  transform: translateY(-4px);
  box-shadow: var(--nx-shadow-lg);
  border-color: var(--nx-border-hover);
}

/* ============================================================
   15. ATT&CK TECHNIQUE PILLS
   ============================================================ */
.attck-tag {
  display: inline-block;
  background: var(--nx-bg-tertiary);
  color: var(--nx-purple);
  font-family: var(--md-code-font, monospace);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--nx-radius-pill);
  margin: 2px;
  border: 1px solid var(--nx-border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.attck-tag:hover {
  background: rgba(124,58,237,0.1);
  border-color: var(--nx-border-hover);
}

[data-md-color-scheme="slate"] .attck-tag {
  background: rgba(30,27,75,0.9);
  color: var(--nx-purple-light);
}

/* ============================================================
   16. BADGE & PULSE
   ============================================================ */
.nexus-badge-critical {
  display: inline-block;
  background: var(--nx-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--nx-radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  animation: nx-pulse 2s ease-in-out infinite;
}
@keyframes nx-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(248,81,73,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(248,81,73,0); }
}

/* ============================================================
   17. READING PROGRESS BAR
   ============================================================ */
#reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--nx-gradient);
  z-index: 9999; transition: width 0.08s linear;
  box-shadow: 0 0 8px rgba(124,58,237,0.5);
}

/* ============================================================
   18. READING TIME BADGE
   ============================================================ */
.reading-time {
  display: inline-block;
  font-size: 0.72rem;
  background: var(--nx-bg-tertiary);
  color: var(--nx-text-secondary);
  padding: 2px 10px;
  border-radius: var(--nx-radius-pill);
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* ============================================================
   19. MARK COMPLETE BUTTON
   ============================================================ */
#nexus-complete-btn {
  position: fixed;
  bottom: 2rem; right: 2rem;
  z-index: 200;
  padding: 0.6rem 1.2rem;
  border: none; border-radius: var(--nx-radius-pill);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  box-shadow: var(--nx-shadow-md);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.3s;
}
#nexus-complete-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--nx-shadow-lg);
}

/* ============================================================
   20. CHAPTER PROGRESS STRIP
   ============================================================ */
.nexus-progress-strip {
  display: flex; gap: 3px; flex-wrap: wrap;
  margin: 0.5rem 0 1rem;
}
.nexus-progress-strip .prog-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(124,58,237,0.1);
  border: 1px solid var(--nx-border);
  transition: background 0.3s, box-shadow 0.3s;
}
.nexus-progress-strip .prog-dot.done {
  background: var(--nx-teal);
  border-color: var(--nx-teal);
  box-shadow: 0 0 4px var(--nx-teal);
}
.nexus-progress-strip .prog-dot.current {
  background: var(--nx-purple);
  border-color: var(--nx-purple);
  box-shadow: 0 0 8px var(--nx-purple), 0 0 16px rgba(124,58,237,0.4);
  animation: nx-dot-pulse 1.5s ease-in-out infinite;
}
@keyframes nx-dot-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.3); }
}

/* ============================================================
   21. KEYBOARD HINT
   ============================================================ */
.kbd-hint {
  position: fixed; bottom: 5.5rem; right: 2rem;
  font-size: 0.7rem;
  color: var(--nx-text-muted);
  background: var(--nx-bg-card);
  padding: 3px 8px; border-radius: var(--nx-radius-sm);
  border: 1px solid var(--nx-border);
  z-index: 199;
}

/* ============================================================
   22. FOOTER
   ============================================================ */
.md-footer {
  border-top: 2px solid transparent;
  border-image: var(--nx-gradient) 1;
}

/* ============================================================
   23. SKIP-TO-CONTENT
   ============================================================ */
.md-skip:focus {
  background: var(--nx-purple);
  color: #fff;
}

/* ============================================================
   24. ANNOUNCEMENT BAR
   ============================================================ */
.md-banner {
  background: var(--nx-gradient);
}
.md-banner__inner {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
}
.md-banner__inner a {
  color: #fff;
  text-decoration: underline;
  font-weight: 700;
}

/* ============================================================
   25. REVEAL ANIMATION (injected by JS)
   ============================================================ */
.nexus-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.nexus-reveal.visible {
  opacity: 1;
  transform: none;
}

/* ============================================================
   26. PROGRESS DASHBOARD
   ============================================================ */
.nx-progress-ring {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--nx-teal) var(--progress, 0%), var(--nx-bg-tertiary) 0%);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: var(--nx-shadow-sm);
}
.nx-progress-ring::after {
  content: attr(data-label);
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--nx-bg-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
  color: var(--nx-text-primary);
}

.nx-progress-bar {
  height: 8px;
  background: var(--nx-bg-tertiary);
  border-radius: var(--nx-radius-pill);
  overflow: hidden;
  margin: 0.5rem 0;
}
.nx-progress-bar__fill {
  height: 100%;
  background: var(--nx-gradient);
  border-radius: var(--nx-radius-pill);
  transition: width 0.6s ease;
}

/* ============================================================
   27. MOBILE OPTIMIZATIONS
   ============================================================ */
@media (max-width: 768px) {
  .stat-card .stat-number { font-size: 2rem; }
  .nx-hero { padding: 3rem 1.5rem 2.5rem; }
  .nx-hero h1 { font-size: 1.6rem !important; }
  .nx-hero::after { display: none; }
  .md-typeset .highlight::before { display: none; }
  .nexus-cta, .nexus-cta-outline { font-size: 0.9rem; padding: 0.6rem 1.5rem; }
}

/* ============================================================
   28. THEME TRANSITION & SMOOTH SCROLL
   ============================================================ */
html {
  scroll-behavior: smooth;
}
body {
  transition: background-color 0.3s ease;
}
.md-header, .md-footer, .md-sidebar {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ============================================================
   29. ACCESSIBILITY
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--nx-purple);
  outline-offset: 2px;
  border-radius: var(--nx-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   30. PRINT STYLES
   ============================================================ */
@media print {
  /* Hide non-content elements */
  .md-header, .md-footer, .md-sidebar, .md-tabs,
  #reading-progress, #nexus-complete-btn, .kbd-hint,
  .nx-hero::before, .nx-hero::after, .md-search,
  .nexus-progress-strip, .md-top, .md-banner,
  .md-dialog, .md-source, .nx-streak-fire,
  .nexus-cmd-palette, .nexus-badge-toast,
  iframe, .nexus-cta, .nexus-cta-outline,
  .md-header__button, .md-content__button {
    display: none !important;
  }

  /* Page setup */
  @page { margin: 2cm; size: A4; }
  @page :first { margin-top: 3cm; }

  /* Layout */
  .md-content { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .md-main__inner { margin: 0 !important; }
  .md-grid { max-width: 100% !important; }

  /* Typography */
  body { font-size: 12pt !important; line-height: 1.5 !important; color: #000 !important; }
  .md-typeset { font-size: 12pt !important; color: #000 !important; }
  .md-typeset h1 {
    -webkit-text-fill-color: initial !important;
    background: none !important;
    color: #000 !important;
    filter: none !important;
    font-size: 20pt !important;
    border-bottom: 2pt solid #000;
    padding-bottom: 4pt;
    break-after: avoid;
  }
  .md-typeset h2 {
    font-size: 16pt !important;
    color: #000 !important;
    border-bottom: 1pt solid #666;
    break-after: avoid;
  }
  .md-typeset h3 {
    font-size: 13pt !important;
    color: #000 !important;
    break-after: avoid;
  }

  /* Page breaks */
  .md-typeset .admonition,
  .md-typeset details,
  .md-typeset table,
  .md-typeset pre {
    break-inside: avoid;
  }
  .md-typeset h1 { break-before: page; }
  .md-typeset h1:first-of-type { break-before: auto; }

  /* Links */
  .md-typeset a { color: #000 !important; text-decoration: underline; }
  .md-typeset a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  .md-typeset a[href^="#"]::after,
  .md-typeset a[href^="javascript"]::after { content: none; }

  /* Code blocks */
  .md-typeset pre {
    border: 1pt solid #ccc !important;
    background: #f8f8f8 !important;
    padding: 8pt !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow: visible !important;
  }
  .md-typeset code {
    background: #f0f0f0 !important;
    color: #000 !important;
    font-size: 10pt !important;
  }
  .code-lang-badge { display: none !important; }

  /* Tables */
  .md-typeset table {
    border-collapse: collapse !important;
    width: 100% !important;
  }
  .md-typeset table th,
  .md-typeset table td {
    border: 1pt solid #999 !important;
    padding: 4pt 8pt !important;
    color: #000 !important;
    background: #fff !important;
  }
  .md-typeset table th { background: #eee !important; font-weight: 700 !important; }

  /* Admonitions */
  .md-typeset .admonition {
    border: 1pt solid #666 !important;
    background: #fff !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  .md-typeset .admonition-title {
    background: #eee !important;
    color: #000 !important;
  }

  /* Remove all backgrounds and decorations */
  *, *::before, *::after {
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   31. COMMAND PALETTE
   ============================================================ */
.nexus-cmd-palette {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  align-items: flex-start; justify-content: center; padding-top: 20vh;
}
.nexus-cmd-palette.active { display: flex; }
.ncp-box {
  width: min(560px, 90vw); background: var(--nx-bg-card, #161b22);
  border: 1px solid var(--nx-purple, #7c3aed); border-radius: var(--nx-radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(124,58,237,.25); overflow: hidden;
}
.ncp-input {
  width: 100%; padding: 14px 18px; border: none; outline: none;
  background: transparent; color: var(--nx-text, #e6edf3);
  font-size: 1rem; font-family: inherit;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.ncp-input::placeholder { color: rgba(255,255,255,.35); }
.ncp-results { max-height: 320px; overflow-y: auto; }
.ncp-item {
  padding: 10px 18px; cursor: pointer; color: var(--nx-text, #e6edf3);
  transition: background .12s;
}
.ncp-item:hover, .ncp-item.active {
  background: rgba(124,58,237,.2); color: #fff;
}
.ncp-hints {
  padding: 8px 18px; font-size: .75rem; opacity: .4;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ============================================================
   32. GAMIFICATION WIDGETS
   ============================================================ */
.nexus-xp-toast {
  position: fixed; bottom: 80px; right: 24px; z-index: 9000;
  background: var(--nx-purple, #7c3aed); color: #fff;
  padding: 8px 18px; border-radius: 20px; font-weight: 600; font-size: .9rem;
  opacity: 0; transform: translateY(10px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.nexus-xp-toast.show { opacity: 1; transform: translateY(0); }

.nx-streak-fire {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 12px; font-size: .85rem; cursor: default;
}
.nx-streak-fire .fire-icon { font-size: 1.1rem; }
.nx-streak-fire .fire-count { font-weight: 700; color: var(--nx-teal, #0d9488); }
.nx-streak-fire.hot .fire-icon { animation: fireFlicker 1s infinite alternate; }
@keyframes fireFlicker { 0% { transform: scale(1); } 100% { transform: scale(1.15) rotate(-5deg); } }

/* Gamification dashboard */
.nx-gamification { padding: 16px 0; }
.gam-level { font-size: 1.2rem; margin-bottom: 8px; }
.gam-rank { font-weight: 700; color: var(--nx-purple-light, #a78bfa); }
.gam-lv { opacity: .6; font-size: .9rem; }
.gam-xp-bar {
  height: 10px; background: rgba(255,255,255,.1); border-radius: 5px;
  overflow: hidden; margin-bottom: 4px;
}
.gam-xp-fill {
  height: 100%; background: linear-gradient(90deg, var(--nx-purple, #7c3aed), var(--nx-teal, #0d9488));
  border-radius: 5px; transition: width .5s;
}
.gam-xp-label { font-size: .8rem; opacity: .6; margin-bottom: 12px; }
.gam-streak { font-size: .9rem; margin-bottom: 8px; }
.gam-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.gam-badge { font-size: 1.3rem; cursor: default; }

/* Heatmap grid */
.heatmap-grid {
  display: grid; grid-template-columns: repeat(13, 1fr);
  gap: 3px; margin-top: 8px;
}
.heatmap-cell {
  aspect-ratio: 1; border-radius: 2px;
  min-width: 0;
}
