/**
 * The base of the look — VALtima Online's, worn now by Wubarrks New Dawn.
 *
 * The site is dressed as an Ultima Online interface carved out of a Viking
 * longhouse: dark wood and leather for the ground, brass and gold leaf for the
 * trim, parchment where there is something to READ, and the cold blue light of
 * a rune where something is alive. The pieces, in the order they are met:
 *
 *   the page      night, torchlight at the top, grain over everything
 *   .gump         the big framed window — a leather frame with brass corners
 *                 (the container art from BarrkUI, public/assets/ui/)
 *   .glass-panel  a plaque: a card inside a window, four brass rivets
 *   .parchment    a scroll, for chronicles and anything long to read
 *   the header    a carved beam with a knotwork band hung under it
 *
 * Every colour is a token here or a palette entry in tools/gen-utilities.mjs;
 * a literal hex anywhere else is a bug waiting for the next re-theme.
 * Fonts are loaded by index.html (the two <link>s there, not an @import here).
 */

:root {
  /* Wood and leather — the grounds. */
  --night: #0b0805;
  --wood-950: #0e0a06;
  --wood-900: #17100a;
  --wood-850: #1d140c;
  --wood-800: #251a10;
  --leather-700: #3a2616;
  --leather-600: #4d321c;

  /* Brass and gold leaf — the trim. */
  --gold-100: #f6e4a6;
  --gold-300: #f0d07a;
  --gold-400: #e8c25a;
  --gold-500: #cfa545;
  --gold-600: #a8812f;
  --gold-800: #6b5226;

  /* Parchment and ink — what is read. */
  --parch-100: #f1e6c6;
  --parch-200: #e6d7ae;
  --parch-300: #d6c28f;
  --parch-edge: #b79c63;
  --ink: #2b1d0e;
  --ink-soft: #5a452a;
  --ink-red: #8e2a1e;

  /* Light — rune glow, torch ember, banner red, and the status gems. */
  --rune: #4cc9e0;
  --rune-bright: #9be8f3;
  --rune-glow: rgba(76, 201, 224, 0.45);
  --ember: #e0662a;
  --ember-bright: #ee8f4a;
  --banner-red: #9b2a22;
  --banner-red-deep: #5a130e;
  --violet: #a98cec;
  --violet-deep: #3b2a6b;
  --ok: #7fcf72;
  --bad: #e0705c;
  --warn: #e8c25a;

  /* Legacy names the component sheets still read; the values are the realm's. */
  --color-midnight: var(--night);
  --color-obsidian: var(--wood-950);
  --color-slate-panel: var(--wood-900);
  --color-card: var(--wood-850);
  --color-amber: var(--gold-500);
  --color-amber-bright: var(--gold-400);
  --color-gold: var(--gold-400);
  --color-ember: var(--ember);
  --color-ember-bright: var(--ember-bright);
  --color-cyan: var(--rune);
  --color-cyan-bright: var(--rune-bright);
  --color-emerald: #5fae56;
  --color-purple: #8f6fd0;
  --color-crimson: #c4402e;

  --text-primary: #f3ead2;
  --text-secondary: #cdbf9d;
  --text-muted: #928468;
  --text-gold: var(--gold-400);

  --border-card: rgba(207, 165, 69, 0.28);
  --border-subtle: rgba(232, 214, 170, 0.09);
  --border-cyan: rgba(76, 201, 224, 0.28);
  --border-gold: rgba(232, 194, 90, 0.42);
  --border-active: rgba(232, 194, 90, 0.75);

  --bg-card: rgba(23, 16, 10, 0.84);
  --bg-card-hover: rgba(34, 24, 14, 0.94);

  --color-ember-glow: rgba(224, 102, 42, 0.35);
  --color-cyan-glow: var(--rune-glow);
  --shadow-card: 0 10px 26px -8px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 236, 180, 0.05);
  --shadow-glow-gold: 0 0 26px rgba(207, 165, 69, 0.22);
  --shadow-glow-ember: 0 0 26px rgba(224, 102, 42, 0.3);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s ease;

  --font-display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --font-deco: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --font-sans: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
  --font-serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --font-rune: 'Noto Sans Runic', 'Segoe UI Historic', 'Cinzel', serif;
  --font-body: var(--font-sans);

  /* Four brass rivets, one in each corner — the plaque's whole ornament. */
  --rivets:
    radial-gradient(circle at 35% 32%, #f6e4a6 0, #cfa545 38%, #6b5226 72%, transparent 76%) 5px 5px / 9px 9px no-repeat,
    radial-gradient(circle at 35% 32%, #f6e4a6 0, #cfa545 38%, #6b5226 72%, transparent 76%) calc(100% - 5px) 5px / 9px 9px no-repeat,
    radial-gradient(circle at 35% 32%, #f6e4a6 0, #cfa545 38%, #6b5226 72%, transparent 76%) 5px calc(100% - 5px) / 9px 9px no-repeat,
    radial-gradient(circle at 35% 32%, #f6e4a6 0, #cfa545 38%, #6b5226 72%, transparent 76%) calc(100% - 5px) calc(100% - 5px) / 9px 9px no-repeat;
  /* Fine grain, laid over wood and parchment alike. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .85 0 0 0 0 .72 0 0 0 0 .5 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --hero-bg-art: url('/assets/newdawn-hero-960.jpg');
}

/* ---------------------------------------------------------------------------
 * Proxima Maxi Realm Skin: Dark Gothic Eclipse, Occult Runes, Obsidian Steel
 * ------------------------------------------------------------------------- */
[data-realm="proximamaxi"] {
  /* Grounds: obsidian and cold purple-black night */
  --night: #06040a;
  --wood-950: #0a0712;
  --wood-900: #120c1e;
  --wood-850: #181026;
  --wood-800: #211634;
  --leather-700: #301f46;
  --leather-600: #422b60;

  /* Eclipse Violet & Shadow Gold trim */
  --gold-100: #f5edff;
  --gold-300: #d8b4fe;
  --gold-400: #c084fc;
  --gold-500: #a855f7;
  --gold-600: #8f6fd0;
  --gold-800: #581c87;

  /* Blood-red embers and eerie occult runes */
  --rune: #e53935;
  --rune-bright: #ff6b6b;
  --rune-glow: rgba(229, 57, 53, 0.55);
  --ember: #b71c1c;
  --ember-bright: #ef4444;
  --banner-red: #881337;
  --banner-red-deep: #4c0519;

  --accent: #8f6fd0;
  --accent-bright: #c9b6f5;
  --accent-soft: rgba(143, 111, 208, 0.55);
  --accent-bg: rgba(143, 111, 208, 0.12);
  --cloth-top: #4a3585;
  --cloth-bottom: #251848;
  --trim: #b9a2f0;

  --color-midnight: var(--night);
  --color-obsidian: var(--wood-950);
  --color-slate-panel: var(--wood-900);
  --color-card: var(--wood-850);
  --color-amber: #c084fc;
  --color-amber-bright: #d8b4fe;
  --color-gold: #c084fc;
  --color-ember: #ef4444;
  --color-ember-bright: #f87171;
  --color-cyan: #ff6b6b;
  --color-cyan-bright: #fca5a5;

  --text-primary: #f6f3ff;
  --text-secondary: #ddd6fe;
  --text-muted: #9e8bb8;
  --text-gold: #d8b4fe;

  --border-card: rgba(143, 111, 208, 0.35);
  --border-subtle: rgba(200, 180, 240, 0.1);
  --border-cyan: rgba(229, 57, 53, 0.45);
  --border-gold: rgba(192, 132, 252, 0.5);
  --border-active: rgba(239, 68, 68, 0.85);

  --bg-card: rgba(18, 12, 30, 0.88);
  --bg-card-hover: rgba(28, 18, 46, 0.96);

  --color-ember-glow: rgba(239, 68, 68, 0.4);
  --color-cyan-glow: var(--rune-glow);
  --shadow-glow-gold: 0 0 28px rgba(168, 85, 247, 0.32);
  --shadow-glow-ember: 0 0 28px rgba(220, 38, 38, 0.4);

  --hero-bg-art: url('/assets/proxima-hero-960.jpg');

  /* Cold Steel & Amethyst Rivets */
  --rivets:
    radial-gradient(circle at 35% 32%, #f3e8ff 0, #a855f7 38%, #581c87 72%, transparent 76%) 5px 5px / 9px 9px no-repeat,
    radial-gradient(circle at 35% 32%, #f3e8ff 0, #a855f7 38%, #581c87 72%, transparent 76%) calc(100% - 5px) 5px / 9px 9px no-repeat,
    radial-gradient(circle at 35% 32%, #f3e8ff 0, #a855f7 38%, #581c87 72%, transparent 76%) 5px calc(100% - 5px) / 9px 9px no-repeat,
    radial-gradient(circle at 35% 32%, #f3e8ff 0, #a855f7 38%, #581c87 72%, transparent 76%) calc(100% - 5px) calc(100% - 5px) / 9px 9px no-repeat;
}

/* ---------------------------------------------------------------------------
 * Wubarrks Scoop of Vanilla Realm Skin: Frost & Azure (was the unused
 * BetterWorlds / Wonderland skin, re-keyed in 1.18.0)
 * ------------------------------------------------------------------------- */
[data-realm="scoop"] {
  --night: #040d16;
  --wood-950: #061320;
  --wood-900: #0a1e30;
  --wood-850: #0f273e;
  --wood-800: #14324f;
  --leather-700: #174266;
  --leather-600: #1d527e;

  --gold-100: #e0f2fe;
  --gold-300: #7dd3fc;
  --gold-400: #38bdf8;
  --gold-500: #0ea5e9;
  --gold-600: #0284c7;
  --gold-800: #0369a1;

  --rune: #34d399;
  --rune-bright: #6ee7b7;
  --rune-glow: rgba(52, 211, 153, 0.45);
  --ember: #0284c7;
  --ember-bright: #38bdf8;

  --accent: #38bdf8;
  --accent-bright: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, 0.5);
  --accent-bg: rgba(56, 189, 248, 0.12);
  --cloth-top: #0369a1;
  --cloth-bottom: #072a42;
  --trim: #38bdf8;

  --hero-bg-art: url('/assets/scoop-hero-960.jpg');
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Nav jumps land below the sticky bar rather than underneath it. */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.75rem;
}

body {
  background-color: var(--night);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color var(--transition-slow), color var(--transition-slow);
  background-image:
    radial-gradient(ellipse 90% 48% at 50% -8%, rgba(224, 102, 42, 0.17), transparent 62%),
    radial-gradient(ellipse 46% 40% at 96% 38%, rgba(76, 201, 224, 0.07), transparent 70%),
    radial-gradient(ellipse 52% 38% at 2% 72%, rgba(155, 42, 34, 0.12), transparent 70%),
    var(--grain),
    linear-gradient(180deg, #0b0805 0%, #130d08 52%, #080604 100%);
  background-attachment: fixed;
}

body[data-realm="proximamaxi"] {
  background-image:
    radial-gradient(ellipse 90% 48% at 50% -8%, rgba(220, 38, 38, 0.22), transparent 62%),
    radial-gradient(ellipse 46% 40% at 96% 38%, rgba(168, 85, 247, 0.16), transparent 70%),
    radial-gradient(ellipse 52% 38% at 2% 72%, rgba(139, 92, 246, 0.15), transparent 70%),
    var(--grain),
    linear-gradient(180deg, #06040a 0%, #100b1a 52%, #040207 100%);
}

body[data-realm="scoop"] {
  background-image:
    radial-gradient(ellipse 90% 48% at 50% -8%, rgba(14, 165, 233, 0.2), transparent 62%),
    radial-gradient(ellipse 46% 40% at 96% 38%, rgba(52, 211, 153, 0.15), transparent 70%),
    radial-gradient(ellipse 52% 38% at 2% 72%, rgba(2, 132, 199, 0.15), transparent 70%),
    var(--grain),
    linear-gradient(180deg, #040d16 0%, #0a1c2e 52%, #03080e 100%);
}

/* Button & interactive defaults */
button {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--rune);
  outline-offset: 2px;
}

::selection {
  background: rgba(207, 165, 69, 0.35);
  color: var(--parch-100);
}

/* Scrollbars: a brass thumb on dark wood. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #0b0805;
  border-left: 1px solid rgba(207, 165, 69, 0.12);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #8a6a24, #cfa545 50%, #8a6a24);
  border-radius: 5px;
  border: 2px solid #0b0805;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #a8812f, #f0d07a 50%, #a8812f);
}
* {
  scrollbar-color: #a8812f #0b0805;
}

.font-display { font-family: var(--font-display); }
.font-sans { font-family: var(--font-sans); }
.font-serif { font-family: var(--font-serif); }
.font-mono { font-family: var(--font-mono); }
.font-rune { font-family: var(--font-rune); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* ---------------------------------------------------------------------------
 * The gump: a leather frame with brass corners around a window of content.
 * The art is nine-sliced — the corners keep their brass, the edges tile — and
 * the content sits on dark wood inside it. A frame this heavy is for the few
 * big containers (the realm window, the hero picture, the modals), not for
 * every card; cards are plaques.
 * ------------------------------------------------------------------------- */
.gump {
  --gump-edge: 26px;
  position: relative;
  border: var(--gump-edge) solid transparent;
  border-image: url('/assets/ui/gump-container.png') 48 / var(--gump-edge) / 0 round;
  background:
    var(--grain),
    linear-gradient(180deg, #1d140c, #130d08);
  background-clip: padding-box;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.65));
}
.gump--slim { --gump-edge: 18px; }

/* The plaque: a card in a window. */
.glass-panel,
.glass-panel-heavy,
.glass-panel-card {
  position: relative;
  background:
    var(--rivets),
    var(--grain),
    linear-gradient(180deg, rgba(42, 30, 18, 0.94), rgba(24, 16, 10, 0.97));
  border: 1px solid var(--border-card);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 180, 0.08),
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    0 8px 18px -8px rgba(0, 0, 0, 0.75);
}

/* The heavy plaque is double-framed: a thin gold line inside, two rings out. */
.glass-panel-heavy {
  border-color: rgba(207, 165, 69, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 180, 0.1),
    0 0 0 1px #0a0705,
    0 0 0 2px rgba(168, 129, 47, 0.7),
    0 0 0 3px #0a0705,
    0 18px 36px -10px rgba(0, 0, 0, 0.85);
}
.glass-panel-heavy::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(207, 165, 69, 0.2);
  border-radius: 2px;
  pointer-events: none;
}

.glass-panel-card {
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.glass-panel-card:hover {
  transform: translateY(-3px);
  border-color: rgba(232, 194, 90, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 180, 0.1),
    inset 0 0 0 1px rgba(0, 0, 0, 0.55),
    0 14px 28px -10px rgba(0, 0, 0, 0.85),
    0 0 22px rgba(207, 165, 69, 0.16);
}

/* A scroll: parchment with ink on it. */
.parchment {
  color: var(--ink);
  background:
    var(--grain),
    radial-gradient(ellipse at 50% 0%, rgba(255, 248, 224, 0.55), transparent 65%),
    radial-gradient(ellipse at 50% 100%, rgba(150, 105, 50, 0.28), transparent 60%),
    linear-gradient(180deg, var(--parch-100), var(--parch-200) 55%, var(--parch-300));
  box-shadow:
    inset 0 0 38px rgba(110, 70, 25, 0.35),
    inset 0 0 0 1px rgba(110, 70, 25, 0.45);
}

/* Glow utilities */
.glow-amber { box-shadow: 0 0 25px rgba(207, 165, 69, 0.35); }
.glow-ember { box-shadow: 0 0 25px rgba(224, 102, 42, 0.4); }
.glow-cyan { box-shadow: 0 0 25px rgba(76, 201, 224, 0.35); }
.text-glow-gold { text-shadow: 0 1px 0 #000, 0 0 16px rgba(232, 194, 90, 0.45); }
.text-glow-amber { text-shadow: 0 1px 0 #000, 0 0 16px rgba(207, 165, 69, 0.45); }
.text-glow-cyan { text-shadow: 0 0 14px rgba(76, 201, 224, 0.6); }

/* The modal roots carry `z-50` in index.html. Now that utilities are real, that
 * makes each root a stacking context BELOW the sticky header (60), and the
 * overlay's own z-index 999 would only count inside it — the header would
 * paint over every modal. Pinned back to auto so the overlay itself wins. */
#article-modal-root,
#admin-modal-root,
#remote-modal-root { z-index: auto; }

/* The backdrop: embers and runes drifting up (src/main.js builds them). */
@keyframes floatParticle {
  0% { transform: translateY(0) translateX(0) scale(1) rotate(0deg); opacity: 0.15; }
  50% { transform: translateY(-45vh) translateX(25px) scale(1.15) rotate(180deg); opacity: 0.75; }
  100% { transform: translateY(-90vh) translateX(-20px) scale(0.9) rotate(360deg); opacity: 0.05; }
}
@media (prefers-reduced-motion: reduce) {
  #particles-bg { display: none; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------------------
 * The header: a carved beam, a thread of gold on top, a knotwork band hung
 * beneath. It rides along as the page scrolls.
 *
 * `index.html` asks for `sticky top-0 z-40` and this project writes its own
 * utilities, so the offset and the z-index are stated here in real CSS where
 * they cannot go missing. A sticky element with no offset never sticks, and
 * with no z-index it is painted UNDER every section after it. Modals sit at
 * z-index 999 (components.css) and still cover the bar.
 * ------------------------------------------------------------------------- */
#site-header {
  position: sticky;
  top: 0;
  z-index: 60;
}

/* The shell clips what drifts past its sides (the embers) with `clip`, NOT
 * `hidden`. Any `overflow` other than visible/clip on one axis turns the other
 * axis into `auto`, which makes #app a scroll container of its own — and a
 * sticky header sticks to its nearest scroll container. #app is as tall as the
 * page and never scrolls, so with `overflow-x: hidden` here the bar rode up
 * and out of view with everything else. `clip` clips the same and scrolls
 * nothing, so the bar stays on the viewport. */
#app { overflow-x: clip; }

.top-nav-bar {
  position: relative;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.014) 0 2px, transparent 2px 9px),
    var(--grain),
    linear-gradient(180deg, #2c1d11 0%, #1b120a 58%, #120b06 100%);
  border-bottom: 1px solid #000;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 225, 150, 0.14),
    inset 0 -1px 0 rgba(207, 165, 69, 0.4);
}
.top-nav-bar::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #a8812f 14%, #f0d07a 50%, #a8812f 86%, transparent);
  pointer-events: none;
}
.top-nav-bar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 9px;
  background: url('/assets/ui/knot-band-dim.svg') repeat-x left center / auto 9px;
  opacity: 0.85;
  pointer-events: none;
}

/* A gump button: dark leather, a brass rim, a rune in gold. */
.nav-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.95rem;
  border-radius: 3px;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: linear-gradient(180deg, #33231a, #1e140d);
  border: 1px solid #5b4326;
  box-shadow: inset 0 1px 0 rgba(255, 225, 150, 0.12), 0 2px 4px rgba(0, 0, 0, 0.55);
  transition: color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  white-space: nowrap;
}
.nav-link-pill .rune,
.nav-link-pill > span:first-child { font-family: var(--font-rune); color: var(--gold-500); font-size: 1.05em; line-height: 1; }

.nav-link-pill:hover {
  color: var(--parch-100);
  border-color: var(--gold-600);
  background: linear-gradient(180deg, #44301c, #261a0f);
  box-shadow: inset 0 1px 0 rgba(255, 225, 150, 0.2), 0 0 14px rgba(207, 165, 69, 0.25);
}

.nav-link-pill.active {
  color: var(--gold-300);
  background: linear-gradient(180deg, #5e4220, #3a2610);
  border-color: var(--gold-400);
  box-shadow: inset 0 1px 0 rgba(255, 235, 170, 0.35), inset 0 -2px 6px rgba(0, 0, 0, 0.4), 0 0 16px rgba(232, 194, 90, 0.3);
}

.status-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: 3px;
  background: var(--wood-950);
  border: 1px solid var(--border-card);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
