@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,500;1,600&display=swap");

/* Theme tokens */
:root,
html.dark {
  --bg: #050607;
  --bg-elevated: #111318;
  --bg-deep: #020617;
  --text: #cbd5e1;
  --text-strong: #ffffff;
  --text-muted: #64748b;
  --text-faint: #475569;
  --border: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.1);
  --card: rgba(17, 19, 24, 0.6);
  --card-hover: rgba(17, 19, 24, 0.85);
  --grid-line: rgba(0, 147, 68, 0.05);
  --header-bg: rgba(5, 6, 7, 0.92);
  color-scheme: dark;
}

html.light {
  --bg: #f3f5f2;
  --bg-elevated: #ffffff;
  --bg-deep: #e8ece6;
  --text: #334155;
  --text-strong: #0a0b0d;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: rgba(10, 11, 13, 0.08);
  --border-strong: rgba(10, 11, 13, 0.14);
  --card: rgba(255, 255, 255, 0.9);
  --card-hover: #ffffff;
  --grid-line: rgba(0, 147, 68, 0.08);
  --header-bg: rgba(243, 245, 242, 0.94);
  color-scheme: light;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg) !important;
  color: var(--text) !important;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif !important;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6,
.font-display {
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif !important;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.font-mono,
.tech-label,
pre, code, kbd,
.mlke-help {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace !important;
  letter-spacing: 0.02em;
  font-feature-settings: normal;
}

/* Soften the old all-caps / extrabold crunch */
.tracking-tighter { letter-spacing: -0.035em !important; }
.tracking-\[0\.3em\],
.tracking-\[0\.35em\],
.tracking-\[0\.4em\] { letter-spacing: 0.18em !important; }
.tracking-\[0\.2em\],
.tracking-\[0\.25em\],
.tracking-\[0\.22em\],
.tracking-widest { letter-spacing: 0.12em !important; }
.font-extrabold { font-weight: 700 !important; }
.font-black { font-weight: 800 !important; }

/* Theme-aware Tailwind overrides */
html.light .bg-obsidian,
html.light .bg-slate-950 { background-color: var(--bg) !important; }
html.light .bg-surface\/30,
html.light .bg-surface\/40,
html.light .bg-surface\/50,
html.light .bg-surface\/60,
html.light .bg-surface\/80 { background-color: var(--bg-elevated) !important; }
html.light .text-white { color: var(--text-strong) !important; }
html.light .text-slate-300 { color: #475569 !important; }
html.light .text-slate-400 { color: #64748b !important; }
html.light .text-slate-500 { color: #64748b !important; }
html.light .text-slate-600 { color: #94a3b8 !important; }
html.light .border-white\/5,
html.light .border-white\/10 { border-color: var(--border) !important; }
html.light .bg-white\/5 { background-color: rgba(0, 147, 68, 0.06) !important; }
html.light .bg-obsidian\/60,
html.light .bg-obsidian\/80,
html.light .bg-obsidian\/90 { background-color: var(--bg-elevated) !important; }
html.light pre,
html.light .bg-slate-950 { background-color: #0f1412 !important; color: #cbd5e1 !important; }
html.light pre .text-slate-300,
html.light pre code { color: #cbd5e1 !important; }
html.light #site-header header,
html.light #mobile-menu { background-color: var(--header-bg) !important; }
html.light footer { background-color: var(--bg) !important; }
html.light .nairobi-skyline-wireframe { opacity: 0.12; filter: grayscale(100%) invert(20%) sepia(40%) saturate(800%) hue-rotate(90deg); }
html.light .intel-grid { background-size: 44px 44px; }

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 200, "GRAD" 0, "opsz" 24;
}

.foundry-card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: 0.75rem;
  transition: all 0.5s;
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(24px);
}
@media (min-width: 640px) {
  .foundry-card { padding: 2rem; }
}
.foundry-card:hover {
  border-color: rgba(0, 147, 68, 0.4);
  background: var(--card-hover);
}

.mlke-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.mlke-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.875rem 1.25rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 11px;
  transition: transform 0.2s, filter 0.2s, background-color 0.2s, border-color 0.2s, color 0.2s;
  user-select: none;
}
.mlke-btn:active { transform: translateY(1px); }
.mlke-btn-primary {
  background: #009344;
  color: #fff;
  border-color: rgba(0, 147, 68, 0.55);
}
.mlke-btn-primary:hover { filter: brightness(1.08); }
.mlke-btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-strong);
  border-color: var(--border-strong);
}
.mlke-btn-ghost:hover { border-color: rgba(0, 147, 68, 0.4); color: #009344; }
.mlke-btn-gold {
  background: rgba(197, 160, 89, 0.08);
  color: #C5A059;
  border-color: rgba(197, 160, 89, 0.35);
}
.mlke-btn-gold:hover { background: rgba(197, 160, 89, 0.12); border-color: rgba(197, 160, 89, 0.55); }

.mlke-form label .tech-label { margin-bottom: 0.5rem; display: block; }
.mlke-input,
.mlke-select,
.mlke-textarea {
  width: 100%;
  background: rgba(5, 6, 7, 0.6);
  border: 1px solid var(--border-strong);
  color: var(--text-strong);
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  border-radius: 0.5rem;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.mlke-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
.mlke-textarea { resize: vertical; min-height: 6.5rem; }
.mlke-input::placeholder,
.mlke-textarea::placeholder { color: var(--text-faint); }
.mlke-input:focus,
.mlke-select:focus,
.mlke-textarea:focus {
  border-color: rgba(0, 147, 68, 0.6);
  box-shadow: 0 0 0 4px rgba(0, 147, 68, 0.12);
}
html.light .mlke-input,
html.light .mlke-select,
html.light .mlke-textarea {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-strong);
}
html.light .mlke-input:focus,
html.light .mlke-select:focus,
html.light .mlke-textarea:focus {
  box-shadow: 0 0 0 4px rgba(0, 147, 68, 0.16);
}
.mlke-help {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.intel-grid {
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
}

.nairobi-skyline-wireframe {
  background-image: url('https://lh3.googleusercontent.com/aida-public/AB6AXuDtrcb0buW47UffK_WxZ0fMbUP_88Pp1rYsxo-ZvKbjMoyP3tfXYP8wcv9Utym3CGkgxOrNlvrHAh9NBH92NW5mYeLbMRlyP7mDy5Eoz4AGqEkpjf4U0jX5SLXMjjLLR2d2oUBrpK2QobVIRlMmvqp859LOs5D0X_BFFpVbP_LK1uBa5iQsWB8P8XELIZlMRstb3Hej3OIdCKmhNi9yhEhVag86xFScivhIhbCzNX8pef_9E8F2o1cAVYXwE2lX7HZ8QO3tIRi3qvyD');
  background-size: cover;
  background-position: center 85%;
  mask-image: linear-gradient(to top, transparent 0%, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, transparent 0%, black 50%, transparent 100%);
  filter: grayscale(100%) invert(48%) sepia(79%) saturate(2476%) hue-rotate(114deg) brightness(95%) contrast(105%);
  opacity: 0.2;
}

.status-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

.tech-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--text-muted);
}

.blueprint-accent {
  background: radial-gradient(circle at center, rgba(0, 147, 68, 0.15) 0%, transparent 70%);
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.nav-link.active { color: #009344; }

.page-hero {
  padding-top: 6.5rem;
  padding-bottom: 2.5rem;
}
@media (min-width: 768px) {
  .page-hero {
    padding-top: 8rem;
    padding-bottom: 4rem;
  }
}

.terminal-cursor::after {
  content: "▋";
  animation: blink 1s step-end infinite;
  color: #009344;
  margin-left: 2px;
}
@keyframes blink {
  50% { opacity: 0; }
}

.tab-btn.active {
  color: var(--text-strong);
  border-color: #009344;
  background: rgba(0, 147, 68, 0.1);
}

.model-row:hover {
  background: rgba(0, 147, 68, 0.06);
}

.doc-nav a.active {
  color: #009344;
  border-left-color: #009344;
}

::selection {
  background: rgba(0, 147, 68, 0.3);
  color: #fff;
}

#mobile-menu {
  display: none;
  max-height: calc(100dvh - 5rem);
  overflow-y: auto;
}
#mobile-menu.open {
  display: block;
}

/* Theme toggle */
#theme-toggle {
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s;
}
#theme-toggle:hover {
  color: #009344;
  border-color: rgba(0, 147, 68, 0.4);
}
html.light #theme-toggle .icon-sun { display: none; }
html.light #theme-toggle .icon-moon { display: inline; }
html.dark #theme-toggle .icon-sun { display: inline; }
html.dark #theme-toggle .icon-moon { display: none; }

/* Mobile polish */
@media (max-width: 639px) {
  .logo-tagline { display: none; }
  .page-hero h1 {
    font-size: clamp(2.25rem, 11vw, 3rem) !important;
    line-height: 0.95 !important;
  }
  .foundry-card { border-radius: 0.5rem; }
  .mlke-btn { width: 100%; }
}

/* Safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
  #mobile-menu {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Map nodes */
.map-node {
  cursor: pointer;
  transition: transform 0.2s;
}
.map-node:hover,
.map-node.active {
  transform: scale(1.15);
}
.map-node circle.pulse {
  animation: map-pulse 2s ease-out infinite;
}
@keyframes map-pulse {
  0% { r: 6; opacity: 0.5; }
  100% { r: 18; opacity: 0; }
}

.health-bar {
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
}
.health-bar > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.incident-open { border-left: 3px solid #C5A059; }
.incident-resolved { border-left: 3px solid #009344; }
.incident-investigating { border-left: 3px solid #ef4444; }
