/* ============================================================
   Rare Days Gems — design tokens + base styles
   Tailwind (Play CDN) handles utilities; this file holds the
   tokens and the few custom bits Tailwind can't express inline.
   ============================================================ */

:root {
  /* Surfaces (dark jewel) */
  --bg:        #141019;
  --surface:   #1E1830;
  --surface-2: #2A2340;

  /* Ink */
  --cream:     #F4F1E6;
  --muted:     #9A93B0;

  /* Gem hues */
  --blue:      #254DB1;
  --vermilion: #E3503C;
  --marigold:  #E6A62E;
  --berry:     #C42A6B;
  --pink:      #D9607A;
  --forest:    #2E8B72;
  --anchor:    #241033;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--cream);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

.font-display {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
}

::selection {
  background: var(--vermilion);
  color: var(--cream);
}

/* Keyboard focus — visible on dark surfaces */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 3px;
  border-radius: 9999px;
}

/* Pill buttons (shared shape; colour via Tailwind classes) */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 9999px;
  padding: 1rem 2rem;
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1;
  transition: transform 120ms ease, background-color 120ms ease,
              box-shadow 120ms ease, border-color 120ms ease;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}
.pill:hover { transform: translateY(-2px); }
.pill:active { transform: translateY(0); }

.pill-primary {
  background: var(--vermilion);
  color: var(--cream);
}
.pill-primary:hover { background: #ef6350; }

.pill-secondary {
  background: transparent;
  color: var(--cream);
  border: 2px solid rgba(244, 241, 230, 0.4);
  box-shadow: none;
}
.pill-secondary:hover {
  border-color: var(--cream);
  background: rgba(244, 241, 230, 0.06);
}

/* Nav links */
.nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: color 120ms ease, background-color 120ms ease;
}
@media (min-width: 768px) {
  .nav-link { padding: 0.5rem 1rem; font-size: 0.9375rem; }
}
.nav-link:hover { color: var(--cream); background: var(--surface); }
.nav-link[aria-current="page"] { color: var(--cream); background: var(--surface-2); }

/* Segmented toggles (leaderboard) */
.seg {
  display: inline-flex;
  flex-wrap: wrap; /* stack inside the pill when labels run out of room */
  background: var(--surface);
  border-radius: 1.5rem;
  padding: 0.25rem;
  gap: 0.25rem;
}
@media (max-width: 420px) {
  .seg { width: 100%; }
  .seg-btn { flex: 1 1 auto; justify-content: center; padding: 0.55rem 0.9rem; font-size: 0.875rem; }
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 120ms ease, background-color 120ms ease;
}
.seg-btn:hover { color: var(--cream); }
.seg-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--cream); }
.seg-accent .seg-btn[aria-pressed="true"] { background: var(--vermilion); }

/* Page transitions — content rises into place on entry, the whole
   page fades on exit (gemrain.js adds .page-exit before navigating) */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise-in {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }
  /* #hero-flourish is excluded: a transform on it would re-anchor its
     absolutely-positioned gems mid-animation. Fill mode is `backwards`
     (not `both`) so finished animations don't pin transform/opacity and
     block later transitions (e.g. the leaderboard toggle fade). */
  main section > *:not(#hero-flourish) { animation: rise-in 650ms cubic-bezier(0.22, 1, 0.36, 1) backwards; }
  main section > *:nth-child(2):not(#hero-flourish) { animation-delay: 90ms; }
  main section > *:nth-child(3):not(#hero-flourish) { animation-delay: 180ms; }
  main section > *:nth-child(4):not(#hero-flourish) { animation-delay: 270ms; }
  main section > *:nth-child(n+5):not(#hero-flourish) { animation-delay: 340ms; }

  body { transition: opacity 240ms ease; }
  body.page-exit { opacity: 0; }

  /* Leaderboard toggle transitions — old rows dip out, new rows
     stagger in on the same curve as the page entrance */
  #board { transition: opacity 170ms ease, transform 170ms ease; }
  #board.board-leave { opacity: 0; transform: translateY(8px); }
  .board-row {
    animation: rise-in 450ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
    animation-delay: calc(var(--i, 0) * 55ms);
  }
}

/* Hero flourish — gems drifting gently behind the headline */
.hero-gem {
  position: absolute;
  opacity: 0.85;
  animation: gem-float 7s ease-in-out infinite;
  animation-delay: var(--float-delay, 0s);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
}
@keyframes gem-float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-18px) rotate(5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-gem { animation: none; }
}

/* Gem containers get square footprints; inline SVGs fill them */
.gem-slot svg { width: 100%; height: 100%; display: block; }

/* Numbered step markers — a gem with the step number overlaid */
.step-gem {
  position: relative;
  width: 5rem;
  height: 5rem;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .step-gem { width: 6rem; height: 6rem; }
}
.step-gem svg {
  position: absolute;
  inset: 0;
}
.step-gem span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.75rem;
  color: var(--cream);
  text-shadow: 0 2px 6px rgba(36, 16, 51, 0.7);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
