/* Krestfell wiki theme.
   Apple-clean on warm cream: charcoal ink, hairline rules, generous space,
   Krestfell red (#8a0000, the title's stroke) as the single accent.
   Nation colours survive only as data (dots, tile accent bars). */

:root {
  --cream: #fffcf8;        /* page background */
  --cream-raised: #fbf8f0; /* cards */
  --cream-inset: #efe9da;  /* wells, image placeholders */
  --side-bg: #222225;      /* sidebar charcoal */
  --side-ink: #edeae3;
  --side-faint: rgba(237, 234, 227, 0.55);
  --ink: #26231e;          /* warm charcoal */
  --ink-soft: #5f5a4f;
  --ink-faint: #8d8778;
  --red: #8a0000;
  --red-hover: #a81414;
  --red-wash: rgba(138, 0, 0, 0.07);
  --hairline: rgba(38, 35, 30, 0.1);
  --hairline-strong: rgba(38, 35, 30, 0.18);

  /* Legacy accent vars some generated markup reads */
  --accent: var(--red);
  --accent-ink: var(--red);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Frame: sidebar + content ---- */

.frame {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  flex: none;
  padding: 28px 18px 40px;
  background: var(--side-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--side-ink);
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: block;
  margin: 0 8px 16px;
  text-decoration: none;
}
.sidebar .brand img { width: 100%; max-width: 180px; display: block; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5)) brightness(1.5); }
.sidebar .brand-sub {
  display: block;
  margin: 8px 2px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--side-faint);
}

.nav-section { margin-top: 24px; }
.nav-section > .nav-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--side-faint);
  margin: 0 10px 6px;
}
.nav-section a {
  display: block;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--side-ink);
  text-decoration: none;
  font-size: 14px;
}
.nav-section a:hover { background: rgba(255, 255, 255, 0.07); }
.nav-section a.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-weight: 600;
}
.nav-section a .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: baseline;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.nav-search {
  width: 100%;
  margin: 14px 0 2px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: var(--side-ink);
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
}
.nav-search:focus { border-color: rgba(255, 255, 255, 0.3); }
.nav-search::placeholder { color: var(--side-faint); }
.search-results { margin: 8px 0 0; }
.search-results a { font-size: 13px; }
.search-results .sr-section { color: var(--side-faint); font-size: 11px; margin-left: 6px; }

/* ---- Content column ---- */

.content {
  flex: 1;
  min-width: 0;
  padding: 40px clamp(16px, 4vw, 56px) 80px;
}

.page {
  max-width: 880px;
  margin: 0 auto;
}

.crumbs {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 0 0 14px 4px;
}
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--red); }

.card {
  background: var(--cream-raised);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(38, 35, 30, 0.04), 0 16px 40px -28px rgba(38, 35, 30, 0.25);
  padding: clamp(24px, 4vw, 48px);
  margin-bottom: 24px;
  overflow-wrap: break-word;
}

.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* Page header card with optional hero art */
.hero-card { padding: 0; overflow: hidden; }
.hero-art { width: 100%; display: block; max-height: 420px; object-fit: cover; object-position: center 25%; }
.hero-body { padding: clamp(24px, 4vw, 44px); }
.hero-body > :first-child { margin-top: 0; }
.hero-body > :last-child { margin-bottom: 0; }

.kicker {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
  font-weight: 700;
  margin: 0 0 10px;
}

h1 { font-weight: 700; font-size: clamp(30px, 4.5vw, 42px); line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 14px; }
h2 { font-weight: 700; font-size: 25px; line-height: 1.25; letter-spacing: -0.015em; margin: 40px 0 12px; }
h3 { font-weight: 650; font-size: 19px; letter-spacing: -0.01em; margin: 28px 0 10px; }
h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin: 24px 0 8px; }

h2 { border-bottom: 1px solid var(--hairline); padding-bottom: 10px; }

p { margin: 0 0 14px; }
.lede { font-size: 19px; line-height: 1.5; color: var(--ink-soft); letter-spacing: -0.01em; }

.lore, .lore p { font-family: var(--serif); font-size: 17px; line-height: 1.75; }
.lore h1, .lore h2, .lore h3 { font-family: var(--sans); }

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-hover); text-decoration: underline; }

blockquote {
  margin: 18px 0;
  padding: 10px 20px;
  border-left: 3px solid var(--red);
  background: var(--red-wash);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
  font-family: var(--serif);
}
blockquote p:last-child { margin-bottom: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: rgba(38, 35, 30, 0.07);
  padding: 1px 5px;
  border-radius: 5px;
}

hr { border: none; border-top: 1px solid var(--hairline); margin: 28px 0; }

ul, ol { margin: 0 0 14px; padding-left: 24px; }
li { margin-bottom: 6px; }

img { max-width: 100%; }

/* ---- Tables ---- */

.table-wrap { overflow-x: auto; margin: 0 0 16px; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--hairline-strong);
}
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Figures / screenshots ---- */

figure {
  margin: 22px 0;
}
figure img {
  display: block;
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--hairline);
}
figcaption {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 10px;
  text-align: center;
}

/* ---- Grids of tiles/cards ---- */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin: 20px 0;
}
.grid-wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.tile {
  display: block;
  background: var(--cream-raised);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: var(--hairline-strong);
  box-shadow: 0 12px 28px -18px rgba(38, 35, 30, 0.3);
  color: var(--ink);
  text-decoration: none;
}
.tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.tile .tile-body { padding: 12px 14px 14px; }
.tile .tile-title { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; }
.tile .tile-sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
.tile .tile-accent { height: 4px; }

/* Unit / structure stat cards */
.stat-card {
  background: var(--cream-raised);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
}
.stat-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--cream-inset); }
.stat-card .sc-body { padding: 12px 14px 14px; }
.stat-card .sc-name { font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.stat-card .sc-flavor { font-family: var(--serif); font-style: italic; font-size: 13.5px; color: var(--ink-soft); margin: 6px 0 10px; line-height: 1.5; }
.stat-line { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(38, 35, 30, 0.06);
  color: var(--ink-soft);
  white-space: nowrap;
}
.stat-pill.cost { background: var(--red-wash); color: var(--red); }
.stat-pill.ability { background: rgba(38, 35, 30, 0.09); color: var(--ink); }

/* Kindred chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 12px 3px 8px;
  border-radius: 999px;
  background: rgba(38, 35, 30, 0.06);
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  margin: 0 6px 6px 0;
}
.chip:hover { background: rgba(38, 35, 30, 0.1); color: var(--ink); text-decoration: none; }
.chip .dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.18); }

/* Fact table (frontmatter facts on kindred pages) */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 20px;
  margin: 18px 0;
  padding: 16px 18px;
  background: var(--cream-inset);
  border-radius: 12px;
}
.facts .fact-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.facts .fact-value { font-size: 14px; margin-top: 2px; }

/* Prev/next footer */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 6px;
}
.pager a {
  flex: 1;
  background: var(--cream-raised);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--ink);
}
.pager a:hover { border-color: var(--hairline-strong); text-decoration: none; }
.pager a:hover .pager-title { color: var(--red); }
.pager .pager-dir { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
.pager .pager-title { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; margin-top: 2px; }
.pager a.next { text-align: right; }

/* Footer */
.site-footer {
  max-width: 880px;
  margin: 48px auto 0;
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--red); }

/* Mobile */
.nav-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 30;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--hairline-strong);
  background: rgba(251, 248, 240, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .sidebar {
    position: fixed;
    z-index: 20;
    left: 0; top: 0; bottom: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: min(300px, 84vw);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.35);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .content { padding-top: 68px; }
}

@media print {
  .sidebar, .nav-toggle, .pager, .site-footer { display: none; }
  .card { box-shadow: none; border: none; padding: 0; }
}
