/* How Dark Souls III works: the site's one stylesheet. Plain HTML pages; lightbox.js shows pictures full size. */
:root {
  --bg: #f5f1e8; --bg2: #ece6d9; --fg: #221e18; --muted: #6a6254; --card: #fffdf8; --line: #d9d0bf;
  --accent: #a4501a; --accent2: #7a5a1e; --code: #ede6d8; --head: #1b1712;
  --ember: #c9631f; --glow: rgba(201, 99, 31, 0.10);
  --data: #2c7a4b; --exe: #2d5f9a; --cap: #7a4fa0; --er: #5f6b2a; --guess: #a8571b; --open: #858585;
  --v-faith: #2c7a4b; --v-close: #2d5f9a; --v-ours: #a8571b; --v-none: #858585;
  --heroA: #2a2119; --heroB: #120f0b; --heroFg: #f1e7d3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100d; --bg2: #1a1712; --fg: #e8e1d3; --muted: #a39a89; --card: #1c1914; --line: #342e25;
    --accent: #e39a52; --accent2: #d7b46a; --code: #262119; --head: #f3ead8;
    --ember: #f0873a; --glow: rgba(240, 135, 58, 0.08);
    --data: #6cc28e; --exe: #7fb0e8; --cap: #c19be0; --er: #b8c46a; --guess: #e8995b; --open: #9a9a9a;
    --v-faith: #6cc28e; --v-close: #7fb0e8; --v-ours: #e8995b; --v-none: #9a9a9a;
  }
}
:root[data-theme="dark"] {
  --bg: #12100d; --bg2: #1a1712; --fg: #e8e1d3; --muted: #a39a89; --card: #1c1914; --line: #342e25;
  --accent: #e39a52; --accent2: #d7b46a; --code: #262119; --head: #f3ead8;
  --ember: #f0873a; --glow: rgba(240, 135, 58, 0.08);
  --data: #6cc28e; --exe: #7fb0e8; --cap: #c19be0; --er: #b8c46a; --guess: #e8995b; --open: #9a9a9a;
  --v-faith: #6cc28e; --v-close: #7fb0e8; --v-ours: #e8995b; --v-none: #9a9a9a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16.5px/1.62 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, .brand, .hero .lede { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ember); }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top .in { max-width: 1180px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 6px 18px; align-items: center; flex-wrap: wrap; }
.brand { font-size: 1.12rem; font-weight: 700; color: var(--head); text-decoration: none; white-space: nowrap; }
.brand::before { content: ""; display: inline-block; width: 9px; height: 14px; margin-right: 8px; vertical-align: -1px;
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%; background: radial-gradient(circle at 50% 75%, #ffd27a, var(--ember) 60%, transparent 70%); }
nav.pages { display: flex; flex-wrap: wrap; gap: 2px 4px; font-size: 0.86rem; }
nav.pages a { color: var(--muted); text-decoration: none; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
nav.pages a:hover { color: var(--fg); background: var(--bg2); }
nav.pages a[aria-current] { color: var(--bg); background: var(--accent); }

/* hero */
.hero { background: radial-gradient(ellipse at 50% 120%, rgba(240,135,58,0.28), transparent 60%),
  linear-gradient(180deg, var(--heroA), var(--heroB)); color: var(--heroFg); }
.hero .in { max-width: 1180px; margin: 0 auto; padding: 44px 16px 36px; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); line-height: 1.12; margin: 0 0 10px; color: #fbf3e3; letter-spacing: 0.01em; }
.hero .kicker { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; color: #e9a865; margin-bottom: 8px; }
.hero .lede { font-size: 1.18rem; max-width: 64ch; color: #e6dac4; margin: 0; }
.hero code { background: rgba(255,255,255,0.08); color: #f6e7cc; }

/* page layout: content and an in-page contents column */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 80px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
@media (min-width: 1060px) { .wrap.toc-side { grid-template-columns: minmax(0, 1fr) 230px; } }
main { min-width: 0; max-width: 860px; }
aside.toc { display: none; }
@media (min-width: 1060px) {
  aside.toc { display: block; position: sticky; top: 64px; align-self: start; margin-top: 34px; font-size: 0.86rem;
    max-height: calc(100vh - 80px); overflow: auto; border-left: 1px solid var(--line); padding-left: 14px; }
  aside.toc strong { display: block; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
  aside.toc a { display: block; color: var(--muted); text-decoration: none; padding: 3px 0; line-height: 1.3; }
  aside.toc a:hover { color: var(--accent); }
}

h2 { font-size: 1.62rem; margin: 52px 0 12px; color: var(--head); padding-bottom: 6px; border-bottom: 1px solid var(--line); scroll-margin-top: 70px; }
h2 .num { color: var(--ember); font-size: 0.8em; margin-right: 8px; }
h3 { font-size: 1.18rem; margin: 30px 0 8px; color: var(--head); scroll-margin-top: 70px; }
h4 { font-size: 0.95rem; margin: 20px 0 6px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p, li { max-width: 74ch; }
ul, ol { padding-left: 1.3em; }
li { margin: 3px 0; }
code, .mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; font-size: 0.86em; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--code); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 0.84rem; line-height: 1.5; border: 1px solid var(--line); }
pre code { background: none; padding: 0; overflow-wrap: normal; }
.small { font-size: 0.88em; }
.muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

/* tables */
.tw { overflow-x: auto; margin: 10px 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg2); }
td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover td { background: var(--glow); }

/* cards and callouts */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin: 18px 0; }
.card > :first-child { margin-top: 0; } .card > :last-child { margin-bottom: 0; }
.tldr { border-left: 4px solid var(--ember); }
.tldr strong.t { display: block; font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 1.1rem; margin-bottom: 4px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); margin: 16px 0; }
.grid3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 16px 0; }
.grid2 .card, .grid3 .card { margin: 0; }

/* DS3 vs ours, side by side */
.vs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: 16px 0; }
.vs > div { border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; background: var(--card); }
.vs > div > :first-child { margin-top: 0; } .vs > div > :last-child { margin-bottom: 0; }
.vs h4 { margin: 0 0 8px; }
.vs .ds3 { border-top: 3px solid var(--accent2); }
.vs .ours { border-top: 3px solid var(--ember); }
.vs .ds3 h4::before { content: "DS3 · "; color: var(--accent2); }
.vs .ours h4::before { content: "Our engine · "; color: var(--ember); }

/* evidence tags */
.tag { display: inline-block; font-size: 0.7em; font-weight: 700; letter-spacing: 0.03em; padding: 0 6px; line-height: 1.55;
  border-radius: 9px; border: 1px solid currentColor; vertical-align: 1px; white-space: nowrap; font-family: system-ui, sans-serif; }
.t-data { color: var(--data); } .t-exe { color: var(--exe); } .t-cap { color: var(--cap); } .t-er { color: var(--er); }
.t-guess { color: var(--guess); } .t-open { color: var(--open); }

/* fidelity verdicts */
.verdict { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 10px 14px; margin: 14px 0;
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--c); }
.verdict .v { flex: none; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c);
  padding-top: 3px; min-width: 6.4em; }
.verdict p { margin: 0; }
.v-faith { --c: var(--v-faith); } .v-close { --c: var(--v-close); } .v-ours { --c: var(--v-ours); } .v-none { --c: var(--v-none); }
.chip { display: inline-block; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--c); border: 1px solid var(--c); border-radius: 999px; padding: 0 8px; line-height: 1.6; white-space: nowrap; }

/* flow diagrams */
.flow { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin: 18px 0; max-width: 640px; }
.flow .step { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; position: relative; }
.flow .step b { color: var(--head); }
.flow .step .k { display: block; font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.flow .step.hot { border-color: var(--ember); box-shadow: 0 0 0 3px var(--glow); }
.flow .arrow { align-self: center; color: var(--ember); font-size: 0.82rem; line-height: 1; padding: 4px 0; text-align: center; }
.flow .arrow::before { content: "▼"; display: block; font-size: 0.7rem; }
.flow .arrow span { color: var(--muted); font-size: 0.8rem; }
.hflow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 14px 0; }
.hflow .step { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 0.9rem; }
.hflow .step.hot { border-color: var(--ember); }
.hflow .to { color: var(--ember); }

/* the frame's passes as a bar */
.passes { display: grid; gap: 4px; margin: 16px 0; }
.pass { display: grid; grid-template-columns: 2.2em minmax(0, 1fr); gap: 10px; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.pass .i { font-family: "Iowan Old Style", Georgia, serif; font-size: 1.3rem; color: var(--ember); text-align: center; line-height: 1.2; }
.pass b { color: var(--head); }
.pass .s { font-size: 0.86rem; color: var(--muted); }

/* page index cards */
.topics { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin: 20px 0; }
.topic { display: block; text-decoration: none; color: var(--fg); background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; transition: border-color .15s, transform .15s; }
.topic:hover { border-color: var(--ember); transform: translateY(-2px); color: var(--fg); }
.topic .ic { font-size: 1.5rem; line-height: 1; }
.topic h3 { margin: 8px 0 4px; font-size: 1.12rem; }
.topic p { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* stat tiles */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); margin: 16px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .n { font-family: "Iowan Old Style", Georgia, serif; font-size: 1.6rem; color: var(--head); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.8rem; color: var(--muted); }

/* stacked bar */
.bar { display: flex; height: 30px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); margin: 8px 0 4px; }
.bar div { display: flex; align-items: center; justify-content: center; font-size: 0.72rem; color: #1d1a14;
  overflow: hidden; white-space: nowrap; padding: 0 3px; border-right: 1px solid rgba(0,0,0,0.15); }

/* weighted roll table cells */
td.w { position: relative; font-variant-numeric: tabular-nums; }
td.w span { position: relative; z-index: 1; }
td.w::before { content: ""; position: absolute; left: 0; top: 18%; bottom: 18%; width: calc(var(--p) * 1%); background: var(--glow);
  border-right: 2px solid var(--ember); opacity: 0.9; }

/* footer, pager */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 56px; flex-wrap: wrap; }
.pager a { flex: 1 1 220px; text-decoration: none; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: var(--card); }
.pager a:hover { border-color: var(--ember); }
.pager .d { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.pager .next { text-align: right; }
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
footer .in { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.86rem; color: var(--muted); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .hero .in { padding: 30px 16px 26px; }
  h2 { font-size: 1.38rem; }
  .verdict { flex-direction: column; gap: 2px; }
}

/* codex flavour: an item-description style epigraph under each page's title */
.flavour { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-style: italic;
  color: #d9c8a6; border-left: 2px solid rgba(233,168,101,0.6); padding: 2px 0 2px 16px; margin: 18px 0 0; max-width: 62ch; font-size: 1.02rem; }
.flavour .src { display: block; font-style: normal; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: #b99a6c; margin-top: 6px; }

/* figures: pictures are generated by tools/site_images.py into img/ (not in git) */
figure { margin: 20px 0; }
figure img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line);
  background: repeating-linear-gradient(45deg, var(--bg2), var(--bg2) 10px, var(--card) 10px, var(--card) 20px);
  min-height: 60px; color: var(--muted); font-size: 0.85rem; }
figcaption { font-size: 0.86rem; color: var(--muted); margin-top: 6px; line-height: 1.45; }
figcaption b { color: var(--fg); }
figure.wide { margin-left: 0; margin-right: 0; }
.gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin: 18px 0; }
.gallery figure { margin: 0; }
.gallery.g3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gallery.g2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.gallery figcaption { font-size: 0.8rem; }
.gallery img.sq { aspect-ratio: 1; object-fit: cover; }
.hero.pic { background-size: cover; background-position: center; position: relative; }
.hero.pic::before { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(10,8,6,0.92) 0%, rgba(10,8,6,0.72) 45%, rgba(10,8,6,0.25) 100%), linear-gradient(0deg, rgba(10,8,6,0.85), transparent 45%); }
.hero.pic .in { position: relative; padding-top: 72px; padding-bottom: 56px; }
.imgnote { font-size: 0.8rem; color: var(--muted); }
@media (max-width: 700px) { .top { position: static; } }

/* speculation: the "how it was made" page */
.spec { border: 1px dashed var(--guess); background: color-mix(in srgb, var(--guess) 7%, var(--card)); border-radius: 12px;
  padding: 14px 18px; margin: 20px 0; }
.spec > :first-child { margin-top: 0; } .spec > :last-child { margin-bottom: 0; }
.spec strong.t { color: var(--guess); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; display: block; margin-bottom: 4px; }
.c-strong { --c: var(--v-faith); } .c-plaus { --c: var(--v-close); } .c-guess { --c: var(--v-ours); }

/* the save page: a slot's layout as a bar */
:root { --r1: #c9a45c; --r2: #7fa7c9; --r3: #9cc28e; --r4: #d58f6b; --r0: #e6e1d6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --r0: #2c281f; } }
:root[data-theme="dark"] { --r0: #2c281f; }
.scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.75em; font-family: ui-monospace, Menlo, monospace; }
.legend.sw span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--c); vertical-align: -1px; }
p.note { color: var(--muted); font-size: 0.9em; }

/* the lightbox (lightbox.js): every figure picture opens full size */
main figure img { cursor: zoom-in; transition: filter .15s; }
main figure img:hover { filter: brightness(1.08); }
main figure img:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
html.lb-on { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 100; background: rgba(8, 6, 4, 0.97); display: flex; align-items: center; justify-content: center; }
.lb[hidden] { display: none; }
.lb-fig { margin: 0; max-width: min(94vw, 1600px); display: flex; flex-direction: column; align-items: center; }
.lb-fig img { display: block; max-width: 100%; max-height: calc(100vh - 140px); width: auto; height: auto; border-radius: 6px;
  border: 1px solid #3a3226; box-shadow: 0 10px 60px rgba(0,0,0,0.6); background: #12100d; }
.lb-fig figcaption { color: #d8cdb8; font-size: 0.9rem; max-width: 80ch; margin-top: 12px; text-align: center; line-height: 1.5; }
.lb-fig figcaption b { color: #f3ead8; }
.lb-fig figcaption code { background: rgba(255,255,255,0.08); color: #f0dfc0; }
.lb-fig figcaption a { color: #e9a865; }
.lb-n { display: block; color: #e9a865; font-size: 0.75rem; letter-spacing: 0.12em; margin-bottom: 4px; }
.lb button { position: absolute; background: rgba(30, 26, 20, 0.7); color: #f3ead8; border: 1px solid #4a4030; border-radius: 999px;
  width: 46px; height: 46px; font-size: 1.7rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lb button:hover, .lb button:focus-visible { background: #c9631f; border-color: #e9a865; outline: none; }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
@media (max-width: 600px) { .lb-prev, .lb-next { top: auto; bottom: 14px; transform: none; } .lb-fig img { max-height: calc(100vh - 220px); } }
