/* AION 2 Kompass — dark-first, light theme via [data-theme="light"] or system preference */

:root {
  color-scheme: dark;
  --bg: #0c0e13;
  --bg-2: #11141b;
  --surface: #161a23;
  --surface-2: #1d2230;
  --line: #262c3b;
  --text: #e7e9ee;
  --muted: #8f97a8;
  --faint: #5d6576;
  --gold: #d9b45a;      /* Elyos */
  --gold-soft: #d9b45a22;
  --violet: #9b8cff;    /* Asmodier */
  --violet-soft: #9b8cff22;
  --ok: #4cc38a;
  --warn: #e8a33d;
  --bad: #e5604f;
  --radius: 14px;
  --shadow: 0 1px 0 #ffffff08 inset, 0 10px 30px -12px #000a;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Cinzel", "Iowan Old Style", Georgia, serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4ef;
  --bg-2: #efece4;
  --surface: #ffffff;
  --surface-2: #f3f1ea;
  --line: #e2ddd0;
  --text: #1b1d24;
  --muted: #5f6573;
  --faint: #969aa5;
  --gold: #a87a12;
  --gold-soft: #a87a1218;
  --violet: #5b48d6;
  --violet-soft: #5b48d618;
  --shadow: 0 1px 2px #0000000d, 0 8px 24px -14px #0003;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f6f4ef; --bg-2: #efece4; --surface: #ffffff; --surface-2: #f3f1ea; --line: #e2ddd0;
    --text: #1b1d24; --muted: #5f6573; --faint: #969aa5; --gold: #a87a12; --gold-soft: #a87a1218;
    --violet: #5b48d6; --violet-soft: #5b48d618; --shadow: 0 1px 2px #0000000d, 0 8px 24px -14px #0003;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--gold-soft), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, var(--violet-soft), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: #000; padding: 8px 12px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.top__inner { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-size: 18px; letter-spacing: .04em; white-space: nowrap; }
.brand b { color: var(--gold); font-weight: 700; }
.brand svg { width: 26px; height: 26px; fill: var(--gold); }
.brand__cut { fill: var(--bg); }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 9px; font-weight: 500; white-space: nowrap; transition: color .15s, background .15s; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--gold); }
.top__tools { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: var(--muted); }

.fresh { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.fresh[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.fresh[data-state="warn"] .dot { background: var(--warn); }
.fresh[data-state="bad"] .dot { background: var(--bad); }
.fresh-tip { position: absolute; right: 20px; top: calc(100% + 6px); width: min(380px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); font-size: 13px; }
.fresh-tip table { width: 100%; border-collapse: collapse; }
.fresh-tip td { padding: 4px 0; vertical-align: top; }
.fresh-tip td:last-child { text-align: right; color: var(--muted); }

/* ---------- layout ---------- */
main:focus { outline: none; }
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 20px 48px; outline: none; }
.loading, .empty { color: var(--muted); padding: 40px 0; text-align: center; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-family: var(--display); font-size: clamp(26px, 4vw, 36px); letter-spacing: .02em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.section { margin-top: 28px; }
.section > header, .card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section > header a, .card > header a { font-size: 13px; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card--link { text-decoration: none; display: block; transition: transform .15s, border-color .15s; }
.card--link:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.note { font-size: 12.5px; color: var(--faint); margin-top: 12px; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

.kpi__label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; }
.kpi__value { font-size: 28px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi__sub { color: var(--faint); font-size: 13px; margin-top: 2px; }

/* faction split bar */
.split { display: flex; height: 8px; border-radius: 999px; overflow: hidden; margin-top: 12px; background: var(--surface-2); }
.split > span:first-child { background: var(--gold); }
.split > span:last-child { background: var(--violet); }

/* ---------- charts ---------- */
.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 112px 1fr 64px; align-items: center; gap: 10px; font-size: 13.5px; }
.bar__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__track { display: block; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 70%, transparent), var(--gold)); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar__fill--alt { background: linear-gradient(90deg, color-mix(in srgb, var(--violet) 70%, transparent), var(--violet)); }
.bar__value { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.spark { width: 100%; height: 36px; display: block; margin-top: 10px; }
.spark path { fill: none; stroke: var(--gold); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* ---------- classes ---------- */
.class-card h3 { font-family: var(--display); font-size: 19px; letter-spacing: .02em; }
.class-card .role { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stats dt { white-space: nowrap; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.stats dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.guide { line-height: 1.7; }
.guide ul { padding-left: 20px; }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag--gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.tag--violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 40%, transparent); }

/* ---------- controls ---------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
select, input[type="search"] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
input[type="search"] { flex: 1 1 240px; }
.btn { border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line)); background: var(--gold-soft); color: var(--text); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 500; }
.btn:hover { background: color-mix(in srgb, var(--gold) 25%, transparent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { text-decoration: none; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13.5px; color: var(--muted); }
.tabs a[aria-selected="true"] { color: var(--text); border-color: var(--gold); background: var(--gold-soft); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 500; background: var(--bg-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--ok); } .down { color: var(--bad); }

/* ---------- news ---------- */
.news-card { display: flex; flex-direction: column; text-decoration: none; padding: 0; overflow: hidden; }
.news-card__img { aspect-ratio: 16 / 9; background: var(--surface-2); object-fit: cover; width: 100%; }
.news-card__body { padding: 14px 16px 16px; display: grid; gap: 6px; }
.news-card__meta { font-size: 12.5px; color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.news-card p { margin: 0; font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- character ---------- */
.char-row { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 10px 12px; border-radius: 10px; }
.char-row:hover { background: var(--surface-2); }
.avatar { width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); object-fit: cover; flex: none; }
.avatar--lg { width: 96px; height: 96px; border-radius: 16px; }
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

.callout { border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px; color: var(--muted); background: var(--bg-2); }
.callout strong { color: var(--text); }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; z-index: 30; }

.foot { border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; }
.foot p { max-width: 1180px; margin: 0 auto; padding: 18px 20px; }
.noscript { text-align: center; padding: 20px; }

@media (max-width: 720px) {
  .top__inner { gap: 10px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  main { padding: 20px 16px 40px; }
  .bar { grid-template-columns: 88px 1fr 52px; }
  .nav a { padding: 6px 8px; font-size: 14px; }
  .fresh #fresh-label { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
