/* MasterEngine Developer Hub — shared styles
   Dark-first developer theme: cyan accent on deep GitHub-dark.
   Light scheme follows the OS (prefers-color-scheme) via variable overrides. */
:root {
  --bg: #0d1117;
  --bg-raised: #161b22;
  --bg-card: #1c2330;
  --code-bg: #0a0e14;
  --border: #2d3748;
  --border-soft: #232c3d;
  --text: #e6edf3;
  --muted: #9aa7b8;
  --accent: #22d3ee;
  --accent-ink: #04121a;
  --accent-dim: #0e7490;
  --accent-soft: rgba(34, 211, 238, .09);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .08);
  --radius: 10px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --glow: radial-gradient(52rem 26rem at 50% -6rem, rgba(34, 211, 238, .10), transparent 70%);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--glow);
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.68;
  font-size: 16px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Skip link */
.skip {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: .9rem;
  padding: 10px 18px; border-radius: 8px;
  transition: top .18s ease;
}
.skip:focus { top: 12px; text-decoration: none; }

code, pre { font-family: var(--mono); font-size: .88em; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  line-height: 1.58;
  color: #c9d4e3;
}
p code, li code, h1 code, h2 code, h3 code, td code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--accent);
  white-space: nowrap;
}

/* Preview banner — required on every page */
.preview-banner {
  background: var(--warn-bg);
  border-bottom: 1px solid rgba(251, 191, 36, .35);
  color: var(--warn);
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 9px 16px;
  text-transform: uppercase;
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
  white-space: nowrap;
  flex: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0e7490, #22d3ee);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 15px; color: #04121a;
  flex: none;
}
.nav-links {
  display: flex; gap: 2px; margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--muted);
  font-size: .9rem;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--bg-raised); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }

/* Layout */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
section.block { padding: 54px 0; }
section.block + section.block { border-top: 1px solid var(--border-soft); }

/* Hero */
.hero { padding: 88px 0 60px; }
.hero-eyebrow {
  display: inline-block;
  font-size: .76rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, .38);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 7px 16px;
  margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.1;
  margin: 0 0 18px;
  letter-spacing: -0.025em;
  font-weight: 750;
  max-width: 16em;
}
.hero h1 .hl {
  color: var(--accent);
  background: linear-gradient(100deg, #22d3ee, #7dd3fc);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p.lede { font-size: 1.16rem; color: var(--muted); max-width: 700px; margin: 0 0 30px; }
.hero-meta {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  margin: 0 0 8px;
  font-size: .85rem; color: var(--muted);
}
.hero-meta time { font-family: var(--mono); font-size: .82rem; }
.cta-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: var(--radius);
  font-weight: 650;
  font-size: .97rem;
  border: 1px solid transparent;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #67e8f9; }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--bg-raised); }
.btn-ghost:hover { border-color: var(--accent); }

/* Typography helpers */
h2 { font-size: 1.65rem; letter-spacing: -0.015em; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 1.18rem; margin: 28px 0 8px; font-weight: 650; }
.section-kicker {
  font-size: .76rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Cards */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .18s ease, transform .18s ease;
}
a.card:hover { border-color: var(--accent-dim); transform: translateY(-2px); text-decoration: none; }
.card h3 { margin-top: 0; }
.card .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-weight: 700; margin-bottom: 12px;
}
.card p:last-child { margin-bottom: 0; }

/* Chain timeline */
.chain { counter-reset: stage; list-style: none; margin: 26px 0 0; padding: 0; }
.chain li {
  counter-increment: stage;
  position: relative;
  padding: 0 0 26px 60px;
}
.chain li::before {
  content: counter(stage);
  position: absolute; left: 0; top: 2px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--accent-dim);
  color: var(--accent); font-family: var(--mono); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.chain li:not(:last-child)::after {
  content: "";
  position: absolute; left: 17px; top: 44px; bottom: 2px;
  width: 2px; background: linear-gradient(var(--accent-dim), var(--border-soft));
}
.chain li strong { display: block; font-size: 1.02rem; margin-bottom: 4px; }
.chain li p { margin: 0; color: var(--muted); font-size: .95rem; }
.chain li:last-child { padding-bottom: 0; }

/* Callouts */
.callout {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--bg-raised);
  padding: 16px 20px;
  margin: 24px 0;
}
.callout.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.callout p { margin: 0; }
.callout .label { font-weight: 700; font-size: .8rem; letter-spacing: .09em; text-transform: uppercase; display: block; margin-bottom: 6px; color: var(--accent); }
.callout.warn .label { color: var(--warn); }

/* Badge */
.badge {
  display: inline-block;
  font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(251, 191, 36, .12); color: var(--warn);
  border: 1px solid rgba(251, 191, 36, .4);
  margin-bottom: 12px;
}

/* Recipes */
.recipe { margin-bottom: 44px; }
.recipe:last-child { margin-bottom: 0; }
.recipe-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.recipe-head h3 { margin: 0; font-size: 1.35rem; }
.recipe-tag {
  font-size: .74rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px;
}

/* Changelog */
.entry { padding: 22px 0; border-bottom: 1px solid var(--border-soft); }
.entry:last-child { border-bottom: none; }
.entry .ver {
  display: inline-block; font-family: var(--mono); font-weight: 700; font-size: .84rem;
  color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 6px;
  padding: 3px 10px; margin-right: 10px;
}
.entry .date { color: var(--muted); font-size: .84rem; font-family: var(--mono); }
.entry ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.entry ul li { margin-bottom: 6px; }
.roadmap-phase { margin-bottom: 8px; }
.roadmap-phase strong { color: var(--warn); }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 34px 0 46px;
  color: var(--muted);
  font-size: .88rem;
}
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px;
  display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: center;
}
footer nav { display: flex; gap: 6px 18px; flex-wrap: wrap; }
footer nav a { color: var(--muted); }
footer nav a:hover { color: var(--accent); }

/* Tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 18px 0; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 560px; }
.table-scroll > table { margin: 0; border: 0; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
th { color: var(--accent); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; background: var(--bg-raised); }
tbody tr:hover { background: rgba(34, 211, 238, .04); }
td { color: var(--muted); }
td:first-child { color: var(--text); font-family: var(--mono); font-size: .84rem; }

/* Responsive */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav-inner { gap: 16px; padding: 0 14px; }
  .brand { font-size: .95rem; }
  .nav-links a { padding: 8px 10px; font-size: .85rem; }
  .wrap { padding: 0 16px; }
  section.block { padding: 38px 0; }
  .hero { padding: 54px 0 42px; }
  .chain li { padding-left: 52px; }
  pre { padding: 14px 16px; }
}

/* Light scheme — follows the OS; brand accent stays cyan, deepened for contrast */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f9fc;
    --bg-raised: #ffffff;
    --bg-card: #ffffff;
    --code-bg: #eef2f7;
    --border: #d9e0ea;
    --border-soft: #e6ebf2;
    --text: #17222f;
    --muted: #55637a;
    --accent: #0e7490;
    --accent-ink: #ffffff;
    --accent-dim: #0e7490;
    --accent-soft: rgba(14, 116, 144, .09);
    --warn: #92600a;
    --warn-bg: rgba(251, 191, 36, .18);
    --glow: radial-gradient(52rem 26rem at 50% -6rem, rgba(14, 116, 144, .10), transparent 70%);
  }
  .nav { background: rgba(247, 249, 252, .92); }
  .brand-mark { color: #fff; }
  .btn-primary:hover { background: #155e75; }
  pre { color: #2b3a4e; }
  p code, li code, h1 code, h2 code, h3 code, td code { color: #0e7490; }
  .hero h1 .hl { -webkit-text-fill-color: #0e7490; color: #0e7490; background: none; }
  tbody tr:hover { background: rgba(14, 116, 144, .05); }
}

/* Print */
@media print {
  .nav, .preview-banner, .cta-row, footer nav, .skip { display: none !important; }
  body { background: #fff; color: #111; font-size: 12pt; }
  .hero { padding: 0 0 12px; }
  .card, .callout, pre, .table-scroll { break-inside: avoid; }
  a { color: #0e7490; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
}
