/* ============================================================
   ALYTH AI FACTORY — PORTAL DESIGN SYSTEM
   Dark infrastructure aesthetic. Shared by all portal pages.
   ============================================================ */

:root {
  --bg: #07090d;
  --bg-raise: #0c1016;
  --panel: #11161d;
  --panel-2: #161c25;
  --border: #1e2733;
  --border-hi: #2c3947;
  --text: #e8eef4;
  --muted: #93a1b0;
  --faint: #5c6a78;

  --green: #76b900;         /* compute / NVIDIA accent */
  --green-dim: #4c7a00;
  --cyan: #38bdf8;          /* grid power */
  --teal: #2dd4bf;          /* wind / private wire */
  --amber: #fbbf24;         /* BESS / storage */
  --orange: #f97316;        /* thermal / heat */
  --violet: #a78bfa;        /* protection & control */
  --red: #f8636f;           /* faults / contingency */
  --blue: #60a5fa;          /* water / coolant */

  --font: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

  --rad: 12px;
  --rad-sm: 8px;
  --maxw: 1480px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(118,185,0,.35); }

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }

/* ---------- top navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 300;
  background: rgba(7,9,13,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 22px;
  padding: 0 24px; height: 58px;
}
.nav-brand {
  display: flex; align-items: baseline; gap: 10px;
  font-weight: 800; letter-spacing: .06em; font-size: 15px;
  color: var(--text); white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand .dot { color: var(--green); }
.nav-brand small {
  font-weight: 600; font-size: 10px; letter-spacing: .18em;
  color: var(--faint); text-transform: uppercase;
}
.nav-links { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 7px; letter-spacing: .02em;
}
.nav-links a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav-links a.active { color: var(--green); background: rgba(118,185,0,.10); }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 28px 24px 90px; }

.page-head { margin: 26px 0 8px; }
.page-head .crumb {
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--green); margin-bottom: 10px;
}
.page-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.page-head .sub { color: var(--muted); max-width: 900px; margin-top: 10px; font-size: 15.5px; }

.section { margin-top: 46px; }
.section > h2 {
  font-size: 21px; font-weight: 750; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
}
.section > h2 .tick { width: 22px; height: 3px; background: var(--green); border-radius: 2px; flex: none; }
.section > .lede { color: var(--muted); max-width: 940px; margin-bottom: 18px; }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .g4, .g6 { grid-template-columns: repeat(3, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px)  { .g2, .g3, .g4, .g6 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px)  { .g2, .g3, .g4, .g6 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--rad); padding: 18px 20px;
}
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.card.pad0 { padding: 0; overflow: hidden; }

/* KPI tiles */
.kpi {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-raise) 100%);
  border: 1px solid var(--border); border-radius: var(--rad);
  padding: 16px 18px 14px; position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--kpi-accent, var(--green)); opacity: .85;
}
.kpi .k-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.kpi .k-value {
  font-family: var(--mono); font-size: 30px; font-weight: 700;
  letter-spacing: -.02em; margin-top: 6px; color: var(--text);
}
.kpi .k-value small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.kpi .k-note { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* stat rows inside cards */
.spec-list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.spec-list tr { border-top: 1px solid var(--border); }
.spec-list tr:first-child { border-top: 0; }
.spec-list td { padding: 8px 2px; vertical-align: top; }
.spec-list td:first-child { color: var(--muted); width: 46%; padding-right: 14px; }
.spec-list td:last-child { font-family: var(--mono); font-size: 12.8px; }

/* data tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--rad); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.tbl thead th {
  text-align: left; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); background: var(--bg-raise);
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl tbody td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(255,255,255,.02); }
.tbl .num { font-family: var(--mono); font-size: 12.8px; white-space: nowrap; }

/* badges & chips */
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border-hi); color: var(--muted);
}
.badge.green  { color: var(--green);  border-color: rgba(118,185,0,.4);  background: rgba(118,185,0,.08); }
.badge.cyan   { color: var(--cyan);   border-color: rgba(56,189,248,.4); background: rgba(56,189,248,.08); }
.badge.teal   { color: var(--teal);   border-color: rgba(45,212,191,.4); background: rgba(45,212,191,.08); }
.badge.amber  { color: var(--amber);  border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.08); }
.badge.orange { color: var(--orange); border-color: rgba(249,115,22,.4); background: rgba(249,115,22,.08); }
.badge.violet { color: var(--violet); border-color: rgba(167,139,250,.4);background: rgba(167,139,250,.08); }
.badge.red    { color: var(--red);    border-color: rgba(248,99,111,.4); background: rgba(248,99,111,.08); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
  background: var(--bg-raise); cursor: default;
}
.chip .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* segmented control (mode / phase / layer switches) */
.seg {
  display: inline-flex; background: var(--bg-raise);
  border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px;
  flex-wrap: wrap;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: 600 12.5px/1 var(--font); letter-spacing: .02em;
  padding: 8px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--green); color: #0a0f04; font-weight: 750; }
.seg.cyan button.on { background: var(--cyan); color: #04121c; }
.seg.amber button.on { background: var(--amber); color: #1c1204; }

/* toggle pills for layers */
.layer-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.layer-toggles button {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-raise); color: var(--muted);
  font: 600 12px/1 var(--font); padding: 8px 13px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all .15s;
}
.layer-toggles button .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.layer-toggles button.on { color: var(--text); border-color: var(--border-hi); }
.layer-toggles button.on .sw { box-shadow: 0 0 8px currentColor; }

/* viewport shells (3D / SVG stages) */
.stage {
  position: relative; background: #05070a;
  border: 1px solid var(--border); border-radius: var(--rad);
  overflow: hidden;
}
.stage .hud {
  position: absolute; z-index: 20; display: flex; gap: 10px; flex-wrap: wrap;
}
.stage .hud.tl { top: 14px; left: 14px; }
.stage .hud.tr { top: 14px; right: 14px; }
.stage .hud.bl { bottom: 14px; left: 14px; }
.stage .hud.br { bottom: 14px; right: 14px; }

.hud-panel {
  background: rgba(10,14,19,.88); backdrop-filter: blur(8px);
  border: 1px solid var(--border-hi); border-radius: 10px;
  padding: 12px 14px; max-width: 330px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.hud-panel h4 {
  font-size: 12.5px; font-weight: 750; letter-spacing: .04em;
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.hud-panel .hint { font-size: 11.5px; color: var(--faint); }

/* detail drawer (click-to-inspect) */
.inspector {
  position: absolute; top: 14px; right: 14px; bottom: 14px; width: 340px; z-index: 30;
  background: rgba(10,14,19,.94); backdrop-filter: blur(10px);
  border: 1px solid var(--border-hi); border-radius: 12px;
  padding: 18px; overflow-y: auto;
  transform: translateX(calc(100% + 20px)); transition: transform .28s ease;
  box-shadow: -6px 0 40px rgba(0,0,0,.5);
}
.inspector.open { transform: translateX(0); }
.inspector .close {
  position: absolute; top: 10px; right: 12px; cursor: pointer;
  background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1;
}
.inspector h3 { font-size: 16px; font-weight: 750; margin: 2px 24px 2px 0; }
.inspector .type { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; margin-bottom: 12px; }
@media (max-width: 720px) { .inspector { width: calc(100% - 28px); } }

/* callouts */
.note {
  border-left: 3px solid var(--green); background: rgba(118,185,0,.06);
  border-radius: 0 var(--rad-sm) var(--rad-sm) 0; padding: 13px 16px;
  font-size: 13.5px; color: var(--muted);
}
.note b { color: var(--text); }
.note.cyan { border-color: var(--cyan); background: rgba(56,189,248,.06); }
.note.amber { border-color: var(--amber); background: rgba(251,191,36,.06); }
.note.orange { border-color: var(--orange); background: rgba(249,115,22,.06); }

/* footer */
.foot {
  border-top: 1px solid var(--border); margin-top: 70px;
  padding: 26px 24px 40px; color: var(--faint); font-size: 12px;
}
.foot .wrapf { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 20px; flex-wrap: wrap; justify-content: space-between; }

/* utility */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt20 { margin-top: 20px; } .mt28 { margin-top: 28px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* svg diagram common */
.diagram-svg { display: block; width: 100%; height: auto; }
.diagram-svg text { font-family: var(--font); }
.diagram-svg .mono-t { font-family: var(--mono); }

@keyframes dashflow { to { stroke-dashoffset: -26; } }
.flow-line { stroke-dasharray: 7 6; animation: dashflow 1.1s linear infinite; }
.flow-line.slow { animation-duration: 2s; }
.flow-line.off { animation-play-state: paused; opacity: .18; }

@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.pulse { animation: pulse 2.2s ease-in-out infinite; }

/* cinematic tour (letterbox + caption) */
.stage .hud, .stage .inspector { transition: opacity .5s ease; }
.stage.cine .hud, .stage.cine .inspector { opacity: 0 !important; pointer-events: none; }
.cine-bar { position: absolute; left: 0; right: 0; height: 0; background: #000; z-index: 45; transition: height .9s ease; pointer-events: none; }
.cine-bar.top { top: 0; } .cine-bar.bot { bottom: 0; }
.stage.cine .cine-bar { height: 9%; }
.cine-cap {
  position: absolute; bottom: 11.5%; left: 50%; transform: translateX(-50%);
  z-index: 46; text-align: center; opacity: 0; transition: opacity .7s; pointer-events: none;
  width: min(720px, 86%);
}
.stage.cine .cine-cap { opacity: 1; }
.cine-cap .t { font: 750 21px/1.2 var(--font); color: #fff; letter-spacing: .01em; text-shadow: 0 2px 16px rgba(0,0,0,.9); }
.cine-cap .d { font: 400 13.5px/1.5 var(--font); color: #cdd8e2; margin-top: 7px; text-shadow: 0 1px 10px rgba(0,0,0,.9); }
.tour-btn {
  appearance: none; cursor: pointer; border: 1px solid rgba(118,185,0,.5);
  background: rgba(118,185,0,.1); color: var(--green);
  font: 700 12.5px/1 var(--font); padding: 9px 16px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px; transition: all .15s;
}
.tour-btn:hover { background: rgba(118,185,0,.2); }
.tour-btn.on { background: var(--red); border-color: var(--red); color: #fff; }
