/* MEGA Wiki - colours match the in-game HUD (HudWidgets.cs) */
@font-face { font-family: "Agenda"; src: url("../fonts/agenda-14.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Retimoa"; src: url("../fonts/retimoa-straight.otf") format("opentype"); font-display: swap; }

:root {
  --ink: #060b13;
  --ink-2: #0b1520;
  --panel: #0e1a26;
  --panel-2: #12222f;
  --line: rgba(169, 195, 200, .22);
  --paper: #f0f0e3;
  --muted: #a6b8bb;
  --cyan: #14c9f0;
  --gold: #ffbd4a;
  --coral: #ff5240;
  --green: #33d666;
  --radius: 8px;
  --side: 270px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--ink); color: var(--paper); font: 18px/1.6 "Agenda", "Segoe UI", system-ui, sans-serif; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; height: 64px; padding: 0 20px; background: rgba(6, 11, 19, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--paper); font-family: "Retimoa", sans-serif; font-size: 24px; letter-spacing: .12em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; object-fit: contain; }
.brand small { font-family: "Agenda", sans-serif; font-size: 14px; letter-spacing: .3em; color: var(--gold); }
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--paper); border-radius: 6px; width: 42px; height: 38px; font-size: 20px; cursor: pointer; }
.search { position: relative; margin-left: auto; width: min(360px, 40vw); }
.search input { width: 100%; height: 40px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--paper); font: inherit; font-size: 16px; }
.search input:focus { outline: 2px solid var(--cyan); outline-offset: 0; }
.results { position: absolute; top: 46px; left: 0; right: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.5); display: none; max-height: 60vh; overflow: auto; }
.results.open { display: block; }
.results a { display: block; padding: 10px 14px; color: var(--paper); border-bottom: 1px solid var(--line); }
.results a:hover, .results a.active { background: rgba(20, 201, 240, .12); text-decoration: none; }
.results a small { display: block; color: var(--muted); font-size: 14px; }
.results .none { padding: 12px 14px; color: var(--muted); font-size: 15px; }

/* Layout */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - 64px); }
.side { position: sticky; top: 64px; height: calc(100vh - 64px); overflow: auto; padding: 24px 18px 40px; border-right: 1px solid var(--line); background: var(--ink-2); }
.side h4 { margin: 22px 10px 6px; font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold); font-weight: normal; }
.side h4:first-child { margin-top: 0; }
.side a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--paper); font-size: 17px; }
.side a img { width: 20px; height: 20px; object-fit: contain; opacity: .85; }
.side a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.side a.on { background: rgba(20, 201, 240, .14); color: var(--cyan); }

main { padding: 40px clamp(20px, 4vw, 56px) 80px; width: 100%; min-width: 0; }
.page-grid { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 56px; }
.rail { display: none; }
.rail-in { position: sticky; top: 96px; padding-left: 24px; border-left: 1px solid var(--line); }
.rail h4 { margin: 0 0 10px; font-size: 13px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold); font-weight: normal; }
.rail-toc { display: flex; flex-direction: column; margin-bottom: 28px; }
.rail-toc a { padding: 6px 0; color: var(--muted); font-size: 16px; line-height: 1.3; }
.rail-toc a:hover { color: var(--cyan); text-decoration: none; }
.rail-pic { display: block; margin-bottom: 12px; }
.rail-pic img { border-radius: 6px; border: 1px solid var(--line); width: 100%; height: auto; transition: border-color .12s ease; }
.rail-pic:hover img { border-color: var(--cyan); }
@media (min-width: 1280px) {
  .page-grid.has-rail { max-width: 1340px; grid-template-columns: minmax(0, 1fr) 300px; }
  .has-rail .rail { display: block; }
  .has-rail .toc { display: none; }
}
.crumbs { font-size: 14px; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
h1, h2, h3 { font-family: "Retimoa", sans-serif; font-weight: normal; text-transform: uppercase; letter-spacing: .02em; line-height: 1.05; }
h1 { font-size: clamp(40px, 6vw, 64px); margin: 8px 0 14px; }
h2 { font-size: clamp(26px, 3.4vw, 34px); margin: 52px 0 14px; padding-top: 6px; color: var(--cyan); scroll-margin-top: 84px; }
h3 { font-size: 22px; margin: 30px 0 8px; scroll-margin-top: 84px; }
.lede { font-size: 21px; color: var(--paper); opacity: .9; max-width: 900px; margin: 0 0 8px; }
p { max-width: 900px; }
ul, ol { max-width: 900px; padding-left: 24px; }
li { margin: 4px 0; }
strong { color: var(--paper); }
.muted { color: var(--muted); }

/* Hero (home) */
.hero { position: relative; border-radius: 12px; overflow: hidden; min-height: 380px; display: flex; align-items: flex-end; margin-bottom: 36px; background: var(--panel) center/cover; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(6,11,19,.96) 10%, rgba(6,11,19,.35) 60%, rgba(6,11,19,.15)); }
.hero > div { position: relative; padding: 36px clamp(20px, 4vw, 44px); }
.hero h1 { margin: 6px 0 10px; font-size: clamp(44px, 7vw, 78px); }
.hero p { font-size: 20px; margin: 0; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin: 20px 0; }
.tile { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--cyan); color: var(--paper); transition: transform .12s ease, border-color .12s ease; }
.tile:hover { transform: translateY(-2px); border-color: rgba(20,201,240,.6); text-decoration: none; }
.tile img { width: 42px; height: 42px; object-fit: contain; }
.tile b { font-family: "Retimoa", sans-serif; font-weight: normal; font-size: 21px; text-transform: uppercase; }
.tile span { color: var(--muted); font-size: 15px; line-height: 1.45; }
.tile.gold { border-top-color: var(--gold); } .tile.coral { border-top-color: var(--coral); }

/* Callouts */
.note { max-width: 900px; margin: 20px 0; padding: 16px 20px; border-radius: var(--radius); background: var(--panel); border-left: 5px solid var(--gold); }
.note.cyan { border-left-color: var(--cyan); } .note.coral { border-left-color: var(--coral); }
.note b { display: block; font-family: "Retimoa", sans-serif; font-weight: normal; text-transform: uppercase; font-size: 18px; margin-bottom: 4px; }

/* Keys */
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; border: 3px solid #f2f2f2; border-radius: 7px; font: 15px "Agenda", sans-serif; color: #f2f2f2; vertical-align: middle; line-height: 1; margin: 0 2px; }
.ki { height: 32px; width: auto; display: inline-block; vertical-align: middle; margin: 0 2px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 16px 0 24px; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: normal; font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); background: var(--ink-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .thumb { width: 54px; height: 54px; object-fit: contain; border-radius: 6px; background: rgba(31,74,87,.5); }
td.input { white-space: nowrap; }
.name-cell { display: flex; align-items: center; gap: 14px; }
.name-cell { min-width: 190px; }
.name-cell b { font-weight: bold; font-size: 17px; line-height: 1.25; }
td .name-cell .thumb { flex: none; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; letter-spacing: .08em; background: rgba(20,201,240,.14); color: var(--cyan); margin: 2px 4px 2px 0; white-space: nowrap; }
.tag.gold { background: rgba(255,189,74,.14); color: var(--gold); }
.tag.coral { background: rgba(255,82,64,.14); color: var(--coral); }

/* Titan cards */
.titans { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 22px 0; }
.titan { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; scroll-margin-top: 84px; }
.titan .pic { aspect-ratio: 1 / 1; background: radial-gradient(circle at 50% 40%, #1d3a47, #0b1520 70%); display: flex; align-items: center; justify-content: center; }
.titan .pic img { width: 82%; height: 82%; object-fit: contain; }
.titan .body { padding: 18px 20px 22px; }
.titan h3 { margin: 0 0 4px; font-size: 26px; }
.titan .role { font-size: 13px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.stat { display: grid; grid-template-columns: 96px 1fr 52px; align-items: center; gap: 10px; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; margin: 8px 0; }
.stat .bar { height: 8px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--cyan); border-radius: 4px; }
.stat .v { text-align: right; font-variant-numeric: tabular-nums; }
.special { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.special b { font-family: "Retimoa", sans-serif; font-weight: normal; font-size: 19px; text-transform: uppercase; color: var(--gold); }
.special p { font-size: 16px; color: var(--muted); margin: 6px 0 0; }

/* Figures */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin: 18px 0 26px; }
figure { margin: 0; }
figure img { border-radius: var(--radius); border: 1px solid var(--line); width: 100%; height: auto; }
figure.wide { margin: 18px 0 26px; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; }
.gallery figure a { display: block; }

/* On-page contents */
.toc { margin: 18px 0 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.toc a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 15px; color: var(--paper); }
.toc a:hover { border-color: var(--cyan); text-decoration: none; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--paper); max-width: 48%; }
.pager a small { display: block; font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.pager a:hover { border-color: var(--cyan); text-decoration: none; }
.pager .next { margin-left: auto; text-align: right; }

footer { padding: 30px clamp(20px, 5vw, 64px); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* Mobile */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: inline-block; }
  .side { position: fixed; top: 64px; left: 0; width: min(300px, 86vw); z-index: 15; transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  body.nav-open .side { transform: none; }
  .brand small { display: none; }
  .search { width: auto; flex: 1; }
  main { padding-top: 28px; }
  .gallery { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  body { font-size: 17px; }
  .brand span { display: none; }
  .hero { min-height: 300px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
