/* ==========================================================================
   Zero to Hero — shared stylesheet
   One CSS file styles every page. Read the comments: this file is also a
   lesson in how a small design system works.
   ========================================================================== */

/* ---- 1. Design tokens (CSS custom properties / "variables") --------------
   Defining colors and sizes once here means you change them in ONE place
   and the whole site updates. Try editing --accent and reloading. */
:root {
  --accent: #f6821f;          /* Cloudflare-ish orange */
  --accent-strong: #e06d0a;
  --accent-soft: #fff2e6;

  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --bg-card: #ffffff;
  --border: #e6e6ea;
  --text: #1a1a1f;
  --text-muted: #5c5c6b;
  --code-bg: #f4f4f6;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 18, 30, .06), 0 8px 24px rgba(18, 18, 30, .06);
  --maxw: 860px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

/* Dark mode: activated when <html data-theme="dark"> (see main.js).
   We also respect the OS preference as a fallback below. */
:root[data-theme="dark"] {
  --accent: #ff9a4a;
  --accent-strong: #ffb06e;
  --accent-soft: #2a1c0e;

  --bg: #0f0f14;
  --bg-subtle: #16161d;
  --bg-card: #17171f;
  --border: #2a2a35;
  --text: #ececf1;
  --text-muted: #a0a0b0;
  --code-bg: #1c1c25;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #ff9a4a;
    --accent-strong: #ffb06e;
    --accent-soft: #2a1c0e;
    --bg: #0f0f14;
    --bg-subtle: #16161d;
    --bg-card: #17171f;
    --border: #2a2a35;
    --text: #ececf1;
    --text-muted: #a0a0b0;
    --code-bg: #1c1c25;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

/* ---- 2. Reset & base ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
  transition: background .2s ease, color .2s ease;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- 3. Layout ---------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---- 4. Top navigation -------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 18px;
}
.nav__brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; color: var(--text); font-size: 1.02rem;
}
.nav__brand:hover { text-decoration: none; }
.nav__logo {
  width: 26px; height: 26px; flex: none;
  border-radius: 7px; background: linear-gradient(135deg, var(--accent), #ffb06e);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .8rem;
}
.nav__links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav__links a {
  color: var(--text-muted); font-size: .92rem; font-weight: 500;
  padding: 6px 11px; border-radius: 8px;
}
.nav__links a:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.nav__links a.is-active { color: var(--accent-strong); background: var(--accent-soft); }

.theme-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 1.05rem;
  display: grid; place-items: center; flex: none;
}
.theme-btn:hover { border-color: var(--accent); }

.nav__toggle {
  display: none; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  font-size: 1.1rem;
}

@media (max-width: 720px) {
  .nav__toggle { display: grid; place-items: center; }
  .nav__links {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 10px 16px 16px; margin: 0;
    display: none;
  }
  .nav__links.is-open { display: flex; }
  .nav__links a { padding: 10px 12px; }
  .nav__links .theme-btn { width: 100%; height: 42px; margin-top: 6px; }
}

/* ---- 5. Hero ------------------------------------------------------------ */
.hero { padding: 74px 0 48px; text-align: center; }
.hero .eyebrow {
  display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent-strong);
  background: var(--accent-soft); padding: 5px 12px; border-radius: 100px;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem); line-height: 1.08; margin: 0 0 18px;
  letter-spacing: -.02em; font-weight: 800;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent), #ff5e7e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead {
  font-size: 1.18rem; color: var(--text-muted); max-width: 640px;
  margin: 0 auto 30px;
}
.hero__cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- 6. Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 11px; font-weight: 600; font-size: .98rem;
  cursor: pointer; border: 1px solid transparent; transition: transform .06s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); }

/* ---- 7. Roadmap cards --------------------------------------------------- */
.section { padding: 44px 0; }
.section__head { text-align: center; margin-bottom: 34px; }
.section__head h2 { font-size: 1.9rem; margin: 0 0 10px; letter-spacing: -.01em; }
.section__head p { color: var(--text-muted); margin: 0; }

.grid { display: grid; gap: 18px; }
.grid--roadmap { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
  display: block; color: inherit; transition: transform .12s ease, border-color .12s ease;
}
a.card:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--accent); }
.card__step {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 800; margin-bottom: 14px; font-size: .95rem;
}
.card h3 { margin: 0 0 8px; font-size: 1.18rem; }
.card p { margin: 0; color: var(--text-muted); font-size: .96rem; }
.card__more { margin-top: 14px; color: var(--accent-strong); font-weight: 600; font-size: .9rem; }

/* ---- 8. Article / lesson pages ------------------------------------------ */
.article { padding: 40px 0 60px; }
.article .kicker {
  color: var(--accent-strong); font-weight: 600; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .05em;
}
.article h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 8px 0 6px; letter-spacing: -.02em; }
.article .subtitle { color: var(--text-muted); font-size: 1.12rem; margin: 0 0 8px; }
.article h2 {
  font-size: 1.5rem; margin: 42px 0 12px; padding-top: 8px; letter-spacing: -.01em;
  scroll-margin-top: 80px;
}
.article h3 { font-size: 1.15rem; margin: 26px 0 8px; }
.article p, .article li { color: var(--text); }
.article ul, .article ol { padding-left: 22px; }
.article li { margin: 6px 0; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

/* Inline code + code blocks */
code {
  font-family: var(--mono); font-size: .88em;
  background: var(--code-bg); padding: 2px 6px; border-radius: 6px;
}
.code {
  position: relative; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin: 16px 0; overflow: hidden;
}
.code__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  font-size: .78rem; color: var(--text-muted); font-family: var(--mono);
}
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code pre code { background: none; padding: 0; font-size: .86rem; line-height: 1.6; }
.copy-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted);
  font-size: .72rem; padding: 3px 10px; border-radius: 6px; cursor: pointer;
  font-family: var(--font);
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }

/* Callout boxes */
.callout {
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  background: var(--bg-subtle); border-radius: var(--radius-sm);
  padding: 14px 18px; margin: 20px 0;
}
.callout strong { color: var(--text); }
.callout--tip { border-left-color: #16a34a; }
.callout--warn { border-left-color: #dc2626; }

/* Step list with numbers */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 22px 0; }
.steps > li {
  counter-increment: step; position: relative; padding: 2px 0 18px 46px; margin: 0;
}
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem;
  display: grid; place-items: center;
}
.steps > li:not(:last-child)::after {
  content: ""; position: absolute; left: 14px; top: 32px; bottom: 2px;
  width: 2px; background: var(--border);
}

/* Prev / next pager */
.pager { display: flex; gap: 14px; margin-top: 48px; flex-wrap: wrap; }
.pager a {
  flex: 1 1 220px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; background: var(--bg-card); color: inherit;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { display: block; font-size: .78rem; color: var(--text-muted); }
.pager b { font-weight: 600; }
.pager .next { text-align: right; }

/* Table of contents chip row */
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }
.toc a {
  font-size: .85rem; padding: 5px 12px; border-radius: 100px;
  background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-muted);
}
.toc a:hover { color: var(--accent-strong); border-color: var(--accent); text-decoration: none; }

/* ---- 9. Footer ---------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--border); margin-top: 40px;
  padding: 30px 0; color: var(--text-muted); font-size: .9rem;
}
.footer__inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent-strong); }

/* ---- 9b. Contact form --------------------------------------------------- */
.form { margin: 26px 0 8px; max-width: 560px; }
.field { margin-bottom: 18px; }
.field label {
  display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; color: var(--text);
}
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px; resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Honeypot: visually hidden but still in the DOM for bots to trip over. */
.honeypot {
  position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden;
}
#submit-btn[disabled] { opacity: .6; cursor: progress; }
.form-status { margin: 14px 0 0; font-weight: 600; font-size: .95rem; min-height: 1.2em; }
.form-status.is-ok { color: #16a34a; }
.form-status.is-err { color: #dc2626; }

/* ---- 10. Small helpers -------------------------------------------------- */
.muted { color: var(--text-muted); }
.center { text-align: center; }
.pill {
  display: inline-block; font-size: .78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 100px; background: var(--accent-soft);
  color: var(--accent-strong);
}
