/*
 * Rainbow Cups: Water Sort (games/water-sort/style.css)
 * Preschool-friendly glass cups, layered fruit liquids, pouring stream, and celebration FX.
 */

:root {
  --game-bg: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 52%, #e0e7ff 100%);
  --game-ink: #0f172a;
  --game-accent: #0284c7;
  --game-banner-bg: rgba(255, 255, 255, 0.85);
}

.water-workspace {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 12px;
  overflow: hidden;
  outline: none;
}

/* --- Ambient Backdrop --------------------------------------------------- */

.ambient-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.08) 70%);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.65);
}

.orb-1 {
  width: 140px;
  height: 140px;
  top: 8%;
  left: 5%;
}

.orb-2 {
  width: 96px;
  height: 96px;
  top: 16%;
  right: 7%;
}

.orb-3 {
  width: 120px;
  height: 120px;
  bottom: 14%;
  left: 12%;
}

/* --- Status Bar --------------------------------------------------------- */

.status-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  width: 100%;
  max-width: 720px;
  margin-top: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.98rem;
  font-weight: 700;
  color: #0c4a6e;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.1);
  font-variant-numeric: tabular-nums;
}

.pill-icon {
  font-size: 1.1rem;
}

.pill-num {
  color: #0284c7;
  font-weight: 800;
}

.pill-sep,
.pill-total {
  color: #64748b;
}

.level-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid #94a3b8;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.level-dot.done {
  background: #22c55e;
  border-color: #15803d;
}

.level-dot.current {
  background: #38bdf8;
  border-color: #0284c7;
  transform: scale(1.25);
}

/* --- Shelf Stage & Cups Grid -------------------------------------------- */

.shelf-stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 8px 6px;
}

.cups-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 24px 22px;
  width: 100%;
  padding: 20px 10px 4px;
}

.wooden-shelf {
  width: min(92%, 760px);
  height: 18px;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 60%, #b45309 100%);
  border-radius: 10px;
  border: 2px solid #92400e;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.18), inset 0 2px 3px rgba(254, 243, 199, 0.75);
  position: relative;
  overflow: hidden;
}

.shelf-highlight {
  position: absolute;
  top: 2px;
  left: 12px;
  right: 12px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 251, 235, 0.45);
}

/* --- Individual Glass Cup ----------------------------------------------- */

.cup-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cup-btn {
  position: relative;
  width: 96px;
  height: 196px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  touch-action: manipulation;
}

.cup-btn:focus-visible {
  outline: 4px solid #f59e0b;
  outline-offset: 6px;
  border-radius: 24px;
}

.cup-btn.is-selected {
  transform: translateY(-22px) scale(1.05);
  z-index: 6;
}

.cup-btn.is-selected .cup-glass {
  border-color: #0284c7;
  box-shadow:
    0 16px 28px rgba(2, 132, 199, 0.28),
    0 0 0 4px rgba(56, 189, 248, 0.55),
    inset 0 0 14px rgba(255, 255, 255, 0.85);
}

.cup-btn.is-valid-target .cup-glass {
  border-color: #10b981;
  box-shadow:
    0 8px 20px rgba(16, 185, 129, 0.24),
    0 0 0 3px rgba(52, 211, 153, 0.55),
    inset 0 0 12px rgba(255, 255, 255, 0.8);
}

.cup-btn.is-hint-source .cup-glass,
.cup-btn.is-hint-target .cup-glass {
  border-color: #f59e0b;
  box-shadow:
    0 0 0 5px rgba(251, 191, 36, 0.75),
    0 10px 24px rgba(245, 158, 11, 0.35);
}

.cup-btn.is-tilting-right {
  transform: translateY(-28px) translateX(10px) rotate(26deg);
  z-index: 8;
}

.cup-btn.is-tilting-left {
  transform: translateY(-28px) translateX(-10px) rotate(-26deg);
  z-index: 8;
}

.cup-btn.is-receiving {
  transform: scale(1.03);
}

.cup-btn.is-shaking {
  animation: cup-shake 0.36s ease;
}

@keyframes cup-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-5px); }
}

/* Top indicators above the glass rim */
.cup-top-indicator {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 4px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cup-btn.is-valid-target .cup-top-indicator,
.cup-btn.is-completed .cup-top-indicator,
.cup-btn.is-hint-source .cup-top-indicator,
.cup-btn.is-hint-target .cup-top-indicator {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.cup-btn.is-valid-target .cup-top-indicator {
  animation: indicator-bob 1s ease-in-out infinite alternate;
}

@keyframes indicator-bob {
  from { transform: translateY(-2px); }
  to { transform: translateY(3px); }
}

/* Glass Rim & Body */
.cup-rim {
  width: 92px;
  height: 10px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.95) 0%, rgba(224, 242, 254, 0.85) 50%, rgba(255, 255, 255, 0.95) 100%);
  border: 3px solid rgba(71, 85, 105, 0.55);
  border-radius: 999px;
  z-index: 4;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
}

.cup-glass {
  position: relative;
  width: 84px;
  height: 154px;
  margin-top: -3px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.62) 0%,
    rgba(255, 255, 255, 0.28) 38%,
    rgba(240, 249, 255, 0.22) 70%,
    rgba(255, 255, 255, 0.55) 100%
  );
  border: 3px solid rgba(71, 85, 105, 0.55);
  border-top: none;
  border-radius: 6px 6px 32px 32px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  padding: 5px 5px 6px;
  gap: 2px;
  box-shadow:
    0 8px 18px rgba(15, 23, 42, 0.14),
    inset 0 -6px 12px rgba(255, 255, 255, 0.65);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cup-btn.is-completed .cup-glass {
  border-color: #eab308;
  box-shadow:
    0 8px 22px rgba(234, 179, 8, 0.32),
    0 0 0 3px rgba(253, 224, 71, 0.65),
    inset 0 0 14px rgba(255, 255, 255, 0.85);
}

/* Specular glass highlight and measurement ticks */
.cup-shine {
  position: absolute;
  top: 8px;
  bottom: 18px;
  left: 9px;
  width: 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0.18) 100%);
  pointer-events: none;
  z-index: 4;
}

.cup-ticks {
  position: absolute;
  top: 14px;
  bottom: 16px;
  right: 7px;
  width: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  pointer-events: none;
  z-index: 4;
}

.cup-tick {
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: rgba(71, 85, 105, 0.35);
}

/* Cup Number Badge */
.cup-number {
  position: absolute;
  bottom: -10px;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #64748b;
  color: #1e293b;
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
}

/* --- Liquid Layers Inside the Cup --------------------------------------- */

.cup-layer {
  position: relative;
  width: 100%;
  height: 32%;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.24s ease, opacity 0.22s ease;
  z-index: 2;
  overflow: hidden;
}

.cup-layer:first-child {
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
}

.cup-layer.is-top-surface::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.42);
  border-radius: 50%;
}

.cup-layer.is-newly-poured {
  animation: layer-rise 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes layer-rise {
  0% {
    transform: scaleY(0.15);
    transform-origin: bottom;
    opacity: 0.4;
  }
  100% {
    transform: scaleY(1);
    transform-origin: bottom;
    opacity: 1;
  }
}

.layer-badge {
  font-size: 1.15rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
  pointer-events: none;
  z-index: 3;
}

/* Liquid Color Palettes */
.liquid-red {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 50%, #dc2626 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.liquid-orange {
  background: linear-gradient(180deg, #fb923c 0%, #f97316 50%, #ea580c 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.liquid-yellow {
  background: linear-gradient(180deg, #fde047 0%, #facc15 50%, #eab308 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.45);
}

.liquid-green {
  background: linear-gradient(180deg, #4ade80 0%, #22c55e 50%, #16a34a 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.liquid-blue {
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.liquid-purple {
  background: linear-gradient(180deg, #c084fc 0%, #a855f7 50%, #7e22ce 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

/*Pouring Stream Indicator Inside Receiving Cup */
.pour-stream {
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 100%;
  transform: translateX(-50%);
  border-radius: 999px;
  z-index: 3;
  opacity: 0.9;
  pointer-events: none;
  animation: stream-flow 0.34s ease-out forwards;
}

@keyframes stream-flow {
  0% {
    height: 0%;
    opacity: 0.95;
  }
  55% {
    height: 95%;
    opacity: 0.95;
  }
  100% {
    height: 95%;
    opacity: 0;
  }
}

/* --- Sparkle & Bubble FX Layer ------------------------------------------ */

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.fx-particle {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  animation: fx-float-up 0.95s ease-out forwards;
}

.fx-pos-1 { left: 22%; top: 55%; }
.fx-pos-2 { left: 36%; top: 48%; }
.fx-pos-3 { left: 50%; top: 42%; }
.fx-pos-4 { left: 64%; top: 48%; }
.fx-pos-5 { left: 78%; top: 55%; }
.fx-pos-6 { left: 44%; top: 58%; }

@keyframes fx-float-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.7);
  }
  100% {
    opacity: 0;
    transform: translateY(-64px) scale(1.25);
  }
}

/* --- Bottom Action Controls --------------------------------------------- */

.controls-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-width: 680px;
  padding: 4px 6px;
}

.water-action-btn {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 3px solid #ffffff;
  font-size: 1.02rem;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.16);
  transition: transform 0.12s ease, opacity 0.2s ease, filter 0.2s ease;
  touch-action: manipulation;
}

.water-action-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.water-action-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.water-action-btn:focus-visible {
  outline: 4px solid #f59e0b;
  outline-offset: 3px;
}

.undo-btn {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
}

.hint-btn {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}

.reset-btn {
  background: linear-gradient(180deg, #94a3b8 0%, #475569 100%);
}

.next-btn {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  animation: pulse-cta 1.2s ease-in-out infinite alternate;
}

@keyframes pulse-cta {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

/* --- Grand Finale Celebration Overlay ----------------------------------- */

.celebration-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.celebration-card {
  background: #ffffff;
  border: 4px solid #38bdf8;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.28);
}

.celebration-emojis {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.celebration-text {
  margin: 0 0 20px;
  font-size: 1.22rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
}

/* --- Responsive Adjustments (Phones & Compact Landscape) ---------------- */

@media (max-width: 540px) {
  .cups-grid {
    gap: 14px 12px;
    padding: 10px 4px 4px;
  }

  .cup-btn {
    width: 78px;
    height: 162px;
  }

  .cup-rim {
    width: 74px;
    height: 8px;
  }

  .cup-glass {
    width: 68px;
    height: 126px;
    border-radius: 5px 5px 26px 26px;
  }

  .layer-badge {
    font-size: 0.98rem;
  }

  .water-action-btn {
    min-height: 44px;
    padding: 8px 14px;
    font-size: 0.92rem;
  }
}

@media (max-height: 540px) {
  .status-bar {
    gap: 6px 10px;
  }

  .status-pill {
    padding: 3px 10px;
    font-size: 0.85rem;
  }

  .shelf-stage {
    padding: 4px;
  }

  .cups-grid {
    gap: 10px 14px;
    padding: 6px 4px 2px;
  }

  .cup-btn {
    width: 70px;
    height: 132px;
  }

  .cup-rim {
    width: 66px;
    height: 7px;
  }

  .cup-glass {
    width: 60px;
    height: 98px;
  }

  .cup-top-indicator {
    height: 20px;
    font-size: 1rem;
  }

  .wooden-shelf {
    height: 12px;
  }

  .water-action-btn {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 0.88rem;
  }
}

/* --- Reduced Motion Support (TZ 5.4) ------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .cup-btn,
  .cup-layer,
  .level-dot,
  .water-action-btn,
  .cup-top-indicator {
    transition: none !important;
    animation: none !important;
  }

  .cup-btn.is-selected {
    transform: translateY(-10px);
  }

  .cup-btn.is-tilting-left,
  .cup-btn.is-tilting-right {
    transform: translateY(-10px);
  }
}
