/*
 * Pour to the Line: Water Measure (games/water-measure/style.css)
 * Interactive graduated vessels, hold-to-pour pitcher, and discrete measuring cups (+1, +2, +3, -1).
 */

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

.measure-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;
}

/* --- Top Status Row ----------------------------------------------------- */

.measure-status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  width: 100%;
  max-width: 780px;
  z-index: 2;
}

.measure-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid rgba(14, 165, 233, 0.4);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.96rem;
  font-weight: 700;
  color: #0c4a6e;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.08);
  font-variant-numeric: tabular-nums;
}

.pill-emoji {
  font-size: 1.15rem;
}

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

.pill-target {
  color: #15803d;
  font-weight: 800;
}

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

/* --- Center Vessel & Pitcher Stage -------------------------------------- */

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

.pitcher-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 5;
}

.pitcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 20px;
  border-radius: 999px;
  border: 3px solid #ffffff;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  touch-action: none;
}

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

.pitcher-btn.is-pouring {
  transform: translateY(2px) rotate(-8deg) scale(1.04);
  background: linear-gradient(180deg, #0ea5e9 0%, #0369a1 100%);
}

.pitcher-icon {
  font-size: 1.35rem;
}

.pitcher-stream {
  width: 14px;
  height: 0;
  background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 50%, #0284c7 100%);
  border-radius: 999px;
  opacity: 0;
  transition: height 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
  margin-top: -2px;
  margin-bottom: -14px;
  z-index: 4;
}

.pitcher-stream.is-active {
  height: 36px;
  opacity: 0.92;
}

/* --- Transparent Graduated Vessel --------------------------------------- */

.vessel-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.vessel-rim {
  width: 226px;
  height: 12px;
  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.6);
  border-radius: 999px;
  z-index: 4;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.vessel-glass {
  --fill-pct: 0%;
  --target-pct: 50%;
  position: relative;
  width: 214px;
  height: 220px;
  margin-top: -3px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.68) 0%,
    rgba(255, 255, 255, 0.30) 40%,
    rgba(240, 249, 255, 0.25) 70%,
    rgba(255, 255, 255, 0.62) 100%
  );
  border: 4px solid rgba(51, 65, 85, 0.6);
  border-top: none;
  border-radius: 14px 14px 48px 48px;
  overflow: hidden;
  box-shadow:
    0 14px 28px rgba(15, 23, 42, 0.15),
    inset 0 -8px 18px rgba(255, 255, 255, 0.72);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, border-radius 0.25s ease;
}

.vessel-glass.shape-bowl {
  border-radius: 22px 22px 72px 72px;
}

.vessel-glass.shape-vase {
  border-radius: 16px 16px 56px 56px;
}

.vessel-glass.shape-tub {
  border-radius: 12px 12px 36px 36px;
}

.vessel-glass.shape-jug {
  border-radius: 14px 14px 44px 44px;
}

.vessel-glass.is-exact {
  border-color: #16a34a;
  box-shadow:
    0 14px 32px rgba(22, 163, 74, 0.3),
    0 0 0 5px rgba(74, 222, 128, 0.65),
    inset 0 0 18px rgba(255, 255, 255, 0.85);
}

.vessel-glass.is-over {
  border-color: #f59e0b;
  box-shadow:
    0 10px 24px rgba(245, 158, 11, 0.26),
    0 0 0 4px rgba(251, 191, 36, 0.55);
}

.vessel-base {
  width: 164px;
  height: 12px;
  margin-top: -2px;
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
  border: 2px solid #475569;
  border-radius: 999px;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.18);
}

/* Specular Glass Highlight */
.vessel-shine {
  position: absolute;
  top: 10px;
  bottom: 24px;
  left: 14px;
  width: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 255, 255, 0.18) 100%);
  pointer-events: none;
  z-index: 5;
}

/* --- Target Watermark Line ---------------------------------------------- */

.target-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--target-pct);
  height: 0;
  border-top: 4px dashed #16a34a;
  z-index: 6;
  pointer-events: none;
  transition: bottom 0.25s ease, border-color 0.2s ease;
}

.vessel-glass.is-exact .target-line {
  border-top-style: solid;
  border-top-color: #15803d;
}

.target-badge {
  position: absolute;
  left: 12px;
  top: -26px;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35);
  white-space: nowrap;
}

/* --- Numbered Graduation Scale Ticks ------------------------------------ */

.vessel-scale {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 8px;
  width: 44px;
  pointer-events: none;
  z-index: 6;
}

.scale-mark {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  transform: translateY(50%);
  font-size: 0.74rem;
  font-weight: 800;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
}

.scale-mark.is-target-mark {
  color: #15803d;
  font-size: 0.84rem;
}

.scale-tick-line {
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: rgba(30, 41, 59, 0.5);
}

.scale-mark.is-target-mark .scale-tick-line {
  width: 18px;
  height: 3px;
  background: #16a34a;
}

/* --- Rising Liquid Body & Friend Mascot --------------------------------- */

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

.water-surface {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.water-aqua {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.85) 0%, rgba(2, 132, 199, 0.92) 100%);
}

.water-spring {
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.85) 0%, rgba(22, 163, 74, 0.92) 100%);
}

.water-sky {
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.85) 0%, rgba(37, 99, 235, 0.92) 100%);
}

.water-lemon {
  background: linear-gradient(180deg, rgba(253, 224, 71, 0.88) 0%, rgba(234, 179, 8, 0.94) 100%);
}

.water-teal {
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.85) 0%, rgba(13, 148, 136, 0.92) 100%);
}

.water-amber {
  background: linear-gradient(180deg, rgba(251, 146, 60, 0.85) 0%, rgba(217, 119, 6, 0.92) 100%);
}

.water-ocean {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.86) 0%, rgba(29, 78, 216, 0.94) 100%);
}

.water-magic {
  background: linear-gradient(180deg, rgba(192, 132, 252, 0.86) 0%, rgba(126, 34, 206, 0.94) 100%);
}

.vessel-friend {
  position: absolute;
  left: 50%;
  bottom: max(10%, calc(var(--fill-pct) - 18%));
  transform: translateX(-50%);
  font-size: 2.9rem;
  line-height: 1;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.22));
  transition: bottom 0.24s ease, transform 0.24s ease;
}

.vessel-glass.is-exact .vessel-friend {
  animation: friend-dance 0.8s ease-in-out infinite alternate;
}

@keyframes friend-dance {
  from { transform: translateX(-50%) translateY(0) scale(1.05); }
  to { transform: translateX(-50%) translateY(-10px) scale(1.16); }
}

/* --- 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: 24%; top: 56%; }
.fx-pos-2 { left: 36%; top: 48%; }
.fx-pos-3 { left: 50%; top: 40%; }
.fx-pos-4 { left: 64%; top: 48%; }
.fx-pos-5 { left: 76%; top: 56%; }
.fx-pos-6 { left: 46%; top: 60%; }

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

/* --- Bottom Measuring Cups & Valves ------------------------------------- */

.measuring-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 720px;
  z-index: 3;
}

.cups-tray,
.valves-tray {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.measure-cup-btn,
.valve-btn {
  min-height: 46px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 3px solid #ffffff;
  font-size: 0.98rem;
  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;
}

.measure-cup-btn:active:not(:disabled),
.valve-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.measure-cup-btn:disabled,
.valve-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.measure-cup-btn:focus-visible,
.valve-btn:focus-visible {
  outline: 4px solid #f59e0b;
  outline-offset: 3px;
}

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

.cup-2 {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
}

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

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

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

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

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

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

@media (max-width: 540px) {
  .vessel-rim {
    width: 194px;
  }

  .vessel-glass {
    width: 184px;
    height: 184px;
  }

  .vessel-friend {
    font-size: 2.4rem;
  }

  .measure-cup-btn,
  .valve-btn {
    min-height: 42px;
    padding: 7px 13px;
    font-size: 0.88rem;
  }
}

@media (max-height: 560px) {
  .measure-status-row {
    gap: 6px 10px;
  }

  .measure-pill {
    padding: 2px 10px;
    font-size: 0.84rem;
  }

  .pitcher-btn {
    min-height: 38px;
    padding: 5px 14px;
    font-size: 0.88rem;
  }

  .vessel-rim {
    width: 170px;
    height: 9px;
  }

  .vessel-glass {
    width: 160px;
    height: 136px;
  }

  .vessel-friend {
    font-size: 2rem;
  }

  .measuring-controls {
    gap: 5px;
  }

  .measure-cup-btn,
  .valve-btn {
    min-height: 36px;
    padding: 5px 11px;
    font-size: 0.84rem;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .pitcher-btn,
  .pitcher-stream,
  .vessel-glass,
  .water-fill,
  .vessel-friend,
  .measure-cup-btn,
  .valve-btn {
    transition: none !important;
    animation: none !important;
  }
}
