/* ==========================================================================
   menu.css — Main Menu, Game Over, Highscores Screens
   Mushroom Grove — Enchanted Forest Whack-a-Mole
   ========================================================================== */

/* =========================================================================
   MAIN MENU
   ========================================================================= */

.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  max-width: 360px;
  padding: var(--space-xl) var(--space-base);
  gap: var(--space-lg);
}

/* Logo container */
.menu__logo {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-sm);
}

/* Logo image — Responsive, glow effect */
.menu__logo-img {
  max-width: 85%;
  height: auto;
  filter:
    drop-shadow(0 0 12px var(--glow-green-soft))
    drop-shadow(0 0 30px rgba(60, 255, 110, 0.12));
  animation: fadeIn 800ms var(--ease-smooth) both;
}

/* Logo text fallback — When image doesn't load */
.menu__logo-fallback {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-green-300);
  line-height: 1.1;
  text-shadow:
    0 0 10px var(--glow-green),
    0 0 20px var(--glow-green),
    0 0 40px var(--glow-green-soft),
    0 0 80px rgba(60, 255, 110, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.5);
  animation: fadeIn 800ms var(--ease-smooth) both;
  letter-spacing: 0.02em;
}

/* Subtitle */
.menu__subtitle {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: slideUp 600ms var(--ease-smooth) 200ms both;
}

/* Button group */
.menu__buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
  animation: slideUp 600ms var(--ease-smooth) 400ms both;
}

/* Hint text */
.menu__hint {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-muted);
  animation: fadeIn 600ms var(--ease-smooth) 800ms both;
  line-height: 1.4;
}


/* =========================================================================
   GAME OVER SCREEN
   ========================================================================= */

.gameover {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 380px;
  padding: var(--space-xl) var(--space-lg);
  background: var(--bg-panel);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(60, 255, 110, 0.1);
  box-shadow:
    0 0 30px rgba(60, 255, 110, 0.05),
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: slideUp 500ms var(--ease-bounce) both;
}

/* Title */
.gameover__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-amber-400);
  margin-bottom: var(--space-lg);
  text-shadow:
    0 0 10px var(--glow-amber-soft),
    0 2px 4px rgba(0, 0, 0, 0.4);
  animation: fadeIn 400ms var(--ease-smooth) 200ms both;
}

/* Stats container */
.gameover__stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* Primary score display */
.gameover__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: slideUp 400ms var(--ease-smooth) 300ms both;
}

.gameover__label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.gameover__value {
  font-family: var(--font-body);
  font-size: var(--text-4xl);
  font-weight: var(--weight-extrabold);
  color: var(--color-amber-400);
  line-height: 1;
  text-shadow:
    0 0 12px var(--glow-amber),
    0 0 24px var(--glow-amber-soft);
}

/* Detail stats grid */
.gameover__details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md) var(--space-lg);
  width: 100%;
  padding: var(--space-base) 0;
  border-top: 1px solid rgba(245, 230, 200, 0.08);
  border-bottom: 1px solid rgba(245, 230, 200, 0.08);
  animation: fadeIn 400ms var(--ease-smooth) 500ms both;
}

/* Individual stat */
.gameover__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.gameover__stat-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gameover__stat-value {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

/* New Record badge */
.gameover__newrecord {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-gold-400);
  text-shadow:
    0 0 12px var(--glow-gold),
    0 0 24px var(--glow-gold),
    0 0 48px var(--glow-gold-soft);
  animation: newRecord 2000ms ease-in-out infinite;
  padding: var(--space-sm) var(--space-base);
}

.gameover__newrecord[hidden] {
  display: none;
}

/* Buttons */
.gameover__buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
  animation: slideUp 400ms var(--ease-smooth) 600ms both;
}


/* =========================================================================
   HIGHSCORES SCREEN
   ========================================================================= */

.highscores {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 380px;
  padding: var(--space-xl) var(--space-lg);
  background: var(--bg-panel);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(60, 255, 110, 0.1);
  box-shadow:
    0 0 30px rgba(60, 255, 110, 0.05),
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  gap: var(--space-lg);
  animation: slideUp 500ms var(--ease-bounce) both;
}

/* Title */
.highscores__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-green-300);
  text-shadow:
    0 0 10px var(--glow-green-soft),
    0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Score list */
.highscores__list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 50dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Subtle scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--color-teal-600) transparent;
}

.highscores__list::-webkit-scrollbar {
  width: 4px;
}

.highscores__list::-webkit-scrollbar-track {
  background: transparent;
}

.highscores__list::-webkit-scrollbar-thumb {
  background: var(--color-teal-600);
  border-radius: var(--radius-pill);
}

/* Individual score entry */
.highscores__list li {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-base);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  transition: background-color 150ms;
}

/* Alternating backgrounds */
.highscores__list li:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.highscores__list li:nth-child(even) {
  background: rgba(0, 0, 0, 0.1);
}

/* Rank number */
.highscores__list li::before {
  counter-increment: list-item;
  content: counter(list-item) '.';
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
  font-size: var(--text-base);
}

/* Enable counter */
.highscores__list {
  counter-reset: list-item;
}

/* Score value in list row (JS can add .highscores__score / .highscores__date spans) */
.highscores__list li .highscores__score {
  font-weight: var(--weight-extrabold);
  font-size: var(--text-lg);
  color: var(--text-primary);
  flex: 1;
  text-align: left;
}

.highscores__list li .highscores__date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---- Top 3 Special Accents ---- */

/* 1st place — Gold */
.highscores__list li:nth-child(1) {
  background: linear-gradient(
    90deg,
    rgba(255, 215, 0, 0.1) 0%,
    rgba(255, 215, 0, 0.03) 100%
  );
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.highscores__list li:nth-child(1)::before {
  color: var(--color-gold-400);
  text-shadow: 0 0 6px var(--glow-gold-soft);
}

.highscores__list li:nth-child(1) .highscores__score {
  color: var(--color-gold-400);
}

/* 2nd place — Silver */
.highscores__list li:nth-child(2) {
  background: linear-gradient(
    90deg,
    rgba(192, 192, 192, 0.08) 0%,
    rgba(192, 192, 192, 0.02) 100%
  );
  border: 1px solid rgba(192, 192, 192, 0.15);
}

.highscores__list li:nth-child(2)::before {
  color: #c0c0c0;
  text-shadow: 0 0 4px rgba(192, 192, 192, 0.4);
}

.highscores__list li:nth-child(2) .highscores__score {
  color: #d0d0d0;
}

/* 3rd place — Bronze */
.highscores__list li:nth-child(3) {
  background: linear-gradient(
    90deg,
    rgba(205, 127, 50, 0.08) 0%,
    rgba(205, 127, 50, 0.02) 100%
  );
  border: 1px solid rgba(205, 127, 50, 0.15);
}

.highscores__list li:nth-child(3)::before {
  color: #cd7f32;
  text-shadow: 0 0 4px rgba(205, 127, 50, 0.4);
}

.highscores__list li:nth-child(3) .highscores__score {
  color: #d4923a;
}

/* Empty state — JS-inserted message */
.highscores__empty::before {
  content: none;
}

.highscores__empty {
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
  padding: var(--space-xl) var(--space-base);
}

/* Empty state — no children at all */
.highscores__list:empty::after {
  content: 'No scores yet. Play a game!';
  display: block;
  padding: var(--space-xl) var(--space-base);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-muted);
  font-style: italic;
}

/* Back button extra spacing */
.highscores > .btn--secondary {
  margin-top: var(--space-sm);
}


/* =========================================================================
   SCREEN ENTRANCE ANIMATIONS (staggered children)
   ========================================================================= */

/* Menu — stagger children on entrance */
.screen--menu.active .menu__logo {
  animation: fadeIn 600ms var(--ease-smooth) both;
}

.screen--menu.active .menu__subtitle {
  animation: slideUp 600ms var(--ease-smooth) 150ms both;
}

.screen--menu.active .menu__buttons {
  animation: slideUp 600ms var(--ease-smooth) 300ms both;
}

.screen--menu.active .menu__hint {
  animation: fadeIn 600ms var(--ease-smooth) 600ms both;
}

/* Game Over — stagger children on entrance */
.screen--gameover.active .gameover {
  animation: slideUp 500ms var(--ease-bounce) both;
}

.screen--gameover.active .gameover__title {
  animation: fadeIn 400ms var(--ease-smooth) 200ms both;
}

.screen--gameover.active .gameover__score {
  animation: slideUp 400ms var(--ease-smooth) 300ms both;
}

.screen--gameover.active .gameover__details {
  animation: fadeIn 400ms var(--ease-smooth) 500ms both;
}

.screen--gameover.active .gameover__buttons {
  animation: slideUp 400ms var(--ease-smooth) 600ms both;
}

/* Highscores — stagger children on entrance */
.screen--highscores.active .highscores {
  animation: slideUp 500ms var(--ease-bounce) both;
}

.screen--highscores.active .highscores__title {
  animation: fadeIn 400ms var(--ease-smooth) 150ms both;
}

.screen--highscores.active .highscores__list {
  animation: fadeIn 400ms var(--ease-smooth) 300ms both;
}

.screen--highscores.active .highscores > .btn--secondary {
  animation: slideUp 400ms var(--ease-smooth) 450ms both;
}
