/* ═══════════════════════════════════════════════════════════════════
   WoOOL — "The Shattering" theme layer
   Dark-fantasy design system: abyss black · parchment gold · molten
   orange · blood red. Shared by every public portal page.

   This file is hand-written and served locally, so it is ALSO the
   graceful-degradation path when the Tailwind / Lucide CDNs are
   unreachable (see shattering-theme.js). Component looks live here;
   Tailwind utilities are only ever ornament on top.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --sh-abyss:       #050505;
  --sh-blood:       #8B0000;
  --sh-blood-deep:  #4A0000;
  --sh-parchment:   #C5A059;
  --sh-parchment-lit: #E8D3A0;
  --sh-molten:      #FF6A00;
  --sh-molten-lit:  #FFA24D;
  --sh-ember:       #E85D1F;
  --sh-ghost:       #00F0FF;

  --sh-font-gothic: 'Cinzel', 'Times New Roman', serif;
  --sh-font-body:   'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sh-font-fell:   'IM Fell English', Georgia, serif;

  /* ── Rarity ─────────────────────────────────────────────────────
     The server's Rarity enum is { Common, Superior, Elite, Legendary }.
     These MUST stay in step with the RARITY table in portal-item-ui.js,
     which is the source of truth for the JS side. */
  --rarity-common:    #9D9D9D;
  --rarity-superior:  #4DA6FF;
  --rarity-elite:     #B16BEA;
  --rarity-legendary: #FF7D0A;

  --rarity-common-glow:    rgba(157, 157, 157, 0.35);
  --rarity-superior-glow:  rgba(77, 166, 255, 0.45);
  --rarity-elite-glow:     rgba(177, 107, 234, 0.50);
  --rarity-legendary-glow: rgba(255, 125, 10, 0.45);
}

/* Any element carrying a rarity class publishes --rarity/--rarity-glow to
   its subtree, so .loot-slot hover glow and the tooltip both work whether
   the rarity came from markup (a class) or from JS (PortalItemUI). */
.rarity-common    { --rarity: var(--rarity-common);    --rarity-glow: var(--rarity-common-glow); }
.rarity-superior  { --rarity: var(--rarity-superior);  --rarity-glow: var(--rarity-superior-glow); }
.rarity-elite     { --rarity: var(--rarity-elite);     --rarity-glow: var(--rarity-elite-glow); }
.rarity-legendary { --rarity: var(--rarity-legendary); --rarity-glow: var(--rarity-legendary-glow); }
.rarity-unknown   { --rarity: var(--rarity-common);    --rarity-glow: var(--rarity-common-glow); }

/* ── Atmosphere overlays ────────────────────────────────────────── */
/* Stone / charcoal grain. Fixed, inert, sits above content but never
   takes pointer events. */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.7) 100%);
}

::selection { background: var(--sh-blood); color: #f5e9d2; }

/* ── Gothic scrollbar ───────────────────────────────────────────── */
.shattering ::-webkit-scrollbar { width: 10px; height: 10px; }
.shattering ::-webkit-scrollbar-track { background: #070608; }
.shattering ::-webkit-scrollbar-thumb {
  background: #241a1c;
  border-radius: 5px;
  border: 2px solid #070608;
}
.shattering ::-webkit-scrollbar-thumb:hover { background: var(--sh-ember); }

/* ═══════════════════════════════════════════════════════════════════
   STONE SLAB — the base panel treatment
   ═══════════════════════════════════════════════════════════════════ */
.stone-slab {
  position: relative;
  background: linear-gradient(155deg, #16131a 0%, #0d0b10 48%, #120e12 100%);
  border: 1px solid rgba(197, 160, 89, 0.16);
  box-shadow:
    inset 0 0 28px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(197, 160, 89, 0.08),
    0 14px 34px -14px rgba(0, 0, 0, 0.9);
  transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.4s ease;
}

/* Rune card — molten fire border awakens on hover */
.rune-card:hover {
  border-color: rgba(255, 106, 0, 0.45);
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 106, 0, 0.28),
    0 0 34px -6px rgba(255, 106, 0, 0.45),
    inset 0 0 18px rgba(255, 106, 0, 0.07);
  transform: translateY(-6px);
}
.rune-card:hover .rune-icon {
  color: var(--sh-molten-lit);
  filter: drop-shadow(0 0 10px rgba(255, 106, 0, 0.8));
  transform: scale(1.08) rotate(-3deg);
}
.rune-card:hover .rune-title {
  color: #ffe9d6;
  text-shadow: 0 0 16px rgba(255, 106, 0, 0.55);
}
.rune-icon,
.rune-title {
  transition: color .3s ease, transform .3s ease, filter .3s ease, text-shadow .3s ease;
}

/* ═══════════════════════════════════════════════════════════════════
   CURSED RELIC CTA — the molten forge button
   ═══════════════════════════════════════════════════════════════════ */
.cta-relic {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(180deg, #241309 0%, #100a07 60%, #170c08 100%);
  border: 1px solid rgba(197, 160, 89, 0.55);
  color: var(--sh-parchment);
  font-family: var(--sh-font-gothic);
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.22em;
  box-shadow:
    0 0 16px -6px rgba(232, 93, 31, 0.6),
    inset 0 0 14px rgba(74, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: relic-pulse 2.8s ease-in-out infinite;
  transition: color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}
.cta-relic:hover {
  color: #ffe9d6;
  border-color: rgba(255, 140, 41, 0.85);
  transform: translateY(-2px);
  animation-play-state: paused;
  box-shadow:
    0 0 36px -2px rgba(255, 106, 0, 0.75),
    0 0 74px -10px rgba(232, 93, 31, 0.85),
    inset 0 0 20px rgba(255, 106, 0, 0.28);
}
@keyframes relic-pulse {
  0%, 100% { box-shadow: 0 0 14px -8px rgba(232, 93, 31, 0.55), inset 0 0 12px rgba(74, 0, 0, 0.3); }
  50%      { box-shadow: 0 0 38px -4px rgba(255, 106, 0, 0.65), inset 0 0 20px rgba(232, 93, 31, 0.5); }
}

/* ── Ghost link — eerie cyan on hover (arcane element) ──────────── */
.ghost-link { transition: color 0.3s ease, text-shadow 0.3s ease; }
.ghost-link:hover { color: var(--sh-ghost); text-shadow: 0 0 14px rgba(0, 240, 255, 0.6); }

/* ── Title glow — molten + blood behind parchment ───────────────── */
.title-glow {
  color: var(--sh-parchment);
  text-shadow:
    0 0 16px rgba(255, 106, 0, 0.4),
    0 0 44px rgba(139, 0, 0, 0.55),
    0 0 80px rgba(74, 0, 0, 0.4),
    0 2px 2px rgba(0, 0, 0, 0.9);
}

/* Molten eyebrow that sits above a section title */
.sh-eyebrow {
  margin: 0 0 8px;
  font-family: var(--sh-font-gothic);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5em;
  color: var(--sh-molten);
  filter: drop-shadow(0 0 10px rgba(255, 106, 0, 0.7));
}

/* Flavour text — the italic serif voice */
.sh-fell { font-family: var(--sh-font-fell); font-style: italic; }

/* Hairline rule that fades out from the left */
.sh-rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, rgba(197, 160, 89, 0.55), rgba(197, 160, 89, 0.14), transparent);
}

/* ═══════════════════════════════════════════════════════════════════
   LOOT SLOTS & RPG TOOLTIPS — driven by --rarity / --rarity-glow
   Rarity values are supplied by portal-item-ui.js; the rarity map is
   NOT duplicated here.
   ═══════════════════════════════════════════════════════════════════ */
.loot-slot {
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}
.loot-slot:hover {
  border-color: var(--rarity);
  box-shadow:
    inset 0 0 24px rgba(0, 0, 0, 0.85),
    0 0 0 1px var(--rarity-glow),
    0 0 26px -4px var(--rarity-glow);
  transform: translateY(-3px);
}
.loot-slot:hover .loot-icon {
  filter: drop-shadow(0 0 9px var(--rarity-glow));
  transform: scale(1.12) rotate(4deg);
}
.loot-icon { transition: filter .3s ease, transform .3s ease; }

.loot-tip {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  z-index: 50;
  width: min(260px, 78vw);
  transform: translateX(-50%) translateY(10px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  background: linear-gradient(170deg, #100d13 0%, #070609 100%);
  border: 1px solid var(--rarity);
  box-shadow: 0 0 24px -4px var(--rarity-glow), inset 0 0 18px rgba(0, 0, 0, 0.9);
}
.loot-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--rarity);
}
.loot-slot:hover .loot-tip {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ═══════════════════════════════════════════════════════════════════
   ITEM TOOLTIP
   The floating tooltip PortalItemUI.bindItemTooltip renders. Defined
   here rather than per-page so the armory, the marketplace and the
   daily spin share one look — they previously each had their own copy.

   PortalItemUI stamps --rarity / --rarity-glow on the box before it is
   shown, so every rule below tints itself. Uses --sh-* tokens only, as
   the mini-game pages do not load portal.css.
   ═══════════════════════════════════════════════════════════════════ */
.armory-item-tip {
  --rarity: #9D9D9D;
  --rarity-glow: rgba(157, 157, 157, 0.35);
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  min-width: 190px;
  max-width: 320px;
  padding: 12px 14px;
  background: linear-gradient(170deg, #100d13 0%, #070609 100%);
  border: 1px solid var(--rarity);
  border-radius: 0;
  box-shadow:
    0 0 24px -4px var(--rarity-glow),
    inset 0 0 18px rgba(0, 0, 0, 0.9),
    0 18px 40px -18px rgba(0, 0, 0, 0.95);
  font-family: var(--sh-font-body);
  font-size: 12px;
  line-height: 1.5;
}

.armory-tip-name {
  color: var(--rarity);
  font-family: var(--sh-font-gothic);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px var(--rarity-glow);
}

.armory-tip-type {
  margin-top: 3px;
  font-family: var(--sh-font-fell);
  font-style: italic;
  font-size: 11px;
  color: #8a8279;
}

/* Rarity-tinted hairline fading out to the right, as in the reference. */
.armory-tip-rule {
  height: 1px;
  margin: 10px 0;
  background: linear-gradient(90deg, var(--rarity), var(--rarity-glow), transparent);
  opacity: 0.75;
}

.armory-tip-meta { margin-top: 2px; }

.armory-tip-line {
  color: #a8a29e;
  font-size: 11px;
}

.armory-tip-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.armory-tip-stat {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #a8a29e;
  font-size: 11px;
}

.armory-tip-stat .tip-stat-label { color: #8a8279; }

/* The number is the part that carries the rarity, as in the reference. */
.armory-tip-stat .tip-stat-value {
  color: var(--rarity);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.armory-tip-req {
  margin-top: 8px;
  font-size: 11px;
  color: var(--sh-ember);
}

.armory-tip-flavour {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--sh-font-fell);
  font-style: italic;
  font-size: 11px;
  line-height: 1.35;
  color: #8a8279;
}

/* ═══════════════════════════════════════════════════════════════════
   EMBERS — Firelands drift. Populated by shattering-theme.js.
   ═══════════════════════════════════════════════════════════════════ */
.ember {
  position: absolute;
  bottom: -8px;
  border-radius: 9999px;
  background: #FF7A1F;
  box-shadow: 0 0 8px 2px rgba(255, 122, 31, 0.7);
  animation: ember-rise linear infinite;
  opacity: 0;
  pointer-events: none;
}
@keyframes ember-rise {
  0%   { transform: translate(0, 0) scale(1); opacity: 0; }
  8%   { opacity: 0.9; }
  70%  { opacity: 0.5; }
  100% { transform: translate(var(--drift, 24px), -46vh) scale(0.25); opacity: 0; }
}

/* ── Scroll reveal ──────────────────────────────────────────────── */
[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
[data-reveal].revealed { opacity: 1; transform: none; }

/* ═══════════════════════════════════════════════════════════════════
   CDN FALLBACK
   shattering-theme.js stamps data-no-tailwind="1" on <html> when the
   Tailwind Play CDN did not load. Everything above is local CSS and
   still applies; these rules cover the few utility-only affordances
   the static chrome leans on, and stop un-rendered Lucide <i> stubs
   from collapsing the layouts they sit in.
   ═══════════════════════════════════════════════════════════════════ */
[data-no-tailwind] body {
  background-color: var(--sh-abyss);
  color: #d6d3d1;
  font-family: var(--sh-font-body);
}
[data-no-tailwind] h1,
[data-no-tailwind] h2,
[data-no-tailwind] h3 {
  font-family: var(--sh-font-gothic);
  letter-spacing: 0.1em;
}

/* An <i data-lucide> that never got replaced by an <svg> has no
   intrinsic size — give it one so icon slots keep their footprint. */
i[data-lucide] {
  display: inline-block;
  min-width: 1em;
  min-height: 1em;
  vertical-align: -0.125em;
}
i[data-lucide] > svg { display: block; width: 100%; height: 100%; }

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cta-relic,
  .ember { animation: none !important; }
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  .rune-card:hover,
  .loot-slot:hover { transform: none !important; }
  * { scroll-behavior: auto !important; }
}
