/* /pipe-flow/ — Pipe Flow waterworks puzzle. Page frame, SEO cards and the
   play shell come from games.css / play.css. The ceramic tiles, steel pipes
   and tanks are game art (inline SVG) and keep their own colours; the UI
   chrome around the board reads tokens. Shared by all locales. */

.pipe-flow-play { text-align: center; }
.pipe-flow-play h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--text);
}
.pipe-flow-sub { max-inline-size: 60ch; margin-inline: auto !important; color: var(--text-muted); text-wrap: pretty; }
:lang(zh) .pipe-flow-play h1, :lang(ja) .pipe-flow-play h1 { font-family: var(--font-body); font-weight: 700; font-size: var(--step-3); line-height: 1.15; }
:lang(ar) .pipe-flow-play h1, :lang(ru) .pipe-flow-play h1, :lang(hi) .pipe-flow-play h1 { line-height: 1.15; }
:lang(ar) .pipe-flow-play h1 { line-height: 1.4; letter-spacing: 0; }

.pipe-flow-card {
  inline-size: 100%;
  max-inline-size: 680px;
  box-sizing: border-box;
  margin-inline: auto;
  padding: var(--space-3) !important;
  background:
    radial-gradient(ellipse at 30% 0, rgb(34 64 90 / 0.55), transparent 60%),
    linear-gradient(rgb(21 36 52 / 0.85), rgb(15 26 39 / 0.9)) !important;
}
.pipe-flow-stage { min-inline-size: 0; position: relative; display: flex; flex-direction: column; gap: var(--space-2); color: var(--text); }
.pipe-flow-stage, .pipe-flow-stage * { -webkit-user-select: none; user-select: none; }

/* ── HUD ─────────────────────────────────────────────────────────────── */
.pf-hud { display: flex; align-items: center; gap: var(--space-2); }
.pf-level { display: flex; align-items: center; gap: var(--space-1); margin-inline-end: auto; min-inline-size: 0; }
.pf-level__txt { display: grid; justify-items: start; line-height: 1; min-inline-size: 0; }
.pf-tag { display: flex; align-items: center; gap: 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; color: #7fd8f2; white-space: nowrap; }
.pf-level b { font-family: var(--font-display); font-size: var(--step-3); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pf-nav {
  display: inline-grid; place-items: center;
  inline-size: 36px; block-size: 36px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text-muted); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.pf-nav:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.pf-nav:disabled { opacity: 0.35; cursor: default; }
[dir="rtl"] .pf-nav i { transform: scaleX(-1); }
.pf-stat {
  display: grid; justify-items: center; min-inline-size: 70px;
  padding: 6px 10px; border: 1px solid rgb(125 243 255 / 0.18); border-radius: var(--radius-md);
  background: rgb(27 43 61 / 0.75); line-height: 1;
}
.pf-stat b { font-family: var(--font-display); font-size: var(--step-2); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pf-stat--supply b { color: #7df3ff; }
.pf-stat em { font-style: normal; font-size: 0.8em; color: var(--text-muted); }
.pf-stat > span { margin-block-start: 3px; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.pf-badge {
  display: inline-block; padding: 2px 6px; border-radius: 6px;
  background: var(--amber); color: #0b141d;
  font-size: 0.6rem; font-style: normal; font-weight: 800; letter-spacing: 0.06em;
}
.pf-badge[hidden] { display: none; }
.pf-status { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding-inline: 4px; font-size: 0.78rem; font-weight: 700; color: var(--amber); text-align: start; }
.pf-status > span::before { content: ''; display: inline-block; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; margin-inline-end: 6px; vertical-align: middle; }
.pf-status > span.is-sealed { color: #7df3ff; }
.pf-status small { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; }

/* ── Board ───────────────────────────────────────────────────────────── */
.pf-board {
  position: relative;
  inline-size: min(100%, 620px, calc(100dvh - 300px));
  min-inline-size: min(100%, 280px);
  aspect-ratio: 1;
  margin-inline: auto;
  border-radius: 22px;
  background: #0f1a27;
  box-shadow: inset 0 0 0 1px #2f4560, inset 0 8px 24px rgb(0 0 0 / 0.55);
  overflow: hidden;
}
.pf-svg { display: block; inline-size: 100%; block-size: 100%; touch-action: manipulation; font-family: var(--font-body); }
.pf-cell[role="button"] { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.pf-cell.is-fixed { cursor: not-allowed; }
.pf-cell[role="button"]:hover .pf-tile { fill: #3a5a76; }
.pf-cell:focus-visible .pf-tile { stroke: var(--amber) !important; stroke-width: 2.5 !important; }
.pf-cell.is-nope { animation: pf-nope 280ms var(--ease); }
@keyframes pf-nope { 25% { translate: -3px 0; } 50% { translate: 3px 0; } 75% { translate: -2px 0; } }
.pipe-flow-stage:not(.is-playing) .pf-cell { pointer-events: none; }

/* Praise pop ("Water through!") */
.pf-praise {
  position: absolute; inset-inline: 0; inset-block-start: 38%;
  display: grid; justify-items: center; gap: 2px;
  pointer-events: none; opacity: 0;
}
.pf-praise strong { font-family: var(--font-display); font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 600; letter-spacing: 0.02em; color: #eafcff; text-shadow: 0 3px 0 #1590d6, 0 8px 22px rgb(45 200 242 / 0.45); rotate: -2deg; }
.pf-praise small { font-size: 0.85rem; font-weight: 700; color: #9fe9ff; text-shadow: 0 1px 0 #0b141d, 0 2px 8px #0b141d; }
.pf-praise.is-on { animation: pf-praise 1700ms var(--ease) forwards; }
@keyframes pf-praise {
  0% { opacity: 0; transform: translateY(14px) scale(0.8); }
  14% { opacity: 1; transform: translateY(0) scale(1.06); }
  24% { transform: scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* Win splash droplets */
.pf-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pf-fx i {
  position: absolute; inset-block-start: 50%; inset-inline-start: 50%;
  inline-size: 8px; block-size: 11px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: pf-drop 1100ms cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes pf-drop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 60px)) scale(1); opacity: 0; }
}

/* Start / level-clear overlay */
.pf-overlay {
  position: absolute; inset: 0;
  display: none; place-items: center;
  padding: var(--space-4);
  background: radial-gradient(ellipse at 50% 40%, rgb(15 26 39 / 0.55), rgb(7 12 20 / 0.82));
  backdrop-filter: blur(2px);
}
.pf-overlay.is-on { display: grid; animation: pf-fade var(--dur-med) var(--ease); }
.pf-overlay.is-win { animation-delay: 300ms; animation-fill-mode: both; }
@keyframes pf-fade { from { opacity: 0; } to { opacity: 1; } }
.pf-overlay__card {
  display: grid; justify-items: center; gap: var(--space-2);
  max-inline-size: 420px; padding: var(--space-5) var(--space-5);
  border: 1px solid rgb(125 243 255 / 0.25); border-radius: var(--radius-lg);
  background: rgb(20 34 50 / 0.92); box-shadow: 0 18px 40px rgb(0 0 0 / 0.45);
}
.pf-overlay__kicker { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; color: #7fd8f2; }
.pf-overlay h2 { margin: 0; font-family: var(--font-display); font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); text-transform: none; letter-spacing: 0.01em; font-weight: 600; line-height: 1; color: var(--text); text-wrap: balance; }
:lang(zh) .pf-overlay h2, :lang(ja) .pf-overlay h2, :lang(ar) .pf-overlay h2 { font-family: var(--font-body); font-weight: 700; font-size: var(--step-2); line-height: 1.3; }
.pf-overlay__meta, .pf-overlay__note { margin: 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.pf-overlay__meta b { color: var(--text); }
.pf-overlay__note { font-size: 0.76rem; }
.pf-overlay__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-block-start: var(--space-1); }
.pf-primary {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-block-size: var(--tap); padding: 0 var(--space-5);
  border: 1px solid #1fa9d3; border-block-end-width: 4px; border-block-end-color: #147fa3; border-radius: var(--radius-lg);
  background: linear-gradient(#37d0f6, #1bb0e0); color: #06222f;
  font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 18px rgb(45 200 242 / 0.2);
}
.pf-primary:active { transform: translateY(2px); border-block-end-width: 2px; }
.pf-primary:focus-visible, .pf-secondary:focus-visible, .pf-tool:focus-visible, .pf-nav:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[dir="rtl"] .pf-primary i { transform: scaleX(-1); }
.pf-secondary {
  min-block-size: var(--tap); padding: 0 var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer;
}
.pf-stars { display: flex; gap: 8px; font-size: 1.7rem; color: rgb(255 255 255 / 0.16); }
.pf-stars .is-on { color: #ffb84d; text-shadow: 0 0 14px rgb(255 184 77 / 0.55); }
.pf-overlay.is-win .pf-stars .is-on { animation: pf-star 520ms var(--ease) both; animation-delay: calc(350ms + var(--i) * 160ms); }
@keyframes pf-star { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 70% { transform: scale(1.3) rotate(8deg); opacity: 1; } 100% { transform: scale(1); } }

/* ── Message + tools ─────────────────────────────────────────────────── */
.pf-message { min-block-size: 2.6em; margin: 0; display: grid; place-items: center; font-size: 0.85rem; font-weight: 600; line-height: 1.35; color: #b9c9da; text-wrap: balance; }
.pf-tools { display: flex; justify-content: center; gap: var(--space-2); }
.pf-tool {
  display: inline-flex; align-items: center; gap: 6px;
  min-block-size: 40px; padding: 0 var(--space-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text-muted); font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.pf-tool:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.pf-tool:disabled { opacity: 0.4; cursor: default; }
.pf-tool small { display: inline-grid; place-items: center; min-inline-size: 1.5em; padding: 1px 5px; border-radius: 999px; background: rgb(45 200 242 / 0.18); color: #7df3ff; font-weight: 700; }

/* ── Play shell: fit the board between the bar and the tools ─────────── */
.play-slot .pipe-flow-play { max-inline-size: 680px; }
.play-slot .pipe-flow-card { margin: 0 auto; }
.play-slot .pf-board { inline-size: min(100%, calc(100dvh - 350px)); }

@media (max-width: 480px) {
  .pipe-flow-card { padding: var(--space-2) !important; }
  .pf-hud { gap: 6px; }
  .pf-stat { min-inline-size: 0; max-inline-size: 84px; padding: 5px 6px; }
  .pf-stat > span { white-space: normal; font-size: 0.56rem; line-height: 1.15; text-align: center; }
  .pf-tag > span { display: none; }
  .pf-status { font-size: 0.72rem; }
  .pf-level b { font-size: var(--step-2); }
  .pf-nav { inline-size: 32px; block-size: 32px; }
  .pf-tool span { display: none; }
  .pf-overlay__card { padding: var(--space-4); }
}
@media (prefers-reduced-motion: reduce) {
  .pf-praise.is-on { animation-duration: 1ms; animation-delay: 0s; opacity: 0; }
  .pf-overlay.is-on, .pf-overlay.is-win .pf-stars .is-on, .pf-cell.is-nope { animation: none; }
  .pf-nav, .pf-tool { transition: none; }
}
