/* =============================================================
   SHARED STYLESHEET — AI / Biotech / Defence dashboards
   Loaded by all sector pages via <link rel="stylesheet" href="../shared.css">
   Page-specific and sector-specific CSS lives in each page's own <style> block.
   ============================================================= */

/* ---- CSS Reset ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Design tokens ---- */
/* Light mode (default) */
:root {
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --surface2: #f1f5f9;
  --border:   #cbd5e1;
  --accent:   #0284c7;
  --accent2:  #ea580c;
  --accent3:  #65a30d;
  --gold:     #b45309;
  --text:     #0f172a;
  --muted:    #1e293b;
  --red:      #dc2626;
  --green:    #16a34a;
  --purple:   #7c3aed;
  --blue:     #2563eb;
  --indigo:   #4f46e5;
  --rose:     #e11d48;
  --teal:     #0d9488;
  --amber:    #d97706;
  --slate:    #334155;
  --lime:     #65a30d;
}

/* Dark mode */
html[data-theme="dark"] {
  --bg:       #000000;
  --surface:  #0e1419;
  --surface2: #141b22;
  --border:   #1e2d3d;
  --accent:   #00d4ff;
  --accent2:  #ff6b35;
  --accent3:  #39ff14;
  --gold:     #ffd700;
  --text:     #e0eaf5;
  --muted:    #5a7a9a;
  --red:      #ff4444;
  --green:    #00e676;
  --purple:   #c084fc;
  --blue:     #4488ff;
  --indigo:   #a78bfa;
  --rose:     #fb7185;
  --teal:     #2dd4bf;
  --amber:    #f59e0b;
  --slate:    #94a3b8;
  --lime:     #a3e635;
}

/* ---- Base ---- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  padding-top: 36px;
}

/* Animated background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(2,132,199,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(2,132,199,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

html[data-theme="dark"] body::before {
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
}

/* ---- Ticker tape ---- */
#ticker-tape {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg);
  border-bottom: 1px solid var(--accent);
  z-index: 200;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.tape-track {
  display: flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
}

.tape-track.running {
  animation: tape-scroll linear infinite;
}

.tape-track:hover { animation-play-state: paused; }

@keyframes tape-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.tape-item {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  border-right: 1px solid var(--border);
  cursor: default;
}

.tape-t  { color: var(--text); font-weight: 700; letter-spacing: 1px; }
.tape-p  { color: var(--text); }
.tape-r  { font-weight: 700; }
.tape-r.pos  { color: var(--green); }
.tape-r.neg  { color: var(--red); }
.tape-r.flat { color: var(--muted); }

/* ---- Header ---- */
header {
  position: relative;
  z-index: 10;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  max-width: 1920px;
  margin: 0 auto;
  padding: 0 24px 0 43px;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-left { flex: 1; min-width: 0; }

.header-inner::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.header-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

h1 {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
  margin-bottom: 10px;
}

h1 span { color: var(--accent); }

.header-sub {
  color: var(--muted);
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ---- Sector switcher (header right side) ---- */
.sector-switcher {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-self: center;
}

.sector-card {
  flex: 1;
  min-width: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--muted);
  border-radius: 4px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  opacity: 0.45;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.sector-card:hover { background: var(--surface2); border-top-color: var(--accent); border-color: var(--accent); opacity: 1; cursor: pointer; }
.sector-card.active { border-top-color: var(--accent); border-color: var(--border); background: var(--surface2); opacity: 1; cursor: default; pointer-events: none; }

.sector-card-top { display: flex; align-items: center; justify-content: space-between; }
.sector-card-icon { font-size: 18px; line-height: 1; }
.sector-card-name { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }

/* Hub card — back to root sectors chooser */
.hub-card { border-top-color: var(--border); min-width: 80px; flex: 0 0 auto; }

/* Badge (shared with root sectors page) */
.badge { font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 6px; border-radius: 2px; }
.badge-live { background: rgba(0,230,118,0.12); color: var(--green); border: 1px solid rgba(0,230,118,0.3); }

/* ---- Nav ---- */
nav {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.nav-inner {
  max-width: 1920px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  gap: 2px;
  align-items: center;
}

.nav-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 20px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all 0.2s;
  position: relative;
}
.nav-link:hover  { color: var(--accent); border-color: var(--accent); }
.nav-link.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700; }

/* Nav tooltips */
.nav-link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 400;
  line-height: 1.5;
  width: 200px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.nav-link[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--accent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 1001;
}
.nav-link:hover[data-tooltip]::after,
.nav-link:hover[data-tooltip]::before { opacity: 1; }

/* Prevent first/last tooltip from clipping off-screen */
a[href="index.html"].nav-link[data-tooltip]::after    { left: 0; transform: none; }
a[href="index.html"].nav-link[data-tooltip]::before   { left: 16px; transform: none; }
a[href="calculator.html"].nav-link[data-tooltip]::after  { left: auto; right: 0; transform: none; }
a[href="calculator.html"].nav-link[data-tooltip]::before { left: auto; right: 16px; transform: none; }

/* ---- Theme toggle (card-style square in sector switcher) ---- */
.theme-toggle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  width: 44px;
  min-width: 44px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s, color 0.15s, opacity 0.15s;
  opacity: 0.65;
  padding: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); border-top-color: var(--accent); opacity: 1; background: var(--surface2); }

/* ---- Content container ---- */
.container {
  position: relative;
  z-index: 20;
  max-width: 1920px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* Header note — disclaimer strip below sector switcher, matches table width */
.header-note {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.2px;
  width: calc(100% - 48px);
  max-width: 1552px;
  margin: 8px auto 0;
  padding: 8px 16px;
  line-height: 1.5;
  border: 1px solid var(--border);
}

/* ---- Dashboard: price change pills ---- */
.change-pills {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: nowrap;
}
.cpill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
}
.cpill.pos  { background: rgba(22,163,74,0.12);   color: var(--green); }
.cpill.neg  { background: rgba(220,38,38,0.12);   color: var(--red); }
.cpill.flat { background: rgba(100,116,139,0.12); color: var(--muted); }

html[data-theme="dark"] .cpill.pos  { background: rgba(0,230,118,0.12); }
html[data-theme="dark"] .cpill.neg  { background: rgba(255,68,68,0.12); }
html[data-theme="dark"] .cpill.flat { background: rgba(90,122,154,0.12); }

/* ---- Dashboard: notes / key angle column ---- */
.notes-text {
  color: var(--muted);
  font-size: 13px;
  max-width: 260px;
  white-space: normal;
  line-height: 1.4;
}

/* ---- Footer ---- */
footer {
  margin-top: 48px;
  padding: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---- Disclaimer bar ---- */
.disclaimer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 10px 16px;
  margin-bottom: 20px;
  letter-spacing: 0.3px;
}
.disclaimer span { color: var(--accent2); }
