/* rpgspeedruns.com — custom theme */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --text: #1b1c1e;
  --text-2: #4a4c52;
  --muted: #74767c;
  --border: #e3e2de;
  --border-strong: #cfcec9;
  --accent: #0b7a75;
  --accent-strong: #075f5b;
  --accent-soft: #e2f2f0;
  --code-bg: #efeeea;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .04);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --sidebar-w: 264px;
  --content-w: 780px;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --surface: #18191c;
    --surface-2: #1f2024;
    --text: #e9e9ec;
    --text-2: #c2c3c9;
    --muted: #8f9199;
    --border: #2a2b30;
    --border-strong: #3a3c42;
    --accent: #3cc4bb;
    --accent-strong: #6ad8d0;
    --accent-soft: #15302e;
    --code-bg: #232428;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111214;
  --surface: #18191c;
  --surface-2: #1f2024;
  --text: #e9e9ec;
  --text-2: #c2c3c9;
  --muted: #8f9199;
  --border: #2a2b30;
  --border-strong: #3a3c42;
  --accent: #3cc4bb;
  --accent-strong: #6ad8d0;
  --accent-soft: #15302e;
  --code-bg: #232428;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
img, video { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.main {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 32px;
  display: flex;
  flex-direction: column;
}
.main > * { width: 100%; max-width: var(--content-w); }
.main > .page--toc { max-width: calc(var(--content-w) + 260px); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px 24px;
}
.sidebar__top { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
  font-weight: 700; font-size: 17px; letter-spacing: -.01em;
  padding: 4px 8px;
}
.brand:hover { color: var(--text); }
.brand__mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: var(--surface);
}
.menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 7px; cursor: pointer;
}

/* Search */
.search { position: relative; margin: 20px 0 18px; }
.search__icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search__input {
  width: 100%;
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 32px 8px 34px;
  -webkit-appearance: none; appearance: none;
}
.search__input::placeholder { color: var(--muted); }
.search__input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font: 11px/1 var(--mono); color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 3px 5px;
}
.search__input:focus ~ .search__kbd, .search__input:not(:placeholder-shown) ~ .search__kbd { display: none; }
.search__results {
  list-style: none; margin: 6px 0 0; padding: 4px;
  position: absolute; left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
  max-height: 60vh; overflow-y: auto;
}
.search__results a { display: block; padding: 7px 9px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.35; }
.search__results a small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.search__results a:hover, .search__results a.is-selected { background: var(--accent-soft); }
.search__empty { padding: 8px 9px; color: var(--muted); font-size: 13px; }

/* Nav */
.nav__label {
  margin: 16px 8px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border-radius: 7px;
  color: var(--text-2); text-decoration: none; font-size: 14.5px; line-height: 1.35;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav__count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a.is-active .nav__count { color: var(--accent); }

/* ---------- Home ---------- */
.hero { padding: 12px 0 28px; }
.hero__title { font-size: clamp(32px, 5vw, 44px); line-height: 1.1; letter-spacing: -.025em; margin: 0 0 12px; }
.hero__lede { font-size: 18px; color: var(--text-2); margin: 0 0 8px; max-width: 36em; }
.hero__stats { font-size: 14px; color: var(--muted); margin: 0; }

/* Link list (game pages) */
.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list li + li { border-top: 1px solid var(--border); }
.list a {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 18px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.list a:hover { background: var(--surface-2); color: var(--accent-strong); }
.list__arrow { color: var(--muted); transition: transform .15s, color .15s; }
.list a:hover .list__arrow { color: var(--accent); transform: translateX(3px); }

/* ---------- Page chrome ---------- */
.crumbs { display: flex; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: clamp(28px, 4vw, 36px); line-height: 1.15; letter-spacing: -.02em; margin: 0; }
.page-head__meta { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.section-intro { margin-bottom: 20px; }

.page--toc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; }
.toc--rail { display: none; }
@media (min-width: 1280px) {
  .page--toc { grid-template-columns: minmax(0, var(--content-w)) 212px; }
  .toc--rail { display: block; position: sticky; top: 32px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding-top: 70px; }
  .toc--inline { display: none; }
}
.toc__label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: 12px; }
.toc li { margin: 0; }
.toc a { display: block; padding: 3px 0; font-size: 13.5px; line-height: 1.4; color: var(--text-2); text-decoration: none; }
.toc a:hover, .toc a.is-current { color: var(--accent); }
.toc--rail a { border-left: 2px solid var(--border); padding-left: 10px; margin-left: -2px; }
.toc--rail ul ul a { padding-left: 10px; }
.toc--rail a.is-current { border-left-color: var(--accent); }
.toc--inline {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 24px;
}
.toc--inline summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); }
.toc--inline nav { margin-top: 8px; max-height: 50vh; overflow-y: auto; }

.page-foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 15px; }
.page-foot a { text-decoration: none; font-weight: 500; }

.site-footer {
  margin-top: auto; padding-top: 56px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted);
}
.theme-toggle {
  font: inherit; font-size: 13px; color: var(--muted);
  background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- Prose (page content) ---------- */
.prose { font-size: 16.5px; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2, .prose h3, .prose h4, .prose h5 { letter-spacing: -.01em; line-height: 1.3; scroll-margin-top: 24px; }
.prose h2 { font-size: 24px; margin: 44px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 19px; margin: 32px 0 8px; }
.prose h4 { font-size: 16.5px; margin: 24px 0 6px; }
.prose h5 { font-size: 15px; margin: 20px 0 4px; color: var(--text-2); }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 24px; margin: 0 0 14px; }
.prose li { margin: 3px 0; }
.prose li > ul, .prose li > ol { margin: 4px 0; }
.prose strong { font-weight: 650; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.prose blockquote { margin: 0 0 14px; padding: 4px 16px; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--surface); border-radius: 0 6px 6px 0; }
.prose code {
  font-family: var(--mono); font-size: .88em;
  background: var(--code-bg); border-radius: 5px; padding: .12em .38em;
}
.prose pre { background: var(--code-bg); border-radius: 8px; padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose img { border-radius: 6px; }
.prose video { border-radius: 8px; display: block; margin: 0 0 14px; }

/* Tables: Markdown tables are wrapped in .table-wrap; raw HTML tables scroll on their own */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.prose table { border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
.table-wrap table { width: 100%; }
.prose > table {
  display: block; max-width: 100%; overflow-x: auto;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin: 0 0 20px;
}
.prose th, .prose td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { background: var(--surface-2); font-weight: 600; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover td { background: var(--surface-2); }
.prose td img { max-width: none; }
.prose caption { caption-side: top; text-align: left; font-weight: 600; padding: 10px 12px 4px; color: var(--text-2); }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: sticky; top: 0; z-index: 30;
    width: auto; height: auto; max-height: 100vh;
    border-right: 0; border-bottom: 1px solid var(--border);
    padding: 10px 16px;
  }
  .menu-toggle { display: inline-flex; }
  .sidebar__body { display: none; padding-bottom: 8px; }
  .sidebar.is-open .sidebar__body { display: block; }
  .search { margin-top: 12px; }
  .search__kbd { display: none; }
  .main { padding: 24px 16px 24px; }
  .prose h2 { font-size: 21px; }
}

/* Image galleries ({{< gallery >}} shortcode) */
.gallery {
  display: grid; gap: 14px; margin: 0 0 20px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.gallery figure {
  margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.gallery a { display: grid; place-items: center; min-height: 120px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.gallery img { display: block; max-height: 220px; width: auto; max-width: 100%; border-radius: 0; }
.gallery figcaption { font-size: 13.5px; color: var(--text-2); text-align: center; }
