/* =========================================================================
   SEO: The Definitive Guide — site styles
   Static, framework-free. Light/dark themes via CSS variables.
   Design language ported from GEO Basics and extended for a long-form guide.
   ========================================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #eef6f7;
  --text: #172033;
  --muted: #5d6b82;
  --faint: #8190a6;
  --line: #d8e0ea;
  --line-strong: #b9c6d6;
  --indigo: #3147a8;
  --indigo-soft: #e7ecfa;
  --teal: #0e766f;
  --amber: #b46a00;
  --rose: #b4233a;
  --ink: #111827;
  --code-bg: #121826;
  --code-text: #e7edf6;
  --shadow: 0 18px 48px rgba(23, 32, 51, 0.10);
  --shadow-sm: 0 6px 18px rgba(23, 32, 51, 0.08);
  --radius: 10px;
  --radius-sm: 7px;
  --max: 1180px;
  --topbar-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-soft: #0f1622;
    --surface: #131b29;
    --surface-strong: #16212f;
    --text: #e8eef7;
    --muted: #a3b2c8;
    --faint: #7f8ea6;
    --line: #243042;
    --line-strong: #33425b;
    --indigo: #8ea6ff;
    --indigo-soft: #1b2540;
    --teal: #45c9bd;
    --amber: #e0a44e;
    --rose: #ff7a8c;
    --ink: #f3f6fb;
    --code-bg: #0a0e16;
    --code-text: #e7edf6;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-soft: #0f1622;
  --surface: #131b29;
  --surface-strong: #16212f;
  --text: #e8eef7;
  --muted: #a3b2c8;
  --faint: #7f8ea6;
  --line: #243042;
  --line-strong: #33425b;
  --indigo: #8ea6ff;
  --indigo-soft: #1b2540;
  --teal: #45c9bd;
  --amber: #e0a44e;
  --rose: #ff7a8c;
  --ink: #f3f6fb;
  --code-bg: #0a0e16;
  --code-text: #e7edf6;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.22; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); font-weight: 800; margin: 0 0 0.6rem; }
h3 { font-size: 1.18rem; font-weight: 700; margin: 1.4rem 0 0.5rem; }
h4 { font-size: 1rem; font-weight: 700; margin: 1rem 0 0.4rem; }
p { margin: 0 0 1rem; }

a { color: var(--indigo); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
a:hover { color: var(--teal); }

:focus-visible {
  outline: 3px solid var(--indigo);
  outline-offset: 2px;
  border-radius: 4px;
}

img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  border: 1px solid var(--line);
}

/* ---- Accessibility helpers ---- */
.skip-link {
  position: absolute;
  left: 1rem;
  top: 0.75rem;
  z-index: 100;
  transform: translateY(-200%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Reading progress ---- */
.progress { position: fixed; inset: 0 0 auto 0; z-index: 90; height: 3px; background: transparent; }
.progress__bar { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--indigo), var(--amber)); transition: width 0.1s linear; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 70;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.topbar__inner {
  max-width: var(--max); margin: 0 auto; min-height: var(--topbar-h);
  padding: 0.5rem 1.25rem; display: flex; align-items: center; gap: 0.75rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--ink); text-decoration: none; font-weight: 800; white-space: nowrap;
}
.brand__mark { width: 30px; height: 30px; }
.brand__text { font-size: 1.02rem; }
.brand__text small { display: block; font-size: 0.66rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.topbar__links { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; }
.topbar__links a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.topbar__links a:hover, .topbar__links a[aria-current="true"] { color: var(--ink); }
.topbar__links a[aria-current="true"] { color: var(--indigo); }

.topbar__tools { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

.language-switch {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem; text-decoration: none; color: var(--ink);
  font-weight: 700; font-size: 0.82rem; background: var(--surface);
}
.language-switch:hover { border-color: var(--line-strong); color: var(--ink); }
.flag-icon { width: 22px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.06); }

.menu-toggle { display: none; }

/* ---- Hero ---- */
.hero { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--bg-soft), var(--bg)); }
.hero__inner {
  max-width: var(--max); margin: 0 auto; padding: 3rem 1.25rem 2.6rem;
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; align-items: center;
}
.eyebrow {
  display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--teal); margin-bottom: 0.6rem;
}
.hero h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.1rem); font-weight: 800; margin: 0 0 0.5rem; }
.hero__subtitle { font-size: 1.2rem; color: var(--muted); margin: 0 0 1rem; font-weight: 500; }
.hero__text { color: var(--text); margin: 0 0 1.3rem; }
.reading-path { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--muted); margin-bottom: 1.3rem; }
.reading-path span { font-weight: 700; color: var(--ink); }
.reading-path a { background: var(--indigo-soft); color: var(--indigo); padding: 0.18rem 0.6rem; border-radius: 999px; text-decoration: none; font-weight: 600; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.button {
  display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer;
  padding: 0.7rem 1.2rem; border-radius: var(--radius-sm); font-weight: 700;
  text-decoration: none; border: 1px solid transparent; font-size: 0.95rem;
}
.button--primary { background: var(--indigo); color: #fff; }
.button--primary:hover { background: var(--teal); color: #fff; }
.button--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button--ghost:hover { border-color: var(--indigo); color: var(--indigo); }

.hero__card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.hero__card strong { color: var(--teal); display: block; margin-bottom: 0.4rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.hero__card p { font-size: 0.96rem; }
.hero__card p:last-child { margin-bottom: 0; }

/* ---- Shell: sidebar TOC + content ---- */
.shell {
  max-width: var(--max); margin: 0 auto; padding: 0 1.25rem;
  display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 2.5rem; align-items: start;
}
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + 12px);
  max-height: calc(100vh - var(--topbar-h) - 24px); overflow: auto;
  padding: 1.5rem 0.5rem 2rem 0; margin-top: 1.5rem;
}
.toc__title { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 700; margin: 0 0 0.7rem 0.4rem; }
.toc { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li { margin: 0; }
.toc a {
  display: block; padding: 0.32rem 0.4rem 0.32rem 0.85rem; margin-left: -1px;
  color: var(--muted); text-decoration: none; font-size: 0.88rem; line-height: 1.35;
  border-left: 2px solid transparent;
}
.toc a:hover { color: var(--ink); }
.toc a[aria-current="true"] { color: var(--indigo); font-weight: 700; border-left-color: var(--indigo); background: var(--indigo-soft); border-radius: 0 6px 6px 0; }

.main { min-width: 0; padding-bottom: 2rem; }

/* ---- Sections ---- */
.section { padding: 2.6rem 0; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--topbar-h) + 16px); }
.section:first-child { border-top: 0; }
.section__number { display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--teal); margin-bottom: 0.4rem; }
.section__header { margin-bottom: 1.3rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 70ch; }
.section h3 + p, .section p + p { max-width: 75ch; }
.section ul, .section ol { max-width: 75ch; padding-left: 1.25rem; }
.section li { margin-bottom: 0.4rem; }

/* ---- Cards & grids ---- */
.grid { display: grid; gap: 1rem; margin: 1.2rem 0; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; box-shadow: var(--shadow-sm);
}
.card h3 { margin-top: 0; font-size: 1.05rem; }
.card p:last-child { margin-bottom: 0; }
.card__icon { font-size: 1.4rem; line-height: 1; margin-bottom: 0.5rem; }

/* ---- Callouts ---- */
.callout {
  border: 1px solid var(--line); border-left: 4px solid var(--indigo);
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 1rem 1.15rem; margin: 1.3rem 0;
}
.callout p:last-child { margin-bottom: 0; }
.callout--tip { border-left-color: var(--teal); }
.callout--warn { border-left-color: var(--amber); }
.callout--danger { border-left-color: var(--rose); }
.callout__label { font-weight: 700; }

/* ---- Pill / tag lists ---- */
.pill-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 !important; margin: 1.1rem 0; }
.pill-list li { background: var(--surface-strong); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.8rem; font-size: 0.86rem; font-weight: 600; margin: 0; }

/* ---- Steps ---- */
.steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps > li { position: relative; padding-left: 2.6rem; margin-bottom: 1rem; }
.steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -0.1rem; width: 1.9rem; height: 1.9rem;
  background: var(--indigo); color: #fff; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
}

/* ---- Diagram ---- */
.diagram { margin: 1.5rem 0; }
.diagram img { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 1rem; }
.caption { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }

/* ---- Code snippets w/ copy ---- */
.snippet { margin: 1.3rem 0; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.snippet__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface-strong); border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.5rem 0.5rem 0.9rem;
}
.snippet__title { font-size: 0.82rem; font-weight: 700; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 6px; padding: 0.3rem 0.6rem; font-size: 0.78rem; font-weight: 700;
}
.copy-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.copy-btn.is-copied { border-color: var(--teal); color: var(--teal); }
.snippet pre { margin: 0; padding: 1rem 1.1rem; overflow-x: auto; background: var(--code-bg); }
.snippet pre code { background: none; border: 0; padding: 0; color: var(--code-text); font-size: 0.85rem; line-height: 1.6; display: block; }

/* ---- Tables (tools / libraries / generators) ---- */
.table-wrap { overflow-x: auto; margin: 1.3rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 560px; }
.table th, .table td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { background: var(--surface-strong); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-soft); }
.table td strong { color: var(--ink); }

.tag { display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; padding: 0.12rem 0.45rem; border-radius: 5px; white-space: nowrap; }
.tag--oss { background: #def7ec; color: #046c4e; }
.tag--free { background: var(--indigo-soft); color: var(--indigo); }
.tag--freemium { background: #fdf6b2; color: #8e6a00; }
[data-theme="dark"] .tag--oss { background: #043b2c; color: #6ee7b7; }
[data-theme="dark"] .tag--freemium { background: #3a3410; color: #fbe27a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag--oss { background: #043b2c; color: #6ee7b7; }
  :root:not([data-theme="light"]) .tag--freemium { background: #3a3410; color: #fbe27a; }
}

/* ---- Checklist ---- */
.checklist { list-style: none; padding-left: 0 !important; margin: 1.2rem 0; }
.checklist li { position: relative; padding-left: 2rem; margin-bottom: 0.6rem; }
.checklist li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  width: 1.4rem; height: 1.4rem; border-radius: 5px; background: var(--surface-strong);
  border: 1px solid var(--line-strong); color: var(--teal); font-weight: 800;
  display: grid; place-items: center; font-size: 0.85rem;
}

/* ---- Glossary ---- */
.glossary { margin: 1.3rem 0; display: grid; gap: 0.2rem; }
.glossary dt { font-weight: 700; color: var(--ink); margin-top: 0.9rem; }
.glossary dd { margin: 0.1rem 0 0; color: var(--muted); }

/* ---- FAQ ---- */
.faq { display: grid; gap: 0.7rem; margin-top: 1rem; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; }
.faq-item h3 { margin: 0 0 0.4rem; font-size: 1.02rem; }
.faq-item p:last-child { margin-bottom: 0; }

/* ---- Sources ---- */
.source-list { display: grid; gap: 0.7rem; margin-top: 1rem; }
.source { display: grid; gap: 0.15rem; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.source a { font-weight: 600; }
.source span { font-size: 0.86rem; color: var(--muted); }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--line); background: var(--bg-soft); margin-top: 2rem; }
.footer__inner { max-width: var(--max); margin: 0 auto; padding: 2rem 1.25rem; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.9rem; }
.footer__links { display: flex; flex-wrap: wrap; gap: 1rem; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--indigo); }

/* ---- Back to top ---- */
.to-top {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 60;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
  display: grid; place-items: center; opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---- Responsive ---- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; gap: 0; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: min(86vw, 320px);
    max-height: none; background: var(--bg); border-right: 1px solid var(--line);
    padding: 1.2rem 1rem 2rem; margin: 0; z-index: 65; transform: translateX(-105%);
    transition: transform 0.25s ease; box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .menu-toggle { display: inline-grid; }
  .hero__inner { grid-template-columns: 1fr; }
  .grid--3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  body { font-size: 16px; }
  .topbar__links .nav-link { display: none; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .hero__inner { padding: 2rem 1.1rem; }
  .language-switch__label { display: none; }
}

/* ---- Print ---- */
@media print {
  .topbar, .sidebar, .progress, .to-top, .menu-toggle, .hero__actions, .reading-path, .copy-btn { display: none !important; }
  .shell { display: block; padding: 0; }
  body { font-size: 11pt; color: #000; background: #fff; }
  a { color: #000; text-decoration: underline; }
  .section { page-break-inside: avoid; border-top: 1px solid #ccc; }
  .snippet pre { white-space: pre-wrap; }
  h1, h2, h3 { page-break-after: avoid; }
}
