:root {
  --bg: #0d0b14;
  --bg-elevated: #17141f;
  --fg: #f3eee8;
  --fg-muted: #9a93a8;
  --border: #2a2434;
  --accent-pink: #ff3d6e;
  --accent-green: #8fff4a;
  --accent-blue: #4dc8ff;
  --accent: var(--accent-green);
  --max-width: 52rem;
  --radius: 14px;

  --font-display:
    ui-rounded,
    "SF Pro Rounded",
    "Hiragino Maru Gothic ProN",
    Quicksand,
    Comfortaa,
    Manjari,
    "Arial Rounded MT",
    "Arial Rounded MT Bold",
    Calibri,
    source-sans-pro,
    sans-serif;
  --font-sans:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    system-ui,
    sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  color: var(--fg);
  background-color: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Animated colored glow layer (drifts slowly) */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -2;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(143, 255, 74, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 40% at 15% 100%, rgba(255, 61, 110, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 100%, rgba(77, 200, 255, 0.08), transparent 60%);
  animation: drift 80s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2%, 1.5%, 0) scale(1.05); }
}

/* SVG grain overlay — tiny inline noise filter */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

.site-header, main, .site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover { color: var(--accent-pink); }

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  line-height: 1.15;
  font-weight: 700;
}

/* Header */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
  position: relative;
}

/* Coloured accent line below the menu */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--accent-pink) 0%,
    var(--accent-green) 50%,
    var(--accent-blue) 100%
  );
  opacity: 0.9;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.site-brand:hover { transform: rotate(-1deg) scale(1.02); }

.site-brand img {
  display: block;
  height: 56px;
  width: auto;
  max-width: 100%;
}

.site-header nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.site-header nav a {
  color: var(--fg);
  position: relative;
  padding: 0.25rem 0;
}

.site-header nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent-green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.site-header nav a:hover { color: var(--accent-green); }
.site-header nav a:hover::after { transform: scaleX(1); }

/* Content blocks — open, no card chrome. The accent line lives only on
   the header and footer dividers. */

.panel,
main > article,
main > section:not(.hero) {
  padding: 1.5rem 0;
  margin-bottom: 1.5rem;
}

/* Hero */

.hero {
  text-align: center;
  padding: 3.5rem 2.5rem;
}

.hero-logo {
  display: block;
  margin: 0 auto 1.5rem;
  width: 100%;
  max-width: 600px;
  height: auto;
  filter: drop-shadow(0 8px 40px rgba(143, 255, 74, 0.18));
}

.tagline {
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  margin: 0 auto;
  max-width: 36rem;
}

.hero-body {
  margin-top: 2rem;
  font-size: 1.1rem;
}

/* Articles & lists (inner pages) */

article h1, main > h1 {
  font-size: 2.5rem;
  margin: 0 0 1.25rem;
}

article h1::after, main > h1::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  background: var(--accent-green);
  margin-top: 0.5rem;
  border-radius: 2px;
}

article p, main p { margin: 0 0 1rem; }

main ul { padding-left: 1.25rem; }

/* Footer */

.site-footer {
  position: relative;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Bottom divider — identical to the header's accent line */
.site-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--accent-pink) 0%,
    var(--accent-green) 50%,
    var(--accent-blue) 100%
  );
  opacity: 0.9;
}

/* Mobile */

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
  }
  .site-brand img { height: 48px; }
  .hero { padding: 2rem 1.25rem 2.5rem; }
  main > article, main > section:not(.hero) { padding: 1.5rem 0; }
  .hero-logo { max-width: 100%; }
  .tagline { font-size: 1.15rem; }
  article h1, main > h1 { font-size: 2rem; }
}

/* === Compendium TOC layout === */

/* Wider shell on compendium pages to fit the sidebar tree. */
body.section-compendium .site-header,
body.section-compendium main,
body.section-compendium .site-footer {
  max-width: 72rem;
}

.compendium-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
  padding-top: 1.5rem;
}

.compendium-toc {
  position: sticky;
  top: 1.5rem;
}

.compendium-toc ul { list-style: none; margin: 0; padding: 0; }
.compendium-toc li { margin: 0.2rem 0; }
.compendium-toc ul ul {
  margin: 0.25rem 0 0.5rem 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

/* Section nodes — labels, not links */
.compendium-toc .toc-section {
  display: block;
  padding: 0.15rem 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--fg-muted);
}
.compendium-toc .toc-root > li > .toc-section,
.compendium-toc .toc-root > li > a {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--fg);
}

.compendium-toc a {
  display: block;
  color: var(--fg-muted);
  padding: 0.15rem 0;
  font-size: 0.95rem;
  transition: color 0.15s ease;
}

.compendium-toc a:hover { color: var(--accent-green); }
.compendium-toc a.active { color: var(--fg); font-weight: 600; }

/* Disclosure toggle: hidden on desktop, the sidebar is always shown. */
.toc-toggle, .toc-toggle__input { display: none; }

@media (max-width: 720px) {
  .compendium-layout { grid-template-columns: 1fr; gap: 1rem; }
  .compendium-toc {
    position: static;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
  }
  /* Tap-to-open the navigation tree instead of dumping it above every page. */
  .toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--fg);
    padding: 0.5rem 0;
  }
  .toc-toggle::after { content: "\25BE"; color: var(--fg-muted); font-size: 0.8em; }
  .toc-toggle__input { /* visually hidden but focusable for keyboard users */
    display: block;
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    opacity: 0;
  }
  .toc-toggle__input:checked ~ .toc-toggle::after { content: "\25B4"; }
  .toc-toggle__input:focus-visible ~ .toc-toggle { outline: 2px solid var(--accent-green); outline-offset: 3px; }
  .toc-body { display: none; }
  .toc-toggle__input:checked ~ .toc-body { display: block; }
}

/* === Compendium hub === */

.compendium-hero { text-align: center; }

.compendium-emblem {
  display: block;
  width: 160px;
  height: auto;
  margin: 0 auto 1rem;
  filter: drop-shadow(0 6px 28px rgba(143, 255, 74, 0.16));
}

.compendium-intro { color: var(--fg-muted); max-width: 36rem; margin: 0 auto; }

.compendium-cats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.cat-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--fg);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.cat-card:hover { transform: translateY(-3px); border-color: var(--accent-green); color: var(--fg); }
.cat-card h2 { margin: 0 0 0.4rem; font-size: 1.3rem; }
.cat-card p { margin: 0; color: var(--fg-muted); font-size: 0.95rem; }

/* === Compendium pages === */

.page-head .breadcrumb {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 0 0 0.5rem;
}

.page-head .breadcrumb a { color: var(--fg-muted); }
.page-head .breadcrumb a:hover { color: var(--accent-green); }
.page-head .lead { color: var(--fg-muted); font-size: 1.1rem; margin: 0; }

.card-art {
  align-self: start;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

.card-art img { display: block; width: 100%; height: auto; }

.card-art--missing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0 10px, transparent 10px 20px),
    var(--bg-elevated);
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}


/* Weapon entries */

.entry-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.entry-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.75rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.entry-body { min-width: 0; }

.entry-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.entry-head h2 { margin: 0; margin-right: auto; font-size: 1.4rem; }

.entry-tag {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.entry-fullname { color: var(--fg-muted); font-style: italic; margin: 0.2rem 0 1rem; }

.entry-tag--historical { color: #ff5a5a; border-color: #ff5a5a; }
.entry-tag--green { color: var(--accent-green); border-color: var(--accent-green); }
.entry-tag--notable { color: var(--accent-pink); border-color: var(--accent-pink); }

/* World classification codes, coloured by category */
.entry-tag--world-hpw { color: var(--accent-green); border-color: var(--accent-green); }   /* Habitable Population World */
.entry-tag--world-apw { color: #c4d24a; border-color: #c4d24a; }                            /* Agro-Production World */
.entry-tag--world-umw { color: var(--accent-blue); border-color: var(--accent-blue); }     /* Urban Megastructure World */
.entry-tag--world-rew { color: #e6912f; border-color: #e6912f; }                            /* Resource-Extraction World */
.entry-tag--world-vhw { color: #b07ce0; border-color: #b07ce0; }                            /* Volatile Harvest World */
.entry-tag--world-unh { color: var(--fg-muted); border-color: var(--fg-muted); }           /* Uninhabited */
.entry-tag--world-dz  { color: #d2683c; border-color: #d2683c; }                            /* Debris Zone */

/* Bestiary tiers, low-to-high heat scale (F cheapest to S most expensive) */
.entry-tag--tier-f { color: #5ac46a; border-color: #5ac46a; }
.entry-tag--tier-e { color: #9ccb4a; border-color: #9ccb4a; }
.entry-tag--tier-d { color: #d2c44a; border-color: #d2c44a; }
.entry-tag--tier-c { color: #e6a23d; border-color: #e6a23d; }
.entry-tag--tier-b { color: #e6772f; border-color: #e6772f; }
.entry-tag--tier-a { color: #e6512f; border-color: #e6512f; }
.entry-tag--tier-s { color: #e63956; border-color: #e63956; }

/* Weapon damage, coloured by type */
.entry-tag--dmg-laser      { color: var(--accent-blue); border-color: var(--accent-blue); }
.entry-tag--dmg-bodkin5mm  { color: #e6c44a; border-color: #e6c44a; }
.entry-tag--dmg-bodkin10mm { color: #e6912f; border-color: #e6912f; }
.entry-tag--dmg-bodkin20mm { color: #e6512f; border-color: #e6512f; }
.entry-tag--dmg-melee      { color: #9aa0a8; border-color: #9aa0a8; }
.entry-tag--dmg-ordnance   { color: #b07ce0; border-color: #b07ce0; }

/* Armour toughness, low-to-high cool ramp */
.entry-tag--tough-1 { color: #6fae8f; border-color: #6fae8f; }
.entry-tag--tough-2 { color: #4aaeae; border-color: #4aaeae; }
.entry-tag--tough-3 { color: #4a8fe6; border-color: #4a8fe6; }
.entry-tag--tough-4 { color: #6a6ae6; border-color: #6a6ae6; }

.entry-stats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 0;
  margin: 0 0 1rem;
}

.entry-stats li { display: flex; flex-direction: column; }
.entry-stats span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); }
.entry-stats strong { font-family: var(--font-display); font-size: 1rem; }

.dice-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.dice-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
.dice-table td { padding: 0.35rem 0.7rem; }
.dice-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }

.entry-desc { margin: 0; color: var(--fg); }

.page-subtitle { margin: 0.1rem 0 0; color: var(--fg-muted); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; }
.class-key { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: 1rem 0 0; }
.class-key__items { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0; padding: 0; }
.class-key__items li { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--fg-muted); font-size: 0.85rem; }
.class-key__caption { color: var(--fg-muted); font-size: 0.85rem; }
.page-lead { color: var(--fg-muted); font-size: 1.05rem; line-height: 1.6; max-width: 46rem; margin: 0.5rem 0 1.5rem; }

/* Bestiary variant sub-roster */
.variant-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.variant {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.variant-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.variant-head h3 { margin: 0; font-size: 1.1rem; }

.variant-stats { font-size: 0.85rem; color: var(--fg-muted); }

@media (max-width: 640px) {
  .entry-card { grid-template-columns: 1fr; }
  .card-art { max-width: 280px; margin: 0 auto; }
}

