/* ==========================================================================
   BG3 Ultimate Strategy Guide — shared styles
   ========================================================================== */

:root {
  --bg: #f6f1e7;
  --bg-elev: #fffaf0;
  --bg-sunk: #ece4d4;
  --text: #2a2118;
  --text-muted: #6b5d4c;
  --border: #d9cdb6;
  --accent: #8a5a12;
  --accent-strong: #6e4508;
  --accent-soft: #f1e2c2;
  --danger: #a3262a;
  --danger-soft: #f7dcdc;
  --ok: #2f6b3a;
  --ok-soft: #dcefdf;
  --info: #2c5a8a;
  --info-soft: #dce8f5;
  --tier-s: #b8860b;
  --tier-a: #2f6b3a;
  --tier-b: #2c5a8a;
  --tier-c: #6b5d4c;
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 4px 16px rgba(60, 40, 10, .06);
  --radius: 10px;
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --maxw: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110e;
    --bg-elev: #1d1915;
    --bg-sunk: #0f0d0b;
    --text: #ece3d3;
    --text-muted: #a99a84;
    --border: #3a3128;
    --accent: #d9a54a;
    --accent-strong: #f0c068;
    --accent-soft: #3a2c15;
    --danger: #ef7a7a;
    --danger-soft: #3d1a1a;
    --ok: #7fcf8c;
    --ok-soft: #173020;
    --info: #86b6ea;
    --info-soft: #162a40;
    --tier-s: #f0c068;
    --tier-a: #7fcf8c;
    --tier-b: #86b6ea;
    --tier-c: #a99a84;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14110e;
  --bg-elev: #1d1915;
  --bg-sunk: #0f0d0b;
  --text: #ece3d3;
  --text-muted: #a99a84;
  --border: #3a3128;
  --accent: #d9a54a;
  --accent-strong: #f0c068;
  --accent-soft: #3a2c15;
  --danger: #ef7a7a;
  --danger-soft: #3d1a1a;
  --ok: #7fcf8c;
  --ok-soft: #173020;
  --info: #86b6ea;
  --info-soft: #162a40;
  --tier-s: #f0c068;
  --tier-a: #7fcf8c;
  --tier-b: #86b6ea;
  --tier-c: #a99a84;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font-body);
  overflow-x: hidden;
}
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; letter-spacing: .01em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin: 0 0 .4em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 2.2em 0 .6em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
h4 { font-size: 1rem; margin: 1.2em 0 .4em; font-family: var(--font-body); font-weight: 700; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; margin: 0 0 1em; }
li { margin-bottom: .3em; }
code, kbd { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9em; background: var(--bg-sunk); padding: .1em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-family: var(--font-display); font-weight: 700; white-space: nowrap; }
.brand .d20 { width: 28px; height: 28px; flex: none; }
.brand small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .7rem; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; margin-left: auto; flex-wrap: nowrap; }
.nav a { text-decoration: none; color: var(--text-muted); padding: 6px 9px; white-space: nowrap; border-radius: 6px; font-size: .9rem; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--bg-sunk); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.header-tools { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elev); color: var(--text); cursor: pointer; font: inherit; font-size: .85rem;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-toggle { display: none; }
.search-btn kbd { font-size: .7rem; padding: 1px 5px; border: 1px solid var(--border); background: transparent; }

@media (max-width: 1100px) {
  .menu-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: var(--bg-elev); border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px; box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; font-size: 1rem; }
  .header-tools { margin-left: auto; }
  .search-btn kbd, .search-btn .label { display: none; }
}

/* ---------- Layout ---------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 24px 16px 64px; }
.with-toc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }
.toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; font-size: .88rem; padding-top: 8px; }
.toc h4 { margin: 0 0 8px; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--border); }
.toc li { margin: 0; }
.toc a { display: block; padding: 4px 12px; color: var(--text-muted); text-decoration: none; border-left: 2px solid transparent; margin-left: -1px; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc .sub a { padding-left: 24px; font-size: .82rem; }
@media (max-width: 900px) {
  .with-toc { grid-template-columns: 1fr; gap: 0; }
  .toc { position: static; max-height: none; margin-bottom: 16px; }
  .toc details { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; background: var(--bg-elev); }
}
.toc summary { cursor: pointer; font-weight: 600; font-size: .9rem; list-style: none; }
@media (min-width: 901px) { .toc summary { display: none; } .toc details > ol { display: block; } }

.page-head { padding: 24px 0 8px; }
.page-head .eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.page-head .lede { font-size: 1.12rem; color: var(--text-muted); max-width: 70ch; }
.content { min-width: 0; }
.content > h2:first-child { margin-top: .5em; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 16px; margin: 8px 0 32px; padding: clamp(28px, 6vw, 64px);
  background:
    radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 60%),
    radial-gradient(600px 300px at -10% 110%, color-mix(in srgb, var(--danger) 18%, transparent), transparent 60%),
    var(--bg-elev);
  border: 1px solid var(--border);
}
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); max-width: 16ch; }
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 60ch; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.hero-d20 { position: absolute; right: -40px; bottom: -60px; width: 320px; opacity: .08; color: var(--accent); pointer-events: none; }
@media (max-width: 640px) { .hero-d20 { width: 200px; } }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 8px;
  background: var(--accent); color: var(--bg-elev); text-decoration: none; font-weight: 600; border: 1px solid var(--accent);
}
.btn:hover { background: var(--accent-strong); color: var(--bg-elev); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
a.card { display: block; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--accent); color: inherit; }
a.card .card-icon { font-size: 1.6rem; line-height: 1; margin-bottom: 10px; display: block; }
a.card h3 { margin: 0 0 6px; color: var(--accent); }
a.card p { color: var(--text-muted); font-size: .94rem; }

/* ---------- Callouts ---------- */
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.2em 0; }
.callout > :last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; margin-bottom: 4px; }
.callout.danger { border-color: var(--danger); background: var(--danger-soft); }
.callout.ok { border-color: var(--ok); background: var(--ok-soft); }
.callout.info { border-color: var(--info); background: var(--info-soft); }

/* ---------- Badges / tiers ---------- */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle; white-space: nowrap;
}
.badge.missable { color: var(--danger); }
.badge.new { color: var(--info); }
.badge.hm { color: var(--accent); }
.badge.ok { color: var(--ok); }
.tier { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; font-family: var(--font-display); font-weight: 700; color: var(--bg-elev); flex: none; }
.tier.S { background: var(--tier-s); }
.tier.A { background: var(--tier-a); }
.tier.B { background: var(--tier-b); }
.tier.C { background: var(--tier-c); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 1em 0 1.5em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-sunk); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; }

/* ---------- Tier list rows ---------- */
.tier-list { display: grid; gap: 10px; margin: 1em 0 2em; }
.tier-row { display: grid; grid-template-columns: 52px 1fr; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); }
.tier-row .tier-label { display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--bg-elev); }
.tier-row .tier-items { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 6px; background: var(--bg-sunk); font-size: .88rem; border: 1px solid var(--border); }

/* ---------- Details / accordions ---------- */
details.acc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); margin: 10px 0; }
details.acc > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "+"; margin-left: auto; font-size: 1.3rem; color: var(--text-muted); line-height: 1; }
details.acc[open] > summary::after { content: "−"; }
details.acc > .acc-body { padding: 0 18px 16px; }
details.acc > .acc-body > :last-child { margin-bottom: 0; }

/* ---------- Spoilers ---------- */
.spoiler { position: relative; border-radius: 6px; }
html:not(.show-spoilers) .spoiler { filter: blur(6px); cursor: pointer; user-select: none; transition: filter .2s; }
html:not(.show-spoilers) .spoiler.revealed { filter: none; cursor: auto; user-select: auto; }
html:not(.show-spoilers) .spoiler:not(.revealed) * { pointer-events: none; }
.spoiler-note { font-size: .82rem; color: var(--text-muted); display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Builds ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; align-items: center; }
.filters .label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin-right: 4px; }
.filter-btn { font: inherit; font-size: .88rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); cursor: pointer; }
.filter-btn:hover { border-color: var(--accent); }
.filter-btn[aria-pressed="true"] { background: var(--accent); color: var(--bg-elev); border-color: var(--accent); }
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-search { flex: 1 1 220px; min-width: 0; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font: inherit; }

.build { scroll-margin-top: 80px; }
.build-head { display: flex; gap: 12px; align-items: flex-start; }
.build-head h3 { margin: 0; }
.build-meta { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.build-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.split { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 10px 0 4px; background: var(--bg-sunk); }
.split span { display: block; height: 100%; }
.split-legend { font-size: .82rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 12px; }
.split-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.levels { width: 100%; font-size: .88rem; }
.levels td:first-child { white-space: nowrap; width: 1%; color: var(--accent); }
.build .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.build ul { margin-bottom: .6em; }
.empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* ---------- Checklist ---------- */
.checklist { list-style: none; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--border); margin: 0; }
.checklist input { margin-top: 5px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.checklist label { cursor: pointer; }
.checklist input:checked + label { text-decoration: line-through; color: var(--text-muted); }
.progress { font-size: .85rem; color: var(--text-muted); }

/* ---------- Numbered tips ---------- */
.tips { counter-reset: tip; list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.tips li { counter-increment: tip; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 16px 62px; position: relative; margin: 0; }
.tips li::before { content: counter(tip); position: absolute; left: 16px; top: 14px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.tips li strong { display: block; margin-bottom: 2px; }

/* ---------- Search dialog ---------- */
.search-dialog { border: 0; padding: 0; background: transparent; width: min(640px, calc(100vw - 32px)); max-height: 80vh; margin: 10vh auto auto; color: var(--text); }
.search-dialog::backdrop { background: rgba(10, 8, 5, .55); backdrop-filter: blur(2px); }
.search-panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; max-height: 80vh; }
.search-panel input { font: inherit; font-size: 1.05rem; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); outline: none; }
.search-results { overflow: auto; list-style: none; margin: 0; padding: 6px; }
.search-results li { margin: 0; }
.search-results a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); }
.search-results .r-title { font-weight: 600; }
.search-results .r-page { font-size: .75rem; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin-left: 6px; }
.search-results .r-snip { display: block; font-size: .85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 2px; }
.search-hint { padding: 10px 18px; font-size: .78rem; color: var(--text-muted); border-top: 1px solid var(--border); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 28px 16px; color: var(--text-muted); font-size: .85rem; }
.site-footer .inner { max-width: var(--maxw); margin: 0 auto; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; }
.site-footer a { color: var(--text-muted); }

.muted { color: var(--text-muted); }
.small { font-size: .88rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Small phones ---------- */
@media (max-width: 480px) {
  .site-header .inner { gap: 8px; }
  .brand { min-width: 0; font-size: .95rem; }
  .brand > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .brand small { display: none; }
  .header-tools { gap: 4px; }
  .icon-btn { min-width: 34px; height: 34px; padding: 0 7px; }
}
