/* Adaptive Ecosystem Lab — demo. Matches the portfolio "Engineered dark" theme.
   Dependency-free: no fonts, no frameworks. */
:root {
  --bg: #0a0e16;
  --panel: rgba(255, 255, 255, 0.025);
  --panel-2: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --ink: #e8edf6;
  --muted: #98a2b8;
  --soft: #b8c0d2;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --good: #34d399;
  --bad: #f87171;
  --grad: linear-gradient(100deg, #a5b4fc 0%, #818cf8 38%, #22d3ee 100%);
  --radius: 16px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --max: 1000px;

  /* species palette */
  --sp-herb: #34d399;
  --sp-pred: #f87171;
  --sp-deco: #a78bfa;
  --sp-poll: #fbbf24;
  --sp-engi: #22d3ee;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  overflow-x: hidden;
}
.bg-grid {
  position: fixed; inset: 0; z-index: -2;
  background-image: radial-gradient(circle at center, rgba(255,255,255,0.05) 1px, transparent 1.3px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,0.18) 62%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,0.18) 62%, transparent 100%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -3; pointer-events: none;
  background:
    radial-gradient(40rem 40rem at 12% -8%, rgba(129,140,248,0.10), transparent 60%),
    radial-gradient(36rem 36rem at 100% 0%, rgba(34,211,238,0.08), transparent 60%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--panel-2); padding: 0.1em 0.35em; border-radius: 6px; color: var(--soft); }
em { color: var(--ink); font-style: normal; font-weight: 600; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--max); margin: 0 auto; padding: 22px 22px 0;
}
.back { color: var(--soft); font-weight: 600; }
.top-links a { color: var(--soft); }

main { max-width: var(--max); margin: 0 auto; padding: 0 22px; }

/* hero */
.hero { padding: 56px 0 28px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.74rem;
  font-weight: 700; color: var(--accent-2); margin: 0 0 14px; font-family: var(--mono);
}
.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.3rem); line-height: 1.05; margin: 0 0 18px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { font-size: 1.12rem; color: var(--soft); max-width: 62ch; margin: 0; }

/* section blocks */
.block { padding: 40px 0; border-top: 1px solid var(--border); }
.block-head h2 { font-size: 1.5rem; margin: 0 0 10px; }
.block-head p { color: var(--muted); max-width: 64ch; margin: 0 0 22px; }

/* ---- simulation ---- */
.sim-wrap { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(220px, 1fr); gap: 22px; align-items: start; }
.sim-stage { position: relative; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: #05070d; }
#eco { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.sim-tick {
  position: absolute; top: 10px; right: 12px; font-family: var(--mono); font-size: 0.78rem;
  color: var(--soft); background: rgba(5,7,13,0.6); padding: 3px 8px; border-radius: 8px; border: 1px solid var(--border);
}

.sim-side { display: flex; flex-direction: column; gap: 16px; }

.seg { display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.seg-btn { flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 6px; border-radius: 9px; cursor: pointer; transition: 0.15s; }
.seg-btn.active { background: var(--accent); color: #0a0e16; }

.legend { display: flex; flex-direction: column; gap: 7px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.leg-row { display: flex; align-items: center; gap: 9px; font-size: 0.92rem; }
.leg-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.leg-name { color: var(--soft); }
.leg-count { margin-left: auto; font-family: var(--mono); color: var(--ink); font-weight: 600; }

.controls { display: flex; align-items: center; gap: 12px; }
.ctl-play { width: 42px; height: 42px; flex: none; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--ink); font-size: 0.8rem; cursor: pointer; }
.ctl-play:hover { border-color: var(--accent); }
.scrub { flex: 1; accent-color: var(--accent); }
.speed { display: flex; align-items: center; gap: 6px; }
.speed-lbl { font-size: 0.8rem; color: var(--muted); margin-right: 2px; }
.spd { background: var(--panel); border: 1px solid var(--border); color: var(--muted); font: inherit; font-size: 0.8rem; padding: 5px 9px; border-radius: 8px; cursor: pointer; }
.spd.active { color: var(--ink); border-color: var(--accent); }

/* ---- chart ---- */
.chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 12px; }
#chart { width: 100%; height: auto; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 6px; font-size: 0.86rem; }
.k { font-weight: 600; }
.k-bad { color: var(--bad); }
.k-good { color: var(--good); }

/* ---- fixes ---- */
.fix-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.fix { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px; }
.fix h3 { margin: 0 0 8px; font-size: 1.04rem; }
.fix p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.footnote { color: var(--muted); font-size: 0.9rem; margin-top: 22px; }

/* footer */
.foot { max-width: var(--max); margin: 0 auto; padding: 30px 22px 50px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; margin-top: 20px; }

@media (max-width: 760px) {
  .sim-wrap { grid-template-columns: 1fr; }
}
