/* Create: Solarpunk wiki. Warm parchment and forest green by day, deep moss by night,
   with brass and copper accents from the mod's machines. */

:root {
  --bg: #f5f0e3;
  --surface: #fffbf2;
  --surface-2: #efe8d6;
  --ink: #1d271d;
  --muted: #586453;
  --line: #ddd3bb;
  --green: #2f6b3a;
  --green-soft: #dfead6;
  --brass: #a8761c;
  --copper: #b05f37;
  --link: #2a6534;
  --shadow: 0 1px 2px rgb(40 50 30 / .06), 0 6px 20px rgb(40 50 30 / .07);
  --radius: 14px;
  --topbar: 60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111711;
    --surface: #182018;
    --surface-2: #1f291f;
    --ink: #e7eadf;
    --muted: #a3ae99;
    --line: #2c382b;
    --green: #86c790;
    --green-soft: #213323;
    --brass: #e2b65a;
    --copper: #e08a5c;
    --link: #93d39c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111711;
  --surface: #182018;
  --surface-2: #1f291f;
  --ink: #e7eadf;
  --muted: #a3ae99;
  --line: #2c382b;
  --green: #86c790;
  --green-soft: #213323;
  --brass: #e2b65a;
  --copper: #e08a5c;
  --link: #93d39c;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar);
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font: 650 19px/1 var(--display);
  margin-right: auto;
  white-space: nowrap;
}
.brand img { border-radius: 50%; }
.brand small {
  font: 600 11px/1 var(--font); letter-spacing: .08em; text-transform: uppercase;
  color: var(--green); background: var(--green-soft); padding: 4px 7px; border-radius: 99px;
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-btn svg.fill { fill: currentColor; stroke: none; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
.menu-btn { display: none; }

/* ---------- search ---------- */

.search { position: relative; width: min(340px, 34vw); }
.search > svg {
  position: absolute; left: 12px; top: 50%; translate: 0 -50%;
  width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%; height: 40px;
  padding: 0 36px 0 38px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  position: absolute; right: 10px; top: 50%; translate: 0 -50%;
  font: 12px var(--mono); color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}
.search input:focus ~ kbd { display: none; }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  min-width: 320px;
  max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.results a {
  display: block; padding: 9px 11px; border-radius: 8px;
  color: var(--ink); text-decoration: none;
}
.results a[aria-selected="true"], .results a:hover { background: var(--green-soft); }
.results strong { display: block; font-weight: 600; }
.results .where { font-size: 12px; color: var(--green); font-weight: 600; letter-spacing: .03em; }
.results .snippet { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.results mark { background: none; color: var(--ink); font-weight: 600; }
.results .empty { padding: 12px; color: var(--muted); font-size: 14px; }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  width: 100%; max-width: 1440px; margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 210px;
  gap: 40px;
  padding: 0 24px;
}
.sidebar, .toc {
  position: sticky; top: var(--topbar);
  align-self: start;
  max-height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 28px 0 40px;
  scrollbar-width: thin;
}
main { min-width: 0; padding: 36px 0 64px; }

.nav-section { margin-bottom: 22px; }
.nav-section p {
  margin: 0 0 6px; padding-left: 12px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--brass);
}
.sidebar a {
  display: block; padding: 5px 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 14.5px;
}
.sidebar a:hover { color: var(--ink); background: var(--surface-2); }
.sidebar a.active { color: var(--green); background: var(--green-soft); font-weight: 600; }

.toc .toc-title {
  margin: 0 0 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.toc a {
  display: block; padding: 4px 0 4px 12px;
  border-left: 2px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: 13.5px; line-height: 1.4;
}
.toc a.lvl3 { padding-left: 24px; font-size: 13px; }
.toc a:hover { color: var(--ink); }
.toc a.current { color: var(--green); border-left-color: var(--green); }

/* ---------- article ---------- */

.prose { max-width: 760px; }
.prose > :first-child { margin-top: 0; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--brass);
}
.prose h1, .prose h2, .prose h3 { font-family: var(--display); font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.prose h1 { font-size: clamp(32px, 5vw, 44px); margin: 0 0 18px; }
.prose h2 {
  font-size: 27px; margin: 46px 0 14px; padding-top: 22px;
  border-top: 1px solid var(--line);
  position: relative;
}
.prose h2::before {
  content: ""; position: absolute; top: -1px; left: 0;
  width: 48px; height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--brass), var(--copper));
}
.prose h3 { font-size: 20.5px; margin: 32px 0 10px; }
.prose .anchor {
  margin-left: 8px; color: var(--line); text-decoration: none; font-family: var(--font); font-weight: 400;
  opacity: 0; transition: opacity .15s;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus { opacity: 1; color: var(--muted); }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li { margin: 4px 0; }
.prose li > ul, .prose li > ol { margin: 4px 0 6px; }
.prose ul { padding-left: 22px; }
.prose ul li::marker { color: var(--brass); }
.prose ol { padding-left: 24px; }
.prose ol li::marker { color: var(--green); font-weight: 600; }
.prose strong { font-weight: 600; }
.prose code {
  font: .88em var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 5px;
}
.prose pre {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.55;
}
.prose pre code { background: none; padding: 0; }
.prose blockquote {
  margin: 0 0 16px; padding: 12px 18px;
  border-left: 3px solid var(--brass); background: var(--surface); border-radius: 0 10px 10px 0;
  color: var(--muted);
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

.prose img.shot {
  display: block; width: 100%; margin: 6px 0;
  border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: zoom-in; background: var(--surface-2);
}
.prose img.recipe {
  display: inline-block; vertical-align: top; margin: 4px 8px 4px 0;
  border-radius: 8px; image-rendering: pixelated;
  border: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto; margin: 0 0 20px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose th, .prose td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; font-size: 13.5px; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover td { background: color-mix(in srgb, var(--green-soft) 45%, transparent); }

.edit { margin-top: 40px; font-size: 14px; }
.edit a { color: var(--muted); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 760px; margin-top: 28px; }
.pager a {
  padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  text-decoration: none; color: var(--ink); font-weight: 600;
}
.pager a:hover { border-color: var(--green); }
.pager span { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.pager .next { grid-column: 2; text-align: right; }

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

.home .layout { display: block; max-width: none; padding: 0; }
.home .toc { display: none; }
.home main { padding: 0 0 64px; }

.hero {
  position: relative;
  min-height: min(78vh, 720px);
  display: flex; align-items: flex-end;
  padding: 120px max(24px, calc((100vw - 1200px) / 2)) 72px;
  background: #1b231b var(--hero) center 40% / cover no-repeat;
  color: #fff;
  isolation: isolate;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgb(12 20 12 / .86) 0%, rgb(12 20 12 / .6) 45%, rgb(12 20 12 / .1) 100%),
    linear-gradient(0deg, rgb(12 20 12 / .55), transparent 45%);
}
.hero-inner { max-width: 620px; }
.hero-icon { border-radius: 50%; filter: drop-shadow(0 8px 22px rgb(0 0 0 / .45)); margin-bottom: 20px; }
.eyebrow.light { color: #f0c96a; }
.hero h1 {
  font: 650 clamp(42px, 7vw, 76px)/1.02 var(--display);
  letter-spacing: -.02em; margin: 6px 0 18px;
}
.hero-lede p { font-size: clamp(17px, 2vw, 19px); line-height: 1.6; color: rgb(255 255 255 / .88); margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; height: 46px; padding: 0 20px;
  border-radius: 12px; font-weight: 600; text-decoration: none;
  color: #fff; background: rgb(255 255 255 / .12); border: 1px solid rgb(255 255 255 / .35);
  backdrop-filter: blur(6px);
}
.btn:hover { background: rgb(255 255 255 / .2); }
.btn.primary { background: #e2b14d; border-color: #e2b14d; color: #1d1a10; }
.btn.primary:hover { background: #ecc066; }

.chains { max-width: 1200px; margin: 0 auto; padding: 64px 24px 16px; }
.chains-head h2 { font: 650 clamp(28px, 4vw, 38px)/1.15 var(--display); margin: 0 0 28px; letter-spacing: -.01em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform .2s, border-color .2s;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
.card-media { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .card-media img { transform: scale(1.04); }
.card-art {
  width: 100%; height: 100%;
  background:
    radial-gradient(circle at 78% 30%, color-mix(in srgb, var(--brass) 70%, transparent) 0 14%, transparent 15%),
    repeating-linear-gradient(-35deg, transparent 0 18px, color-mix(in srgb, var(--green) 14%, transparent) 18px 20px),
    linear-gradient(160deg, var(--green-soft), var(--surface-2));
}
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.card h3 { font: 650 21px/1.2 var(--display); margin: 0 0 6px; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--green); }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.card ul { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.card li a {
  display: inline-block; padding: 4px 10px; border-radius: 99px;
  font-size: 13px; font-weight: 500; text-decoration: none;
  color: var(--green); background: var(--green-soft);
}
.card li a:hover { background: var(--green); color: var(--surface); }

.home-prose { max-width: 820px; margin: 0 auto; padding: 32px 24px 0; }

/* ---------- footer, lightbox ---------- */

.footer {
  border-top: 1px solid var(--line);
  padding: 28px 24px 36px; text-align: center;
  font-size: 14px; color: var(--muted);
}
.footer p { margin: 4px 0; }
.footer a { color: var(--muted); }

.lightbox {
  border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 94vh; overflow: visible;
}
.lightbox::backdrop { background: rgb(8 12 8 / .85); }
.lightbox img { display: block; max-width: 96vw; max-height: 94vh; border-radius: 10px; }
.lightbox button {
  position: absolute; top: -14px; right: -14px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: #fff; color: #111; font-size: 22px; line-height: 1; cursor: pointer;
}

.scrim { position: fixed; inset: 0; z-index: 35; background: rgb(8 12 8 / .45); }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 36px; }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .layout { display: block; padding: 0 16px; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; left: 0; bottom: 0;
    width: min(300px, 86vw); max-height: none;
    align-self: stretch; overscroll-behavior: contain;
    padding: 20px 14px 40px;
    background: var(--bg); border-right: 1px solid var(--line);
    translate: -100% 0; transition: translate .25s ease;
  }
  body.nav-open .sidebar { translate: 0 0; }
  main { padding-top: 24px; }
  .brand small { display: none; }
  .search { width: auto; flex: 1; max-width: 340px; }
  .search kbd { display: none; }
  .hero { padding: 96px 16px 48px; min-height: 0; }
  .hero::before { background: linear-gradient(0deg, rgb(12 20 12 / .9) 10%, rgb(12 20 12 / .45)); }
  .chains { padding: 44px 16px 8px; }
  .home-prose { padding: 24px 16px 0; }
}

/* the landing page keeps the drawer at every width */
.home .menu-btn { display: inline-grid; }
.home .sidebar {
  position: fixed; z-index: 40; top: 0; left: 0; bottom: 0;
  width: min(300px, 86vw); max-height: none;
  /* the docked sidebar's align-self: start would size a fixed drawer to its content,
     taller than the window, so it couldn't scroll */
  align-self: stretch; overscroll-behavior: contain;
  padding: 20px 14px 40px;
  background: var(--bg); border-right: 1px solid var(--line);
  translate: -100% 0; transition: translate .25s ease;
}
.home.nav-open .sidebar { translate: 0 0; }

@media (max-width: 560px) {
  .topbar { padding: 0 8px; gap: 2px; }
  .brand span { display: none; }
  .brand { margin-right: 6px; }
  .search { max-width: none; }
  .results { position: fixed; left: 8px; right: 8px; top: calc(var(--topbar) - 2px); min-width: 0; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .prose h2 { font-size: 24px; }
  .prose th, .prose td { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
