/* ============================================================
   LitDigi Phase 2 — Pilar Discord Styles
   - Animated Avatar Borders, Profile Banners, Name Glows, Card Themes
   - Arcade & LitShop Modal, 4 Minigame Boards, Author Tipping UI
   ============================================================ */

@keyframes ldSpinRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes ldFloatStars {
  0% { background-position: 0 0, 40px 60px; }
  100% { background-position: 120px 180px, 160px 240px; }
}

@keyframes ldAuroraShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes ldGridScroll {
  0% { background-position: 0 0; }
  100% { background-position: 0 36px; }
}

@keyframes ldGlowPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.55)); }
  50% { filter: drop-shadow(0 0 14px rgba(56, 189, 248, 0.95)); }
}

/* ── Animated Avatar Borders ── */
.ld-avatar-fx {
  position: relative;
  border-radius: 50% !important;
  transition: box-shadow 0.25s ease;
}

.ld-fx-border_aurora_pulse {
  box-shadow: 0 0 0 3px #0ea5e9, 0 0 18px rgba(14, 165, 233, 0.75) !important;
  animation: ldGlowPulse 2.4s ease-in-out infinite;
}

.ld-fx-border_sakura_drift {
  box-shadow: 0 0 0 3px #f472b6, 0 0 18px rgba(244, 114, 182, 0.7) !important;
}

.ld-fx-border_cyber_neon {
  box-shadow: 0 0 0 3px #00e1ff, 0 0 16px #d946ef, inset 0 0 8px rgba(0, 225, 255, 0.5) !important;
}

.ld-fx-border_eclipse_gold {
  box-shadow: 0 0 0 3px #f59e0b, 0 0 22px rgba(251, 191, 36, 0.85) !important;
}

.ld-fx-border_patron_halo {
  box-shadow: 0 0 0 3px #fde047, 0 0 24px rgba(234, 179, 8, 0.95), 0 0 42px rgba(56, 189, 248, 0.45) !important;
}

/* ── Animated Profile Banners ── */
.ld-banner-fx {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.72;
}

.ld-banner-banner_starlight_free {
  background-color: #0b1120;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #ffffff, transparent),
    radial-gradient(1.5px 1.5px at 80px 90px, #7dd3fc, transparent);
  background-size: 120px 120px, 160px 160px;
  animation: ldFloatStars 14s linear infinite;
}

.ld-banner-banner_aurora_wave {
  background: linear-gradient(125deg, #0f172a, #0e7490, #10b981, #3b82f6, #0f172a);
  background-size: 300% 300%;
  animation: ldAuroraShift 9s ease infinite;
}

.ld-banner-banner_cyber_grid {
  background-color: #090d16;
  background-image:
    linear-gradient(rgba(0, 225, 255, 0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 70, 239, 0.25) 1px, transparent 1px);
  background-size: 36px 36px;
  animation: ldGridScroll 2.2s linear infinite;
}

.ld-banner-banner_ember_sparks {
  background: linear-gradient(180deg, #1a0b0e 0%, #451a03 70%, #7c2d12 100%);
  background-image:
    radial-gradient(2.5px 2.5px at 30px 40px, #fb923c, transparent),
    radial-gradient(2px 2px at 110px 70px, #fde047, transparent);
  background-size: 140px 140px;
  animation: ldFloatStars 9s linear infinite reverse;
}

.ld-banner-banner_golden_quill {
  background: linear-gradient(135deg, #1c1917, #78350f, #ca8a04, #1e293b);
  background-size: 260% 260%;
  animation: ldAuroraShift 7s ease infinite;
}

/* ── Name Glow Effects ── */
.ld-glow-glow_cyan_pulse {
  background: linear-gradient(90deg, #00e1ff, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  text-shadow: 0 0 12px rgba(0, 225, 255, 0.45);
}

.ld-glow-glow_sunset_gold {
  background: linear-gradient(90deg, #fde047, #fb923c, #f43f5e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  text-shadow: 0 0 12px rgba(251, 146, 60, 0.45);
}

.ld-glow-glow_royal_violet {
  background: linear-gradient(90deg, #c084fc, #a855f7, #38bdf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.45);
}

/* ── Profile Card Themes ── */
.ld-card-card_midnight_glass {
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35) !important;
}
.ld-card-card_obsidian_gold {
  border: 1.5px solid rgba(251, 191, 36, 0.6) !important;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.25) !important;
}
.ld-card-card_cyber_slate {
  border: 1.5px solid rgba(0, 225, 255, 0.65) !important;
  box-shadow: 0 10px 30px rgba(0, 225, 255, 0.25) !important;
}

/* ── Floating Arcade & LitShop Pill ── */
.ld-discord-fab {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 9500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 999px;
  border: 1px solid rgba(0, 225, 255, 0.45);
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #f8fafc;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.45);
  transition: transform 0.16s ease;
}
.ld-discord-fab:hover { transform: translateY(-2px); }
.ld-coin-pill {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
}
body.zen-mode .ld-discord-fab,
body.ld-in-reader .ld-discord-fab {
  display: none !important;
}

/* ── Discord Hub & Tip Modal ── */
.ld-hub-overlay {
  position: fixed;
  inset: 0;
  z-index: 10080;
  background: rgba(2, 6, 23, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.ld-hub-overlay.active { display: flex; }

.ld-hub-modal {
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.ld-hub-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #111827;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  flex-wrap: wrap;
}

.ld-hub-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  background: #0b1120;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  overflow-x: auto;
}
.ld-hub-tab {
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #1e293b;
  color: #cbd5e1;
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ld-hub-tab.active {
  background: linear-gradient(135deg, #23a6d5, #0284c7);
  border-color: #38bdf8;
  color: #ffffff;
}

.ld-hub-body {
  padding: 16px 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.ld-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.ld-card {
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ld-card h4 { margin: 0; font-size: 0.96rem; color: #f8fafc; }
.ld-card p { margin: 0; font-size: 0.8rem; color: #94a3b8; line-height: 1.45; }

.ld-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #23a6d5, #0e7490);
}
.ld-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ld-btn-sec {
  background: #334155;
  color: #e2e8f0;
}
.ld-btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #111827;
}

/* ── Katla Sastra Board ── */
.ld-katla-grid {
  display: grid;
  grid-template-rows: repeat(6, 42px);
  gap: 6px;
  justify-content: center;
  margin: 12px 0;
}
.ld-katla-row {
  display: grid;
  grid-template-columns: repeat(5, 42px);
  gap: 6px;
}
.ld-katla-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1.5px solid #475569;
  font-weight: 800;
  font-size: 1.05rem;
  text-transform: uppercase;
  background: #0f172a;
}
.ld-katla-cell.correct { background: #16a34a; border-color: #22c55e; }
.ld-katla-cell.present { background: #ca8a04; border-color: #eab308; }
.ld-katla-cell.absent  { background: #334155; border-color: #475569; }

.ld-kb {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}
.ld-kb-row { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.ld-kb-key {
  min-width: 29px;
  height: 36px;
  padding: 0 7px;
  border: none;
  border-radius: 6px;
  background: #334155;
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}
.ld-kb-key.correct { background: #16a34a; }
.ld-kb-key.present { background: #ca8a04; }
.ld-kb-key.absent  { background: #1e293b; color: #64748b; }

.ld-scramble-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}
.ld-tile-btn {
  min-width: 36px;
  height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: #0f172a;
  color: #f8fafc;
  font-weight: 700;
  cursor: pointer;
}


/* Light Mode Parity, Focus States & Reduced Motion */
body:not(.dark-mode):not(.theme-merdeka2026) .ld-discord-fab {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(2, 132, 199, 0.35);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-hub-modal {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.14);
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-hub-top,
body:not(.dark-mode):not(.theme-merdeka2026) .ld-hub-tabs {
  background: #f8fafc;
  border-bottom-color: rgba(15, 23, 42, 0.1);
}

.ld-hub-brand {
  font-size: 1.05rem;
  color: #0369a1;
}

body.dark-mode .ld-hub-brand {
  color: #38bdf8;
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-hub-tab {
  background: #ffffff;
  color: #334155;
  border-color: rgba(15, 23, 42, 0.14);
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-hub-tab.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-card {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.1);
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-card h4 {
  color: #0f172a;
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-card p {
  color: #475569;
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-btn-sec {
  background: #e2e8f0;
  color: #0f172a;
}

body:not(.dark-mode):not(.theme-merdeka2026) .ld-katla-cell {
  background: #ffffff;
  color: #0f172a;
}

.ld-discord-fab:focus-visible,
.ld-hub-modal button:focus-visible,
.ld-hub-modal input:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ld-discord-fab,
  .ld-avatar-fx,
  .ld-banner-fx {
    animation: none !important;
    transition: none !important;
  }
}


/* ==========================================================================
   Universal Discord Animated WebP Avatar Decorations (All 9 LitDigi Borders)
   126% GPU-accelerated CSS Overlay + Static Fallback + Zero Offscreen Cost
   ========================================================================== */

@property --nw-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

@keyframes ldNwSpin {
  to { --nw-angle: 360deg; }
}

.profile-header {
  overflow: visible !important;
}

.ld-banner-fx {
  border-radius: inherit;
  overflow: hidden;
}

.profile-avatar-section,
.avatar-wrapper,
.ld-shop-preview-wrap,
.ld-card.has-border-preview,
.collection-tile {
  overflow: visible !important;
}

.avatar-wrapper.ld-has-webp-deco > .avatar-fx {
  display: none !important;
}

.ld-avatar-deco-img {
  position: absolute;
  width: 126%;
  height: 126%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateZ(0);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 6;
  will-change: transform, opacity;
  object-fit: contain;
}

/* Subtle fallback ring for Netherwing even while WebP streams in */
.border-netherwing-castorice,
.ld-fx-border_netherwing_castorice {
  border: 2.5px solid transparent !important;
  background:
    linear-gradient(#060310, #060310) padding-box,
    conic-gradient(
      from var(--nw-angle, 0deg),
      #09041a 0deg,
      #3b0764 42deg,
      #7c3aed 88deg,
      #e0f2fe 128deg,
      #d946ef 176deg,
      #1e1b4b 228deg,
      #a855f7 282deg,
      #38bdf8 322deg,
      #09041a 360deg
    ) border-box !important;
  box-shadow:
    0 0 0 1px rgba(7, 3, 18, 0.78),
    0 0 12px rgba(124, 58, 237, 0.65) !important;
  animation: ldNwSpin 4.4s linear infinite;
  position: relative;
}

/* LitShop Live Border Preview */
.ld-shop-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  padding: 14px 0 10px;
}

.ld-shop-avatar-demo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #312e81 0%, #1e1b4b 62%, #070312 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e0f2fe;
  font-size: 1.35rem;
}

@media (prefers-reduced-motion: reduce) {
  .border-netherwing-castorice,
  .ld-fx-border_netherwing_castorice {
    animation: none !important;
  }
}

/* ── LitShop Tier & FX Silhouette Metadata Pills (anti-slop WCAG AA) ── */
.ld-shop-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.ld-tier-pill,
.ld-fx-tag-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.ld-tier-pill.is-mythic {
  background: rgba(147, 51, 234, 0.28);
  color: #f3e8ff;
  border: 1px solid rgba(192, 132, 252, 0.55);
}

.ld-tier-pill.is-legendary {
  background: rgba(217, 119, 6, 0.26);
  color: #fef3c7;
  border: 1px solid rgba(251, 191, 36, 0.55);
}

.ld-tier-pill.is-epic {
  background: rgba(14, 165, 233, 0.24);
  color: #e0f2fe;
  border: 1px solid rgba(56, 189, 248, 0.5);
}

.ld-fx-tag-pill {
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

body.light-mode .ld-fx-tag-pill,
:root[data-theme="light"] .ld-fx-tag-pill {
  background: rgba(15, 23, 42, 0.85);
  color: #f1f5f9;
}

/* ── Animated WebP Profile Banners & Upload Policy UI ── */
.ld-banner-fx {
  overflow: hidden;
}

.ld-banner-webp-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: translateZ(0);
  pointer-events: none;
  user-select: none;
}

.ld-shop-banner-preview {
  position: relative;
  width: 100%;
  height: 78px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #0b1120;
}

.ld-banner-policy-note {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.28);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

body.light-mode .ld-banner-policy-note,
:root[data-theme="light"] .ld-banner-policy-note {
  color: #0f172a;
  background: #f0f9ff;
  border-color: #7dd3fc;
}

.ld-banner-shop-link {
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: #0284c7;
  color: #ffffff;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
