/*
 * Magic Jugs: Volume Math (games/water-jugs/style.css)
 * Graduated water jugs, live arithmetic equation display, and garden flowerbed.
 */

:root {
  --game-bg: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 54%, #dcfce7 100%);
  --game-ink: #0f172a;
  --game-accent: #0284c7;
  --game-banner-bg: rgba(255, 255, 255, 0.88);
}

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

/* --- Top Status & Math Equation Banner ---------------------------------- */

.jugs-top-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 780px;
  z-index: 3;
}

.jugs-badges-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.jug-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0c4a6e;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.08);
  font-variant-numeric: tabular-nums;
}

.goal-pill {
  border-color: rgba(34, 197, 94, 0.55);
  background: #f0fdf4;
}

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

.goal-number {
  color: #15803d;
  font-weight: 900;
  font-size: 1.05rem;
}

.pill-dim {
  color: #64748b;
}

.math-equation-banner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #93c5fd;
  border-radius: 16px;
  padding: 6px 16px;
  font-size: 1rem;
  font-weight: 800;
  color: #1e3a8a;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.08);
  text-align: center;
  max-width: 96%;
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.math-equation-banner.is-highlight {
  background: #fef9c3;
  border-color: #facc15;
  color: #854d0e;
  transform: scale(1.03);
}

/* --- Main Stage: Jugs Row & Garden Bed ---------------------------------- */

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

.jugs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 14px 22px;
  width: 100%;
  padding: 6px 4px;
}

.jug-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.62);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.jug-column.is-selected {
  border-color: #0284c7;
  box-shadow: 0 12px 26px rgba(2, 132, 199, 0.22), 0 0 0 3px rgba(56, 189, 248, 0.5);
  transform: translateY(-6px);
}

.jug-column.is-goal-reached {
  border-color: #16a34a;
  background: rgba(240, 253, 244, 0.88);
  box-shadow: 0 12px 28px rgba(22, 163, 74, 0.28), 0 0 0 4px rgba(74, 222, 128, 0.65);
}

.jug-header-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.94rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.jug-readout-badge {
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.86rem;
  font-weight: 900;
}

.jug-column.is-goal-reached .jug-readout-badge {
  background: #dcfce7;
  color: #15803d;
}

/* --- Glass Jug Body ----------------------------------------------------- */

.jug-vessel-btn {
  position: relative;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  touch-action: manipulation;
}

.jug-vessel-btn:focus-visible {
  outline: 4px solid #f59e0b;
  outline-offset: 4px;
  border-radius: 20px;
}

.jug-rim {
  width: 122px;
  height: 9px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(224, 242, 254, 0.85), rgba(255, 255, 255, 0.96));
  border: 3px solid rgba(51, 65, 85, 0.58);
  border-radius: 999px;
  z-index: 4;
}

.jug-glass {
  --fill-pct: 0%;
  --target-pct: 0%;
  --jug-h: 150px;
  position: relative;
  width: 112px;
  height: var(--jug-h);
  margin-top: -2px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.72) 0%,
    rgba(255, 255, 255, 0.32) 40%,
    rgba(240, 249, 255, 0.26) 70%,
    rgba(255, 255, 255, 0.65) 100%
  );
  border: 3px solid rgba(51, 65, 85, 0.58);
  border-top: none;
  border-radius: 10px 10px 30px 30px;
  overflow: hidden;
  box-shadow:
    0 8px 18px rgba(15, 23, 42, 0.12),
    inset 0 -6px 14px rgba(255, 255, 255, 0.72);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.jug-column.is-goal-reached .jug-glass {
  border-color: #16a34a;
}

.jug-shine {
  position: absolute;
  top: 8px;
  bottom: 16px;
  left: 10px;
  width: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 255, 255, 0.15) 100%);
  pointer-events: none;
  z-index: 5;
}

/* Target Line Inside Capable Jugs */
.jug-target-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--target-pct);
  height: 0;
  border-top: 3px dashed #16a34a;
  z-index: 6;
  pointer-events: none;
}

.jug-target-tag {
  position: absolute;
  left: 6px;
  top: -20px;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Scale Ticks */
.jug-scale {
  position: absolute;
  inset: 0;
  right: 5px;
  pointer-events: none;
  z-index: 6;
}

.jug-tick-row {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  transform: translateY(50%);
  font-size: 0.68rem;
  font-weight: 800;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.jug-tick-row.is-goal-tick {
  color: #15803d;
  font-weight: 900;
}

.jug-tick-dash {
  width: 9px;
  height: 2px;
  background: rgba(51, 65, 85, 0.45);
  border-radius: 2px;
}

.jug-tick-row.is-goal-tick .jug-tick-dash {
  width: 13px;
  height: 3px;
  background: #16a34a;
}

/* Liquid Fill */
.jug-water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--fill-pct);
  z-index: 2;
  transition: height 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.jug-water::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.jug-water-sky {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.86) 0%, rgba(2, 132, 199, 0.94) 100%);
}

.jug-water-aqua {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.86) 0%, rgba(13, 148, 136, 0.94) 100%);
}

.jug-water-emerald {
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.86) 0%, rgba(22, 163, 74, 0.94) 100%);
}

.jug-water-amber {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.88) 0%, rgba(217, 119, 6, 0.94) 100%);
}

.jug-water-violet {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.86) 0%, rgba(124, 58, 237, 0.94) 100%);
}

.jug-water-rose {
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.86) 0%, rgba(225, 29, 72, 0.94) 100%);
}

.jug-water-magic {
  background: linear-gradient(180deg, rgba(192, 132, 252, 0.86) 0%, rgba(79, 70, 229, 0.94) 100%);
}

/* --- Per-Jug Action Buttons --------------------------------------------- */

.jug-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 176px;
}

.jug-op-btn {
  min-height: 36px;
  padding: 5px 10px;
  border-radius: 12px;
  border: 2px solid #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.14);
  transition: transform 0.12s ease, opacity 0.18s ease, box-shadow 0.18s ease;
  touch-action: manipulation;
  white-space: nowrap;
}

.jug-op-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.jug-op-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.jug-op-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

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

.op-pour {
  background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
}

.op-empty {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
}

.jug-op-btn.is-hint-glow {
  border-color: #fde047;
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.85), 0 6px 16px rgba(245, 158, 11, 0.45);
  animation: hint-throb 0.75s ease-in-out infinite alternate;
}

@keyframes hint-throb {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* --- Garden Flowerbed Strip --------------------------------------------- */

.garden-bed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 3px 18px;
  background: rgba(220, 252, 231, 0.78);
  border: 2px solid rgba(74, 222, 128, 0.55);
  border-radius: 999px;
  font-size: 1.3rem;
  transition: transform 0.24s ease;
}

.garden-bed.is-watered {
  transform: scale(1.08);
  background: #dcfce7;
}

/* --- Sparkle FX Layer --------------------------------------------------- */

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

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

.fx-pos-1 { left: 22%; top: 54%; }
.fx-pos-2 { left: 36%; top: 46%; }
.fx-pos-3 { left: 50%; top: 40%; }
.fx-pos-4 { left: 64%; top: 46%; }
.fx-pos-5 { left: 78%; top: 54%; }
.fx-pos-6 { left: 46%; top: 58%; }

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

/* --- Bottom Utility Controls Bar ---------------------------------------- */

.jugs-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  width: 100%;
  max-width: 680px;
  z-index: 3;
}

.jug-util-btn {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 3px solid #ffffff;
  font-size: 0.96rem;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  transition: transform 0.12s ease, opacity 0.2s ease;
  touch-action: manipulation;
}

.jug-util-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.jug-util-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.jug-util-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.1s ease-in-out infinite alternate;
}

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

/* --- 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 --------------------------------------------- */

@media (max-width: 560px) {
  .jugs-row {
    gap: 10px 12px;
  }

  .jug-column {
    padding: 8px 8px;
  }

  .jug-rim {
    width: 100px;
  }

  .jug-glass {
    width: 92px;
  }

  .jug-actions {
    max-width: 146px;
  }

  .jug-op-btn {
    min-height: 32px;
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .jug-util-btn {
    min-height: 40px;
    padding: 7px 14px;
    font-size: 0.88rem;
  }
}

@media (max-height: 560px) {
  .math-equation-banner {
    padding: 3px 12px;
    font-size: 0.88rem;
  }

  .jug-column {
    padding: 6px 8px;
    gap: 4px;
  }

  .garden-bed {
    display: none;
  }

  .jug-util-btn {
    min-height: 36px;
    padding: 5px 12px;
    font-size: 0.84rem;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .math-equation-banner,
  .jug-column,
  .jug-glass,
  .jug-water,
  .jug-op-btn,
  .jug-util-btn,
  .garden-bed {
    transition: none !important;
    animation: none !important;
  }
}
