/* The Illustrated Guide to Local AI — single stylesheet.
   Warm paper, serif headings, quiet book feel. Offline friendly. */

:root {
  --paper: #F4F1EC;
  --ink: #2B2620;
  --accent: #8B7355;
  --accent-deep: #6B543A;
  --card: #E8E4DD;
  --line: #D9D2C6;
  --muted: #6E6659;

  --common: #6B6B6B;
  --uncommon: #3E7C4F;
  --rare: #3B6EA5;
  --epic: #7C4D8F;
  --legendary: #C9702A;
  --mythic: #A63D40;
  --joker: #1C1A18;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.72;
}

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

img { max-width: 100%; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.reading { max-width: 72ch; margin: 0 auto; }

/* ---------- top bar ---------- */
header.top {
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
header.top .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}
header.top .wordmark {
  font-size: 15px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
header.top .wordmark:hover { text-decoration: none; color: var(--accent-deep); }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 15px; }
header.top nav a { letter-spacing: 0.04em; text-transform: uppercase; }
header.top nav .sep { color: var(--line); }

/* ---------- headings ---------- */
h1, h2, h3 { font-weight: normal; line-height: 1.25; }
h1 { font-size: clamp(28px, 5vw, 40px); margin-bottom: 18px; }
h2 { font-size: 24px; margin: 36px 0 12px; }
h3 { font-size: 20px; margin: 26px 0 10px; }

p { margin-bottom: 18px; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 64px 0 40px; }
.hero h1 { max-width: 22ch; margin: 0 auto 18px; }
.hero p {
  color: var(--accent-deep);
  font-size: 20px;
  max-width: 56ch;
  margin: 0 auto;
}

.page-head { padding: 44px 0 8px; }
.page-head p.lede { color: var(--muted); max-width: 68ch; }

/* ---------- pillars ---------- */
.pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 24px 0 44px;
}
.pillar {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 20px 18px;
  transition: transform 0.15s ease;
}
.pillar:hover { transform: translateY(-3px); text-decoration: none; }
.pillar .kicker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.pillar h2 { font-size: 21px; margin: 0 0 6px; }
.pillar p { font-size: 16px; color: var(--muted); margin: 0; }

/* ---------- deck strip ---------- */
.section-title {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 40px 0 14px;
}
.deck-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.cover-tile {
  display: block;
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  transition: transform 0.15s ease;
}
.cover-tile:hover { transform: translateY(-3px); text-decoration: none; }
.cover-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-tile .cover-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 22px 12px 10px;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(to top, rgba(20,18,15,0.78), rgba(20,18,15,0));
}
.cover-tile .cover-placeholder {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  background: var(--tile, var(--accent));
}

/* ---------- generic card tiles (2:3) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin: 8px 0 40px;
}
.card-tile {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  border-top: 4px solid var(--tile, var(--accent));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-tile:hover { transform: translateY(-4px); }
.card-tile .thumb {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--tile, var(--accent));
  overflow: hidden;
}
.card-tile .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-tile .thumb .placeholder {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  color: rgba(255,255,255,0.92);
  font-size: 17px;
}
.card-tile .tile-meta { padding: 10px 12px 12px; }
.card-tile .tile-name { font-size: 17px; line-height: 1.3; }
.card-tile .tile-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ---------- rarity badges ---------- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  white-space: nowrap;
}
.r-Common { color: var(--common); }
.r-Uncommon { color: var(--uncommon); }
.r-Rare { color: var(--rare); }
.r-Epic { color: var(--epic); }
.r-Legendary { color: var(--legendary); }
.r-Mythic { color: var(--mythic); }
.r-Joker {
  color: #fff;
  border-color: transparent;
  background: var(--joker);
  box-shadow: 0 0 0 2px #C9A227 inset;
}

/* ---------- chapter list ---------- */
.chapter-list { list-style: none; margin: 8px 0 40px; }
.chapter-list li { border-bottom: 1px solid var(--line); }
.chapter-list a {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 18px 4px;
}
.chapter-list a:hover { text-decoration: none; }
.chapter-list a:hover .ch-title { text-decoration: underline; }
.chapter-list .ch-num {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--accent);
  min-width: 7ch;
  text-transform: uppercase;
}
.chapter-list .ch-title { font-size: 21px; }
.chapter-list .ch-hook { display: block; font-size: 16px; color: var(--muted); margin-top: 3px; }

/* ---------- chapter article ---------- */
article.chapter { padding: 20px 0 8px; }
article.chapter .chapter-body p { margin-bottom: 20px; }
article.chapter .chapter-body h2 {
  font-size: 22px;
  margin: 40px 0 14px;
  color: var(--accent-deep);
}
article.chapter code, .inline-code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: #ECE7DE;
  color: #4A3B28;
  padding: 0.08em 0.4em;
  border-radius: 4px;
}
article.chapter ul, article.chapter ol { margin: 0 0 20px 26px; }
article.chapter li { margin-bottom: 6px; }
article.chapter blockquote {
  border-left: 4px solid var(--accent);
  background: var(--card);
  border-radius: 0 10px 10px 0;
  padding: 10px 20px;
  margin: 0 0 20px;
  font-style: italic;
}
article.chapter pre {
  background: #2C2C2C;
  color: #EDE7DC;
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  margin-bottom: 20px;
}
article.chapter pre code { background: none; color: inherit; padding: 0; }

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding-top: 18px;
  font-size: 16px;
}

/* ---------- linked-cards strip ---------- */
.linked {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}
.linked h2 { font-size: 20px; margin: 0 0 16px; }
.linked .strip {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.linked .strip a {
  flex: 0 0 120px;
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid var(--tile, var(--accent));
  background: #fff;
}
.linked .strip a:hover { text-decoration: none; transform: translateY(-3px); }
.linked .strip .thumb {
  aspect-ratio: 2 / 3;
  background: var(--tile, var(--accent));
  overflow: hidden;
  position: relative;
}
.linked .strip .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.linked .strip .thumb .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 10px; color: rgba(255,255,255,0.92); font-size: 15px;
}
.linked .strip .name {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  padding: 8px 9px 10px;
}
.linked .empty {
  color: var(--muted);
  font-size: 16px;
  font-style: italic;
}

/* ---------- filters (card browser) ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 18px 0 22px;
}
.filters label { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.filters select, .filters input {
  font-family: inherit;
  font-size: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
}
.filters input { min-width: 200px; }
.filters select:focus, .filters input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.count-line { color: var(--muted); font-size: 15px; margin-bottom: 14px; }

/* browser tiles */
.tile-link { display: block; }
.tile-link:hover { text-decoration: none; }

/* ---------- expandable deck cards ---------- */
details.card-detail {
  border: 1px solid var(--line);
  border-top: 4px solid var(--tile, var(--accent));
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
details.card-detail > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
details.card-detail > summary::-webkit-details-marker { display: none; }
details.card-detail .thumb {
  aspect-ratio: 2 / 3;
  background: var(--tile, var(--accent));
  position: relative;
  overflow: hidden;
}
details.card-detail .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
details.card-detail .thumb .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 14px; color: rgba(255,255,255,0.92); font-size: 17px;
}
details.card-detail .tile-meta { padding: 10px 12px 12px; }
details.card-detail .tile-name { font-size: 17px; line-height: 1.3; }
details.card-detail .tile-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
details.card-detail .card-body {
  border-top: 1px solid var(--line);
  padding: 16px 16px 18px;
  font-size: 16px;
}
details.card-detail .card-body h4 {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 14px 0 4px;
  font-weight: normal;
}
details.card-detail .card-body h4:first-child { margin-top: 0; }
details.card-detail .card-body p { margin-bottom: 6px; }
details.card-detail .card-body .analogy { font-style: italic; color: #4a4a4a; }
details.card-detail .card-body .flavor { font-style: italic; color: var(--muted); }
details.card-detail .card-body pre {
  background: #2C2C2C;
  color: #EDE7DC;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13.5px;
  overflow-x: auto;
  margin: 4px 0 6px;
}
details.card-detail .card-body .badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
details.card-detail .card-body .stats { font-size: 14px; color: var(--muted); }
details.card-detail .card-body .learn-link { display: inline-block; margin-top: 12px; font-size: 15px; }

/* anchor highlight */
.card-anchor { scroll-margin-top: 90px; }

/* ---------- builders ---------- */
.builders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin: 8px 0 40px;
}
.person {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--tile, var(--accent));
  border-radius: 12px;
  padding: 18px 20px;
}
.person .phead {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.person h3 { margin: 0 0 8px; font-size: 21px; }
.person .pwho { font-size: 15px; line-height: 1.55; margin-bottom: 8px; }
.person .porigin {
  font-size: 14.5px;
  color: #4A3B28;
  background: #F7F3EA;
  border-radius: 8px;
  padding: 8px 11px;
  margin: 10px 0;
}
.person .pflavor { font-size: 14px; font-style: italic; color: var(--muted); margin-top: 10px; }
.person .pthumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--tile, var(--accent));
}
.person .pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- learn ---------- */
.track-teasers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin: 8px 0 40px;
}
.track-teaser {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.track-teaser:hover { text-decoration: none; transform: translateY(-3px); }
.track-teaser .track-art { aspect-ratio: 2 / 1; background: var(--tile, var(--accent)); position: relative; }
.track-teaser .track-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.track-teaser .track-art .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.92); font-size: 20px;
}
.track-teaser .track-body { padding: 16px 18px 18px; }
.track-teaser h2 { font-size: 20px; margin: 0 0 6px; }
.track-teaser p { font-size: 15.5px; color: var(--muted); margin: 0; }

.status-pill {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 10px;
}

.track-detail .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 22px; }
.track-detail .chip {
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
}
.track-detail .quests {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 24px 0;
  color: var(--muted);
  font-style: italic;
}

/* ---------- game ---------- */
main.game { padding: 12px 0 8px; }
main.game h2 { margin-top: 40px; }
main.game table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 22px;
  font-size: 15.5px;
}
main.game th, main.game td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
main.game th { background: var(--card); }
main.game ul, main.game ol { margin: 0 0 20px 26px; }
main.game li { margin-bottom: 7px; }
main.game .callout {
  background: var(--card);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 14px 20px;
  margin: 0 0 22px;
}
main.game .callout p:last-child { margin-bottom: 0; }
main.game code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #ECE7DE;
  color: #4A3B28;
  padding: 0.08em 0.4em;
  border-radius: 4px;
}

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 96px 0; }
.notfound h1 { font-size: clamp(30px, 6vw, 44px); }
.notfound p { color: var(--muted); max-width: 48ch; margin: 0 auto 26px; }

/* ---------- footer ---------- */
footer {
  text-align: center;
  color: var(--accent);
  font-size: 15px;
  padding: 48px 0 40px;
  font-style: italic;
  border-top: 1px solid var(--line);
  margin-top: 56px;
}
footer a { font-style: normal; }

/* ---------- responsive ---------- */
@media (max-width: 620px) {
  body { font-size: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .deck-strip { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .linked .strip a { flex-basis: 104px; }
  .chapter-list .ch-num { min-width: 5.5ch; }
}
