/* Fonts are self-hosted (SIL Open Font License, see fonts/OFL-*.txt) so no visitor data goes to a font service. */
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("fonts/cinzel-normal-500-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("fonts/cinzel-normal-500-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/spectral-italic-400-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 400; font-display: swap; src: url("fonts/spectral-italic-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/spectral-normal-400-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/spectral-normal-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/spectral-normal-600-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/spectral-normal-600-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Two faction themes, after AION's Elyos (dawn sky, ivory, gold) and Asmodians (night violet, crimson, silver). */
:root, :root[data-theme="elyos"] {
  --bg: #f4f1e8;
  --bg-sky: linear-gradient(180deg, #bcd8f0 0%, #e3eef6 38%, #f4f1e8 72%);
  --fg: #2a2418;
  --muted: #6b6250;
  --card: rgba(255, 253, 246, .82);
  --card-solid: #fffdf6;
  --line: #d9cba6;
  --accent: #8a6416;
  --accent-bg: #8a6416;
  --accent-2: #2c63a0;
  --accent-fg: #fff;
  --warn: #93560c;
  /* Class and grade colours are darkened this much when used as text */
  --tint: #000;
  --tint-amt: 46%;
  --glow: rgba(255, 214, 120, .55);
  --frame: linear-gradient(135deg, #e9c877, #b8862b 40%, #f3dc9b 60%, #a3741f);
  --wing: #ffffff;
  --wing-edge: #e7c77a;
  --mote: #ffe8a8;
  --ok: #24702f;
  --head-font: "Cinzel", "Trajan Pro", Georgia, serif;
}
:root[data-theme="asmodian"] {
  --bg: #120d1c;
  --bg-sky: linear-gradient(180deg, #2a1640 0%, #1a1029 40%, #120d1c 75%);
  --fg: #ece6f5;
  --muted: #a99bbf;
  --card: rgba(32, 22, 48, .78);
  --card-solid: #1f1630;
  --line: #4a3566;
  --accent: #f07088;
  --accent-bg: #b8334d;
  --accent-2: #a98be0;
  --accent-fg: #fff;
  --warn: #d08a2c;
  --tint: #fff;
  --tint-amt: 12%;
  --glow: rgba(217, 70, 95, .5);
  --frame: linear-gradient(135deg, #c9c2d8, #7b6a96 40%, #e4def0 60%, #6a5885);
  --wing: #3b2556;
  --wing-edge: #d9465f;
  --mote: #ff7d95;
  --ok: #6fd38a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #120d1c; --bg-sky: linear-gradient(180deg, #2a1640 0%, #1a1029 40%, #120d1c 75%);
    --fg: #ece6f5; --muted: #a99bbf; --card: rgba(32, 22, 48, .78); --card-solid: #1f1630; --line: #4a3566;
    --accent: #f07088; --accent-bg: #b8334d; --accent-2: #a98be0; --warn: #d08a2c; --tint: #fff; --tint-amt: 12%; --glow: rgba(217, 70, 95, .5);
    --frame: linear-gradient(135deg, #c9c2d8, #7b6a96 40%, #e4def0 60%, #6a5885);
    --wing: #3b2556; --wing-edge: #d9465f; --mote: #ff7d95; --ok: #6fd38a;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg-sky) no-repeat, var(--bg);
  background-size: 100% 900px, auto;
  color: var(--fg);
  font: 16px/1.6 "Spectral", Georgia, serif;
  transition: background-color .4s, color .4s;
}
a { color: var(--accent-2); }
h1, h2, h3, h4 { font-family: var(--head-font); letter-spacing: .04em; }

/* Top bar */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.brand { font-family: var(--head-font); font-weight: 700; letter-spacing: .12em; text-decoration: none; color: var(--fg); }
header nav { display: flex; flex-wrap: nowrap; gap: 4px 14px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
header nav a { white-space: nowrap; }
header nav a {
  color: var(--muted); text-decoration: none; font-family: var(--head-font);
  font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; padding: 2px 0;
  border-bottom: 1px solid transparent; transition: color .2s, border-color .2s;
}
header nav a:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 1180px) {
  header { justify-content: space-between; padding: 8px 16px 6px; }
  header nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 16px; }
  header nav a { white-space: nowrap; }
}

.faction-toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; padding: 2px;
  background: var(--card);
}
.faction-toggle button {
  border: 0; border-radius: 999px; padding: 4px 12px; background: transparent; color: var(--muted);
  font-family: var(--head-font); font-size: .75rem; letter-spacing: .08em; box-shadow: none;
}
.faction-toggle button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-fg); }

/* Hero */
.hero {
  position: relative; z-index: 1; text-align: center; overflow: hidden;
  min-height: calc(100vh - 56px); padding: 72px 16px 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.hero .welcome, .hero .title-2 {
  position: relative; margin: 0; font-family: var(--head-font); text-transform: uppercase; color: var(--fg);
}
.hero .welcome { font-size: clamp(.9rem, 2.4vw, 1.15rem); letter-spacing: .4em; color: var(--muted); }
.hero .title-2 { font-size: clamp(1.1rem, 3.4vw, 1.7rem); letter-spacing: .3em; margin-top: 4px; }
.cta {
  position: relative; margin-top: 26px; padding: 10px 28px; border-radius: 4px; text-decoration: none;
  font-family: var(--head-font); letter-spacing: .14em; text-transform: uppercase; font-size: .9rem;
  background: var(--accent-bg); color: var(--accent-fg); box-shadow: 0 0 22px var(--glow);
  transition: transform .2s, box-shadow .2s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 0 32px var(--glow); }
.page-title { position: relative; z-index: 1; text-align: center; padding: 48px 16px 28px; }
.page-title .welcome { margin: 0; font-family: var(--head-font); text-transform: uppercase; letter-spacing: .4em; color: var(--muted); font-size: .9rem; }
.page-title h1 {
  margin: 4px 0 0; font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: .14em;
  background: var(--frame); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 10px var(--glow));
}
.tiles {
  position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px;
  width: 100%; max-width: 960px; margin-top: 40px;
}
.tiles a {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 14px; text-decoration: none; text-align: left;
  color: var(--fg); border-radius: 6px; border: 1px solid transparent;
  background-image: linear-gradient(var(--card-solid), var(--card-solid)), var(--frame);
  background-origin: border-box; background-clip: padding-box, border-box;
  transition: transform .25s, box-shadow .25s;
}
.tiles a:hover { transform: translateY(-3px); box-shadow: 0 10px 26px var(--glow); }
.tiles strong { font-family: var(--head-font); color: var(--accent); letter-spacing: .06em; }
.tiles span { font-size: .88rem; color: var(--muted); }
.title-block { position: relative; padding: 40px 0 10px; }
.wings { position: absolute; left: 50%; top: 50%; width: min(820px, 150vw); transform: translate(-50%, -54%); opacity: .55; pointer-events: none; }
.wings { fill: var(--wing); stroke: var(--wing-edge); stroke-width: 1.2; filter: drop-shadow(0 0 18px var(--glow)); }
.wings .halo { fill: none; stroke: var(--accent); stroke-width: 1; opacity: .5; }
.hero h1 {
  position: relative; margin: 0; font-size: clamp(2.2rem, 7vw, 4.2rem); font-weight: 700; letter-spacing: .14em;
  background: var(--frame); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 10px var(--glow));
}
.hero .sub { position: relative; margin: 6px 0 0; color: var(--muted); font-style: italic; font-size: 1.1rem; }
.hero .tag { position: relative; display: inline-block; margin-top: 14px; }
.tag {
  font-family: var(--head-font); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  background: var(--accent-bg); color: var(--accent-fg); padding: 3px 12px; border-radius: 999px;
  box-shadow: 0 0 14px var(--glow);
}

/* Aether motes */
.motes { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.mote {
  position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--mote); box-shadow: 0 0 8px 2px var(--mote); opacity: 0;
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: .8; }
  100% { transform: translate(30px, -105vh); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .mote { display: none; } html { scroll-behavior: auto; } }

main { position: relative; z-index: 1; min-width: 0; }
section { margin-bottom: 56px; scroll-margin-top: 80px; }

/* Ornamented section headings */
h2 {
  display: flex; align-items: center; gap: 14px; margin: 0 0 20px;
  font-size: 1.5rem; text-transform: uppercase; letter-spacing: .16em; color: var(--fg);
}
h2::before, h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--accent)); }
h2::after { background: linear-gradient(90deg, var(--accent), transparent); }
h2 span::before, h2 span::after { content: "◆"; color: var(--accent); font-size: .6em; margin: 0 10px; vertical-align: middle; }
h3 { color: var(--accent); font-size: 1.05rem; margin: 24px 0 10px; }
h4 { margin: 0 0 6px; font-size: .9rem; color: var(--muted); text-transform: uppercase; }

.notice {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 14px 10px 40px; color: var(--muted); margin: 0 0 40px;
}
.notice::before { content: "✦"; position: absolute; left: 14px; top: 9px; color: var(--accent); }
.small { color: var(--muted); font-size: .9rem; }

/* Gilded frame panels */
.panel, .card, .tool, .reset {
  position: relative; background: var(--card); border-radius: 6px; padding: 16px;
  border: 1px solid transparent;
  background-image: linear-gradient(var(--card-solid), var(--card-solid)), var(--frame);
  background-origin: border-box; background-clip: padding-box, border-box;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
}
.panel::before, .card::before, .tool::before, .reset::before,
.panel::after, .card::after, .tool::after, .reset::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--accent); pointer-events: none;
}
.panel::before, .card::before, .tool::before, .reset::before { top: 4px; left: 4px; border-right: 0; border-bottom: 0; }
.panel::after, .card::after, .tool::after, .reset::after { bottom: 4px; right: 4px; border-left: 0; border-top: 0; }

/* Global section */
.resets { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 8px; }
.reset { text-align: center; }
.reset .small { font-family: var(--head-font); text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; }
.timer {
  font-family: var(--head-font); font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--accent); text-shadow: 0 0 16px var(--glow);
}
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 18px 0 0; }
.facts dt { font-family: var(--head-font); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); padding-top: 2px; }
.facts dd { margin: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 10px; } }
ul.runes { list-style: none; padding: 0; }
ul.runes li { position: relative; padding-left: 22px; margin: 6px 0; }
ul.runes li::before { content: "✧"; position: absolute; left: 0; color: var(--accent); }

/* Buttons and inputs */
button, select, input[type=number] {
  font: inherit; font-size: .95rem; padding: 6px 14px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--card-solid); color: var(--fg);
}
button {
  cursor: pointer; font-family: var(--head-font); letter-spacing: .06em; text-transform: capitalize;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
button:hover { border-color: var(--accent); box-shadow: 0 0 10px var(--glow); }
button.active, #enh-go { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-fg); }
input[type=number] { width: 130px; margin-left: 6px; }
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Classes */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { padding: 18px 18px 14px; transition: transform .25s, box-shadow .25s; overflow: hidden; }
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px var(--glow); }
.card .crest {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px;
  font-family: var(--head-font); font-weight: 700; font-size: 1.2rem; color: var(--accent-fg);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--role) 60%, #fff), var(--role));
  box-shadow: 0 0 0 2px var(--card-solid), 0 0 0 3px var(--role), 0 0 14px var(--role);
}
.card h3 { margin: 0 0 2px; color: var(--fg); font-size: 1.1rem; }
.card .meta { color: color-mix(in srgb, var(--role), var(--tint) var(--tint-amt)); font-size: .82rem; font-family: var(--head-font); letter-spacing: .06em; margin-bottom: 8px; }
.card p { margin: 0; font-size: .95rem; }

/* Grades */
.grades { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.grade {
  padding: 5px 14px; border-radius: 4px; border: 1px solid; font-family: var(--head-font); font-weight: 700;
  font-size: .85rem; letter-spacing: .06em; background: var(--card-solid);
  box-shadow: inset 0 0 12px color-mix(in srgb, currentColor 30%, transparent), 0 0 10px color-mix(in srgb, currentColor 35%, transparent);
}
.grade small { font-family: "Spectral", serif; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.grade.off { opacity: .5; box-shadow: none; text-decoration: line-through; text-decoration-thickness: 1px; }
.grade.off small { text-decoration: none; display: inline-block; }

/* Progression */
.steps { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.steps li { position: relative; padding: 0 0 16px 22px; }
.steps li::before {
  content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; transform: rotate(45deg);
  background: var(--accent); box-shadow: 0 0 10px var(--glow);
}
.steps strong { font-family: var(--head-font); color: var(--accent); letter-spacing: .04em; }
.table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--card); }
.table th {
  font-family: var(--head-font); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); border-bottom: 2px solid var(--accent);
}
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table.num td:last-child, .table.num th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.ok td { color: var(--ok); }
.table tr.ok td:first-child::before { content: "✓ "; }

/* Tools */
.tool { margin-bottom: 18px; padding: 20px; }
.tool h3 { margin-top: 0; }
.tool label { margin-right: 12px; }
.out { margin-top: 12px; font-variant-numeric: tabular-nums; }
.out strong { color: var(--accent); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 10px; }
.check { list-style: none; padding: 0; margin: 0; }
.check li { margin: 8px 0; }
.check label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input {
  appearance: none; flex: none; width: 16px; height: 16px; margin-top: 4px; transform: rotate(45deg);
  border: 1.5px solid var(--accent); background: transparent; cursor: pointer; transition: background .2s, box-shadow .2s;
}
.check input:checked { background: var(--accent); box-shadow: 0 0 10px var(--glow); }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }

#source-list { columns: 2 280px; column-gap: 24px; }
#source-list li { break-inside: avoid; margin-bottom: 4px; }

footer { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: .85rem; padding: 0 16px 32px; }

/* ---------- Transitions that follow the faction theme ---------- */

/* Page-to-page: cross-document view transitions (Chromium); other browsers just navigate. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .55s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }

/* Elyos: the old page dissolves into a golden burst of light, the new one settles in from above. */
::view-transition-old(root) { animation-name: elyos-out; }
::view-transition-new(root) { animation-name: elyos-in; }
@keyframes elyos-out { to { opacity: 0; filter: brightness(1.6) sepia(.5) saturate(1.6) blur(3px); transform: translateY(-12px); } }
@keyframes elyos-in { from { opacity: 0; filter: brightness(1.6) sepia(.5) saturate(1.6) blur(3px); transform: translateY(12px); } }

/* Asmodian: the old page sinks into violet shadow, the new one surfaces out of it. */
:root[data-theme="asmodian"]::view-transition-old(root) { animation-name: asmo-out; }
:root[data-theme="asmodian"]::view-transition-new(root) { animation-name: asmo-in; }
@keyframes asmo-out { to { opacity: 0; filter: brightness(.25) hue-rotate(-25deg) blur(4px); transform: scale(.97); } }
@keyframes asmo-in { from { opacity: 0; filter: brightness(.25) hue-rotate(-25deg) blur(4px); transform: scale(1.03); } }

/* Theme switch: the new faction spreads out from the toggle in a circle. */
:root.theme-switching::view-transition-old(root) { animation: none; }
:root.theme-switching::view-transition-new(root) {
  animation: faction-reveal .7s cubic-bezier(.4, 0, .2, 1);
}
@keyframes faction-reveal {
  from { clip-path: circle(0 at var(--tx, 100%) var(--ty, 0)); filter: brightness(1.5); }
  to { clip-path: circle(150vmax at var(--tx, 100%) var(--ty, 0)); filter: none; }
}

/* Fallback for browsers without view transitions: colors cross-fade instead. */
header, .card, .tool, .reset, .notice, .tiles a, .grade, button, .table, h2, h3, .timer {
  transition: background-color .4s, color .4s, border-color .4s, box-shadow .4s;
}
.card, .tiles a { transition: background-color .4s, color .4s, border-color .4s, box-shadow .25s, transform .25s; }

/* Content enters with the theme's motion on first load. */
.hero > *, .page-title, main > section { animation: rise-in .7s cubic-bezier(.2, .7, .2, 1) backwards; }
.hero > :nth-child(2) { animation-delay: .08s; }
.hero > :nth-child(3) { animation-delay: .16s; }
.hero > :nth-child(4) { animation-delay: .24s; }
.hero > :nth-child(5) { animation-delay: .32s; }
main > section:nth-of-type(2) { animation-delay: .08s; }
main > section:nth-of-type(n+3) { animation-delay: .16s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); filter: blur(2px) brightness(1.3); } }
:root[data-theme="asmodian"] .hero > *, :root[data-theme="asmodian"] .page-title, :root[data-theme="asmodian"] main > section { animation-name: surface-in; }
@keyframes surface-in { from { opacity: 0; transform: scale(.98); filter: blur(3px) brightness(.4); } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .hero > *, .page-title, main > section { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}

/* ---------- Section pages: layout, "On this page" menu, detail blocks ---------- */
.layout {
  position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 16px 64px;
  display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 44px; align-items: start;
}
.page-title .intro { max-width: 680px; margin: 12px auto 0; color: var(--muted); }
header nav a[aria-current="page"] { color: var(--accent); border-color: var(--accent); }

.toc { position: sticky; top: 76px; }
.toc-title {
  margin: 0 0 10px; font-family: var(--head-font); font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.toc ol { position: relative; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); max-height: calc(100vh - 140px); overflow-y: auto; scrollbar-width: thin; }
.toc a {
  display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: .92rem; transition: color .2s, border-color .2s;
}
.toc a:hover { color: var(--fg); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 8px; }
  .toc { position: static; margin-bottom: 24px; }
  .toc ol { display: flex; flex-wrap: wrap; gap: 8px; border: 0; max-height: none; overflow: visible; }
  .toc a {
    padding: 5px 12px; margin: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: .85rem;
  }
  .toc a.active { border-color: var(--accent); }
}

.to-top {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.1rem; text-decoration: none;
  background: var(--accent-bg); color: var(--accent-fg); box-shadow: 0 0 16px var(--glow);
  opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .25s, transform .25s;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }

/* Headings inside sections, and tables that scroll sideways on small screens */
section h3 { border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.table-wrap .table { margin: 0; min-width: 520px; }
.table td small { color: var(--muted); }
.table a { font-weight: 600; }

.callout {
  position: relative; border-left: 3px solid var(--accent); background: var(--card); padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 16px 0;
}
.callout.warn { border-left-color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chips span {
  padding: 3px 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--card-solid); font-size: .9rem;
}
.stat-order { counter-reset: stat; }
.stat-order span::before { counter-increment: stat; content: counter(stat) ". "; color: var(--accent); font-weight: 700; }
ul.runes.pros li::before { content: "+"; color: var(--ok); font-weight: 700; }
ul.runes.cons li::before { content: "−"; color: var(--warn); font-weight: 700; }

/* Class detail header */
.class-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.class-head .crest, .class-table-crest {
  width: 58px; height: 58px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--head-font); font-weight: 700; font-size: 1.5rem; color: #fff;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--role) 60%, #fff), var(--role));
  box-shadow: 0 0 0 2px var(--card-solid), 0 0 0 3px var(--role), 0 0 16px var(--role);
}
.badges { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 20px; margin: 0; flex: 1; }
.badges dt { font-family: var(--head-font); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.badges dd { margin: 0; font-weight: 600; color: color-mix(in srgb, var(--role), var(--tint) var(--tint-amt)); }
.class-section h2 span::before, .class-section h2 span::after { color: var(--role); }

/* Fact check confidence labels */
.conf { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.conf.high { color: var(--ok); }
.conf.med { color: var(--warn); }
.conf.low { color: var(--muted); }

/* Builds page class picker */
.build-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 900px; margin: 22px auto 0; }
.build-tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card-solid); color: var(--fg); text-decoration: none;
  font-family: var(--head-font); font-size: .85rem; letter-spacing: .05em; transition: border-color .2s, box-shadow .2s;
}
.build-tabs a:hover { border-color: var(--role); }
.build-tabs a[aria-current="page"] { border-color: var(--role); box-shadow: 0 0 0 1px var(--role), 0 0 14px color-mix(in srgb, var(--role) 50%, transparent); }
.crest-sm {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--role) 60%, #fff), var(--role));
}
#build-root section h2 span::before, #build-root section h2 span::after { color: var(--role); }
.cta-link { font-family: var(--head-font); font-weight: 700; letter-spacing: .04em; }
.src { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; white-space: nowrap; border: 1px solid currentColor; }
.src.always { color: var(--ok); }
.src.set { color: var(--accent-2); }
.src.swap { color: var(--warn); }

/* Skill icons */
.skill { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; }
.skill-icon { width: 28px; height: 28px; flex: none; border-radius: 6px; border: 1px solid var(--line); background: #000; box-shadow: 0 0 6px color-mix(in srgb, var(--role, var(--accent)) 35%, transparent); }
.chips .skill-icon { width: 24px; height: 24px; }
.chips span:has(.skill) { padding: 3px 10px 3px 4px; }

/* Grade labels: --g is the grade colour; text is tinted per theme for contrast */
.grade[style*="--g"] { color: color-mix(in srgb, var(--g), var(--tint) var(--tint-amt)); border-color: var(--g); }

/* Keyboard: skip link and visible focus on every interactive element */
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 4px;
  background: var(--accent-bg); color: var(--accent-fg); font-family: var(--head-font); text-decoration: none;
}
.skip-link:focus { top: 10px; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px;
}
#content:focus { outline: none; }

/* Glossary */
.glossary { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: 0; margin: 14px 0 0; border-top: 1px solid var(--line); }
.glossary dt, .glossary dd { padding: 8px 10px; border-bottom: 1px solid var(--line); margin: 0; }
.glossary dt { font-family: var(--head-font); font-size: .9rem; color: var(--accent); letter-spacing: .03em; }
.glossary [hidden] { display: none; }
@media (max-width: 560px) { .glossary { grid-template-columns: 1fr; } .glossary dt { border-bottom: 0; padding-bottom: 0; } }
input[type=search] { font: inherit; padding: 4px 10px; width: 220px; margin-left: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card-solid); color: var(--fg); }

/* Party composer */
.party-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 14px 0; }
.party-slots .slot { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin: 0; }
.party-slots select { width: 100%; }

/* Skills page */
.skill-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.skill-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; scroll-margin-top: 90px; }
.skill-card[hidden] { display: none; }
.skill-card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.skill-card-head .skill-icon { width: 40px; height: 40px; }
.skill-card h3 { margin: 0; border: 0; padding: 0; font-size: 1rem; color: var(--fg); }
.skill-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 0; font-size: .8rem; color: var(--muted); }
.tooltip { font-size: .92rem; margin: 6px 0; }
.skill-card details { margin: 4px 0 6px; font-size: .9rem; }
.skill-card summary { cursor: pointer; color: var(--accent-2); }

/* Build planner */
.planner-row { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; }
.planner-row label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin: 0; }
.planner-row .grow { flex: 1; min-width: 200px; }
input[type=text], textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card-solid); color: var(--fg); width: 100%; }
.stigma-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.stigma-slot { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card-solid); font-size: .82rem; color: var(--muted); margin: 0; }
.stigma-slot > span { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.stigma-slot select { width: 100%; }
.slot-empty { width: 36px; height: 36px; flex: none; border: 1px dashed var(--line); border-radius: 6px; }
.stat-slots { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.stat-slots label { margin: 0; }
.plan-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.plan-list li { display: flex; gap: 10px; align-items: flex-start; }
.share-row { display: flex; gap: 8px; margin-top: 12px; }
.share-row input { flex: 1; }
.center { text-align: center; margin-top: 14px; }
a.skill { color: inherit; text-decoration: none; } a.skill:hover { color: var(--accent-2); text-decoration: underline; }

/* Site search */
.search-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .78rem; letter-spacing: .08em; }
.search-dialog {
  width: min(680px, calc(100vw - 32px)); max-height: min(80vh, 720px); margin: 8vh auto auto; padding: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card-solid); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.search-dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px); }
.search-head { display: flex; gap: 8px; }
.search-head input { flex: 1; width: auto; margin: 0; padding: 8px 12px; font-size: 1rem; }
.search-results { list-style: none; padding: 0; margin: 8px 0 0; overflow-y: auto; max-height: calc(min(80vh, 720px) - 120px); }
.search-results a { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 6px; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a:focus-visible { background: var(--card); }
.search-results strong { color: var(--accent); font-family: var(--head-font); font-size: .95rem; }
@media (max-width: 640px) { .search-btn span { display: none; } .search-btn { padding: 6px 8px; } }

/* Phones: tables become stacked cards instead of scrolling sideways */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; margin: 12px 0; }
  .table, .table-wrap .table { display: block; min-width: 0; background: none; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table tbody { display: block; }
  .table tr {
    display: block; margin: 0 0 10px; padding: 6px 0; background: var(--card);
    border: 1px solid var(--line); border-radius: 8px;
  }
  .table td, .table.num td:last-child {
    display: block; border: 0; padding: 5px 14px; text-align: left; font-variant-numeric: normal;
  }
  .table td:first-child { font-weight: 600; padding-top: 6px; }
  .table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 1px; color: var(--accent);
    font-family: var(--head-font); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  }
  .table td:empty { display: none; }
}
