/* ===========================================================================
 * Custard — League-themed visual layer
 * ---------------------------------------------------------------------------
 * Loaded AFTER the app's inline <style>, so these rules win. Adds atmospheric
 * per-page backgrounds (the live particles come from fx.js + #fxCanvas) and
 * recolors the few bits of text that sit directly on the background so they
 * stay readable on the new dark themes. All the app's white content cards are
 * left intact — they now "float" over the themed background.
 * ========================================================================= */

:root {
  --lol-gold: #f2c14e;
  --lol-gold-bright: #ffe08a;
  --lol-ivory: #f4ead0;
  --lol-teal: #2dd4bf;
}

/* Deep base lives on <html> only — it paints BEHIND the fixed canvas.
   <body> MUST stay transparent; an opaque body background paints over the
   canvas (normal-flow backgrounds render after negative z-index layers). */
html { background: #070a10; }
body { background: transparent; }

/* The animated effect layer (drawn by fx.js). Sits behind all content. */
#fxCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
}

/* A faint Hextech "circuit grid" overlay above the canvas, below content. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 600ms ease;
  background-image:
    radial-gradient(circle, rgba(242, 193, 78, 0.10) 1px, transparent 1.6px),
    repeating-linear-gradient(0deg,  transparent 0 47px, rgba(242, 193, 78, 0.045) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(242, 193, 78, 0.045) 47px 48px);
  background-size: 48px 48px, 48px 48px, 48px 48px;
}
/* Organic themes look better without the grid. */
body[data-mode="rift"]::before,
body[data-mode="arcane"]::before { opacity: 0.16; }

/* ---- Text that sits directly on the background -------------------------- */

/* Hero title: glowing gold with an animated shimmer. */
#title {
  color: var(--lol-gold-bright);
  text-shadow:
    0 2px 10px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(242, 193, 78, 0.45);
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  #title {
    background: linear-gradient(100deg, #c8902a 0%, #ffe9b0 28%, #ffd877 50%, #ffe9b0 72%, #c8902a 100%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: custardShimmer 6s linear infinite;
  }
}
@keyframes custardShimmer {
  to { background-position: 220% center; }
}

/* A glowing hextech bar under the hero. */
#custardHero::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  width: 62%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--lol-gold), transparent);
  box-shadow: 0 0 14px rgba(242, 193, 78, 0.6);
}

/* Slowly rotating conic halo behind the hero title. */
#custardHero::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 460px; height: 460px;
  max-width: 90vw; max-height: 60vw;
  transform: translate(-50%, -50%);
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(10px);
  background: conic-gradient(from 0deg,
    rgba(242,193,78,0) 0deg, rgba(242,193,78,0.20) 60deg, rgba(255,224,138,0) 130deg,
    rgba(255,224,138,0.16) 220deg, rgba(242,193,78,0) 300deg, rgba(242,193,78,0) 360deg);
  animation: custardSpin 22s linear infinite;
}
@keyframes custardSpin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* Pulsing glow on the big hextech tiles (filter, so it won't fight box-shadow). */
.mode-button button,
.statsHubButton { animation: custardGlow 4.2s ease-in-out infinite; }
@keyframes custardGlow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(242, 193, 78, 0.18)); }
  50%      { filter: drop-shadow(0 0 15px rgba(242, 193, 78, 0.5)); }
}

/* Gentle drift of the hextech grid. */
body::before { animation: custardDrift 50s linear infinite; }
@keyframes custardDrift {
  to { background-position: 48px 96px, 48px 96px, 96px 48px; }
}

/* Mode titles + the stats header (both use .modeHeader). */
.modeHeader {
  color: var(--lol-ivory);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7), 0 0 18px rgba(242, 193, 78, 0.22);
}

/* Home button captions (if shown). */
.mode-label { color: #e9edf6; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); }

/* Simulator summary lines render on the background. */
.simulatorSummary { color: var(--lol-ivory); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7); }
.simulatorAnalysisSteps { color: #e9edf6; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); }

/* Keep the "match saved" confirmation legible on dark. */
.matchSavedMessage { color: #63e08a !important; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }

/* ---- Make the big interactive tiles feel Hextech ----------------------- */

.mode-button button,
.statsHubButton {
  background: linear-gradient(180deg, #ffffff 0%, #eef1f8 100%) !important;
  border: 2px solid rgba(242, 193, 78, 0.55) !important;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.5),
    0 0 22px rgba(242, 193, 78, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6) !important;
}
.mode-button button:hover,
.statsHubButton:hover {
  border-color: rgba(255, 224, 138, 0.9) !important;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.55),
    0 0 30px rgba(242, 193, 78, 0.35) !important;
}

/* Lift the main content cards so they clearly float over the dark scene. */
.hallPodiumCard,
.historyMatchCard,
#settingsPanel,
.allChampionAwardCard,
.rivalCard {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5) !important;
  border-color: rgba(242, 193, 78, 0.3) !important;
}

/* The back/forward arrows are emoji buttons; give them a soft dark chip. */
.modeBack {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

/* ---- Motion preferences ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  #title, #custardHero::before, .mode-button button, .statsHubButton, body::before { animation: none; }
  body::before { transition: none; }
}
body.effects-reduced #title,
body.effects-reduced #custardHero::before,
body.effects-reduced .mode-button button,
body.effects-reduced .statsHubButton,
body.effects-reduced::before { animation: none; }

/* ===========================================================================
 * Phone layout (<= 600px): make everything fit the screen — no side-scroll.
 * The app shipped with only a 1280px breakpoint, so phones used the laptop
 * layout (side-by-side teams, a 4x130px button grid) and overflowed.
 * ========================================================================= */
@media (max-width: 600px) {
  /* The app forces body{min-width:1000px} below 1280px (it was desktop-only).
     Undo that so the phone uses its real width instead of a 1000px canvas. */
  html, body { overflow-x: hidden; }
  body { min-width: 0 !important; }

  /* Some modes are pinned to height:100vh + overflow:hidden below 1280px,
     which clips taller phone content — let them grow and scroll vertically. */
  #classicMode, #classicDraftMode, #simulatorMode, #statsMode, #settingsMode {
    height: auto !important;
    min-height: 100vh;
    overflow: visible !important;
  }

  /* Home hero + mode buttons (wrap into a tidy 2x2). */
  #custardHero { min-width: 0; height: auto; margin-bottom: 26px; }
  #title { font-size: 44px; letter-spacing: -1px; }
  .mode-container { flex-wrap: wrap; gap: 16px; max-width: 208px; margin: 0 auto; }
  .mode-button button { width: 88px !important; height: 88px !important; font-size: 40px !important; }

  /* Stats hub: 3 across instead of 4x130px. */
  .statsHubGrid { grid-template-columns: repeat(3, 88px); gap: 16px; margin-top: 30px; }
  .statsHubButton { width: 88px !important; height: 88px !important; font-size: 40px !important; }

  .modeHeader { font-size: 26px; }

  /* Simulator + Draft: stack the two teams vertically. */
  #simulatorTeams,
  #classicDraftTeams { grid-template-columns: 1fr; gap: 16px; }

  /* Let the grid items actually shrink so the Name + Champion fields fit
     (grid/flex items default to min-width:auto and overflow otherwise). */
  #simulatorTeams, #classicDraftTeams,
  .simulatorTeam, .classicDraftTeam,
  .simulatorRoleRows, .classicDraftRoleRows,
  .simulatorRoleRow, .classicDraftRoleRow,
  .simulatorRoleRow > *, .classicDraftRoleRow > * { min-width: 0; }

  /* Draft win buttons: stack instead of 3-across (190px buttons overflowed). */
  #classicDraftActionRow { grid-template-columns: 1fr; gap: 12px; }
  #classicDraftActionRow .winnerButton { min-width: 0; width: 100%; }

  /* The mode bodies use fixed pixel widths on desktop (e.g. #simulatorBody is
     900px, #statsBody 920px) and rely on the old horizontal scroll. Make them
     fluid so they fit the phone. */
  #simulatorBody, #classicBody, #classicDraftBody, #statsBody,
  #classicWrapper, #classicDraftLayout, #inputsPanel, #settingsPageBody {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Reclaim side padding so content uses the full width. */
  #statsMode, #settingsMode, #simulatorMode, #classicMode, #classicDraftMode {
    padding-left: 12px; padding-right: 12px;
  }
}
