/*
 * Doodle Dash — supplemental styles (game-specific, beyond what's in the Astro page)
 * The main styles live inline in doodle-dash/index.astro via <style is:global>.
 * This file is loaded as a separate stylesheet for cache-ability.
 */

/* ── Drawer indicator ────────────────────────────────────────────── */
.dd-drawer-badge {
  display: inline-block;
  background: #f5a623;
  color: #1a1a2e;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Close-guess feedback ────────────────────────────────────────── */
.dd-close-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(245, 166, 35, 0.9);
  color: #1a1a2e;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
  animation: dd-close-in 0.3s ease, dd-close-out 0.5s ease 2s forwards;
}

@keyframes dd-close-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes dd-close-out {
  to { opacity: 0; }
}

/* ── Hint letter reveal ──────────────────────────────────────────── */
.dd-hint-letter.revealed {
  color: #f5a623;
  animation: dd-flip 0.4s ease;
}

@keyframes dd-flip {
  0%   { transform: rotateX(90deg); opacity: 0; }
  100% { transform: rotateX(0deg);  opacity: 1; }
}

/* ── Correct-guess celebration ───────────────────────────────────── */
.dd-correct-flash {
  animation: dd-correct-bg 0.6s ease;
}

@keyframes dd-correct-bg {
  0%   { background: #4caf50; }
  100% { background: transparent; }
}

/* ── Star vote animation ─────────────────────────────────────────── */
.dd-star-pop {
  animation: dd-star-pop 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes dd-star-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ── Score delta fly-up ──────────────────────────────────────────── */
.dd-score-delta {
  position: absolute;
  font-size: 1.2rem;
  font-weight: 900;
  color: #4caf50;
  pointer-events: none;
  animation: dd-delta-up 1.2s ease forwards;
}

@keyframes dd-delta-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ── Leaderboard highlight (winner) ─────────────────────────────── */
.dd-score-row:first-child .dd-score-rank::before {
  content: '👑 ';
}

/* ── Speed draw: canvas hidden during draw phase ─────────────────── */
.sd-hidden-during-draw {
  filter: blur(12px);
  pointer-events: none;
  user-select: none;
}

/* ── Room code copy feedback ─────────────────────────────────────── */
.dd-room-code.copied {
  border-color: #4caf50;
  color: #4caf50;
}

/* ── Touch target minimum sizes (desktop — relaxed for toolbar density) ── */
@media (min-width: 701px) {
  .dd-tool-btn {
    min-width: 38px;
    min-height: 38px;
  }
  /* Color swatches and size buttons use their declared sizes on desktop */
}
.dd-color-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
}
.dd-size-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}
.dd-chat-send {
  min-height: 44px;
}

/* ── Focus visible (a11y HIGH-1) ────────────────────────────────── */
.dd-tool-btn:focus-visible,
.dd-mode-btn:focus-visible,
.dd-btn-primary:focus-visible,
.dd-btn-secondary:focus-visible,
.dd-word-choice-btn:focus-visible,
.dd-chat-send:focus-visible,
.dd-star-btn:focus-visible,
.dd-size-btn:focus-visible,
.dd-color-swatch:focus-visible {
  outline: 3px solid #f5a623;
  outline-offset: 2px;
}

/* ── Mobile: compact toolbar that fits without scrolling ─────────── */
@media (max-width: 700px) {
  .dd-toolbar {
    display: grid;
    grid-template-columns: auto auto;
    gap: 4px;
    padding: 6px 8px;
    align-items: center;
  }
  .dd-toolbar .dd-tool-group { display: flex; gap: 3px; align-items: center; }
  .dd-toolbar .dd-brush-size { gap: 3px; }
  .dd-color-palette {
    grid-column: 1 / -1;
    max-width: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
  }
  .dd-divider { display: none; }
  .dd-tool-btn { min-width: 32px; min-height: 32px; width: 32px; height: 32px; font-size: 0.9rem; }
  .dd-size-btn { min-width: unset; min-height: unset; }
  .dd-size-btn.sz-s { width: 12px; height: 12px; }
  .dd-size-btn.sz-m { width: 18px; height: 18px; }
  .dd-size-btn.sz-l { width: 24px; height: 24px; }
  .dd-size-btn.sz-xl { width: 30px; height: 30px; }
  .dd-color-swatch { min-width: unset; min-height: unset; width: 20px; height: 20px; }
}
@media (max-width: 375px) {
  .dd-toolbar { padding: 4px 6px; gap: 3px; }
  .dd-tool-btn { min-width: 28px; min-height: 28px; width: 28px; height: 28px; font-size: 0.8rem; }
  .dd-color-swatch { width: 18px; height: 18px; }
}

/* ── Close guess toast ──────────────────────────────────────────── */
.dd-close-notif {
  background: rgba(251, 146, 60, 0.95) !important;
  color: #1a1a2e !important;
}

@keyframes dd-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.dd-shake {
  animation: dd-shake 0.4s ease;
}

/* ── Drawing reactions ──────────────────────────────────────────── */
.dd-reaction-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}

.dd-reaction-float {
  position: absolute;
  bottom: 0;
  font-size: 2rem;
  animation: dd-react-up 2s ease-out forwards;
  pointer-events: none;
}

@keyframes dd-react-up {
  0%   { transform: translateY(0) scale(0.5); opacity: 1; }
  50%  { transform: translateY(-50%) scale(1.2); opacity: 1; }
  100% { transform: translateY(-100%) scale(1); opacity: 0; }
}

.dd-reaction-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 6px 8px;
  background: #16213e;
  border-radius: 10px;
}
.dd-reaction-bar.hidden { display: none; }

.dd-reaction-btn {
  background: transparent;
  border: 2px solid transparent;
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dd-reaction-btn:hover { transform: scale(1.15); background: rgba(245,166,35,0.1); }
.dd-reaction-btn:active { transform: scale(0.95); }
.dd-reaction-btn.cooldown { opacity: 0.4; pointer-events: none; }

@media (max-width: 700px) {
  .dd-reaction-btn { width: 34px; height: 34px; font-size: 1.2rem; }
  .dd-reaction-bar { gap: 4px; padding: 4px 6px; }
}

/* ── Streak badge ───────────────────────────────────────────────── */
.dd-streak {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(251, 146, 60, 0.2);
  color: #fb923c;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* ── Word pack selection ─────────────────────────────────────────── */
.dd-pack-section {
  background: rgba(22,33,62,0.5);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 12px;
}
.dd-pack-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.dd-pack-card {
  flex-shrink: 0;
  width: 90px;
  padding: 10px 8px;
  background: rgba(13,21,38,0.8);
  border: 2px solid #333;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
.dd-pack-card:hover { transform: translateY(-2px); border-color: #555; }
.dd-pack-card.active {
  border-color: #f5a623;
  background: rgba(245,166,35,0.08);
}
.dd-pack-icon { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.dd-pack-name { font-size: 0.72rem; font-weight: 700; color: #fff; line-height: 1.2; }
.dd-pack-count { font-size: 0.6rem; color: #888; margin-top: 2px; }

.dd-custom-textarea {
  width: 100%;
  background: rgba(13,21,38,0.8);
  border: 1px solid #333;
  color: #fff;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  resize: vertical;
  margin-top: 8px;
  box-sizing: border-box;
}
.dd-custom-textarea:focus { border-color: #f5a623; outline: none; }
.dd-custom-word-count {
  font-size: 0.75rem;
  color: #888;
  text-align: right;
  margin-top: 4px;
}
.dd-custom-word-count.valid { color: #4ade80; }
.dd-custom-word-count.invalid { color: #ff4444; }

/* ── Rounds selector ─────────────────────────────────────────────── */
.dd-rounds-section {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.dd-rounds-select {
  display: flex;
  gap: 6px;
}
.dd-round-opt {
  background: rgba(13,21,38,0.8);
  border: 2px solid #333;
  color: #fff;
  width: 40px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: border-color 0.2s, background 0.2s;
}
.dd-round-opt:hover { border-color: #555; }
.dd-round-opt.active {
  border-color: #f5a623;
  background: rgba(245,166,35,0.1);
  color: #f5a623;
}

/* ── Drawing replay ─────────────────────────────────────────────── */
.dd-replay-wrap {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  aspect-ratio: 4/3;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #333;
  position: relative;
}
.dd-replay-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.dd-replay-label {
  text-align: center;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 6px;
}
.dd-replay-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #f5a623, #ff6b6b);
  transition: width 0.1s linear;
  border-radius: 0 0 10px 10px;
}

/* ── Mode tutorial ──────────────────────────────────────────────── */
.dd-mode-tutorial {
  position: relative;
  z-index: 1;
  background: rgba(22,33,62,0.6);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 380px;
  width: 100%;
}
.dd-tutorial-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f5a623;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dd-tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dd-tutorial-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #ccc;
  line-height: 1.3;
}
.dd-tutorial-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

/* ── Game Over title entrance ────────────────────────────────────── */
.dd-title-entrance {
  animation: dd-title-slam 0.6s cubic-bezier(0.36,0.07,0.19,0.97);
}
@keyframes dd-title-slam {
  0% { transform: scale(2.5) rotate(-5deg); opacity: 0; }
  50% { transform: scale(0.9) rotate(2deg); opacity: 1; }
  70% { transform: scale(1.05) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ── Podium celebration ─────────────────────────────────────────── */
.dd-podium-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  height: 240px;
  perspective: 800px;
}
.dd-podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: dd-slot-entrance 0.5s ease backwards;
}
@keyframes dd-slot-entrance {
  0% { transform: translateY(40px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Crown for 1st place */
.dd-crown {
  font-size: 1.8rem;
  animation: dd-crown-bounce 1s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(245,166,35,0.5));
}
@keyframes dd-crown-bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}

/* Avatar with sparkle ring */
.dd-podium-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dd-sparkle-ring {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px dashed #f5a623;
  animation: dd-sparkle-spin 3s linear infinite;
  opacity: 0.5;
}
@keyframes dd-sparkle-spin {
  0% { transform: rotate(0deg) scale(1); opacity: 0.5; }
  50% { transform: rotate(180deg) scale(1.1); opacity: 0.8; }
  100% { transform: rotate(360deg) scale(1); opacity: 0.5; }
}
.dd-podium-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a1a2e;
  z-index: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: dd-podium-pop 0.6s cubic-bezier(0.36,0.07,0.19,0.97) backwards;
}
.dd-podium-1st .dd-podium-avatar {
  width: 60px;
  height: 60px;
  font-size: 1.8rem;
  box-shadow: 0 0 20px rgba(245,166,35,0.4), 0 4px 16px rgba(0,0,0,0.3);
}
@keyframes dd-podium-pop {
  0% { transform: scale(0) translateY(20px); opacity: 0; }
  60% { transform: scale(1.3) translateY(-8px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.dd-podium-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  max-width: 90px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dd-podium-you {
  display: inline-block;
  background: #f5a623;
  color: #1a1a2e;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 3px;
  vertical-align: middle;
}
.dd-podium-score {
  font-size: 0.75rem;
  color: #f5a623;
  font-weight: 700;
}
.dd-podium-1st .dd-podium-score { font-size: 0.85rem; }
.dd-podium-bar {
  width: 80px;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10px;
  font-size: 1.8rem;
  font-weight: 900;
  animation: dd-bar-grow 0.8s ease backwards;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}
.dd-podium-slot:nth-child(1) { animation-delay: 0.2s; }
.dd-podium-slot:nth-child(1) .dd-podium-bar { animation-delay: 0.4s; }
.dd-podium-slot:nth-child(2) { animation-delay: 0s; }
.dd-podium-slot:nth-child(2) .dd-podium-bar { animation-delay: 0.2s; }
.dd-podium-slot:nth-child(3) { animation-delay: 0.4s; }
.dd-podium-slot:nth-child(3) .dd-podium-bar { animation-delay: 0.6s; }
@keyframes dd-bar-grow {
  0% { height: 0 !important; padding-top: 0; }
}
.dd-podium-1st .dd-podium-bar { height: 150px; color: #1a1a2e; }
.dd-podium-2nd .dd-podium-bar { height: 105px; color: #1a1a2e; }
.dd-podium-3rd .dd-podium-bar { height: 75px; color: #1a1a2e; }

/* ── Confetti ───────────────────────────────────────────────────── */
.dd-confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}
.dd-confetti {
  position: absolute;
  top: -10px;
  animation: dd-confetti-fall linear forwards;
}
@keyframes dd-confetti-fall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  50% { opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.5); opacity: 0; }
}

@media (max-width: 480px) {
  .dd-podium-wrap { height: 200px; gap: 8px; }
  .dd-podium-bar { width: 65px; }
  .dd-podium-1st .dd-podium-bar { height: 120px; }
  .dd-podium-2nd .dd-podium-bar { height: 85px; }
  .dd-podium-3rd .dd-podium-bar { height: 60px; }
  .dd-podium-avatar { width: 44px; height: 44px; font-size: 1.3rem; }
  .dd-podium-1st .dd-podium-avatar { width: 52px; height: 52px; font-size: 1.5rem; }
  .dd-crown { font-size: 1.4rem; }
}

/* ── Sabotage mode ──────────────────────────────────────────────── */
.dd-saboteur-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(239,68,68,0.95), rgba(185,28,28,0.95));
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  z-index: 20;
  animation: dd-saboteur-pulse 2s ease-in-out infinite;
  white-space: nowrap;
  pointer-events: none;
}
@keyframes dd-saboteur-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 24px rgba(239,68,68,0.7); }
}

.dd-vote-yes, .dd-vote-no {
  min-width: 140px;
  font-size: 1.05rem;
  padding: 14px 28px;
}

.dd-sabotage-reveal-icon {
  font-size: 4rem;
  animation: dd-reveal-pop 0.6s cubic-bezier(0.36,0.07,0.19,0.97);
}
@keyframes dd-reveal-pop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}
.dd-sabotage-reveal-text {
  font-size: 1.8rem;
  font-weight: 900;
  animation: dd-reveal-pop 0.6s cubic-bezier(0.36,0.07,0.19,0.97) 0.2s backwards;
}
.dd-sabotage-reveal-text.saboteur { color: #ef4444; }
.dd-sabotage-reveal-text.honest { color: #22c55e; }

/* ── Reduced motion (MED-8) ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
