/* ============================================================
   PLATFORMERS — TERMINAL DARK THEME
   ============================================================ */

:root {
  --bg:           #303841;
  --bg-surface:   #3a4450;
  --bg-elevated:  #424e5c;
  --border:       #4a5668;
  --border-mid:   #556070;
  --border-bright:#607080;

  --green:        #4a9960;
  --green-dim:    #3d7a4a;
  --green-glow:   rgba(74, 153, 96, 0.15);
  --green-glow-lg:rgba(74, 153, 96, 0.07);

  --blue:         #58a6ff;
  --blue-dim:     #388bfd;
  --purple:       #a78bfa;

  --text:         #c9d1d9;
  --text-dim:     #6e7681;
  --text-muted:   #4a5568;
  --text-bright:  #f0f6fc;

  --danger:       #f85149;
  --warning:      #e3b341;

  --mono: 'Hack', 'JetBrains Mono', 'Fira Code', ui-monospace, 'Courier New', monospace;
  --sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  --nav-height: 64px;
  --radius: 4px;

  --nav-bg:        rgba(48, 56, 65, 0.96);
  --nav-mobile-bg: rgba(48, 56, 65, 0.99);
}

/* ---- LIGHT MODE ---- */
[data-theme="light"] {
  --bg:            #f4f5ef;
  --bg-surface:    #e8e9e2;
  --bg-elevated:   #dddeda;
  --border:        #c4c5be;
  --border-mid:    #b2b3ac;
  --border-bright: #9a9b94;

  --green:         #4a9960;
  --green-dim:     #2e5e38;
  --green-glow:    rgba(61, 122, 74, 0.15);
  --green-glow-lg: rgba(61, 122, 74, 0.07);

  --blue:          #2563eb;
  --blue-dim:      #1d4ed8;

  --text:          #2d3748;
  --text-dim:      #4a5568;
  --text-muted:    #718096;
  --text-bright:   #1a202c;

  --danger:        #dc2626;
  --warning:       #d97706;

  --nav-bg:        rgba(48, 56, 65, 0.96);
  --nav-mobile-bg: rgba(48, 56, 65, 0.99);
}

[data-theme="light"] .dropdown-menu {
  background: #3a4450;
  border-color: #556070;
}

/* ---- RESET ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 24px);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

/* ---- NAVBAR ---- */
.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--nav-height);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--green);
  box-shadow: 0 1px 24px var(--green-glow);
}

.nav-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  background: url("/img/logo.png") no-repeat left center;
  background-size: contain;
  height: 40px;
  width: 200px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  color: #c9d1d9;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 13px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.nav-link:hover {
  color: #f0f6fc;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.nav-link.active {
  color: var(--green);
  background: rgba(255, 255, 255, 0.06);
}

/* Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown .nav-link::after {
  content: ' ▾';
  font-size: 10px;
  opacity: 0.5;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  min-width: 200px;
  padding: 6px;
  padding-top: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 230, 118, 0.05);
  z-index: 100;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  color: #c9d1d9;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
  letter-spacing: 0.02em;
}

.dropdown-item:hover {
  color: #f0f6fc;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.dropdown-item.active {
  color: var(--green);
}

/* CTA */
.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green) !important;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 16px;
  border: 1px solid var(--green-dim);
  border-radius: var(--radius);
  margin-left: 10px;
  transition: background 0.15s, box-shadow 0.15s;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.nav-cta::before {
  content: '>';
  opacity: 0.6;
}

.nav-cta:hover {
  background: var(--green-glow);
  box-shadow: 0 0 16px var(--green-glow);
  text-decoration: none;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-mid);
  color: var(--text-dim);
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  vertical-align: middle;
}

.theme-toggle:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-glow);
}

/* Mobile toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--green);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- PAGE STRUCTURE ---- */
.page-wrapper {
  padding-top: var(--nav-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Override MkDocs container */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 40px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 40px;
  align-items: start;
  flex: 1;
}

/* ---- SIDEBAR / TOC ---- */
.bs-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 24px);
  height: fit-content;
  max-height: calc(100vh - var(--nav-height) - 48px);
  overflow-y: auto;
  padding-right: 4px;
}

.bs-sidebar::-webkit-scrollbar {
  width: 3px;
}
.bs-sidebar::-webkit-scrollbar-track { background: transparent; }
.bs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 2px;
}

.toc-heading {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Bootstrap scrollspy targets these classes */
.bs-sidenav {
  list-style: none;
  background: none !important;
}

.well {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.bs-sidenav li + li {
  margin-top: 1px;
}

.bs-sidenav a {
  display: block;
  color: var(--text-dim);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.bs-sidenav a:hover {
  color: var(--text);
  background: var(--bg-elevated);
  text-decoration: none;
}

.bs-sidenav .active > a,
.bs-sidenav > .active > a:hover,
.bs-sidenav > .active > a:focus {
  color: var(--green) !important;
  border-left-color: var(--green) !important;
  background: var(--green-glow) !important;
}

.bs-sidenav .second-level {
  padding-left: 14px;
}

.bs-sidenav .third-level {
  padding-left: 26px;
}

/* ---- MAIN CONTENT ---- */
[role="main"] {
  min-width: 0;
}

.col-md-12 {
  grid-column: 1 / -1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--mono);
  color: var(--text-bright);
  line-height: 1.35;
  margin-top: 2.2em;
  margin-bottom: 0.8em;
  font-weight: 500;
}

h1:first-child, h2:first-child,
h3:first-child, h4:first-child {
  margin-top: 0;
}

h1 {
  font-size: 26px;
  font-weight: 400;
  color: var(--text-bright);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

h1::before { content: '# '; color: var(--text-muted); font-weight: 300; }

h2 {
  font-size: 20px;
  color: var(--text);
}

h2::before { content: '## '; color: var(--text-muted); font-weight: 300; font-size: 14px; }

h3 {
  font-size: 16px;
  color: var(--text-dim);
}

h4 { font-size: 14px; color: var(--text-dim); }

p { margin-bottom: 1.1em; }

strong { color: var(--text-bright); }

em { color: var(--text); }

a {
  color: var(--green);
  text-decoration: none;
  transition: color 0.12s;
}

a:hover {
  color: var(--green-dim);
  text-decoration: underline;
}

/* Lists */
ul, ol {
  margin-bottom: 1.1em;
  padding-left: 1.4em;
}

li { margin-bottom: 0.35em; }

ul > li::marker {
  color: var(--green);
  content: '*  ';
}

ol > li::marker {
  color: var(--green-dim);
}

/* Nested list reset */
ul ul, ul ol, ol ul, ol ol {
  margin-top: 0.3em;
  margin-bottom: 0;
}

/* Code */
code {
  font-family: var(--mono);
  font-size: 0.875em;
  color: var(--green);
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  padding: 2px 6px;
  border-radius: var(--radius);
  word-break: break-word;
}

pre {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  margin-bottom: 1.5em;
  overflow: hidden;
}

pre::before {
  content: '';
  display: block;
  height: 32px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  background-image: radial-gradient(circle, #f85149 6px, transparent 6px),
                    radial-gradient(circle, #e3b341 6px, transparent 6px),
                    radial-gradient(circle, #00e676 6px, transparent 6px);
  background-size: 12px 12px;
  background-position: 14px center, 32px center, 50px center;
  background-repeat: no-repeat;
}

pre code {
  display: block;
  padding: 24px 28px;
  color: var(--text);
  background: none;
  border: none;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: auto;
  word-break: normal;
}

/* highlight.js overrides for dark bg */
.hljs { background: transparent !important; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 14px;
}

/* Override bootstrap class added by base.js */
.table { width: 100%; }
.table-striped tbody tr:nth-of-type(odd) { background: var(--bg-surface); }
.table-hover tbody tr:hover { background: var(--bg-elevated); }

th {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  padding: 10px 16px;
  border-bottom: 1px solid var(--green-dim);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

/* Blockquote */
blockquote {
  border-left: 3px solid var(--green-dim);
  margin: 1.5em 0;
  padding: 14px 20px;
  background: var(--bg-surface);
  color: var(--text-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}

blockquote p:last-child { margin-bottom: 0; }

/* HR */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

/* Images */
img {
  border-radius: var(--radius);
}

/* Kbd */
kbd {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-bottom-width: 2px;
  padding: 2px 7px;
  border-radius: var(--radius);
}

/* Source labels */
.source-links {
  margin-bottom: 1em;
}

.label-primary {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--green-dim);
  border-radius: var(--radius);
  color: var(--green);
  background: var(--green-glow);
  margin-right: 6px;
  text-decoration: none;
}

/* ---- FOOTER ---- */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.02em;
}

.site-footer a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.12s;
}

.site-footer a:hover {
  color: var(--green);
}

.site-footer .sep { margin: 0 10px; opacity: 0.3; }

/* ---- BOOTSTRAP MODAL (dark re-skin) ---- */
.modal { display: none; }
.modal.in { display: block; }

.modal-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1040;
  background: rgba(0, 0, 0, 0.75);
}

.modal {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1050;
  overflow: auto;
  outline: 0;
}

.modal-dialog {
  position: relative;
  max-width: 600px;
  margin: 80px auto;
  padding: 0 16px;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 230, 118, 0.08);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--green);
  letter-spacing: 0.05em;
}

.modal-header .close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.12s;
}

.modal-header .close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
}

.modal-body table { margin-bottom: 0; }
.modal-body th { font-size: 11px; }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  text-align: right;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* form-control for search */
.form-group { margin-bottom: 16px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--green); }
.form-control::placeholder { color: var(--text-muted); }

/* ---- 404 PAGE ---- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  font-family: var(--mono);
  gap: 16px;
}

.error-404 {
  font-size: 96px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
  text-shadow: 0 0 40px var(--green-glow);
  letter-spacing: -2px;
}

.error-page p {
  color: var(--text-dim);
  font-size: 16px;
}

.error-page a {
  color: var(--green);
  font-family: var(--mono);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 32px 20px;
  }

  .bs-sidebar {
    position: static;
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--nav-mobile-bg);
    border-bottom: 1px solid var(--border-mid);
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
    gap: 2px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
    z-index: 999;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-link {
    width: 100%;
  }

  .nav-dropdown .dropdown-menu {
    position: static;
    display: none;
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--border-mid);
    border-radius: 0;
    background: transparent;
    padding: 4px 0 4px 12px;
    margin-top: 2px;
  }

  .nav-dropdown:hover .dropdown-menu,
  .nav-dropdown:focus-within .dropdown-menu {
    display: none;
  }

  .nav-dropdown.open .dropdown-menu {
    display: block;
  }

  .nav-cta {
    margin-left: 0;
    margin-top: 8px;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .container { padding: 24px 16px; }
  .nav-container { padding: 0 16px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

/* ---- PAGE BOOT-IN ---- */
@keyframes boot-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-wrapper {
  animation: boot-in 0.35s ease-out both;
}

/* ---- CRT SCANLINES on navbar ---- */
.site-nav::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.06) 3px,
    rgba(0, 0, 0, 0.06) 4px
  );
}

/* ---- BLINKING CURSOR on H1 ---- */
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

h1::after {
  content: '▋';
  color: var(--green);
  font-weight: 300;
  margin-left: 3px;
  animation: cursor-blink 1.1s step-end infinite;
}

/* ---- GLITCH on H1 hover ---- */
@keyframes text-glitch {
  0%, 78%, 100% {
    text-shadow: none;
    transform: translateX(0);
  }
  80% {
    text-shadow: -3px 0 rgba(255, 23,  68, 0.85), 3px 0 rgba(0, 229, 255, 0.85);
    transform: translateX(3px);
  }
  82% {
    text-shadow: 3px 0 rgba(255, 23,  68, 0.85), -3px 0 rgba(0, 229, 255, 0.85);
    transform: translateX(-3px);
  }
  84% {
    text-shadow: -2px 0 rgba(255, 23,  68, 0.6),  2px 0 rgba(0, 229, 255, 0.6);
    transform: translateX(1px);
  }
  86% {
    text-shadow: 1px 0 rgba(255, 23, 68, 0.4), -1px 0 rgba(0, 229, 255, 0.4);
    transform: translateX(0);
  }
}

h1:hover {
  animation: text-glitch 2.5s step-end infinite;
  cursor: default;
}

/* ---- NAV LINK UNDERLINE (expand from center) ---- */
.nav-link:not(.dropdown-toggle) {
  position: relative;
}

.nav-link:not(.dropdown-toggle)::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  right: 50%;
  height: 1px;
  background: var(--green);
  transition: left 0.2s ease, right 0.2s ease;
}

.nav-link:not(.dropdown-toggle):hover::after,
.nav-link:not(.dropdown-toggle).active::after {
  left: 13px;
  right: 13px;
}

/* ---- CTA GLOW PULSE ---- */
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 6px  rgba(0, 230, 118, 0.2); }
  50%       { box-shadow: 0 0 20px rgba(0, 230, 118, 0.5), 0 0 40px rgba(0, 230, 118, 0.15); }
}

.nav-cta {
  animation: glow-pulse 2.8s ease-in-out infinite;
}

/* ---- SCROLL REVEAL ---- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
