/* ══════════════════════════════════════════════════════════════
   NSYSOps — base.css
   Shared design system: vars, reset, body, nav, ticker, footer,
   section headers, grid/cell, buttons, bars, page wrapper.
   All site pages extend this file.
   ══════════════════════════════════════════════════════════════ */

/* ── RESET ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ── ROOT VARS ── */
:root {
  --bg:          #0a0f0f;
  --bg2:         #0a1010;
  --bg3:         #0d1515;
  --bg4:         #111a1a;
  --border:      rgba(0,255,180,0.12);
  --border-bright: rgba(0,255,180,0.3);
  --cyan:        #00ffb4;
  --cyan-dim:    rgba(0,255,180,0.6);
  --cyan-ghost:  rgba(0,255,180,0.08);
  --amber:       #ffb300;
  --red:         #ff3b3b;
  --blue:        #00aaff;
  --purple:      #9b59ff;
  --text:        rgba(255,255,255,0.85);
  --text-dim:    rgba(255,255,255,0.45);
  --text-ghost:  rgba(255,255,255,0.2);
  --font:        'Share Tech Mono', monospace;
  --scan-speed:  8s;
}

/* ── BODY ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 44px;
  cursor: crosshair;
}

/* ── SCANLINES ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 3px,
    rgba(0,255,180,0.015) 3px, rgba(0,255,180,0.015) 6px
  );
  pointer-events: none;
  z-index: 999;
}

/* ── MOVING SCAN LINE ── */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0; right: 0;
  height: 4px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(0,255,180,0.06),
    rgba(0,255,180,0.12),
    rgba(0,255,180,0.06),
    transparent
  );
  animation: scanline var(--scan-speed) linear infinite;
  pointer-events: none;
  z-index: 999;
}
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; display: none; }
}

/* ── KEYFRAMES ── */
@keyframes scanline { 0% { top: -10px; } 100% { top: 100vh; } }
@keyframes blink    { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes pulse    { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.7); } }
@keyframes ticker   { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,12,12,0.97);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 0;
  backdrop-filter: blur(8px);
}

.nav-logo {
  color: var(--cyan);
  font-size: 15px;
  letter-spacing: 0.15em;
  margin-right: 32px;
  text-decoration: none;
  white-space: nowrap;
}

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

.nav-item {
  position: relative;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-decoration: none;
  padding: 0 14px;
  height: 44px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active { color: var(--cyan); }

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--cyan);
}

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

.nav-dropdown:hover .dropdown-menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dropdown-menu {
  position: absolute;
  top: 44px;
  left: 0;
  background: rgba(8,12,12,0.98);
  border: 1px solid var(--border-bright);
  min-width: 200px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: all 0.15s;
  z-index: 200;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: all 0.1s;
}

.dropdown-item:last-child { border-bottom: none; }

.dropdown-item:hover {
  color: var(--cyan);
  background: var(--cyan-ghost);
  padding-left: 20px;
}

.dropdown-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.nav-badge {
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid;
  letter-spacing: 0.1em;
}

.badge-cyan  { border-color: var(--cyan);  color: var(--cyan); }
.badge-amber { border-color: var(--amber); color: var(--amber); }
.badge-red   { border-color: var(--red);   color: var(--red); }

.nav-ai-btn {
  background: var(--cyan);
  color: #000;
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}

.nav-ai-btn:hover { opacity: 0.85; }

/* ── Hamburger (hidden on desktop) ── */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 16px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
  font-family: var(--font);
  letter-spacing: 0;
  padding: 0;
}
.nav-hamburger:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── Mobile-only nav elements (hidden on desktop) ── */
.nav-mobile-dot  { display: none; }
.nav-mobile-icon { display: none; }


/* ── TICKER ── */
.ticker-bar {
  background: rgba(0,255,180,0.05);
  border-bottom: 1px solid var(--border);
  height: 28px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.ticker-label {
  background: var(--cyan);
  color: #000;
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.ticker-track {
  display: flex;
  animation: ticker 40s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  font-size: 10px;
  color: var(--text-dim);
  padding: 0 32px;
  letter-spacing: 0.05em;
}

.ticker-item span {
  color: var(--cyan);
  margin-right: 8px;
}

/* ── FOOTER BAR ── */
.footer-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 24px;
  background: rgba(8,12,12,0.97);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  font-size: 9px;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.fb {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-ghost);
  letter-spacing: 0.08em;
}

.fb b { color: var(--cyan); font-weight: 400; }

.fb-sep { color: var(--border-bright); }

.fb-right {
  margin-left: auto;
  display: flex;
  gap: 16px;
}

/* ── SHARED SECTION HEADERS ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--border);
}

.section-tag {
  font-size: 9px;
  padding: 2px 8px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  background: var(--cyan-ghost);
  letter-spacing: 0.12em;
}

.section-title {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  flex: 1;
}

.section-meta {
  font-size: 9px;
  color: var(--text-ghost);
  letter-spacing: 0.08em;
}

.section-live {
  font-size: 9px;
  color: var(--cyan);
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.live-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── SHARED GRID / CELL ── */
.grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  margin-bottom: 16px;
}

.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }

.cell {
  background: var(--bg2);
  padding: 14px 16px;
}

.cell-label {
  font-size: 9px;
  color: var(--text-ghost);
  letter-spacing: 0.12em;
  margin-bottom: 5px;
}

.cell-val {
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}

.cell-sub { font-size: 9px; color: var(--text-ghost); }

.vc { color: var(--cyan); }
.va { color: var(--amber); }
.vr { color: var(--red); }
.vb { color: var(--blue); }
.vp { color: var(--purple); }
.vt { color: var(--text); }

/* ── SHARED BUTTONS ── */
.btn {
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border: 1px solid;
  cursor: pointer;
  background: transparent;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-solid  { background: var(--cyan); color: #000; border-color: var(--cyan); }
.btn-solid:hover { opacity: 0.85; }

.btn-outline { border-color: var(--cyan); color: var(--cyan); }
.btn-outline:hover { background: var(--cyan-ghost); }

.btn-dim { border-color: var(--border-bright); color: var(--text-dim); }
.btn-dim:hover { color: var(--text); border-color: var(--text-dim); }

.btn-amber { border-color: var(--amber); color: var(--amber); }
.btn-amber:hover { background: rgba(255,179,0,0.08); }

.btn-red { border-color: var(--red); color: var(--red); }
.btn-red:hover { background: rgba(255,59,59,0.08); }

/* ── SHARED BAR ── */
.bar {
  height: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
  margin: 6px 0 4px;
}

.bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 1px;
}

.bc { background: var(--cyan); }
.ba { background: var(--amber); }
.br { background: var(--red); }
.bb { background: var(--blue); }

/* ── PAGE WRAPPER ── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

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

.page-cmd {
  font-size: 16px;
  color: var(--cyan);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.page-cmd span { color: var(--text-dim); }

.page-meta {
  font-size: 10px;
  color: var(--text-ghost);
  letter-spacing: 0.06em;
}

.page-meta b { color: var(--text-dim); font-weight: 400; }

/* ── MOBILE BOTTOM NAV ── */
.mobile-bottom-nav {
  display: none; /* hidden on desktop */
}

@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.7)} }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  /* ── Mobile bottom tab bar ── */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(8,12,12,0.98);
    border-top: 1px solid var(--border);
    display: flex;
    height: 52px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 400;
    /* iOS Safari fix: force GPU layer so fixed sticks to viewport bottom */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  .m-bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-ghost);
    font-size: 8px;
    letter-spacing: 0.05em;
    cursor: pointer;
    border-right: 1px solid var(--border);
    transition: color 0.15s;
    text-decoration: none;
  }
  .m-bnav-item:last-child { border-right: none; }
  .m-bnav-item.active { color: var(--cyan); }
  .m-bnav-icon { font-size: 15px; line-height: 1; }

  /* Give body bottom padding so content isn't hidden behind nav */
  body { padding-bottom: 52px; }
  .page { padding: 12px; }
  /* Keep top nav sticky — do NOT override to relative */
  nav { padding: 0 12px; }
  .nav-item { padding: 0 8px; font-size: 10px; }
  .nav-dropdown .dropdown-menu { display: none; }
  .footer-bar { display: none; }
  .g3, .g5 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, 1fr); }

  /* ── Top nav: collapse links, swap badges for dot+search ── */
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    background: rgba(8,12,12,0.98);
    border-bottom: 1px solid var(--border-bright);
    padding: 8px 0;
    z-index: 500;
  }
  .nav-links.open .nav-item {
    height: auto;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links.open .nav-item:last-child { border-bottom: none; }
  .nav-links.open .nav-item.active::after { display: none; }

  .nav-logo { margin-right: auto; }
  .nav-right { gap: 8px; }

  /* Hide desktop-only nav elements on mobile */
  .nav-badge  { display: none; }
  .nav-ai-btn { display: none; }

  /* Show mobile-only nav elements */
  .nav-mobile-dot {
    display: block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 5px var(--cyan);
    animation: pulse 2s ease-in-out infinite;
    flex-shrink: 0;
  }
  .nav-mobile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    color: var(--text-dim);
    font-size: 14px;
    border: 1px solid var(--border);
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
    flex-shrink: 0;
  }
  .nav-mobile-icon:hover { border-color: var(--cyan); color: var(--cyan); }

  .nav-hamburger { display: flex; }
  .theme-toggle { display: none; }
}

/* ── THEME TOGGLE BUTTON ── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ── LIGHT THEME ── */
html.theme-light-pending body { background: #f0f2f0; }

body.theme-light {
  --bg: #f0f2f0;
  --bg2: #e8ebe8;
  --bg3: #dfe3df;
  --bg4: #d6dbd6;
  --border: rgba(0,130,80,0.2);
  --border-bright: rgba(0,130,80,0.4);
  --cyan: #007a4d;
  --cyan-dim: rgba(0,122,77,0.7);
  --cyan-ghost: rgba(0,122,77,0.08);
  --amber: #b35900;
  --red: #cc1a1a;
  --blue: #005fa3;
  --purple: #6633cc;
  --text: rgba(0,0,0,0.85);
  --text-dim: rgba(0,0,0,0.55);
  --text-ghost: rgba(0,0,0,0.35);
}

body.theme-light::before {
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px
  );
}

body.theme-light::after { display: none; }

body.theme-light nav {
  background: rgba(240,242,240,0.97);
  border-bottom-color: rgba(0,130,80,0.2);
}

body.theme-light .footer-bar {
  background: rgba(232,235,232,0.97);
}

body.theme-light .dropdown-menu {
  background: rgba(232,235,232,0.99);
}

body.theme-light .ticker-bar {
  background: rgba(0,122,77,0.06);
}

body.theme-light .ticker-label {
  background: var(--cyan);
  color: #fff;
}

/* ── EXPLICIT DARK MODE RESET ──
   Ensures switching back from light mode fully resets all surfaces.
   html.theme-dark is set by applyTheme() in base.js. */
html.theme-dark,
html.theme-dark body {
  background: var(--bg) !important;
  color: rgba(255,255,255,0.85);
}

html.theme-dark nav {
  background: rgba(8,12,12,0.97) !important;
}

html.theme-dark .footer-bar,
html.theme-dark .status-bar {
  background: rgba(8,12,12,0.97) !important;
}

html.theme-dark .dropdown-menu {
  background: rgba(8,12,12,0.98) !important;
}

html.theme-dark .ticker-bar {
  background: rgba(0,255,180,0.05) !important;
}

html.theme-dark .ticker-label {
  background: var(--cyan) !important;
  color: #000 !important;
}
