/* ============================================================
   ESTARI — Shared Stylesheet
   Space magic aesthetic · 9th Era campaign setting
   ============================================================ */

/* --- Variables --- */
:root {
  --bg-0: #07131f;
  --bg-1: #0f2235;
  --bg-2: #15344f;
  --panel: rgba(7, 16, 28, 0.9);
  --line: rgba(120, 180, 235, 0.22);
  --text: #d8e7f5;
  --muted: #8ca4ba;
  --gold: #e6be6e;
  --arcane: #7cc0ff;
  --primal: #79d87f;
  --occult: #d58cff;
  --divine: #f2d26d;
  --danger: #ff6b6b;
  --nav-h: 58px;
  --radius: 10px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-0);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Space Background --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(63, 121, 178, 0.25), transparent 32%),
    radial-gradient(circle at 20% 80%, rgba(41, 92, 71, 0.28), transparent 28%),
    linear-gradient(180deg, #15344f, #07131f);
  z-index: -2;
  pointer-events: none;
}

/* --- Star Particles Canvas --- */
#star-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  background: rgba(7, 16, 28, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-brand {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--arcane);
  text-decoration: none;
  margin-right: 12px;
  text-shadow: 0 0 18px rgba(124, 192, 255, 0.55);
  flex-shrink: 0;
}
.nav-brand:hover { color: #aad5ff; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 11px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  letter-spacing: 0.03em;
}
.nav-links a:hover { color: var(--text); background: rgba(124, 192, 255, 0.1); }
.nav-links a.active { color: var(--arcane); }

/* Worlds dropdown */
.nav-dropdown {
  position: relative;
}
.nav-dropdown > a {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  background: rgba(7, 16, 28, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  padding: 6px 0;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 7px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  border-radius: 0;
}
.dropdown-menu a:hover { background: rgba(124,192,255,0.08); color: var(--text); }

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* --- Page Header --- */
.page-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
  position: relative;
}
.page-header::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 120px; height: 2px;
  background: var(--accent, var(--arcane));
  box-shadow: 0 0 12px var(--accent, var(--arcane));
}
.page-header .eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent, var(--arcane));
  margin-bottom: 8px;
}
.page-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  text-shadow: 0 0 32px rgba(124,192,255,0.2);
}
.page-header .subtitle {
  color: var(--muted);
  font-size: 0.97rem;
  margin-top: 8px;
  max-width: 680px;
}

/* Accent color variants */
.accent-arcane  { --accent: var(--arcane); }
.accent-primal  { --accent: var(--primal); }
.accent-occult  { --accent: var(--occult); }
.accent-divine  { --accent: var(--divine); }
.accent-gold    { --accent: var(--gold); }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 10px 0 0;
}
.breadcrumb a { color: var(--arcane); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { opacity: 0.45; }

/* ============================================================
   PANELS & CARDS
   ============================================================ */
.panel {
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  padding: 22px 26px;
  margin-bottom: 18px;
}
.panel h3 {
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  border-left: 4px solid var(--accent, var(--arcane));
  padding: 6px 16px;
  margin: 32px 0 18px;
  background: rgba(124,192,255,0.04);
  border-radius: 0 6px 6px 0;
}
.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}
.section-header p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

/* Color-coded section headers */
.section-header.arcane  { border-color: var(--arcane);  background: rgba(124,192,255,0.04); }
.section-header.primal  { border-color: var(--primal);  background: rgba(121,216,127,0.04); }
.section-header.occult  { border-color: var(--occult);  background: rgba(213,140,255,0.04); }
.section-header.divine  { border-color: var(--divine);  background: rgba(242,210,109,0.04); }
.section-header.gold    { border-color: var(--gold);    background: rgba(230,190,110,0.04); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
thead tr {
  background: rgba(124,192,255,0.12);
  border-bottom: 2px solid rgba(124,192,255,0.3);
}
thead th {
  padding: 10px 14px;
  text-align: left;
  color: var(--arcane);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
tbody tr {
  border-bottom: 1px solid rgba(120,180,235,0.08);
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(124,192,255,0.05); }
tbody td {
  padding: 9px 14px;
  color: var(--text);
  vertical-align: top;
}
tbody td.muted { color: var(--muted); font-size: 0.88rem; }

/* ============================================================
   STAT BARS
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  margin: 12px 0;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 90px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.stat-track {
  flex: 1;
  height: 7px;
  background: rgba(120,180,235,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--arcane), rgba(124,192,255,0.5));
  transition: width 0.6s ease;
  box-shadow: 0 0 6px rgba(124,192,255,0.4);
}
.stat-fill.primal  { background: linear-gradient(90deg, var(--primal), rgba(121,216,127,0.5)); box-shadow: 0 0 6px rgba(121,216,127,0.4); }
.stat-fill.occult  { background: linear-gradient(90deg, var(--occult), rgba(213,140,255,0.5)); box-shadow: 0 0 6px rgba(213,140,255,0.4); }
.stat-fill.divine  { background: linear-gradient(90deg, var(--divine), rgba(242,210,109,0.5)); box-shadow: 0 0 6px rgba(242,210,109,0.4); }
.stat-fill.gold    { background: linear-gradient(90deg, var(--gold), rgba(230,190,110,0.5));   box-shadow: 0 0 6px rgba(230,190,110,0.4); }
.stat-fill.red     { background: linear-gradient(90deg, var(--danger), rgba(255,107,107,0.5)); box-shadow: 0 0 6px rgba(255,107,107,0.4); }
.stat-val {
  font-size: 0.8rem;
  color: var(--text);
  min-width: 22px;
  text-align: right;
  flex-shrink: 0;
}

/* ============================================================
   FACTION CARDS
   ============================================================ */
.faction-card {
  background: rgba(7, 16, 28, 0.75);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--arcane));
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: border-color 0.2s, background 0.2s;
}
.faction-card:hover { background: rgba(7, 16, 28, 0.92); }
.faction-card h4 {
  color: var(--text);
  font-size: 0.98rem;
  margin-bottom: 5px;
}
.faction-card p { color: var(--muted); font-size: 0.88rem; line-height: 1.6; }

/* ============================================================
   LINK CARDS / GRID
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.link-card {
  display: block;
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  backdrop-filter: blur(6px);
}
.link-card:hover {
  border-color: rgba(124,192,255,0.45);
  background: rgba(10, 22, 38, 0.95);
  transform: translateY(-2px);
}
.link-card .card-icon { font-size: 1.5rem; margin-bottom: 8px; display: block; }
.link-card .card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--arcane);
  margin-bottom: 5px;
}
.link-card .card-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.55; }

/* World cards with accent tint */
.world-card { border-left: 3px solid var(--arcane); }
.world-card:hover { border-left-color: rgba(124,192,255,0.7); }
.world-card .card-rim { font-size: 0.75rem; color: var(--muted); margin-top: 6px; letter-spacing: 0.06em; }

/* ============================================================
   QUICK REFERENCE BOX
   ============================================================ */
.qref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.qref-box {
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent, var(--arcane));
  border-radius: var(--radius);
  padding: 18px 20px;
}
.qref-box h4 {
  font-size: 0.83rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, var(--arcane));
  margin-bottom: 10px;
}
.qref-box ul { list-style: none; padding: 0; }
.qref-box li {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 3px 0;
  border-bottom: 1px solid rgba(120,180,235,0.07);
  line-height: 1.5;
}
.qref-box li:last-child { border-bottom: none; }
.qref-box p { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }

/* ============================================================
   WORLD STAT SHEET
   ============================================================ */
.world-stat-sheet {
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 24px;
}
.world-stat-sheet h3 {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.stat-divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* ============================================================
   FOOTER INFO BAR
   ============================================================ */
.world-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  background: rgba(7, 16, 28, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 22px;
  margin-top: 36px;
  font-size: 0.82rem;
  color: var(--muted);
}
.world-footer .wf-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.world-footer .wf-label { color: var(--arcane); font-weight: 600; }

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  padding: 24px 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.site-footer a { color: var(--arcane); text-decoration: none; }

/* ============================================================
   INLINE UTILITIES
   ============================================================ */
a { color: var(--arcane); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin-bottom: 12px; }
p:last-child { margin-bottom: 0; }
strong { color: var(--text); font-weight: 600; }
em { color: var(--muted); font-style: italic; }
.text-arcane  { color: var(--arcane); }
.text-primal  { color: var(--primal); }
.text-occult  { color: var(--occult); }
.text-divine  { color: var(--divine); }
.text-gold    { color: var(--gold); }
.text-muted   { color: var(--muted); }
.text-danger  { color: var(--danger); }
.italic { font-style: italic; }
.mb8 { margin-bottom: 8px; }
.mb16 { margin-bottom: 16px; }
.mb24 { margin-bottom: 24px; }
.tag {
  display: inline-block;
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(120,180,235,0.06);
}
.tag.tag-arcane  { border-color: rgba(124,192,255,0.3); color: var(--arcane); background: rgba(124,192,255,0.08); }
.tag.tag-primal  { border-color: rgba(121,216,127,0.3); color: var(--primal); background: rgba(121,216,127,0.08); }
.tag.tag-occult  { border-color: rgba(213,140,255,0.3); color: var(--occult); background: rgba(213,140,255,0.08); }
.tag.tag-divine  { border-color: rgba(242,210,109,0.3); color: var(--divine); background: rgba(242,210,109,0.08); }
.tagline-text {
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
  border-left: 3px solid var(--accent, var(--arcane));
  padding: 6px 16px;
  margin: 16px 0 24px;
  background: rgba(120,180,235,0.04);
  border-radius: 0 6px 6px 0;
}

/* two-column info panels */
.info-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 600px) { .info-cols { grid-template-columns: 1fr; } }

/* Magic wheel display */
.magic-wheel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px 0 10px;
}
.magic-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.magic-node .mn-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.magic-node .mn-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 0 12px;
}
.magic-arrow { color: var(--muted); font-size: 1.3rem; align-self: center; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(124,192,255,0.3); }
  50% { box-shadow: 0 0 18px rgba(124,192,255,0.65); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-header { animation: fade-in 0.5s ease both; }
.panel, .link-card, .faction-card { animation: fade-in 0.4s ease both; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  .page-header h1 { font-size: 1.6rem; }
  .card-grid, .card-grid-2, .qref-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-mobile-toggle { display: flex; }
}

/* Nav mobile toggle (hidden on desktop) */
.nav-mobile-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 1rem;
}
.nav-links.open { display: flex; }

/* ============================================================
   STAR PARTICLE SCRIPT (inline target styles)
   ============================================================ */
