/* Early Pandora Wiki — a naturalist's archive of the first Na'vi age */
:root {
  --mist: #EAF0EF;        /* page ground: swamp mist */
  --paper: #F7FAF9;       /* article sheet */
  --ink: #15292F;         /* body text: deep swamp water */
  --ink-soft: #4A5F64;    /* secondary text */
  --rule: #C9D6D4;        /* hairlines */
  --night: #102B33;       /* top band: night swamp */
  --glow: #12736F;        /* links: bioluminescent teal, AA on paper */
  --glow-bright: #5FE0D2; /* glow on the night band */
  --orange: #B4501A;      /* Taktswìkyu orange (legend tag) */
  --violet: #5A3D8C;      /* canon tag */
  --moss: #3F6B2E;        /* real-world tag */
  --amber: #8A5A00;       /* wiki lore tag */
  --gold: #E2853F;
  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Alegreya Sans", "Gill Sans", "Trebuchet MS", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --mist: #0C1F25; --paper: #112A31; --ink: #DCE8E6; --ink-soft: #9DB4B3; --rule: #27454C;
    --night: #071519; --glow: #63D5C8; --orange: #F0935B; --violet: #B9A2EE; --moss: #9BCB7E; --amber: #E3B35A;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--mist); color: var(--ink); font: 400 1.125rem/1.62 var(--serif); }
a { color: var(--glow); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- top band ---------- */
.topbar { background: var(--night); color: #E6F1EF; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 28px; flex-wrap: wrap; position: relative; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--glow-bright) 20%, var(--glow-bright) 80%, transparent); opacity: .55; }
.brand { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.logo-mark { grid-row: 1 / 3; width: 42px; height: 42px; color: var(--glow-bright); }
.brand-name { font: 700 1.5rem/1.1 var(--serif); letter-spacing: .005em; }
.brand-tag { font: 400 .92rem/1.2 var(--sans); color: #9FC3BF; font-style: italic; }
.search { position: relative; flex: 0 1 340px; }
.search input { width: 100%; font: 400 1rem var(--sans); padding: 9px 12px; border-radius: 6px; border: 1px solid #2F5862; background: #0B2127; color: #E6F1EF; }
.search input::placeholder { color: #8DB0AC; }
.results { position: absolute; right: 0; left: 0; top: calc(100% + 6px); margin: 0; padding: 4px; list-style: none; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 10px 30px rgba(6, 28, 33, .25); z-index: 5; max-height: 60vh; overflow: auto; }
.results li a { display: block; padding: 8px 10px; border-radius: 4px; text-decoration: none; color: var(--ink); font-family: var(--sans); }
.results li a b { color: var(--glow); font-weight: 700; display: block; }
.results li a span { font-size: .88rem; color: var(--ink-soft); }
.results li a:hover, .results li a[aria-selected="true"] { background: var(--mist); }
.results .none { padding: 8px 10px; font: .95rem var(--sans); color: var(--ink-soft); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); max-width: 1240px; margin: 0 auto; }
.side { padding: 26px 18px 40px 28px; font-family: var(--sans); font-size: .98rem; }
.side-h { font: 700 .95rem var(--sans); color: var(--ink-soft); margin: 22px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
.side-h:first-child { margin-top: 0; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li { margin: 5px 0; }
.side-tags li { margin: 8px 0; }
main { background: var(--paper); border-left: 1px solid var(--rule); min-height: 100vh; outline: none; }
article { padding: 28px 44px 20px; max-width: 980px; }
article::after { content: ""; display: table; clear: both; }

/* ---------- article type ---------- */
.page-title { font: 500 2.5rem/1.15 var(--serif); margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.page-sub { font: 400 .95rem var(--sans); color: var(--ink-soft); margin: 6px 0 22px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
article p, article li, article dd { max-width: 70ch; }
article h2 { font: 500 1.65rem/1.25 var(--serif); margin: 1.6em 0 .4em; padding-bottom: 3px; border-bottom: 1px solid var(--rule); }
article h3 { font: 700 1.15rem var(--sans); margin: 1.3em 0 .3em; }
blockquote { margin: 1em 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--gold); font-style: italic; font-size: 1.2rem; }

/* ---------- source tags (the signature device) ---------- */
.tag { display: inline-block; font: 500 .74rem/1 var(--sans); letter-spacing: .02em; padding: 3px 7px 4px; border-radius: 999px; vertical-align: .12em; border: 1px solid currentColor; white-space: nowrap; cursor: help; background: color-mix(in srgb, currentColor 9%, transparent); }
.tag-canon { color: var(--violet); }
.tag-legend { color: var(--orange); }
.tag-lore { color: var(--amber); border-style: dashed; }
.tag-real { color: var(--moss); }

/* ---------- infobox ---------- */
.infobox { float: right; width: 300px; margin: 4px 0 18px 28px; border: 1px solid var(--rule); background: var(--mist); font: 400 .95rem/1.4 var(--sans); }
.ib-title { background: var(--night); color: #E6F1EF; text-align: center; font: 700 1.05rem var(--serif); padding: 8px 10px; }
.infobox figure { margin: 0; }
.infobox img { display: block; width: 100%; height: auto; }
.infobox figcaption { padding: 6px 10px; font-size: .85rem; color: var(--ink-soft); border-bottom: 1px solid var(--rule); }
.infobox table { width: 100%; border-collapse: collapse; }
.infobox th, .infobox td { text-align: left; vertical-align: top; padding: 6px 10px; border-top: 1px solid var(--rule); }
.infobox tr:first-child th, .infobox tr:first-child td { border-top: 0; }
.infobox th { width: 42%; font-weight: 700; color: var(--ink-soft); }
.status-x { color: var(--orange); font-weight: 700; }
.status-ok { color: var(--moss); font-weight: 700; }
.status-q { color: var(--ink-soft); font-weight: 700; }

/* ---------- contents box ---------- */
.toc { display: inline-block; min-width: 230px; border: 1px solid var(--rule); background: var(--mist); padding: 10px 18px 10px 14px; margin: 6px 0 4px; font-family: var(--sans); }
.toc-title { font: 700 1rem var(--sans) !important; border: 0 !important; margin: 0 0 4px !important; padding: 0 !important; }
.toc ol { margin: 0; padding-left: 1.3em; }
.toc li { margin: 2px 0; }

/* ---------- tables ---------- */
article table.compare, article table.species, article table.words, article table.glossary { border-collapse: collapse; margin: 14px 0; font: 400 1rem/1.45 var(--sans); width: 100%; max-width: 760px; }
table caption { text-align: left; font-weight: 700; padding-bottom: 6px; }
article table th, article table td { border: 1px solid var(--rule); padding: 7px 10px; text-align: left; vertical-align: top; }
article table thead th { background: var(--mist); }
article table tbody th { background: color-mix(in srgb, var(--mist) 60%, transparent); }

/* ---------- timeline (a real sequence, so it is numbered by era) ---------- */
.timeline { list-style: none; padding: 0; margin: 18px 0; border-left: 2px solid var(--rule); max-width: 760px; }
.timeline li { position: relative; display: grid; grid-template-columns: 180px 1fr; gap: 14px; padding: 10px 0 10px 20px; max-width: none; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--glow); }
.timeline .when { font: 700 .95rem/1.4 var(--sans); color: var(--ink-soft); padding-top: 2px; }

/* ---------- lists of pages ---------- */
.allpages { columns: 2 300px; padding-left: 1.1em; }
.allpages li { break-inside: avoid; margin-bottom: 8px; }
.ap-sum { display: block; font: 400 .9rem/1.35 var(--sans); color: var(--ink-soft); }
dl.tagkey { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; align-items: baseline; }
dl.tagkey dd { margin: 0; }

.see-also ul { columns: 2 220px; }
.refs ol { font: 400 .95rem/1.5 var(--sans); }
.catbar { margin: 30px 0 8px; padding: 8px 12px; border: 1px solid var(--rule); background: var(--mist); font: 400 .95rem var(--sans); }
.foot { padding: 18px 44px 30px; font: 400 .88rem var(--sans); color: var(--ink-soft); border-top: 1px solid var(--rule); }

/* ---------- main page ---------- */
body.main article { max-width: 1100px; }
.mp-lead { font-size: 1.3rem; line-height: 1.5; max-width: 62ch; margin: 6px 0 22px; }
.mp-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; }
.mp-box { border: 1px solid var(--rule); background: var(--paper); padding: 0 20px 14px; }
.mp-box h2 { font: 700 1.15rem var(--serif); margin: 0 -20px 12px; padding: 9px 20px; border-bottom: 1px solid var(--rule); }
.mp-featured h2 { background: color-mix(in srgb, var(--orange) 12%, var(--paper)); }
.mp-dyk h2 { background: color-mix(in srgb, var(--glow) 12%, var(--paper)); }
.mp-explore { grid-column: 1 / -1; }
.mp-explore h2, .mp-start h2 { background: var(--mist); }
.mp-start { grid-column: 1 / -1; }
.mp-fig { margin: 0 0 10px; }
.mp-fig img { width: 100%; height: auto; display: block; }
.mp-dyk ul { padding-left: 1.1em; }
.mp-dyk li { margin-bottom: 8px; }
.mp-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 22px; }
.mp-cat h3 { font: 700 1rem var(--sans); margin: 4px 0 4px; color: var(--ink-soft); }
.mp-cat ul { list-style: none; padding: 0; margin: 0 0 8px; }
.mp-cat li { margin: 3px 0; font-family: var(--sans); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { padding: 12px 16px; border-bottom: 1px solid var(--rule); }
  .side ul { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .side-h { margin-top: 12px; }
  main { border-left: 0; }
  article { padding: 20px 16px; }
  .foot { padding: 16px; }
  .infobox { float: none; width: 100%; margin: 0 0 18px; }
  .mp-grid { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .topbar { padding: 12px 16px; }
  .search { flex: 1 1 100%; }
  .page-title { font-size: 2rem; }
}
@media print {
  .topbar, .side, .search, .foot { display: none; }
  .layout { display: block; }
  main { border: 0; }
}
/* infobox cells keep their own hairlines (beats the generic article table rule) */
article .infobox th, article .infobox td { border: 0; border-top: 1px solid var(--rule); background: none; }
article .infobox tr:first-child th, article .infobox tr:first-child td { border-top: 0; }
.results li a span { line-height: 1.35; }
