/* Boffin Coders brand (boffincoders.com): gold #d4a012 on near-black #0d0d0d,
   Space Grotesk headings, Inter body. Light mode uses a darker gold for text so
   it stays readable on white. */
:root {
  --bg: #ffffff;
  --bg-soft: #fafaf7;
  --bg-code: #111111;
  --panel: #ffffff;
  --border: #e6e3da;
  --text: #0d0d0d;
  --text-soft: #525252;
  --text-faint: #737373;
  --accent: #8a6500;
  --accent-strong: #d4a012;
  --accent-hover: #e4b022;
  --accent-soft: #fbf3d9;
  --accent-text: #0d0d0d;
  --amber: #8a6500;
  --ok: #15803d;
  --code-text: #f5f5f5;
  --shadow: 0 1px 2px rgb(13 13 13 / 6%), 0 8px 24px rgb(13 13 13 / 6%);
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --heading: "Space Grotesk", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0d;
    --bg-soft: #141414;
    --bg-code: #111111;
    --panel: #1a1a1a;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-soft: #d4d4d4;
    --text-faint: #a3a3a3;
    --accent: #d4a012;
    --accent-soft: #2a2108;
    --amber: #e4b022;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
  :root:not([data-theme="light"]) .icon-sun { display: block; }
}
:root[data-theme="dark"] {
  --bg: #0d0d0d;
  --bg-soft: #141414;
  --bg-code: #111111;
  --panel: #1a1a1a;
  --border: #2a2a2a;
  --text: #ffffff;
  --text-soft: #d4d4d4;
  --text-faint: #a3a3a3;
  --accent: #d4a012;
  --accent-soft: #2a2108;
  --amber: #e4b022;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 35%);
  color-scheme: dark;
}
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
.icon-sun { display: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; padding: 0.1em 0.35em; }
h1, h2, h3 { font-family: var(--heading); line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.45rem; margin: 2.6rem 0 0.8rem; }
h3 { font-size: 1.1rem; margin: 1.8rem 0 0.5rem; }
p { margin: 0 0 1rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--panel); padding: 8px 12px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
/* The gold Boffin Coders logo, the same in light and dark themes. */
.brand-mark { width: 30px; height: 30px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--heading); font-size: 15px; font-weight: 700; }
.brand-by { font-size: 11px; font-weight: 400; color: var(--text-faint); }
.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a { color: var(--text-soft); padding: 6px 10px; border-radius: 8px; font-size: 0.93rem; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn, .search-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text-soft);
  font: inherit; font-size: 0.9rem; cursor: pointer;
}
.icon-btn:hover, .search-btn:hover { color: var(--text); text-decoration: none; }
.search-btn kbd { font: 12px var(--mono); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.icon-btn svg, .search-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

/* Layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); max-width: 1320px; margin: 0 auto; }
.sidebar {
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px); overflow-y: auto;
  padding: 24px 16px 40px 20px; border-right: 1px solid var(--border);
}
.sidebar h4 { margin: 18px 0 6px; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.sidebar h4:first-child { margin-top: 0; }
.sidebar a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--text-soft); font-size: 0.93rem; }
.sidebar a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .mono { font-family: var(--mono); font-size: 0.88rem; }
.content { min-width: 0; padding: 40px clamp(16px, 4vw, 56px) 80px; max-width: 920px; }
.lead { font-size: 1.12rem; color: var(--text-soft); }
.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }

/* Code */
pre {
  position: relative; margin: 0 0 1.2rem; padding: 16px 18px; overflow-x: auto;
  background: var(--bg-code); color: var(--code-text);
  border-radius: var(--radius); border: 1px solid var(--border);
  font: 13px/1.7 var(--mono);
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.tok-k { color: #c49bff; }
.tok-s { color: #a5d6a7; }
.tok-c { color: #8a8a8a; font-style: italic; }
.tok-n { color: #6ea8fe; }
.tok-f { color: #e4b022; }
.copy {
  position: absolute; top: 8px; right: 8px;
  border: 1px solid #333333; background: #1a1a1a; color: #d4d4d4;
  border-radius: 7px; padding: 3px 9px; font: 12px var(--sans); cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
pre:hover .copy, .copy:focus-visible { opacity: 1; }
@media (hover: none) { .copy { opacity: 0.9; } }
.code-tabs { margin: 0 0 1.2rem; }
.code-tabs [role="tablist"] { display: flex; gap: 4px; margin-bottom: -1px; }
.code-tabs [role="tab"] {
  border: 1px solid var(--border); border-bottom: 0; background: var(--bg-soft); color: var(--text-soft);
  padding: 7px 14px; border-radius: 9px 9px 0 0; font: inherit; font-size: 0.88rem; cursor: pointer;
}
.code-tabs [role="tab"][aria-selected="true"] { background: var(--bg-code); color: var(--code-text); border-color: var(--border); }
.code-tabs pre { border-top-left-radius: 0; }

/* Tables, callouts, cards */
.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.good { color: var(--ok); }
.callout { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--bg-soft); border-radius: 10px; padding: 14px 16px; margin: 0 0 1.4rem; }
.callout.warn { border-left-color: var(--amber); }
.callout p:last-child { margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin: 0 0 1.4rem; }
.card {
  display: block; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); color: var(--text); box-shadow: var(--shadow);
}
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 0; color: var(--text-soft); font-size: 0.93rem; }
.card .mono { font-family: var(--mono); }
.pill { display: inline-block; font: 600 11px var(--mono); padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, #3b82f6 16%, transparent); color: #3b82f6; vertical-align: middle; }
.pill.post { background: var(--accent-soft); color: var(--accent); }
.pill.put { background: color-mix(in srgb, #16a34a 16%, transparent); color: #16a34a; }
.figure { margin: 0 0 1.6rem; }
.figure img { display: block; border-radius: var(--radius); }

/* Home */
.hero { padding: 72px 20px 24px; text-align: center; max-width: 980px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); letter-spacing: -0.025em; margin-bottom: 16px; }
.hero h1 .accent { color: #d4a012; }
.hero .lead { max-width: 700px; margin: 0 auto 28px; font-size: 1.18rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 18px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 600; border: 1px solid var(--border); color: var(--text); background: var(--panel); }
.btn:hover { text-decoration: none; border-color: #d4a012; }
.btn.primary { background: #d4a012; color: #0d0d0d; border-color: #d4a012; }
.btn.primary:hover { background: #e4b022; border-color: #e4b022; }
.install { display: inline-flex; align-items: center; gap: 12px; font: 14px var(--mono); padding: 8px 8px 8px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); }
.install button { border: 1px solid var(--border); background: var(--panel); color: var(--text-soft); border-radius: 7px; padding: 4px 10px; cursor: pointer; font: 12px var(--sans); }
.home-section { max-width: 1080px; margin: 0 auto; padding: 24px 20px; }
.home-section > h2 { text-align: center; margin-top: 48px; }
.home-section > .lead { text-align: center; max-width: 720px; margin: 0 auto 28px; }
.badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; color: var(--text-faint); font-size: 0.88rem; }
.badges span { border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; background: var(--bg-soft); }

/* Playground */
.pg { display: grid; gap: 18px; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
.pg form { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.pg label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--text-soft); font-weight: 600; }
.pg input, .pg select, .pg textarea {
  width: 100%; font: 14px var(--mono); color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.pg textarea { min-height: 220px; resize: vertical; }
.pg .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pg .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.pg .check input { width: auto; }
.pg h3 { margin: 0 0 8px; font-size: 0.95rem; }
.pg-out > div { margin-bottom: 16px; }
.pg .hint { font-size: 0.8rem; color: var(--text-faint); font-weight: 400; }
[hidden] { display: none !important; }

/* FAQ */
.faq { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0 0 28px; }
.faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 4px 16px; }
.faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-family: var(--heading); }
.faq details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.faq details p { color: var(--text-soft); }

/* Built by Boffin Coders */
.built-by { display: flex; gap: 20px; align-items: flex-start; margin: 40px 0 28px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.built-by img { flex: none; width: 56px; height: 56px; }
.built-by h2 { margin: 0 0 8px; font-size: 1.3rem; }
.built-by p { color: var(--text-soft); }
.built-by-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
@media (max-width: 600px) { .built-by { flex-direction: column; } }

/* Search */
dialog.search { width: min(640px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); margin-top: 12vh; }
dialog.search::backdrop { background: rgb(2 6 23 / 55%); }
.search input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: 16px var(--sans); padding: 16px 18px; outline: none; }
.search ul { list-style: none; margin: 0; padding: 6px; max-height: 55vh; overflow-y: auto; }
.search li a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); }
.search li a small { display: block; color: var(--text-faint); }
.search li a:hover, .search li a.active { background: var(--accent-soft); text-decoration: none; }

/* Footer */
footer { border-top: 1px solid var(--border); color: var(--text-faint); font-size: 0.88rem; padding: 28px 20px 40px; text-align: center; }
footer p { margin: 0 0 6px; }
.footer-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--text); font-family: var(--heading); font-weight: 600; }
.footer-brand img { width: 36px; height: 36px; object-fit: contain; }
footer p a { color: var(--text-faint); }
footer p a:hover { color: var(--text); }

/* Small screens */
@media (max-width: 900px) {
  .topnav { display: none; }
  .menu-btn { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; top: 60px; left: 0; right: 0; bottom: auto; z-index: 15; height: calc(100dvh - 60px); background: var(--bg); border-right: 0; }
  body.nav-open .sidebar { display: block; }
  .pg { grid-template-columns: minmax(0, 1fr); }
  .search-btn kbd, .search-btn .label { display: none; }
}
@media (max-width: 520px) {
  .install { font-size: 12px; }
}
@media (max-width: 440px) {
  .brand-text { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
