/*
 * Imperium Wiki — parchment theme. The :root colour/font tokens are copied at
 * build time from apps/client-web/src/theme.css (decision #27), so the wiki
 * always matches the game. Placeholder below is replaced by build.ts.
 */
:root {
  /* Surfaces */
  --imp-parchment: #f1e4c3;
  --imp-parchment-deep: #e2cd9f;
  --imp-parchment-edge: #cdb07a;
  --imp-surface: #fbf5e6;
  --imp-surface-alt: #f3e8cd;
  --imp-overlay: rgba(241, 228, 195, 0.97);

  /* Ink */
  --imp-ink: #33241a;
  --imp-ink-soft: #5a4430;
  --imp-ink-muted: #85704f;
  --imp-on-dark: #fbf3e2;

  /* Lines */
  --imp-border: #c4a46e;
  --imp-border-strong: #5b4026;
  --imp-divider: rgba(91, 64, 38, 0.22);

  /* Heraldic accents */
  --imp-crimson: #962620;
  --imp-crimson-dark: #5e1410;
  --imp-crimson-light: #c4473b;
  --imp-navy: #24395c;
  --imp-navy-dark: #172743;
  --imp-gold: #c59a3c;
  --imp-gold-soft: #e8cf8e;

  /* Frame materials (minimap frame, round map tools) */
  --imp-wood: #4a3220;
  --imp-wood-dark: #2b1c10;
  --imp-brass: #c9a24a;
  --imp-brass-dark: #8a6a2a;

  /* Status */
  --imp-ok: #3f7a2a;
  --imp-ok-dark: #2f5c1f;
  --imp-bad: #a3352b;
  --imp-warn: #a8701c;

  /* Bars — the top bar is light parchment (concept A), not dark wood. */
  --imp-topbar: #ecdcb4;
  --imp-topbar-edge: #5b4026;

  /* Type */
  --imp-font-display: "Cinzel", "Times New Roman", serif;
  --imp-font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Shape */
  --imp-radius: 6px;
  --imp-radius-sm: 4px;
  --imp-shadow: 0 6px 20px rgba(43, 28, 16, 0.35);
  --imp-shadow-sm: 0 2px 8px rgba(43, 28, 16, 0.22);
  --imp-topbar-height: 64px;
  --imp-bottomnav-height: 60px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--imp-font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--imp-ink);
  background: var(--imp-parchment-deep) url(/art/ui-background-texture.png) repeat;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--imp-font-display); font-weight: 700; letter-spacing: 0.02em; line-height: 1.25; color: var(--imp-ink); }
a { color: var(--imp-crimson); text-underline-offset: 2px; }
a:hover { color: var(--imp-crimson-dark); }
:focus-visible { outline: 2px solid var(--imp-gold); outline-offset: 2px; }
img { max-width: 100%; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--imp-surface); padding: 6px 12px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ── Top bar (light parchment strip with a gold edge, like the game HUD) ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  min-height: 60px; padding: 6px 18px;
  background: linear-gradient(180deg, #f6ecd2 0%, var(--imp-topbar) 55%, #dcc595 100%);
  border-bottom: 2px solid var(--imp-topbar-edge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -3px 0 rgba(197,154,60,0.45), 0 3px 10px rgba(43,28,16,0.35);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--imp-ink); font-family: var(--imp-font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.05em; white-space: nowrap; }
.brand img { height: 46px; width: auto; margin-top: -4px; }
.menu-button { display: none; }
.search { position: relative; flex: 1; max-width: 520px; margin: 0 auto; }
.search input {
  width: 100%; font: inherit; font-size: 15px; padding: 0.45rem 0.75rem;
  border: 1px solid var(--imp-border); border-radius: var(--imp-radius-sm);
  background: var(--imp-surface); color: var(--imp-ink); box-shadow: inset 0 1px 2px rgba(43,28,16,0.12);
}
.search input:focus { outline: none; border-color: var(--imp-border-strong); box-shadow: 0 0 0 2px rgba(197,154,60,0.35); }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 4px; list-style: none;
  background: var(--imp-overlay); border: 1px solid var(--imp-border-strong); border-radius: var(--imp-radius);
  box-shadow: var(--imp-shadow); max-height: 70vh; overflow-y: auto;
}
.search-results a { display: block; padding: 8px 10px; border-radius: var(--imp-radius-sm); text-decoration: none; color: var(--imp-ink); }
.search-results a:hover, .search-results a:focus { background: rgba(91,64,38,0.1); }
.search-results strong { display: block; font-family: var(--imp-font-display); color: var(--imp-crimson); }
.search-results span { display: block; font-size: 14px; color: var(--imp-ink-soft); }
.search-empty { padding: 8px 10px; color: var(--imp-ink-muted); }

.lang-menu { position: relative; }
.lang-menu summary {
  list-style: none; cursor: pointer; font-family: var(--imp-font-display); font-weight: 700; font-size: 14px;
  padding: 0.35rem 0.6rem; border: 1px solid var(--imp-border); border-radius: var(--imp-radius-sm); background: rgba(251,245,230,0.6);
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul {
  position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; min-width: 170px;
  background: var(--imp-overlay); border: 1px solid var(--imp-border-strong); border-radius: var(--imp-radius); box-shadow: var(--imp-shadow);
}
.lang-menu a { display: block; padding: 5px 10px; text-decoration: none; color: var(--imp-ink); border-radius: var(--imp-radius-sm); }
.lang-menu a:hover { background: rgba(91,64,38,0.1); }
.lang-menu a[aria-current] { color: var(--imp-crimson); font-weight: 700; }

/* Crimson wax-seal primary button. */
.play-button, .start-button {
  display: inline-block; white-space: nowrap; text-decoration: none;
  font-family: var(--imp-font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.04em;
  padding: 0.5rem 1.05rem; border-radius: var(--imp-radius);
  color: var(--imp-on-dark); background: linear-gradient(180deg, var(--imp-crimson-light), var(--imp-crimson) 55%, var(--imp-crimson-dark));
  border: 1px solid var(--imp-crimson-dark); box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 2px 6px rgba(43,28,16,0.35);
}
.play-button:hover, .start-button:hover { color: #fff; filter: brightness(1.06); }
.start-button { background: linear-gradient(180deg, #3a5582, var(--imp-navy) 55%, var(--imp-navy-dark)); border-color: var(--imp-navy-dark); }

/* ── Layout ── */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 24px; max-width: 1280px; margin: 0 auto; padding: 24px 18px 40px; }
.sidebar { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 4px; }
.sidebar section { margin-bottom: 18px; }
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--imp-ink-soft); margin: 0 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--imp-divider); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 1px 0; }
.sidebar a { display: inline-block; padding: 2px 6px; border-radius: var(--imp-radius-sm); color: var(--imp-ink); text-decoration: none; font-size: 15px; }
.sidebar a:hover { background: rgba(91,64,38,0.08); }
.sidebar a[aria-current] { color: var(--imp-crimson); font-weight: 700; background: rgba(251,245,230,0.7); }

.parchment {
  background: var(--imp-parchment);
  border: 1px solid var(--imp-border-strong);
  border-radius: var(--imp-radius);
  box-shadow: inset 0 0 0 4px var(--imp-parchment), inset 0 0 0 5px var(--imp-border), var(--imp-shadow-sm);
  padding: 28px clamp(18px, 4vw, 44px) 32px;
  min-width: 0;
}

/* ── Article ── */
.wiki-article h1 { font-size: clamp(26px, 4vw, 36px); margin: 4px 0 8px; }
.wiki-article h2 { font-size: 23px; margin: 34px 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--imp-divider); }
.wiki-article h3 { font-size: 18px; margin: 24px 0 8px; }
.crumbs { margin: 0; font-size: 14px; color: var(--imp-ink-muted); }
.crumbs a { color: var(--imp-ink-soft); }
.lead { font-size: 19px; color: var(--imp-ink-soft); margin-top: 0; }
.notice { padding: 10px 14px; border-left: 4px solid var(--imp-warn); background: rgba(168,112,28,0.1); border-radius: var(--imp-radius-sm); }
.badge { display: inline-block; vertical-align: middle; font-family: var(--imp-font-body); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; padding: 0 5px; border: 1px solid var(--imp-border-strong); border-radius: 3px; color: var(--imp-ink-soft); }
.badge-data { font-size: 13px; color: var(--imp-navy); border-color: var(--imp-navy); margin-left: 6px; }
.toc { float: right; width: 260px; margin: 0 0 16px 24px; padding: 12px 16px; background: rgba(251,245,230,0.6); border: 1px solid var(--imp-border); border-radius: var(--imp-radius); font-size: 15px; }
.toc h2 { font-size: 14px !important; margin: 0 0 6px !important; border: 0 !important; text-transform: uppercase; letter-spacing: 0.08em; }
.toc ol { margin: 0; padding-left: 20px; }
blockquote { margin: 18px 0; padding: 10px 16px; border-left: 4px solid var(--imp-gold); background: rgba(232,207,142,0.25); border-radius: var(--imp-radius-sm); }
blockquote p { margin: 4px 0; }
code { font-size: 0.92em; background: rgba(91,64,38,0.1); padding: 1px 5px; border-radius: 3px; }
pre { overflow-x: auto; background: rgba(91,64,38,0.08); padding: 12px; border-radius: var(--imp-radius-sm); }
hr { border: 0; border-top: 1px solid var(--imp-divider); margin: 28px 0; }
.wiki-figure { float: right; margin: 0 0 12px 18px; text-align: center; }
.wiki-figure img { width: 96px; height: 96px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(43,28,16,0.35)); }
.wiki-figure figcaption { font-size: 13px; color: var(--imp-ink-muted); }
p img, li img, td img, th img { height: 1.6em; width: auto; vertical-align: middle; margin-right: 4px; }
.footnote { margin-top: 28px; font-size: 14px; color: var(--imp-ink-muted); font-style: italic; }
.to-top { clear: both; margin-top: 28px; font-size: 14px; }

/* Herald-style data tables. */
.wiki-table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--imp-border); border-radius: var(--imp-radius-sm); background: var(--imp-surface); }
.wiki-table-wrap table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
.wiki-table-wrap caption { caption-side: top; text-align: left; padding: 8px 10px 4px; font-family: var(--imp-font-display); font-weight: 700; }
.wiki-table-wrap th, .wiki-table-wrap td { padding: 6px 10px; border-bottom: 1px solid var(--imp-divider); text-align: left; vertical-align: middle; }
.wiki-table-wrap thead th { background: var(--imp-surface-alt); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--imp-ink-soft); border-bottom: 1px solid var(--imp-border); white-space: nowrap; }
.wiki-table-wrap tbody th { font-weight: 600; white-space: nowrap; }
.wiki-table-wrap tbody tr:nth-child(even) { background: rgba(243,232,205,0.5); }
.wiki-table-wrap tbody tr:last-child > * { border-bottom: 0; }
.wiki-right { text-align: right !important; }
.wiki-center { text-align: center !important; }
.wiki-muted { color: var(--imp-ink-muted); }
.wiki-icon { height: 26px !important; width: 26px !important; object-fit: contain; vertical-align: middle; margin-right: 6px; }
.wiki-section-icon { height: 36px; width: 36px; object-fit: contain; vertical-align: middle; margin-right: 10px; }
.wiki-notes { font-size: 15px; color: var(--imp-ink-soft); }
.wiki-embed { margin: 18px 0; padding: 4px 14px 2px; border: 1px dashed var(--imp-border); border-radius: var(--imp-radius); background: rgba(251,245,230,0.45); }
.wiki-embed h3 { margin-top: 12px; }
.wiki-embed-more { font-size: 14px; text-align: right; }

/* ── Home ── */
.home { text-align: center; }
.home-logo { width: min(340px, 80%); height: auto; margin: 0 auto 8px; display: block; }
.home .lead { max-width: 760px; margin: 0 auto 18px; }
.home-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; text-align: left; }
.card { padding: 14px 18px; background: rgba(251,245,230,0.6); border: 1px solid var(--imp-border); border-radius: var(--imp-radius); }
.card h2 { font-size: 19px; margin: 0 0 4px; }
.card p { margin: 0 0 8px; font-size: 15px; color: var(--imp-ink-soft); }
.card ul { margin: 0; padding-left: 18px; font-size: 15px; }

/* ── Root language picker ── */
.root-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.language-picker { text-align: center; max-width: 560px; width: 100%; }
.languages { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.languages a { display: block; padding: 10px; border: 1px solid var(--imp-border); border-radius: var(--imp-radius); background: var(--imp-surface); text-decoration: none; font-family: var(--imp-font-display); font-weight: 700; }
.languages a:hover { background: var(--imp-gold-soft); }

.footer { text-align: center; font-size: 14px; color: var(--imp-ink-soft); padding: 8px 18px 32px; }

/* ── Phones and tablets ── */
@media (max-width: 899px) {
  body { font-size: 16px; }
  .layout { grid-template-columns: 1fr; padding: 12px 10px 28px; }
  .menu-button {
    display: inline-block; font: inherit; font-weight: 700; font-size: 14px; padding: 0.35rem 0.6rem;
    border: 1px solid var(--imp-border); border-radius: var(--imp-radius-sm); background: rgba(251,245,230,0.6); color: var(--imp-ink);
  }
  .js .sidebar { display: none; }
  .js .menu-open .sidebar { display: block; }
  .sidebar { position: static; max-height: none; background: var(--imp-parchment); border: 1px solid var(--imp-border); border-radius: var(--imp-radius); padding: 12px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 6px 10px; }
  .brand span { display: none; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .play-button { margin-left: auto; }
  .toc { float: none; width: auto; margin: 0 0 16px; }
  .wiki-figure { float: none; }
}
