/* Word Showers — game styling.
 *
 * Scoped under #ws-root so nothing leaks into the surrounding Lincoln.Life
 * page chrome (header, signpost, footer). Everything else (breadcrumb,
 * h1, leaderboard) inherits from lincoln_life.css.
 *
 * The inner game UI keeps the dark "rain at night" feel from
 * wordshowers.com so the play area looks like a game and not a form.
 * Stat pills, leaderboard rows, and the sign-in nudge use Lincoln.Life
 * neutral styling for consistency with Family Matters / Directory.
 */

/* Local variables — kept off :root so the rest of the site's variables
   aren't shadowed accidentally. */
#ws-root {
  --ws-rain-blue: #4a90d9;
  --ws-rain-light: #7eb8e8;
  --ws-puddle: #3a7bd5;
  --ws-bg: linear-gradient(180deg, #0a1628 0%, #1a2a4a 60%, #2a3f6a 100%);
  --ws-accent: #ffd700;
  --ws-danger: #ff4757;
  --ws-success: #2ed573;
  --ws-text: #e0e8f5;

  display: block;
  background: var(--ws-bg);
  color: var(--ws-text);
  border-radius: 12px;
  padding: 1.25rem 1rem 1.5rem;
  margin: 1rem 0 2rem;
  min-height: 360px;
  position: relative;
  /* No overflow:hidden — letters animate in from above the puddle and
     would otherwise be clipped to invisibility during the fall. */
}

#ws-root .ws-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#ws-root .ws-loading {
  text-align: center;
  padding: 2rem;
  font-size: 1rem;
  color: var(--ws-rain-light);
}

/* Stats row */
#ws-root .ws-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
#ws-root .ws-pill {
  background: rgba(74, 144, 217, 0.15);
  border: 1px solid rgba(126, 184, 232, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
}
#ws-root .ws-streak {
  display: inline-flex;
  gap: 4px;
  padding-left: 0.5rem;
}
#ws-root .ws-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ws-rain-light);
  display: inline-block;
}
#ws-root .ws-dot.filled {
  background: var(--ws-accent);
  border-color: var(--ws-accent);
}

/* Menu */
#ws-root .ws-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
  padding: 0.75rem 0;
}
#ws-root .ws-tagline {
  font-size: 1.05rem;
  opacity: 0.85;
  max-width: 400px;
  margin: 0;
}
#ws-root .ws-mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  width: 100%;
  max-width: 460px;
}
#ws-root .ws-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(126, 184, 232, 0.2);
  color: var(--ws-rain-light);
  padding: 0.7rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s, border-color 0.15s;
}
#ws-root .ws-mode-btn:hover,
#ws-root .ws-mode-btn:focus {
  background: rgba(126, 184, 232, 0.12);
  border-color: rgba(126, 184, 232, 0.45);
  outline: none;
}
#ws-root .ws-mode-btn.active {
  background: rgba(74, 144, 217, 0.22);
  border-color: var(--ws-rain-blue);
  color: white;
}
#ws-root .ws-mode-name { font-weight: 700; font-size: 0.95rem; }
#ws-root .ws-mode-desc { font-size: 0.75rem; opacity: 0.7; }

#ws-root .ws-play-btn {
  background: linear-gradient(135deg, var(--ws-rain-blue), var(--ws-puddle));
  color: white;
  border: none;
  padding: 0.85rem 2.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 1px;
  font-family: inherit;
  box-shadow: 0 4px 18px rgba(58, 123, 213, 0.3);
}
#ws-root .ws-play-btn:hover { filter: brightness(1.08); }
#ws-root .ws-play-btn:focus { outline: 3px solid var(--ws-accent); outline-offset: 2px; }

#ws-root .ws-accessible-btn {
  background: transparent;
  color: var(--ws-rain-light);
  border: 1px solid var(--ws-rain-light);
  padding: 0.45rem 1.25rem;
  font-size: 0.9rem;
  border-radius: 25px;
  cursor: pointer;
  font-family: inherit;
}
#ws-root .ws-accessible-btn.active {
  background: rgba(46, 213, 115, 0.18);
  border-color: var(--ws-success);
  color: var(--ws-success);
}
#ws-root .ws-accessible-btn:focus { outline: 3px solid var(--ws-accent); outline-offset: 2px; }

/* Play area */
#ws-root .ws-play {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}
#ws-root .ws-speaking {
  text-align: center;
  font-size: 1rem;
  color: var(--ws-rain-light);
  opacity: 0.7;
  padding: 1rem;
  margin: 0;
}
#ws-root .ws-guess-area { padding: 0.4rem 0; }

#ws-root .ws-timer {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-bottom: 1.4rem;
}
#ws-root .ws-timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ws-rain-blue), var(--ws-rain-light));
  border-radius: 4px;
  transition: width 1s linear;
}
#ws-root .ws-timer.urgent .ws-timer-bar {
  background: linear-gradient(90deg, var(--ws-danger), #ff6b81);
}
#ws-root .ws-timer-text {
  position: absolute;
  right: 0;
  top: -22px;
  font-size: 0.85rem;
  font-weight: 700;
}
#ws-root .ws-timer.urgent .ws-timer-text { color: var(--ws-danger); }

#ws-root .ws-form {
  display: flex;
  gap: 0.5rem;
}
#ws-root .ws-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--ws-rain-blue);
  color: white;
  padding: 0.7rem 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 12px;
  outline: none;
  letter-spacing: 2px;
  text-transform: lowercase;
  font-family: inherit;
}
#ws-root .ws-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0;
  font-weight: 400;
  font-size: 0.95rem;
}
#ws-root .ws-input:focus {
  border-color: var(--ws-rain-light);
  box-shadow: 0 0 12px rgba(58, 123, 213, 0.4);
}
#ws-root .ws-submit-btn {
  background: var(--ws-rain-blue);
  color: white;
  border: none;
  padding: 0.7rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}
#ws-root .ws-submit-btn:hover { background: var(--ws-puddle); }
#ws-root .ws-submit-btn:focus { outline: 3px solid var(--ws-accent); outline-offset: 2px; }

/* Visual scrambled letters — decorative; aria-hidden in markup.
   Letters shower down from above the puddle one after another, then
   settle into place with a small bounce. The animation runs purely
   from CSS — every new word recreates the .ws-letter elements, which
   restarts the keyframes via the staggered animation-delay below. */
#ws-root .ws-puddle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(58, 123, 213, 0.4) 0%, rgba(58, 123, 213, 0.08) 70%, transparent 100%);
  border-radius: 200px;
  padding: 1.2rem 2rem;
  margin: 0 auto;
  min-height: 4.5rem;
  align-items: center;
  max-width: 480px;
  overflow: visible;
}

@keyframes ws-letter-shower {
  /* Letters fall ~200px from above the puddle — long enough to feel
     like a proper shower without leaving the column of the play area.
     Single small splash on landing (no spring overshoot). */
  0%   { transform: translateY(-200px) scale(1.3); opacity: 0; }
  15%  { opacity: 1; }
  88%  { transform: translateY(0) scale(1); opacity: 1; }
  94%  { transform: translateY(-4px) scale(1.02); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Animation properties as longhand so a per-letter inline
   animation-delay (set by JS) can't be reset by the shorthand. */
#ws-root .ws-letter {
  font-size: 2rem;
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  display: inline-block;
  animation-name: ws-letter-shower;
  animation-duration: 0.95s;
  /* ease-in for a proper gravity feel — accelerating fall, not springy. */
  animation-timing-function: cubic-bezier(0.55, 0.05, 0.45, 0.95);
  animation-fill-mode: both;
  animation-iteration-count: 1;
}

/* Colour rotation through the rainbow palette — keyed off the JS-set
   data-i attribute (cycles every 5 letters) rather than :nth-child so
   the colour pattern is consistent regardless of word length. */
#ws-root .ws-letter[data-i="1"] { color: #ff6b9d; text-shadow: 0 0 8px rgba(255, 107, 157, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4); }
#ws-root .ws-letter[data-i="2"] { color: #4fc3f7; text-shadow: 0 0 8px rgba(79, 195, 247, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4); }
#ws-root .ws-letter[data-i="3"] { color: #81c784; text-shadow: 0 0 8px rgba(129, 199, 132, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4); }
#ws-root .ws-letter[data-i="4"] { color: #ce93d8; text-shadow: 0 0 8px rgba(206, 147, 216, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4); }

/* Once the shower has finished, subsequent re-renders within the same
   word (e.g. speaking→guessing transition) keep letters in place rather
   than replaying the cascade. */
#ws-root .ws-letter.settled {
  animation: none;
}

/* Honour reduced-motion preference — drop the cascade, keep the puddle
   so the layout is still meaningful for non-screen-reader sighted users
   who just don't want bouncing. */
@media (prefers-reduced-motion: reduce) {
  #ws-root .ws-letter {
    animation: none;
  }
}

/* Game over */
#ws-root .ws-gameover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.5rem;
  text-align: center;
}
#ws-root .ws-go-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--ws-rain-light);
  margin: 0;
}
#ws-root .ws-go-word { margin: 0; opacity: 0.85; }
#ws-root .ws-go-word strong { color: var(--ws-accent); letter-spacing: 2px; }
#ws-root .ws-go-stats {
  display: flex;
  gap: 2rem;
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}
#ws-root .ws-go-stats li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
#ws-root .ws-go-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ws-accent);
}
#ws-root .ws-go-label {
  font-size: 0.75rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#ws-root .ws-submit-msg {
  background: rgba(46, 213, 115, 0.15);
  border: 1px solid rgba(46, 213, 115, 0.4);
  color: var(--ws-success);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}
#ws-root .ws-signin-after-go {
  font-size: 0.9rem;
  opacity: 0.85;
  max-width: 420px;
  margin: 0;
}
#ws-root .ws-signin-after-go a { color: var(--ws-accent); }

/* Mobile */
@media (max-width: 480px) {
  #ws-root .ws-mode-picker { grid-template-columns: 1fr; }
  #ws-root .ws-letter { font-size: 1.5rem; }
  #ws-root .ws-puddle { padding: 0.8rem 1rem; }
  #ws-root .ws-go-stats { gap: 1.2rem; }
  #ws-root .ws-go-value { font-size: 1.6rem; }
}

/* ============================================================
   Game/competition section pages — styling for cards, leaderboards,
   stat pills, sign-in nudges. Lives here rather than in
   lincoln_life.css so the games section is self-contained and
   can be stripped if a franchise turns the section off.
   ============================================================ */

.games-card,
.competitions-card,
.signin-nudge {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  background: rgba(255, 255, 255, 0.6);
}

.signin-nudge {
  background: rgba(255, 215, 0, 0.08);
  border-color: rgba(255, 165, 0, 0.35);
}

.signin-nudge h2,
.signin-nudge h3 {
  margin-top: 0;
}

.game-shortlist,
.game-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.game-shortlist li,
.game-list li {
  margin: 0.4rem 0;
}

.game-leaderboard {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
}

.game-leaderboard li {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.95rem;
}

.game-leaderboard .rank {
  font-weight: 700;
  color: #5a3d00;
}

.game-leaderboard .player { font-weight: 600; }
.game-leaderboard .score { opacity: 0.75; }

.leaderboard-block {
  margin: 1rem 0;
}

.my-stats {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
  background: rgba(255, 255, 255, 0.7);
}

.my-stats h2 { margin-top: 0; }

.stat-pills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat-pills li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 7rem;
}

.stat-pills .stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
}

.stat-pills .stat-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.coming-soon-card {
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.coming-soon-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.coming-soon-list li {
  margin: 0.75rem 0;
}

.coming-soon-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  opacity: 0.7;
}

/* Game controls — Restart / Leave game strip surfaced during play and
 * gameover so members can change difficulty / accessibility / pick a
 * different game without hunting in the breadcrumb trail.
 */
.ws-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin: 0.5rem 0 1rem;
}

.ws-control-btn {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: #f4f7fb;
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.ws-control-btn:hover { background: #e2eaf6; }
.ws-control-btn:focus { outline: 3px solid #2563eb; outline-offset: 2px; }

.ws-control-leave {
  border-color: rgba(0, 0, 0, 0.3);
}

.ws-go-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.75rem;
}
