/* The Etherfall Archive, dressed like "The Story So Far": a Lodge field dossier read by lamplight. Night-blue ground,
   brass for structure, ether green for links and Breaches, breach-blue for what's only an idea; Cinzel titles, Barlow
   Condensed labels, Barlow text. Soft panels (1px line, 6px corners) instead of the game's metal frames. Layout after
   the familiar wiki: header with search, navigation down the left, articles with an infobox and a contents box. */

@font-face { font-family: "Cinzel"; src: url("../assets/fonts/Cinzel-Variable.ttf"); font-weight: 400 900; }
@font-face { font-family: "Barlow Condensed"; src: url("../assets/fonts/BarlowCondensed-Regular.ttf"); font-weight: 400; }
@font-face { font-family: "Barlow Condensed"; src: url("../assets/fonts/BarlowCondensed-SemiBold.ttf"); font-weight: 600; }

:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel2: #1a222c;
  --inset: #10151c;
  --line: #2c3540;
  --ink: #e7e3d8;
  --muted: #a7a596;
  --brass: #d2a75a;
  --brass-d: #8a6a33;
  --ether: #5fe0b0;
  --breach: #bfe3ff;
  --blood: #d96a5a;
  --display: "Cinzel", Georgia, serif;
  --label: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  --side: 220px;
  --header: 58px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--body); overflow-x: clip; }
a { color: var(--ether); text-decoration: none; }
a:hover { text-decoration: underline; }
a.redlink { color: var(--blood); cursor: help; }
h1, h2, h4, .brand { font-family: var(--display); color: var(--brass); font-weight: 700; }
h3 { font: 600 1.18rem/1.25 var(--label); letter-spacing: 0.03em; color: var(--ink); }
strong { color: #f4ecd8; font-weight: 600; }
.muted { color: var(--muted); font-size: 0.92em; }

/* Panels: what used to be the metal frame. The class name stays so lore.js and planner.js need no change. */
.frame { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }

/* ---- Shell: header, sidebar, content, footer ---- */
.header { position: sticky; top: 0; z-index: 20; height: var(--header); display: flex; align-items: center; gap: 18px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; white-space: nowrap; color: #f1e4c4; }
.brand:hover { text-decoration: none; color: var(--brass); }
.brand img { width: 34px; height: 34px; }
#search { margin-left: auto; width: min(420px, 45vw); }
#search input { width: 100%; padding: 8px 12px; font: inherit; font-size: 0.95rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; outline: none; }
#search input:focus { border-color: var(--brass-d); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brass) 25%, transparent); }
#menu { display: none; }

.layout { display: flex; align-items: flex-start; max-width: 1420px; margin: 0 auto; }
#sidebar { position: sticky; top: var(--header); flex: 0 0 var(--side); max-height: calc(100vh - var(--header));
  overflow-y: auto; padding: 22px 14px 18px 20px; }
#sidebar h4 { margin: 16px 0 6px; font: 600 0.8rem var(--label); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brass); }
#sidebar h4:first-child { margin-top: 0; }
#sidebar nav a { display: block; padding: 6px 10px; color: var(--muted); font: 500 1rem/1.2 var(--label);
  letter-spacing: 0.04em; border-radius: 4px; }
#sidebar nav a:hover { color: var(--brass); background: var(--panel); text-decoration: none; }
#sidebar nav a.active { color: var(--ether); background: var(--panel); box-shadow: inset 2px 0 0 var(--ether); }
.note { color: var(--muted); font: 0.85rem/1.4 var(--label); letter-spacing: 0.03em; margin-top: 22px; }

#main { flex: 1; min-width: 0; padding: 26px clamp(18px, 3vw, 44px) 56px; }
.footer { max-width: 1420px; margin: 0 auto; padding: 24px 20px 40px; color: var(--muted); text-align: center;
  font: 500 0.88rem/1.4 var(--label); letter-spacing: 0.03em; border-top: 1px solid var(--line); }

/* ---- Article ---- */
.page-title { font-size: clamp(1.8rem, 3.4vw, 2.4rem); line-height: 1.1; margin: 0; text-wrap: balance; }
.from { color: var(--muted); font: 500 0.95rem var(--label); letter-spacing: 0.04em; margin: 8px 0 20px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.article::after { content: ""; display: block; clear: both; }
.article h2 { font-size: clamp(1.35rem, 2.4vw, 1.7rem); line-height: 1.15; margin: 1.5em 0 0.45em; clear: none; }
.article h3 { margin: 1.4em 0 0.35em; font-size: 1.4rem; color: var(--brass); }
.article h2 + h3 { margin-top: 0.6em; }
.article h2, .article h3 { scroll-margin-top: calc(var(--header) + 14px); }
.anchor { color: inherit; }
.anchor:hover { color: var(--ether); text-decoration: none; }
.article p { margin: 0 0 0.9em; }
.article p, .article li { max-width: 46rem; }
.article ul, .article ol { padding-left: 1.3em; }
.article li { margin: 0.35em 0; }
.article li::marker { color: var(--brass-d); }
blockquote { margin: 1em 0; padding: 0.3em 0 0.3em 1em; border-left: 3px solid var(--brass-d); color: var(--muted);
  font-style: italic; max-width: 46rem; display: flow-root; }

.infobox { float: right; clear: right; width: 310px; margin: 0 0 20px 28px; overflow: hidden; font-size: 0.95rem; }
.infobox-title { font: 700 1.15rem/1.2 var(--display); color: var(--brass); padding: 14px 16px 10px; }
.infobox img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.infobox-caption { color: var(--muted); font-style: italic; font-size: 0.92rem; padding: 10px 16px 0; }
.infobox table { width: 100%; border-collapse: collapse; margin: 6px 0 4px; }
.infobox th { text-align: left; vertical-align: top; width: 38%; padding: 7px 8px 7px 16px; color: var(--muted);
  font: 600 0.9rem/1.4 var(--label); letter-spacing: 0.03em; }
.infobox td { padding: 7px 16px 7px 6px; }
.infobox tr + tr th, .infobox tr + tr td { border-top: 1px solid var(--line); }

.toc { display: inline-block; min-width: 250px; max-width: 100%; margin: 6px 0 14px; padding: 12px 22px 12px 16px;
  background: var(--panel2); }
.toc-title { font: 600 0.8rem var(--label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 3px 0; font: 500 1rem/1.3 var(--label); letter-spacing: 0.02em; }
.toc .toc-3 { padding-left: 1.4em; }
.toc a { color: var(--ink); }
.toc a:hover { color: var(--ether); text-decoration: none; }
.toc-num { color: var(--brass-d); margin-right: 4px; }

.notice { padding: 12px 18px; margin: 0 0 18px; background: var(--panel2); border-left: 3px solid var(--breach); color: var(--breach); }
.notice-spoiler { border-left-color: var(--blood); color: var(--blood); }
.linkshere h2 { font: 600 0.85rem var(--label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass); margin: 34px 0 8px; }
.columns { columns: 3 180px; padding-left: 1.2em; margin: 0; }
.columns li::marker { color: var(--brass-d); }
.catlinks { margin-top: 26px; padding: 10px 16px; font: 500 0.95rem var(--label); letter-spacing: 0.03em; color: var(--muted); }

/* Tables */
.table { overflow-x: auto; margin: 14px 0; }
.wikitable { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.wikitable th { text-align: left; font: 600 0.88rem/1.2 var(--label); letter-spacing: 0.05em; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--brass-d); }
.wikitable td { padding: 9px 10px; vertical-align: top; border-bottom: 1px solid var(--line); }
.wikitable td:first-child { font-weight: 600; }
.category-table td:first-child { white-space: nowrap; }

/* Status tags */
.badge { display: inline-block; font: 600 0.75rem/1 var(--label); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 7px 3px; border-radius: 3px; border: 1px solid; vertical-align: 2px; white-space: nowrap; }
.badge-built { color: var(--ether); border-color: color-mix(in srgb, var(--ether) 50%, transparent); }
.badge-designed { color: var(--brass); border-color: color-mix(in srgb, var(--brass) 50%, transparent); }
.badge-proposed, .badge-dev { color: var(--breach); border-color: color-mix(in srgb, var(--breach) 50%, transparent); }
.badge-open { color: var(--blood); border-color: color-mix(in srgb, var(--blood) 50%, transparent); }

/* ---- Main page ---- */
.hero { position: relative; height: clamp(340px, 52vh, 520px); margin: -26px calc(-1 * clamp(18px, 3vw, 44px)) 34px;
  overflow: hidden; background: #05070a; }
.strip { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); }
.strip a { display: block; height: 100%; }
.strip img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(0.85) brightness(0.75);
  border-right: 1px solid rgba(0, 0, 0, 0.6); transition: filter 0.3s; }
.strip a:hover img { filter: saturate(1) brightness(0.95); }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 7, 10, 0.15) 0%, rgba(5, 7, 10, 0.35) 45%, rgba(13, 17, 23, 0.97) 100%); }
.crack { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
.cap { position: absolute; z-index: 2; inset: auto 0 0 0; padding: 0 clamp(18px, 3vw, 44px) clamp(20px, 3.5vw, 38px); pointer-events: none; }
.cap a { pointer-events: auto; }
.cap img { width: 78px; height: 78px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.7)); }
.cap h1 { font-size: clamp(30px, 5vw, 52px); line-height: 1.05; margin: 0.15em 0 0.25em; color: #f1e4c4;
  text-wrap: balance; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8); }
.cap p { margin: 0 0 0.6em; max-width: 44rem; color: #d6d0bf; font-size: 18px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9); }
.legend .badge { margin-right: 4px; background: rgba(13, 17, 23, 0.6); }
@media (prefers-reduced-motion: no-preference) {
  .crack path { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: tear 2.2s 0.3s ease-out forwards; }
  @keyframes tear { to { stroke-dashoffset: 0; } }
}

.main-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 22px; margin-bottom: 14px; }
.main-columns > section { overflow: hidden; }
.box-title { margin: 0; padding: 16px 20px 0; font: 600 0.8rem var(--label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass); }
.featured-art { display: block; aspect-ratio: 16 / 6; margin-top: 12px; background-size: cover; background-position: center 35%; }
.featured h3, .featured p { padding: 0 20px; }
.featured h3 { margin: 14px 0 0; font: 700 1.5rem/1.15 var(--display); }
.featured h3 a { color: var(--ink); }
.subtitle { color: var(--muted); font-style: italic; margin: 4px 0 8px; }
.start-here ul { list-style: none; padding: 6px 20px 16px; margin: 0; }
.start-here li { padding: 9px 0; border-bottom: 1px solid var(--line); font: 500 1.05rem var(--label); letter-spacing: 0.02em; }
.start-here li:last-child { border-bottom: none; }
.portals-title { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin: 44px 0 16px; }
.portals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.portal { padding: 14px 18px 16px; border-top: 3px solid var(--brass-d); }
.portal:hover { border-top-color: var(--ether); }
.portal h3 { margin: 0 0 4px; font: 700 1.1rem/1.2 var(--display); }
.portal h3 a { color: var(--brass); }
.portal-blurb { color: var(--muted); font-size: 0.93rem; margin: 0 0 8px; }
.portal-links { list-style: none; padding: 0; margin: 0; font: 500 0.98rem/1.5 var(--label); letter-spacing: 0.02em; }
.portal-links li { display: inline; }
.portal-links li + li::before { content: " · "; color: var(--brass-d); }

/* Drifter cards (the Classes category) */
.drifters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; margin: 18px 0 8px; }
.card { overflow: hidden; display: flex; flex-direction: column; color: var(--ink); }
.card:hover { text-decoration: none; border-color: var(--brass-d); }
.card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.card .body { padding: 12px 16px 16px; }
.card h3 { font: 700 1.3rem/1.15 var(--display); color: var(--brass); margin: 0 0 0.3em; }
.card p { font-size: 0.95rem; margin: 0 0 0.6em; color: var(--muted); }

/* ---- Index and search ---- */
.az { columns: 3 240px; column-gap: 30px; }
.letter-group { break-inside: avoid; }
.letter-group h2 { font-size: 1.25rem; margin: 12px 0 4px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.letter-group ul { list-style: none; padding: 0; margin: 0 0 10px; }
.letter-group li { margin: 3px 0; }
.results { list-style: none; padding: 0; }
.results li { margin: 0 0 14px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.results > li > a { font: 700 1.1rem var(--display); }
.snippet { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
mark { background: color-mix(in srgb, var(--brass) 30%, transparent); color: var(--ink); border-radius: 2px; }

/* ---- Spoilers ---- */
.veil { text-align: center; padding: 30px; margin: 14px 0; background: var(--panel2); border-left: 3px solid var(--breach); }
.veil p { color: var(--muted); }
button { font: 600 0.95rem var(--label); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  color: var(--brass); background: var(--panel); border: 1px solid var(--brass-d); border-radius: 4px; padding: 8px 20px; }
button:hover { color: var(--bg); background: var(--brass); border-color: var(--brass); }
.spoiler { background: var(--line); color: transparent; cursor: pointer; padding: 0 3px; border-radius: 2px; }
.spoiler.shown { background: transparent; color: inherit; cursor: auto; border-bottom: 1px dashed var(--breach); }

/* ---- Build codes in articles ---- */
.buildbox { float: right; clear: right; width: 310px; margin: 0 0 20px 28px; padding: 14px 16px 10px; font-size: 0.95rem; }
.buildbox-title { font: 600 0.8rem var(--label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.buildcode { display: block; font: 0.78rem/1.3 Consolas, monospace; color: var(--muted); background: var(--inset);
  border: 1px solid var(--line); border-radius: 4px; padding: 6px; max-height: 4.2em; overflow: hidden; word-break: break-all; }
.buildbox-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.buildbox-actions button, a.button { font-size: 0.85rem; padding: 5px 12px; }
a.button { display: inline-block; font: 600 0.85rem var(--label); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--brass); background: var(--panel); border: 1px solid var(--brass-d); border-radius: 4px; }
a.button:hover { text-decoration: none; color: var(--bg); background: var(--brass); border-color: var(--brass); }

/* ---- Build Planner ---- */
#main.wide { max-width: none; }
.planner { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.pl-tree { position: relative; height: calc(100vh - var(--header) - 150px); min-height: 420px; padding: 0; overflow: hidden; }
.pl-tree canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.tree-tip { position: absolute; pointer-events: none; max-width: 300px; padding: 8px 12px; font-size: 0.92rem; line-height: 1.35;
  background: rgba(13, 17, 23, 0.97); border: 1px solid var(--brass-d); border-radius: 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6); }
.attr-pick { position: absolute; display: flex; flex-direction: column; gap: 6px; padding: 10px; z-index: 2; }
.attr-pick button { padding: 5px 14px; }
.attr-pick[hidden], .tree-tip[hidden] { display: none; }
.pl-panel { display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - var(--header) - 150px); overflow-y: auto; padding: 0 6px 4px 2px; }
.pl-box { padding: 6px 16px 14px; }
.pl-box h3 { margin: 10px 0 6px; font: 700 1.1rem var(--display); color: var(--brass); }
.pl-box h4 { margin: 12px 0 2px; font: 600 0.8rem var(--label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pl-box p { margin: 4px 0; }
.pl-box label { display: block; margin: 6px 0; color: var(--muted); font: 500 0.92rem var(--label); letter-spacing: 0.03em; }
.pl-box select, .pl-box input, .pl-box textarea { width: 100%; margin-top: 3px; padding: 6px 8px; font: inherit; font-size: 0.95rem;
  color: var(--ink); background: var(--inset); border: 1px solid var(--line); border-radius: 4px; outline: none; }
.pl-box select:focus, .pl-box input:focus, .pl-box textarea:focus { border-color: var(--brass-d); }
.pl-box textarea { font: 0.78rem/1.3 Consolas, monospace; resize: vertical; word-break: break-all; }
.pl-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.pl-row button { flex: 1; padding: 5px 10px; font-size: 0.85rem; }
.pl-stats { list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.93rem; }
.pl-mgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 6px; }
.pl-branch { display: flex; flex-direction: column; gap: 4px; }
.pl-mnode { padding: 4px 2px; font-size: 0.68rem; letter-spacing: 0.02em; text-transform: none; line-height: 1.1; min-height: 34px;
  color: var(--muted); border-color: var(--line); }
.pl-mnode:hover { color: var(--ink); background: var(--panel2); border-color: var(--brass-d); }
.pl-mnode.notable { color: var(--brass); border-color: var(--brass-d); }
.pl-mnode.on { color: var(--bg); background: var(--ether); border-color: var(--ether); }
.pl-skill { border-left: 2px solid var(--brass-d); padding-left: 10px; margin: 8px 0 12px; }
.pl-gem { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; }
.pl-gem.skill { font-weight: 600; color: #f4ecd8; }
.pl-gem.effect { padding-left: 12px; color: var(--muted); font-size: 0.95rem; }
.pl-gem .x { padding: 0 8px; font-size: 1rem; letter-spacing: 0; border-color: var(--line); color: var(--muted); }
.pl-msg { color: var(--ether); min-height: 1em; }
.pl-dmg { margin: 6px 0 2px; padding: 8px 10px; background: var(--inset); border: 1px solid var(--line); border-radius: 4px; font-size: 0.88rem; line-height: 1.35; }
.pl-dmg ul { margin: 2px 0; padding-left: 1.1em; }
.pl-dps { color: var(--ether); font-size: 1rem; }
.pl-dps strong { color: var(--ether); font-size: 1.15rem; }
.pl-when { margin-top: 4px; }
.pl-when li::marker { color: var(--brass); }

/* ---- Tablets and phones ---- */
@media (max-width: 1000px) {
  .infobox, .buildbox { width: 270px; }
}
@media (max-width: 820px) {
  :root { --header: 104px; }
  body { font-size: 16px; }
  .header { height: auto; flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .brand { font-size: 1rem; }
  .brand img { width: 30px; height: 30px; }
  #menu { display: block; padding: 2px 11px; font-size: 1.25rem; letter-spacing: 0; }
  #search { order: 3; width: 100%; margin-left: 0; }
  #sidebar { display: none; position: fixed; top: var(--header); left: 0; right: 0; z-index: 19; max-height: calc(100vh - var(--header));
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6); }
  body.menu-open #sidebar { display: block; }
  #main { padding: 18px 14px 32px; }
  .hero { margin: -18px -14px 26px; height: 420px; }
  .strip { grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr 1fr; }
  .cap p { font-size: 16px; }
  .infobox, .buildbox { float: none; width: 100%; margin: 0 0 18px; }
  .main-columns { grid-template-columns: 1fr; }
  .toc { display: block; }
  .category-table td:first-child { white-space: normal; }
  .planner { grid-template-columns: 1fr; }
  .pl-tree { height: 62vh; min-height: 320px; }
  .pl-panel { max-height: none; overflow: visible; }
}
