/* One palette, two themes. Every colour is a token defined here on :root and
   redefined once in the dark block - a colour whose only definition lives
   inside the media query is a colour that disappears in light mode. */
:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1b1a18;
  --ink-dim: #5f5b55;
  --ink-faint: #8b857d;
  --rule: #e2ded7;
  --accent: #9a3412;
  --accent-soft: #fdf0e8;
  --code-bg: #f4f1ec;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --panel: #1e1d1a;
    --ink: #ebe7e0;
    --ink-dim: #a9a39a;
    --ink-faint: #7d766c;
    --rule: #302e2a;
    --accent: #f0a273;
    --accent-soft: #2a211b;
    --code-bg: #211f1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code, pre, .mono { font-family: var(--mono); font-size: 0.875em; }

/* ---------- chrome ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.1rem clamp(1rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark .dim { color: var(--ink-faint); font-weight: 400; }
.top nav { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: 0.9rem; }
.top nav a { color: var(--ink-dim); text-decoration: none; }
.top nav a:hover { color: var(--accent); text-decoration: underline; }

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 5vw, 3.5rem) 5rem;
}

.bottom {
  border-top: 1px solid var(--rule);
  padding: 1.5rem clamp(1rem, 5vw, 3.5rem);
  color: var(--ink-faint);
  font-size: 0.85rem;
}
.bottom p { margin: 0; max-width: 62rem; }

/* ---------- landing ---------- */

.hero { max-width: 44rem; }
.hero h1 {
  font-size: clamp(2rem, 5.5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}
.lede { font-size: 1.1rem; color: var(--ink-dim); margin: 0 0 1.75rem; }

.cta { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.button {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.92rem;
  text-decoration: none;
}
.button:hover { border-color: var(--accent); color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.button.primary:hover { filter: brightness(1.08); color: var(--bg); }
.button.disabled { color: var(--ink-faint); cursor: default; }
.button.disabled:hover { border-color: var(--rule); color: var(--ink-faint); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1.25rem;
  margin: 3.5rem 0;
}
.card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.4rem 1.5rem;
}
.card h2 { margin: 0 0 0.5rem; font-size: 1.15rem; letter-spacing: -0.015em; }
.card h2 a { text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.card p { margin: 0 0 1rem; color: var(--ink-dim); font-size: 0.95rem; }
.doclinks { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.doclinks li { padding: 0.22rem 0; border-top: 1px solid var(--rule); }
.doclinks a { text-decoration: none; }
.doclinks a:hover { text-decoration: underline; }

.empty { color: var(--ink-faint); }

/* ---------- document pages ---------- */

.withside {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
@media (max-width: 46rem) {
  .withside { grid-template-columns: minmax(0, 1fr); }
  .side { position: static !important; border-bottom: 1px solid var(--rule); padding-bottom: 1rem; }
}
.side { position: sticky; top: 1.5rem; font-size: 0.9rem; }
.sidehead {
  font-family: var(--mono);
  color: var(--ink-faint);
  text-transform: lowercase;
  margin: 0 0 0.5rem;
}
.side ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.side li { padding: 0.2rem 0; }
.side li.here > a { color: var(--ink); font-weight: 600; }
.side a { text-decoration: none; }
.side a:hover { text-decoration: underline; }
.sidenote { font-size: 0.85rem; color: var(--ink-faint); margin: 0; }

/* min-width:0 lets the grid item shrink below its content; overflow-wrap stops
   a long unbreakable token from setting the floor. Both are needed - the
   skeleton's README has `https://myapp.example.com/auth/google/callback` as
   inline code in a list, and on a 390px screen that one token pushed the whole
   page 40px wide and clipped every paragraph. */
.prose { min-width: 0; overflow-wrap: break-word; }
.prose h1 { font-size: clamp(1.7rem, 4vw, 2.25rem); letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 1rem; }
.prose h2 {
  font-size: 1.3rem;
  letter-spacing: -0.015em;
  margin: 2.5rem 0 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
}
.prose h3 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
.prose p, .prose li { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li { margin: 0.3rem 0; }
.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.1rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-dim);
}

.prose :not(pre) > code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  /* `anywhere`, not `break-word`: a URL or a dotted path has no break
     opportunity at all, and break-word only helps once one exists. */
  overflow-wrap: anywhere;
}

/* Wide content scrolls inside its own box; the page body never scrolls
   sideways, which is what a table of config keys does on a phone otherwise. */
.prose pre, .sourcebox, .tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  line-height: 1.55;
}
.prose pre code { background: none; padding: 0; }

.prose table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.25rem 0;
}
.prose th, .prose td {
  border: 1px solid var(--rule);
  padding: 0.45rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.prose th { background: var(--code-bg); font-weight: 600; }

/* ---------- source browsing ---------- */

.crumbs { font-family: var(--mono); font-size: 0.9rem; margin: 0 0 1.25rem; overflow-wrap: anywhere; }
.crumbs .sep { color: var(--ink-faint); margin: 0 0.35rem; }
.crumbs .current { color: var(--ink-dim); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.tree {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.tree td { border-bottom: 1px solid var(--rule); padding: 0.32rem 0.5rem; }
.tree td.n a { text-decoration: none; }
.tree td.n a:hover { text-decoration: underline; }
.tree td.n a.dir { font-weight: 600; }
.tree td.sz { text-align: right; color: var(--ink-faint); white-space: nowrap; width: 8rem; }

.sourcebox {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin-top: 0.5rem;
}
.sourcebox .hl { margin: 0; }
.sourcebox pre { margin: 0; padding: 0.9rem 0; background: none; border: 0; line-height: 1.5; }

/* Pygments' linenos="table" is a two-column table: gutter, then code. Both
   need to stop looking like a document table. */
.sourcebox table { border-collapse: collapse; width: 100%; }
.sourcebox td { border: 0; padding: 0; vertical-align: top; }
.sourcebox .linenos {
  width: 1%;
  padding-right: 0.9rem;
  padding-left: 0.9rem;
  border-right: 1px solid var(--rule);
  user-select: none;
}
.sourcebox .linenos a { color: var(--ink-faint); text-decoration: none; }
.sourcebox .code { padding-left: 1rem; width: 100%; }

.demonote {
  margin: 1.5rem 0 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  color: var(--ink-dim);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}
.demonote code {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: var(--ink);
}
