/* ============================================================================
 * Parking Panic — game-specific styles (games/parking-panic/parking-panic.css)
 *
 * Top-down parking-lot environment: asphalt, stall stripes, concrete curb,
 * painted arrows, exit gate with chevrons, traffic cones. Vehicles are
 * inline SVG (see parking-panic.js vehicleSVG): body, glass, wheels,
 * headlights/taillights, Pip's star.
 *
 * Companion to /assets/css/games.css and /assets/css/games-mobile.css.
 * Uses site tokens from lab.css. Mobile-first: board fits 375px, 44px+
 * touch targets, no hover dependency.
 * Success/failure is never color-only (icons + text accompany color).
 * ========================================================================== */

.pp-wrap { max-width: 100%; }

/* ---------- compact shell chrome (Pip header + HUD) ---------- */
.pp-wrap .plg-header { gap: 8px; margin-bottom: 8px; }
.pp-wrap .plg-bubble-text { font-size: .82rem; }
.pp-wrap .plgm-hud {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 0 0 10px;
}
.pp-wrap .plgm-hud .plgm-chip,
.pp-wrap .plgm-hud .plgm-level { font-size: .76rem; }
.pp-wrap .plgm-hud .plgm-btn {
  padding: 7px 10px; font-size: .78rem; min-height: 0;
}

/* ---------- level select ---------- */
.pp-levels { margin: 0 0 14px; }
.pp-levels-title {
  font-family: "DM Mono", monospace; font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 8px;
}
.pp-level-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  list-style: none; margin: 0; padding: 0;
}
.pp-level-btn {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 800;
  font-size: .95rem; cursor: pointer; touch-action: manipulation;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 4px;
}
.pp-level-btn .pp-stars { font-size: .62rem; letter-spacing: .05em; color: var(--muted); }
.pp-level-btn.is-done { border-color: var(--ink); }
.pp-level-btn.is-current {
  background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.pp-level-btn.is-current .pp-stars { color: var(--paper); opacity: .75; }
.pp-level-btn[disabled] { opacity: .38; cursor: not-allowed; }
.pp-level-btn:not([disabled]):active { transform: translateY(1px); }
.pp-level-btn:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ---------- lot frame (curb) + board (asphalt) ---------- */
.pp-board-zone { margin: 0 0 14px; position: relative; }
.pp-lot-frame {
  position: relative; max-width: 452px; margin: 0 auto;
  padding: clamp(8px, 2.4%, 12px);
  border-radius: 20px; border: 2px solid var(--ink);
  background:
    linear-gradient(160deg, #b9bcc0, #a8abad 55%, #989b9f);
  box-shadow: 0 6px 0 rgba(0,0,0,.28), inset 0 2px 6px rgba(255,255,255,.5),
    inset 0 -3px 8px rgba(0,0,0,.18);
}
.pp-board {
  position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 12px;
  overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
  background:
    radial-gradient(ellipse at 28% 18%, rgba(255,255,255,.07), transparent 55%),
    radial-gradient(ellipse at 72% 85%, rgba(0,0,0,.22), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.055 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(155deg, #454b52, #383d43 55%, #30353a);
  box-shadow: inset 0 3px 10px rgba(0,0,0,.45), inset 0 -2px 6px rgba(0,0,0,.3);
}
.pp-grid {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr);
}
/* stall divider stripes, painted on the asphalt */
.pp-cell {
  border: 0; background: transparent; padding: 0;
  cursor: pointer; min-height: 0; font: inherit; touch-action: manipulation;
  position: relative;
}
.pp-cell::before {
  content: ""; position: absolute; top: 7%; left: 14%; right: 14%; height: 2px;
  background: rgba(255,255,255,.26); border-radius: 2px;
}
.pp-cell:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; }
.pp-cell.is-dest::after {
  content: ""; position: absolute; inset: 30%; border-radius: 50%;
  background: var(--teal); opacity: .9;
  border: 2px solid rgba(0,0,0,.55);
  box-shadow: 0 0 8px rgba(0,0,0,.35);
  animation: pp-dest-pulse 1.4s ease-in-out infinite;
}
@keyframes pp-dest-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
.pp-cell.is-dest { cursor: pointer; }

/* painted exit lane leading to the gate */
.pp-exit-lane {
  position: absolute; top: calc(100% / 6 * 2); height: calc(100% / 6);
  right: 0; width: calc(100% / 6 * 1.6); pointer-events: none;
  background: repeating-linear-gradient(-45deg,
    rgba(255,210,63,.34) 0 10px, transparent 10px 20px);
  border-top: 2px dashed rgba(255,210,63,.5);
  border-bottom: 2px dashed rgba(255,210,63,.5);
}
/* painted directional arrows on the asphalt */
.pp-paint-arrow {
  position: absolute; width: 11%; height: 11%;
  opacity: .2; pointer-events: none;
}
/* The car layer covers the whole board; let taps pass through to the grid
   cells except on the car buttons themselves. */
.pp-cars { pointer-events: none; }

/* Contain decorative overflow (exit sign / gate sit slightly proud of the
   curb) so the page never scrolls horizontally on narrow phones. `clip`
   (not hidden) so it never creates a scroll container. */
.pp-board-zone { overflow-x: clip; }

/* exit gate: a gap in the curb with chevrons + sign */
.pp-exit-gate {
  position: absolute; right: -2px; top: calc(clamp(8px, 2.4%, 12px) + (100% - 2 * clamp(8px, 2.4%, 12px)) / 6 * 2);
  height: calc((100% - 2 * clamp(8px, 2.4%, 12px)) / 6);
  width: 16px; pointer-events: none;
  background: repeating-linear-gradient(45deg, #ffd23f 0 7px, #1c1c1c 7px 14px);
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  border-radius: 0 4px 4px 0;
}
.pp-exit-sign {
  position: absolute; bottom: calc(100% + 4px); right: -4px;
  font-family: "DM Mono", monospace; font-size: .6rem; font-weight: 700;
  letter-spacing: .08em; color: #fff; background: #1c7a3d;
  border: 1.5px solid var(--ink); border-radius: 4px; padding: 2px 6px;
  white-space: nowrap;
}
/* traffic cones on the curb */
.pp-cone { position: absolute; width: 20px; height: 26px; pointer-events: none; }
.pp-cone::before {
  content: ""; position: absolute; left: 4px; right: 4px; top: 0; bottom: 5px;
  background: linear-gradient(to bottom, #ff7a1a 0 42%, #ffffff 42% 58%, #e85d04 58% 100%);
  clip-path: polygon(34% 0, 66% 0, 100% 100%, 0 100%);
}
.pp-cone::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: #c24e05; border-radius: 2px;
}
.pp-cone-a { left: 10px; top: 8px; }
.pp-cone-b { left: 10px; bottom: 8px; }

/* ---------- vehicles ---------- */
.pp-car {
  position: absolute; background: none; border: 0; padding: 0;
  cursor: grab; touch-action: none; font: inherit;
  pointer-events: auto;
}
.pp-car .pp-v {
  display: block; width: 100%; height: 100%;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,.38));
  transition: transform .15s ease, filter .15s ease;
}
.pp-car:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.pp-car.is-selected .pp-v {
  transform: scale(1.06);
  filter: drop-shadow(0 0 7px rgba(255,210,63,.95)) drop-shadow(0 9px 9px rgba(0,0,0,.45));
}
/* selection lift: on pointerdown the car pops up like a lifted toy car */
.pp-car.is-press .pp-v {
  transform: scale(1.06);
  filter: drop-shadow(0 12px 10px rgba(0,0,0,.5));
}
.pp-car.is-selected::after {
  content: ""; position: absolute; inset: -7px; border-radius: 16px;
  border: 3px solid var(--teal); pointer-events: none;
  box-shadow: 0 0 0 2px rgba(0,0,0,.4);
}
.pp-car.is-selected .pp-hl { fill: #fffde8; }
.pp-car.is-dragging { cursor: grabbing; z-index: 4; }
.pp-car.is-dragging .pp-v {
  transform: scale(1.09);
  filter: drop-shadow(0 14px 12px rgba(0,0,0,.5));
}
.pp-car.is-driving { z-index: 5; }
.pp-car.is-driving .pp-v { animation: pp-drive-bounce .16s ease-in-out infinite; }
@keyframes pp-drive-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.5px); }
}
.pp-car .pp-car-tag {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: "DM Mono", monospace; font-size: .62rem; font-weight: 700;
  letter-spacing: .04em; color: var(--ink); background: rgba(255,255,255,.72);
  border-radius: 999px; padding: 2px 7px; pointer-events: none;
  white-space: nowrap; border: 1px solid rgba(0,0,0,.35);
}
.pp-car.is-target .pp-car-tag {
  background: #1c1c1c; color: #ffd23f; border-color: #ffd23f;
}

/* first-interaction coach mark */
.pp-car.pp-coach::after {
  content: ""; position: absolute; inset: -9px; border-radius: 18px;
  border: 3px solid #ffd23f; pointer-events: none;
  animation: pp-coach-pulse 1.2s ease-in-out infinite;
}
@keyframes pp-coach-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(1.05); }
}
.pp-coach-tip {
  position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  max-width: 92%; background: rgba(20,20,20,.88); color: #fff;
  font-size: .8rem; font-weight: 600; text-align: center;
  border-radius: 999px; padding: 8px 14px; pointer-events: none; z-index: 6;
  border: 1.5px solid #ffd23f;
}

/* ---------- particles ---------- */
.pp-dust {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: rgba(210,205,195,.55); pointer-events: none; z-index: 5;
  animation: pp-dust-puff .55s ease-out forwards;
}
@keyframes pp-dust-puff {
  0% { transform: scale(.4); opacity: .8; }
  100% { transform: scale(1.8) translateY(-14px); opacity: 0; }
}
.pp-confetti {
  position: absolute; top: -14px; width: 8px; height: 13px; border-radius: 2px;
  pointer-events: none; z-index: 7;
  animation-name: pp-conf-fall; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes pp-conf-fall {
  0% { transform: translate(0,0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx, 0px), 460px) rotate(var(--rot, 360deg)); opacity: 0; }
}

/* ---------- arrow pad ---------- */
/* Arrow pad must sit above the fixed Ask Pip FAB (z-index 60) on narrow
   phones, otherwise the FAB covers the right-arrow button and eats taps. */
.pp-pad { position: relative; z-index: 61; margin: 0 0 14px; }
.pp-pad-title {
  font-family: "DM Mono", monospace; font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 8px; text-align: center;
}
.pp-pad-row { display: flex; justify-content: center; gap: 12px; }
.pp-arrow {
  width: 60px; height: 60px; border-radius: 16px;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  font-size: 1.5rem; cursor: pointer; touch-action: manipulation;
  display: grid; place-items: center;
}
.pp-arrow[disabled] { opacity: .3; cursor: not-allowed; }
.pp-arrow:not([disabled]):active { transform: translateY(2px); background: var(--card); }
.pp-arrow:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.pp-pad-hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 8px 0 0; min-height: 1.2em; }

/* ---------- win panel ---------- */
.pp-win {
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--ink); padding: 22px 20px; margin: 18px 0;
  text-align: center;
  animation: pp-win-in .35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pp-win-in {
  0% { transform: translateY(14px) scale(.97); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.pp-win h3 { margin: 0 0 6px; font-size: 1.4rem; }
.pp-win .pp-win-stars { font-size: 1.7rem; letter-spacing: .15em; margin: 6px 0; }
.pp-win .pp-star { display: inline-block; }
.pp-win .pp-star.is-on { animation: pp-star-pop .5s cubic-bezier(.2,1.6,.4,1) backwards; }
.pp-win .pp-star.is-on:nth-child(2) { animation-delay: .16s; }
.pp-win .pp-star.is-on:nth-child(3) { animation-delay: .32s; }
@keyframes pp-star-pop {
  0% { transform: scale(0) rotate(-40deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.pp-win p { color: var(--muted); margin: 6px 0; }
.pp-win .pp-stats { font-weight: 700; color: var(--ink); }
.pp-win .pp-count { font-variant-numeric: tabular-nums; }
/* the Perfect badge is revealed (and announced) last in the win staging */
.pp-win .pp-perfect { margin: 10px 0 0; }
.pp-win .pp-perfect strong {
  display: inline-block; font-size: 1.02rem; color: #1c1c1c;
  background: #ffd23f; border: 2px solid var(--ink); border-radius: 999px;
  padding: 6px 16px; box-shadow: 0 3px 0 var(--ink);
}
.pp-win .pp-perfect.is-in strong { animation: pp-perfect-in .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pp-perfect-in {
  0% { transform: scale(0) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.pp-win .pp-best { font-size: .88rem; }
.pp-win .pp-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- lesson tree visual ---------- */
.pp-tree { margin: 14px 0; font-size: .92rem; text-align: left; }
.pp-tree-node {
  border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: var(--paper); padding: 10px 12px; margin: 0;
}
.pp-tree-node strong { display: block; margin-bottom: 2px; }
.pp-tree-kids { margin: 0; padding-left: 22px; position: relative; }
.pp-tree-kids::before {
  content: ""; position: absolute; left: 8px; top: 0; bottom: 12px;
  border-left: 2px solid var(--line-strong);
}
.pp-tree-kid { position: relative; margin: 10px 0 0; }
.pp-tree-kid::before {
  content: ""; position: absolute; left: -14px; top: 18px; width: 12px;
  border-top: 2px solid var(--line-strong);
}
.pp-verdict {
  display: inline-block; margin-top: 6px; font-weight: 800; font-size: .8rem;
  font-family: "DM Mono", monospace; letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 3px 10px; border: 1.5px solid var(--ink);
}
.pp-verdict.is-good { background: #d9f2e2; }
.pp-verdict.is-bad { background: #fbe3df; }

/* ---------- how-to (collapsed disclosure) ---------- */
.pp-howto {
  background: var(--card); border: 1.5px solid var(--line-strong);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}
.pp-howto summary {
  cursor: pointer; font-weight: 800; min-height: 44px;
  display: flex; align-items: center;
}
.pp-howto summary:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.pp-howto ol { margin: 8px 0 4px; padding-left: 20px; }
.pp-howto li { margin: 6px 0; }

/* ---------- dark theme tweaks ---------- */
html[data-theme="dark"] .pp-lot-frame {
  background: linear-gradient(160deg, #4a4d52, #3e4146 55%, #35383d);
}
html[data-theme="dark"] .pp-board {
  background:
    radial-gradient(ellipse at 28% 18%, rgba(255,255,255,.05), transparent 55%),
    radial-gradient(ellipse at 72% 85%, rgba(0,0,0,.35), transparent 55%),
    linear-gradient(155deg, #33373d, #282c31 55%, #22262a);
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .pp-car .pp-v { transition: none; }
  .pp-car.is-press .pp-v { transform: none; filter: none; }
  .pp-car.is-driving .pp-v,
  .pp-cell.is-dest::after,
  .pp-car.pp-coach::after,
  .pp-win,
  .pp-win .pp-star.is-on,
  .pp-win .pp-perfect.is-in strong { animation: none; }
}
html[data-motion="reduced"] .pp-car .pp-v { transition: none; }
html[data-motion="reduced"] .pp-car.is-press .pp-v { transform: none; filter: none; }
html[data-motion="reduced"] .pp-car.is-driving .pp-v,
html[data-motion="reduced"] .pp-cell.is-dest::after,
html[data-motion="reduced"] .pp-car.pp-coach::after,
html[data-motion="reduced"] .pp-win,
html[data-motion="reduced"] .pp-win .pp-star.is-on,
html[data-motion="reduced"] .pp-win .pp-perfect.is-in strong { animation: none; }
