/* RTOS, demystified — sibling palette to xv6, demystified */
:root {
  --bg: #0a0b14;
  --bg-2: #10121f;
  --panel: #161a2c;
  --panel-2: #1d2238;
  --line: #2a3050;
  --text: #e8ebf5;
  --muted: #9aa3c4;
  --dim: #6b7299;

  --accent: #7c5cff;
  --accent-2: #21d4fd;
  --grad: linear-gradient(120deg, #7c5cff 0%, #21d4fd 100%);

  --fetch: #ffb020;
  --danger: #ff5c7c;
  --ok: #34e89e;

  --los: #ff5c7c;
  --framer: #21d4fd;
  --telem: #7c5cff;
  --cli: #ffb020;
  --high: #ff5c7c;
  --med: #ffb020;
  --low: #21d4fd;
  --alarm: #ff5c7c;
  --work: #7c5cff;
  --bg-task: #34e89e;

  --radius: 16px;
  --radius-sm: 10px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: rgba(124, 92, 255, 0.4); }
code, kbd, .mono { font-family: var(--mono); }
code {
  background: rgba(124, 92, 255, 0.14);
  color: #c5b8ff;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.88em;
}
a { color: var(--accent-2); }

#scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--grad); z-index: 100;
  box-shadow: 0 0 12px rgba(124, 92, 255, 0.6);
}

#sidenav {
  position: fixed; top: 0; left: 0; width: 230px; height: 100vh;
  padding: 28px 18px;
  background: rgba(13, 15, 26, 0.7);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--line);
  z-index: 90;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.nav-brand {
  font-weight: 800; font-size: 1.2rem; margin-bottom: 18px; letter-spacing: -0.02em;
}
.nav-brand span { color: var(--dim); font-weight: 500; }
.nav-link {
  color: var(--muted); text-decoration: none; font-size: 0.86rem; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; border-left: 2px solid transparent;
  transition: all 0.15s ease;
}
.nav-link:hover { color: var(--text); background: rgba(124, 92, 255, 0.08); }
.nav-link.active {
  color: var(--text); background: rgba(124, 92, 255, 0.14); border-left-color: var(--accent);
}
#nav-toggle {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 95;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  width: 42px; height: 42px; border-radius: 10px; font-size: 1.2rem; cursor: pointer;
}

main { margin-left: 230px; }
.section {
  max-width: 980px; margin: 0 auto; padding: 90px 32px;
  border-bottom: 1px solid rgba(42, 48, 80, 0.5);
}
.section-head { margin-bottom: 40px; }
.kicker {
  display: inline-block; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2);
  margin-bottom: 12px;
}
h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.6rem); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 18px;
}
h2 em { font-style: normal; color: var(--accent); }
.explain { color: var(--muted); font-size: 1.05rem; max-width: 760px; margin-bottom: 14px; }
.explain strong { color: var(--text); }
.caption { color: var(--dim); font-size: 0.9rem; margin-top: 22px; max-width: 800px; }
.caption strong { color: var(--text); }
.panel-title {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--dim); margin-bottom: 12px;
}
.hint { color: var(--dim); font-size: 0.85rem; margin-top: 10px; }

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 80px 40px 64px;
  overflow: hidden;
}
.hero-inner { max-width: 880px; text-align: center; position: relative; z-index: 2; }
.badge {
  display: inline-block; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent-2); border: 1px solid var(--line);
  background: rgba(33, 212, 253, 0.06); padding: 6px 14px; border-radius: 100px;
  margin-bottom: 28px;
}
.hero h1 {
  font-size: clamp(3rem, 9vw, 6rem); font-weight: 800; letter-spacing: -0.04em;
  line-height: 0.95; margin-bottom: 28px;
}
.grad {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lede { font-size: 1.2rem; color: var(--muted); margin-bottom: 16px; }
.lede strong { color: var(--text); }
.lede em { color: var(--accent-2); font-style: normal; }
.lede-soft { font-size: 1.05rem; margin-bottom: 28px; }
.acronym {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--accent-2);
  margin: -12px 0 22px;
  letter-spacing: 0.02em;
}
.acronym strong { color: var(--text); font-weight: 700; }
.sub { color: var(--dim); margin-bottom: 36px; }

.who {
  text-align: left;
  margin: 8px 0 28px;
  padding: 22px;
  background: rgba(16, 18, 31, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.who-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 8px;
  text-align: center;
}
.who-lead {
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  max-width: 640px;
  margin: 0 auto 18px;
}
.who-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.who-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 16px 18px;
}
.who-card h3 { font-size: 0.95rem; margin-bottom: 8px; font-weight: 700; }
.who-card p { color: var(--muted); font-size: 0.88rem; }
.who-card em { color: var(--accent-2); font-style: normal; }
.who-card strong { color: var(--text); }

.ctx { margin: 8px 0 28px; }
.cta {
  display: inline-block; background: var(--grad); color: #0a0b14; font-weight: 700;
  text-decoration: none; padding: 14px 32px; border-radius: 100px; font-size: 1.05rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 30px rgba(124, 92, 255, 0.35);
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(124, 92, 255, 0.5); }
.hero-glow {
  position: absolute; width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(255, 92, 124, 0.18), transparent 60%);
  top: 50%; left: 50%; transform: translate(-50%, -50%); filter: blur(40px); z-index: 1;
  animation: pulse 6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.controls.vertical { flex-direction: column; align-items: stretch; }
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 10px; font-family: var(--sans); font-weight: 600;
  font-size: 0.92rem; cursor: pointer; transition: all 0.13s ease;
}
.btn:hover { border-color: var(--accent); background: #232a44; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #0a0b14; border: none; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255,92,124,0.16); border-color: rgba(255,92,124,0.5); color: #ff9db1; }
.btn-danger:hover { background: rgba(255,92,124,0.28); }

.toggle { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.toggle input { display: none; }
.toggle-track {
  width: 50px; height: 28px; border-radius: 100px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--line); position: relative;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--dim); transition: all 0.2s ease;
}
.toggle input:checked + .toggle-track { background: rgba(52,232,158,0.3); border-color: var(--ok); }
.toggle input:checked + .toggle-track .toggle-thumb { left: 24px; background: var(--ok); }

.screen {
  background: #05060d; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; font-family: var(--mono); font-size: 0.8rem; min-height: 120px;
  max-height: 180px; overflow-y: auto; color: var(--muted); white-space: pre-wrap;
}

/* Gantt */
.gantt {
  background: #05060d; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; overflow-x: auto;
}
.gantt-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gantt-label {
  width: 92px; flex-shrink: 0; font-family: var(--mono); font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.02em;
}
.gantt-cells { display: flex; gap: 2px; }
.gantt-cell {
  width: 16px; height: 18px; border-radius: 3px; background: #12141f; flex-shrink: 0;
}
.gantt-cell.on { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.gantt-cell.now { outline: 1px solid #fff; outline-offset: 1px; }
.gantt-axis {
  display: flex; gap: 2px; margin-left: 102px; margin-top: 4px;
  font-family: var(--mono); font-size: 0.62rem; color: var(--dim);
}
.gantt-axis span { width: 16px; text-align: center; flex-shrink: 0; }

.verdict {
  margin-top: 12px; font-family: var(--mono); font-size: 0.85rem; font-weight: 700;
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted);
}
.verdict.met { color: var(--ok); border-color: rgba(52,232,158,0.45); background: rgba(52,232,158,0.08); }
.verdict.miss { color: var(--danger); border-color: rgba(255,92,124,0.45); background: rgba(255,92,124,0.08); }

/* Fair vs on time */
.vs-demo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.vs-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.vs-col.vs-rt { border-color: rgba(52,232,158,0.35); }
.vs-head h3 { font-size: 1.05rem; margin-bottom: 4px; }
.vs-head p { color: var(--dim); font-size: 0.85rem; margin-bottom: 14px; }
.vs-tag {
  display: inline-block; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.vs-tag.rt { color: var(--ok); }

/* Network element */
.ne-demo {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
}
.ne-stage { min-width: 0; }
.ne-line { display: flex; align-items: center; gap: 0; margin-bottom: 18px; }
.ne-port {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
  padding: 10px 12px; border: 1px solid rgba(33,212,253,0.4); border-radius: 8px;
  color: var(--accent-2); background: rgba(33,212,253,0.08); white-space: nowrap;
}
.fiber {
  flex: 1; height: 8px; margin: 0 4px; border-radius: 99px; position: relative; overflow: hidden;
  background: rgba(33,212,253,0.15);
}
.fiber-pulse {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, #21d4fd, #34e89e, transparent);
  background-size: 40% 100%; animation: flow 1.1s linear infinite;
}
@keyframes flow { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.fiber.cut { background: rgba(255,92,124,0.2); }
.fiber.cut .fiber-pulse {
  animation: none; background: transparent;
  box-shadow: inset 40px 0 0 var(--bg), inset -40px 0 0 var(--bg);
  background-color: var(--danger);
  opacity: 0.55;
}
.ne-box {
  min-width: 160px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; text-align: center;
}
.ne-box-label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.ne-cpu {
  font-family: var(--mono); font-size: 1.15rem; font-weight: 800; margin-top: 6px; min-height: 1.4em;
}
.ne-cpu-sub { font-size: 0.75rem; color: var(--dim); }

.task-row { display: flex; flex-direction: column; gap: 6px; }
.task-chip {
  display: flex; align-items: center; gap: 10px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 0.85rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.task-chip.active { border-color: var(--accent); background: rgba(124,92,255,0.12); }
.task-chip.blocked { opacity: 0.5; }
.task-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.task-meta { margin-left: auto; font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }

.ne-side { display: flex; flex-direction: column; gap: 14px; }
.pick-card, .deadline-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px;
}
.pick-code {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.55; color: #cdd3ee;
  white-space: pre; overflow-x: auto; margin: 0;
}
.pick-code .hit { color: var(--ok); font-weight: 700; }
.deadline-val { font-family: var(--mono); font-size: 1.05rem; font-weight: 800; }

/* Inversion */
.inv-demo { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.inv-cast { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.inv-side {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
}

.compile-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.compile-cmd { max-height: none; font-size: 0.88rem; border-radius: var(--radius-sm); }
.compile-box a { font-weight: 600; }

.map-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.map-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px;
}
.xa-h { font-weight: 700; color: var(--accent-2); font-size: 0.92rem; margin-bottom: 8px; }
.map-card p { color: var(--muted); font-size: 0.9rem; }

.rd { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rd-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 12px 12px 0;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.rd-tab {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  color: var(--muted); font-family: var(--mono); font-size: 0.8rem; font-weight: 600;
  padding: 9px 14px; border-radius: 9px 9px 0 0; cursor: pointer;
}
.rd-tab:hover { color: var(--text); background: rgba(124,92,255,0.08); }
.rd-tab.active { color: var(--text); background: var(--panel); border-color: var(--line); position: relative; top: 1px; }
.rd-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 16px 22px; border-bottom: 1px solid var(--line); background: rgba(124,92,255,0.05);
}
.rd-meta .rd-file { font-family: var(--mono); font-weight: 700; color: var(--text); font-size: 0.95rem; }
.rd-meta .rd-note { flex-basis: 100%; color: var(--muted); font-size: 0.88rem; }
.src-code {
  margin: 0; padding: 22px; font-family: var(--mono); font-size: 0.84rem; line-height: 1.65;
  color: #cdd3ee; background: #05060d; overflow-x: auto; max-height: 540px; overflow-y: auto;
  white-space: pre; tab-size: 2;
}
.src-code .kw { color: #c792ea; }
.src-code .ty { color: #82aaff; }
.src-code .cm { color: #5c6480; font-style: italic; }
.src-code .str { color: #c3e88d; }

.finale {
  text-align: center; margin-top: 64px;
  background: linear-gradient(135deg, rgba(255,92,124,0.1), rgba(124,92,255,0.08));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 48px 32px;
}
.finale h3 { font-size: 2rem; margin-bottom: 16px; }
.finale p { color: var(--muted); max-width: 680px; margin: 0 auto 20px; }
.finale-next { font-size: 0.95rem; }
.footer { text-align: center; padding: 50px 32px; color: var(--dim); font-size: 0.85rem; }
.footer a { color: var(--accent-2); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

.section-head, .vs-demo, .ne-demo, .inv-demo, .rd, .compile-box, .map-grid, .ctx {
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.revealed { opacity: 1 !important; transform: none !important; }

@media (max-width: 1000px) {
  #sidenav { transform: translateX(-100%); transition: transform 0.25s ease; }
  #sidenav.open { transform: translateX(0); }
  #nav-toggle { display: block; }
  main { margin-left: 0; }
  .vs-demo, .ne-demo, .inv-demo, .map-grid, .who-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .section { padding: 60px 18px; }
  .hero h1 { font-size: 3rem; }
}
