/* ============================================
   Magic — The Judge · Shared Shell (Card-Game Arena)
   Inspired by MTG Arena, Hearthstone, Shadowverse, Gwent.
   Palette: gold + arcane violet + crimson over dark void.
   ============================================ */

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

:root {
  /* --- Core Palette (Arena) --- */
  --void: #0A0612;
  --void-deep: #050309;
  --void-warm: #13090A;           /* wood/felt shadow */
  --panel: #14091F;
  --panel-warm: #1C110A;          /* parchment shadow panel */

  --glass: rgba(20, 9, 31, 0.68);
  --glass-hover: rgba(20, 9, 31, 0.82);
  --glass-border: rgba(212, 162, 76, 0.22);
  --glass-border-hover: rgba(242, 198, 109, 0.40);

  /* Primary: Vintage Mana Gold */
  --gold: #D4A24C;
  --gold-bright: #F2C66D;
  --gold-deep: #8B6A2C;
  --gold-dim: rgba(212, 162, 76, 0.55);
  --gold-glow: rgba(242, 198, 109, 0.22);
  --gold-5:  rgba(212, 162, 76, 0.05);
  --gold-8:  rgba(212, 162, 76, 0.10);
  --gold-15: rgba(212, 162, 76, 0.18);
  --gold-25: rgba(212, 162, 76, 0.30);
  --gold-35: rgba(212, 162, 76, 0.45);

  /* Secondary: Arcane Violet */
  --arcane: #9B7BE8;
  --arcane-deep: #6B4FB8;
  --arcane-dim: rgba(155, 123, 232, 0.50);
  --arcane-glow: rgba(155, 123, 232, 0.22);

  /* Tertiary (kept for continuity): Teal glow */
  --cyan: #4FD9C4;
  --cyan-dim: rgba(79, 217, 196, 0.55);
  --cyan-glow: rgba(79, 217, 196, 0.20);
  --cyan-5:  rgba(79, 217, 196, 0.05);
  --cyan-8:  rgba(79, 217, 196, 0.10);
  --cyan-15: rgba(79, 217, 196, 0.18);
  --cyan-25: rgba(79, 217, 196, 0.30);
  --cyan-35: rgba(79, 217, 196, 0.45);

  /* Purple alias (legacy) */
  --purple: var(--arcane);
  --purple-dim: var(--arcane-dim);
  --purple-glow: var(--arcane-glow);

  /* Crimson — red mana / danger */
  --crimson: #C84A4A;
  --crimson-bright: #E26A6A;
  --danger: #E26A6A;

  /* Warning — parchment amber */
  --warning: #E0A450;
  --parchment: #E8D9B6;

  /* Text — WCAG AA on --void-deep (#050309). text >= 12:1, muted >= 7:1 */
  --text: #EBDFC2;               /* body copy — warm parchment, ~13:1 on void */
  --text-muted: #C8B68C;         /* secondary — muted gold-parchment, ~8.5:1 */
  --text-bright: #F6ECD1;        /* emphasis — warm off-white */
  --text-gold: #F2C66D;

  /* --- Font Size Tokens --- */
  --fs-xs: 10px;
  --fs-sm: 11px;
  --fs-base: 13px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 30px;
  --fs-display: 56px;

  /* --- Letter Spacing Tokens --- */
  --ls-tight: 0.5px;
  --ls-normal: 1.5px;
  --ls-wide: 3px;
  --ls-display: 8px;

  /* --- Border Radius Tokens --- */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-card: 14px;       /* MTG card corner */
  --radius-full: 50%;

  /* --- Fonts --- */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Cinzel', 'Libre Caslon Text', 'Trajan Pro', Georgia, serif;
  --font-serif: 'Libre Caslon Text', 'IM Fell DW Pica', Georgia, serif;

  /* --- Motion --- */
  --ease-card: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--void-deep);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Atmospheric Background: arcane glows + parchment grain ---- */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 900px 650px at 15% 15%, rgba(155, 123, 232, 0.10), transparent 60%),
    radial-gradient(ellipse 700px 900px at 85% 80%, rgba(212, 162, 76, 0.08), transparent 55%),
    radial-gradient(ellipse 1300px 1300px at 50% -10%, rgba(107, 79, 184, 0.05), transparent 60%),
    radial-gradient(ellipse 500px 500px at 50% 100%, rgba(200, 74, 74, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle parchment/noise grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.85  0 0 0 0 0.72  0 0 0 0 0.45  0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.55;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}

/* ---- Floating embers (replaces scan-line particles) ---- */

.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-bright) 0%, transparent 70%);
  opacity: 0;
  filter: blur(0.5px);
  animation: float-ember var(--duration) linear infinite;
  animation-delay: var(--delay);
  left: var(--x);
  bottom: -10px;
  box-shadow: 0 0 8px var(--gold-glow);
}

.particle:nth-child(3n) {
  background: radial-gradient(circle, var(--arcane) 0%, transparent 70%);
  box-shadow: 0 0 10px var(--arcane-glow);
}

@keyframes float-ember {
  0%   { transform: translateY(0) translateX(0) scale(0.8); opacity: 0; }
  10%  { opacity: 0.8; }
  50%  { transform: translateY(-50vh) translateX(12px) scale(1); }
  90%  { opacity: 0.6; }
  100% { transform: translateY(-105vh) translateX(-8px) scale(0.5); opacity: 0; }
}

/* ---- Skip Link ---- */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px 16px;
  background: var(--gold);
  color: var(--void-deep);
  font-family: var(--font-mono);
  font-size: 12px;
  z-index: 10000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ---- Sticky Navigation ---- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(10, 6, 18, 0.92) 0%, rgba(10, 6, 18, 0.78) 100%);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 1px 0 rgba(242, 198, 109, 0.08), 0 8px 24px rgba(0, 0, 0, 0.4);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.site-nav::after {
  /* hairline gold gradient under nav */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--gold-dim) 50%, transparent 95%);
  pointer-events: none;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: var(--ls-display);
  color: var(--text-bright);
  text-transform: uppercase;
  text-decoration: none;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(242, 198, 109, 0.25);
  transition: filter 200ms ease;
}

.nav-logo:hover {
  filter: brightness(1.15) drop-shadow(0 0 8px var(--gold-glow));
}

.nav-links {
  display: flex;
  gap: 1.75rem;
  align-items: center;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: var(--ls-tight);
  color: var(--text-muted);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 200ms ease-out, text-shadow 200ms ease-out;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 50%; right: 50%; bottom: -6px;
  height: 1px;
  background: var(--gold);
  opacity: 0;
  transition: left 220ms var(--ease-card), right 220ms var(--ease-card), opacity 220ms ease-out;
}

.nav-links a:hover {
  color: var(--gold-bright);
  text-shadow: 0 0 14px var(--gold-glow);
}

.nav-links a:hover::after {
  left: 0; right: 0; opacity: 1;
}

.nav-links .nav-cta {
  color: var(--void-deep);
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-deep) 100%);
  border: 1px solid var(--gold);
  padding: 0.38rem 0.95rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 0 12px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
  transition: transform 180ms var(--ease-spring), box-shadow 200ms ease, filter 200ms ease;
}

.nav-links .nav-cta::after { display: none; }

.nav-links .nav-cta:hover {
  color: var(--void-deep);
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), 0 0 22px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
}

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 101;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--gold-dim);
  border-radius: 1px;
  transition: background 200ms ease;
}
.nav-hamburger:hover span { background: var(--gold-bright); }

.nav-mobile-panel {
  display: none;
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  background: rgba(10, 6, 18, 0.98);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  flex-direction: column;
  padding: 1rem 1.5rem;
  gap: 1rem;
  z-index: 99;
}
.nav-mobile-panel a {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: var(--ls-tight);
  color: var(--text-muted);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 200ms ease-out;
}
.nav-mobile-panel a:hover { color: var(--gold-bright); }
.nav-mobile-panel .nav-cta {
  color: var(--void-deep);
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-deep) 100%);
  border: 1px solid var(--gold);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 700;
  transition: filter 200ms ease-out;
}
.nav-mobile-panel .nav-cta:hover { filter: brightness(1.1); color: var(--void-deep); }
.nav-mobile-panel.open { display: flex; }

/* ---- Layout ---- */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
  z-index: 3;
}

.doc-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
  z-index: 3;
}

/* ---- Glass / Card Panel ("Card Frame" aesthetic) ---- */

.glass {
  position: relative;
  background:
    linear-gradient(180deg, rgba(28, 17, 10, 0.55) 0%, rgba(20, 9, 31, 0.78) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow:
    0 1px 0 rgba(242, 198, 109, 0.08) inset,
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 18px 40px rgba(0, 0, 0, 0.45);
}

.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(242, 198, 109, 0.08), transparent 35%),
    linear-gradient(0deg, rgba(155, 123, 232, 0.05), transparent 30%);
}

.glass::after {
  /* top gold hairline (card frame shine) */
  content: '';
  position: absolute;
  top: 0; left: 8%; right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 20%, var(--gold-bright) 50%, var(--gold-dim) 80%, transparent);
  pointer-events: none;
  opacity: 0.85;
}

/* ---- Footer ---- */

.site-footer {
  position: relative;
  border-top: 1px solid var(--glass-border);
  padding: 3.5rem 0 2.5rem;
  text-align: center;
  margin-top: 4rem;
  background: linear-gradient(180deg, transparent 0%, rgba(28, 17, 10, 0.25) 100%);
}

.site-footer::before {
  content: '';
  position: absolute;
  top: -1px; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 30%, var(--gold-bright) 50%, var(--gold-dim) 70%, transparent);
}

.footer-logo {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.footer-legal {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.75;
  margin-bottom: 1.5rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
  font-style: italic;
}

.footer-nav {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.footer-nav a {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: var(--ls-normal);
  text-transform: uppercase;
  transition: color 200ms ease-out, text-shadow 200ms ease-out;
}

.footer-nav a:hover {
  color: var(--gold-bright);
  text-shadow: 0 0 10px var(--gold-glow);
}

.footer-copy {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  opacity: 0.5;
  letter-spacing: var(--ls-tight);
}

/* ---- Responsive ---- */

@media (max-width: 640px) {
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  .footer-nav { gap: 1rem; }
}

/* ---- Reduced Motion ---- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .particles { display: none; }
}
