@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root{
  --bg:#ffffff;
  --bg-soft:#f3f4f6;
  --panel:#ffffff;
  --ink:#0d0d0d;
  --ink-soft:#3f4247;
  --muted:#6b7280;
  --line:#e5e7eb;
  --red:#e30613;
  --red-dark:#90040d;
  --blue:#1e3a5f;
  --yellow:#f2b705;
  --success:#10b981;
  --shadow: 0 1px 2px rgba(13,13,13,.04), 0 8px 24px -12px rgba(13,13,13,.14);
  --radius: 14px;
  --sidebar-w: 280px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0e0f11; --bg-soft:#17181b; --panel:#1a1c1f;
    --ink:#f4f4f5; --ink-soft:#c9cacd; --muted:#9a9ea6; --line:#2b2d31;
    --red:#ff3b47; --red-dark:#ff6b74; --blue:#7ea3d1; --yellow:#f2c23d; --success:#34d399;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 30px -14px rgba(0,0,0,.65);
  }
}
:root[data-theme="dark"]{
  --bg:#0e0f11; --bg-soft:#17181b; --panel:#1a1c1f;
  --ink:#f4f4f5; --ink-soft:#c9cacd; --muted:#9a9ea6; --line:#2b2d31;
  --red:#ff3b47; --red-dark:#ff6b74; --blue:#7ea3d1; --yellow:#f2c23d; --success:#34d399;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 30px -14px rgba(0,0,0,.65);
}

*{box-sizing:border-box;}
html{scroll-behavior:smooth;}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4,.display{
  font-family:'Oswald','IBM Plex Sans',sans-serif;
  text-transform:uppercase; letter-spacing:.01em; text-wrap:balance; margin:0;
}
code,.mono{ font-family:'IBM Plex Mono', ui-monospace, monospace; }
a{ color:var(--red); }
::selection{ background:var(--red); color:#fff; }
:focus-visible{ outline:2px solid var(--red); outline-offset:2px; }
img{ max-width:100%; }

@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior:auto; }
  *{ animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
}

/* ============ Top bar (mobile) ============ */
.topbar{
  position:sticky; top:0; z-index:40; display:none;
  align-items:center; justify-content:space-between;
  padding:12px 16px; background:color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter:blur(10px); border-bottom:1px solid var(--line);
}
.topbar .brand{ display:flex; align-items:center; gap:8px; font-family:'Oswald',sans-serif; font-weight:700; font-style:italic; }
.topbar .brand img{ height:22px; width:auto; }
.menu-btn{
  width:38px;height:38px;border-radius:9px;border:1px solid var(--line);
  background:var(--bg-soft); display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.menu-btn svg{ width:18px; height:18px; stroke:var(--ink); fill:none; stroke-width:2; }

/* ============ Layout ============ */
.layout{ display:flex; min-height:100vh; }

.sidebar{
  width:var(--sidebar-w); flex-shrink:0; position:sticky; top:0; height:100vh;
  overflow-y:auto; border-right:1px solid var(--line); background:var(--bg-soft);
  padding:22px 18px 40px;
}
.sidebar .brand{ display:flex; align-items:center; gap:10px; padding:4px 6px 18px; }
.sidebar .brand img{ height:30px; width:auto; }
.sidebar .brand strong{ font-family:'Oswald',sans-serif; font-weight:700; font-style:italic; font-size:1.05rem; }
.sidebar .brand span{ display:block; font-size:.66rem; color:var(--muted); letter-spacing:.08em; text-transform:uppercase; margin-top:1px; }

.nav-group{ margin-bottom:6px; }
.nav-title{
  font-family:'IBM Plex Mono',monospace; font-size:.68rem; letter-spacing:.1em;
  text-transform:uppercase; color:var(--muted); padding:14px 10px 6px;
}
.nav-link{
  display:flex; align-items:center; gap:9px; padding:8px 10px; border-radius:9px;
  color:var(--ink-soft); text-decoration:none; font-size:.87rem; font-weight:500;
  border-left:2px solid transparent; transition:background .15s ease, color .15s ease;
}
.nav-link:hover{ background:var(--panel); color:var(--ink); }
.nav-link.active{ background:var(--panel); color:var(--red); border-left-color:var(--red); font-weight:600; box-shadow:var(--shadow); }
.nav-num{ font-family:'IBM Plex Mono',monospace; font-size:.72rem; color:var(--muted); width:18px; flex-shrink:0; }
.nav-link.active .nav-num{ color:var(--red); }

.theme-toggle{
  margin-top:16px; width:100%; display:flex; align-items:center; justify-content:center; gap:8px;
  padding:9px 10px; border-radius:9px; border:1px solid var(--line); background:var(--panel);
  color:var(--ink-soft); font-size:.8rem; cursor:pointer; font-family:'IBM Plex Sans';
}
.theme-toggle svg{ width:15px;height:15px; stroke:currentColor; fill:none; stroke-width:2; }

.content{ flex:1; min-width:0; }
.wrap{ max-width:900px; margin:0 auto; padding:0 40px; }

/* ============ Hero ============ */
.hero{
  padding:70px 0 40px; border-bottom:1px solid var(--line);
}
.eyebrow{
  font-family:'IBM Plex Mono',monospace; font-size:.72rem; letter-spacing:.14em;
  text-transform:uppercase; color:var(--red); font-weight:600;
}
.hero h1{ font-size:clamp(2.1rem,4.4vw,3.1rem); line-height:1.02; margin:.4em 0 .3em; font-weight:700; }
.hero h1 em{ font-style:italic; color:var(--red); }
.hero p.lede{ font-size:1.05rem; color:var(--ink-soft); max-width:62ch; line-height:1.65; }
.hero .meta-row{ display:flex; gap:10px; flex-wrap:wrap; margin-top:22px; }
.pill{
  display:inline-flex; align-items:center; gap:7px; border:1px solid var(--line); border-radius:999px;
  padding:6px 13px; font-size:.78rem; font-weight:600; color:var(--ink-soft); background:var(--bg-soft);
  font-family:'IBM Plex Mono',monospace;
}
.pill .dot{ width:7px;height:7px;border-radius:50%; background:var(--success); }

/* ============ Sections ============ */
.section{ padding:56px 0; border-bottom:1px solid var(--line); scroll-margin-top:26px; }
.section:last-of-type{ border-bottom:none; }
.section-num{
  font-family:'IBM Plex Mono',monospace; color:var(--red); font-weight:700; font-size:.85rem;
  letter-spacing:.08em;
}
.section h2{ font-size:1.9rem; margin:.2em 0 .3em; font-weight:700; }
.section > p.sub{ color:var(--muted); font-size:1rem; margin-bottom:28px; max-width:60ch; }
.section h3{ font-size:1.15rem; color:var(--red-dark); margin:30px 0 12px; font-weight:600; }
.section h4{ font-size:.98rem; color:var(--blue); margin:22px 0 8px; font-weight:600; text-transform:none; letter-spacing:0; }
.section p{ line-height:1.7; color:var(--ink-soft); margin:0 0 14px; }
.section ul, .section ol{ margin:0 0 16px; padding-left:1.3em; color:var(--ink-soft); line-height:1.75; }
.section li{ margin-bottom:5px; }
.section li strong{ color:var(--ink); }

blockquote{
  margin:18px 0; padding:12px 18px; border-left:3px solid var(--red);
  background:var(--bg-soft); border-radius:0 8px 8px 0; color:var(--blue); font-style:italic;
}

pre{
  background:#15171a; color:#e7e9ec; border-radius:10px; padding:16px 18px;
  overflow-x:auto; font-family:'IBM Plex Mono',monospace; font-size:.82rem; line-height:1.6;
  margin:0 0 18px; border:1px solid #26282c;
}
:root[data-theme="light"] pre, :root:not([data-theme="dark"]) pre{ }
pre code{ font-family:inherit; }

.table-wrap{ overflow-x:auto; margin:0 0 18px; border:1px solid var(--line); border-radius:12px; }
table{ width:100%; border-collapse:collapse; font-size:.88rem; }
thead th{
  background:var(--ink); color:#fff; text-align:left; padding:10px 14px;
  font-family:'IBM Plex Mono',monospace; font-size:.76rem; letter-spacing:.04em; text-transform:uppercase;
}
tbody td{ padding:10px 14px; border-top:1px solid var(--line); color:var(--ink-soft); vertical-align:top; }
tbody tr:nth-child(even){ background:var(--bg-soft); }
tbody td:first-child{ font-family:'IBM Plex Mono',monospace; font-weight:600; color:var(--ink); white-space:nowrap; }

/* ============ Diagram cards ============ */
.diagram-card{
  background:var(--panel); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px 20px 12px; margin:18px 0 24px;
}
.diagram-card svg{ width:100%; height:auto; display:block; }
.diagram-caption{ font-size:.8rem; color:var(--muted); margin-top:10px; padding-top:10px; border-top:1px dashed var(--line); }

.flow-path{ stroke:var(--line); stroke-width:2; fill:none; }
.lbl{ font-family:'IBM Plex Mono',monospace; font-size:11px; fill:var(--ink-soft); }
.node-box{ fill:var(--bg-soft); stroke:var(--line); stroke-width:1.4; }
.node-title{ font-family:'Oswald',sans-serif; font-size:12px; font-weight:600; letter-spacing:.02em; text-transform:uppercase; fill:var(--ink); }
.pkt{ fill:var(--red); }
.fk-line{ stroke-width:1.6; fill:none; opacity:.8; }
.fk-dash{ stroke-dasharray:4 4; animation:dashmove 22s linear infinite; }
@keyframes dashmove{ to{ stroke-dashoffset:-400; } }
.mini-box{ fill:var(--panel); stroke:var(--line); stroke-width:1.3; }
.mini-box.hi{ stroke-width:1.8; }
.mini-t{ font-family:'IBM Plex Mono',monospace; font-size:10.5px; fill:var(--ink); font-weight:600; }
.mini-c{ font-family:'IBM Plex Mono',monospace; font-size:9px; fill:var(--muted); }

/* ============ Stat grid ============ */
.stat-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:1px; background:var(--line); border:1px solid var(--line); border-radius:12px; overflow:hidden; margin:20px 0 8px; }
.stat{ background:var(--panel); padding:16px 18px; }
.stat .num{ font-family:'Oswald',sans-serif; font-size:1.8rem; font-weight:700; line-height:1; }
.stat .cap{ font-size:.72rem; color:var(--muted); margin-top:5px; text-transform:uppercase; letter-spacing:.05em; }
@media (max-width:620px){ .stat-grid{ grid-template-columns:repeat(2,1fr);} }

/* ============ Domain / feature cards ============ */
.card-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:12px; margin:18px 0; }
details.domain{
  background:var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow);
  overflow:hidden; transition:border-color .2s ease;
}
details.domain[open]{ border-color:var(--accent, var(--red)); }
details.domain summary{
  list-style:none; cursor:pointer; padding:15px 16px; display:flex; align-items:center; gap:12px;
}
details.domain summary::-webkit-details-marker{ display:none; }
.d-swatch{
  width:34px;height:34px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  background:color-mix(in srgb, var(--accent, var(--red)) 14%, transparent); flex-shrink:0;
}
.d-swatch svg{ width:17px;height:17px; stroke:var(--accent,var(--red)); fill:none; stroke-width:1.8; }
.d-head{ flex:1; min-width:0; }
.d-head h4{ margin:0; font-size:.95rem; text-transform:none; color:var(--ink); font-weight:700; }
.d-head .d-sub{ font-size:.76rem; color:var(--muted); margin-top:1px; }
.d-count{ font-family:'IBM Plex Mono',monospace; font-size:.74rem; color:var(--accent,var(--red)); font-weight:600; white-space:nowrap; }
.chev{ width:15px;height:15px; stroke:var(--muted); fill:none; stroke-width:2; transition:transform .25s ease; flex-shrink:0; }
details.domain[open] .chev{ transform:rotate(180deg); }
.d-body{ padding:0 16px 18px; border-top:1px solid var(--line); }
.d-body .mini-svg{ width:100%; height:auto; margin:14px 0 4px; }
.mini-table-list{ display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:7px; margin-top:10px; }
.t-row{ display:flex; align-items:baseline; justify-content:space-between; gap:6px; background:var(--bg-soft); border:1px solid var(--line); border-radius:7px; padding:7px 9px; font-size:.76rem; }
.t-row .t-name{ font-family:'IBM Plex Mono',monospace; font-weight:600; }
.t-row .t-cols{ color:var(--muted); font-size:.68rem; white-space:nowrap; }

/* ============ Color swatches ============ */
.swatch-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; margin:16px 0 22px; }
.swatch{ border:1px solid var(--line); border-radius:10px; overflow:hidden; background:var(--panel); }
.swatch .chip{ height:56px; }
.swatch .info{ padding:8px 10px; }
.swatch .info .name{ font-size:.78rem; font-weight:700; }
.swatch .info .hex{ font-family:'IBM Plex Mono',monospace; font-size:.7rem; color:var(--muted); }

/* ============ Status checks ============ */
.check-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px; margin:16px 0; }
.check{ background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:14px 16px; box-shadow:var(--shadow); display:flex; gap:10px; }
.check .led{ width:10px;height:10px;border-radius:50%; margin-top:5px; flex-shrink:0; }
.led.ok{ background:var(--success); box-shadow:0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
.led.warn{ background:var(--yellow); box-shadow:0 0 0 3px color-mix(in srgb, var(--yellow) 25%, transparent); }
.check h4{ margin:0 0 3px; font-size:.85rem; text-transform:none; font-weight:700; color:var(--ink); }
.check p{ margin:0; font-size:.78rem; color:var(--muted); line-height:1.5; }

/* ============ Timeline (deploy flow) ============ */
.timeline{ margin:18px 0; }
.tl-step{ display:flex; gap:14px; padding-bottom:22px; position:relative; }
.tl-step::before{ content:''; position:absolute; left:15px; top:32px; bottom:-4px; width:2px; background:var(--line); }
.tl-step:last-child::before{ display:none; }
.tl-dot{ width:32px;height:32px;border-radius:50%; background:var(--bg-soft); border:2px solid var(--red); display:flex; align-items:center; justify-content:center; flex-shrink:0; font-family:'IBM Plex Mono',monospace; font-weight:700; font-size:.8rem; color:var(--red); }
.tl-body h4{ margin:2px 0 4px; text-transform:none; font-size:.92rem; }
.tl-body p{ margin:0; font-size:.85rem; }

/* ============ Back to top ============ */
.top-btn{
  position:fixed; right:22px; bottom:22px; width:42px; height:42px; border-radius:50%;
  background:var(--red); color:#fff; border:none; display:flex; align-items:center; justify-content:center;
  cursor:pointer; box-shadow:0 10px 24px -8px rgba(227,6,19,.55); opacity:0; pointer-events:none;
  transition:opacity .2s ease, transform .2s ease; z-index:50;
}
.top-btn.show{ opacity:1; pointer-events:auto; }
.top-btn svg{ width:18px;height:18px; stroke:#fff; fill:none; stroke-width:2.4; }

footer.site-footer{ padding:34px 0 60px; text-align:center; }
footer.site-footer p{ color:var(--muted); font-size:.8rem; margin:0; }

/* ============ Reveal on scroll ============ */
.reveal{ opacity:0; transform:translateY(14px); transition:opacity .5s ease, transform .5s ease; }
.reveal.in{ opacity:1; transform:translateY(0); }

/* ============ Overlay for mobile sidebar ============ */
.overlay{ position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:35; display:none; }
.overlay.show{ display:block; }

/* ============ Responsive ============ */
@media (max-width:980px){
  .topbar{ display:flex; }
  .sidebar{
    position:fixed; left:0; top:0; z-index:36; transform:translateX(-100%);
    transition:transform .25s ease; box-shadow:0 0 40px rgba(0,0,0,.25);
  }
  .sidebar.open{ transform:translateX(0); }
  .wrap{ padding:0 20px; }
  .hero{ padding:36px 0 28px; }
  .stat-grid{ grid-template-columns:repeat(2,1fr); }
}
