/* ==========================================================================
   gloop.live mobile dock + touch polish (ermintrude4). Loaded after gloop.css.
   - Narrow screens: dock controls wrap instead of overflowing sideways
     (the .acts row was nowrap and ~690px wide at 390px).
   - Touch/narrow: 44px targets, safe-area padding, pressed feedback.
   - #hud-extras: shared slot in the dock for small icon buttons added by other
     scripts (mute, bestiary, boat, build...). Append <button> elements into it.
   Desktop (wide screen + fine pointer) is unchanged; #hud-extras is hidden
   while empty.
   ========================================================================== */

/* Extras slot. Desktop: neutral container only (buttons keep their own
   styles; desktop dock layout is Bob's). Hidden until someone appends. */
.hud-extras { display: flex; align-items: center; gap: 0.35rem; }
.hud-extras:empty { display: none; }
/* touch-only extras (map / trophies from js/mobile.js) */
.hud-extras .mob-only { display: none; }
@media (pointer: coarse) {
  .hud-extras .mob-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.6rem;
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    border-radius: 9px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
    border: 1px solid rgba(236, 230, 218, 0.12);
    cursor: pointer;
  }
  .mob-ico { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
}

/* Narrow: wrap everything in the dock; nothing may push past the viewport. */
@media (max-width: 900px) {
  .dock { flex-wrap: wrap; row-gap: 0.45rem; column-gap: 0.6rem; overflow-x: hidden; }
  .acts { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; }
  .acts button { flex: 1 1 auto; min-width: 0; }
  .hud-extras { flex: 0 1 auto; flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .hud-extras button { min-width: 0; max-width: 100%; }
}

/* Phone widths: compact spacing, safe-area insets, full-height stage. */
@media (max-width: 560px) {
  .stage { height: 100vh; height: 100dvh; }
  .dock {
    padding: 0.45rem max(0.7rem, env(safe-area-inset-right)) calc(0.45rem + env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
    row-gap: 0.35rem;
  }
  .speed { flex: 1 1 8rem; min-width: 0; gap: 0.4rem; }
  .speed input[type="range"] { flex: 1 1 auto; width: auto; min-width: 3rem; }
  .speed span { min-width: 2.2rem; }
  .zoom { flex: 0 0 auto; gap: 0.3rem; }
  .zoom span { min-width: 2.9rem; padding-left: 0.2rem; padding-right: 0.2rem; }
  .acts { gap: 0.3rem; }
  .acts button { padding-left: 0.35rem; padding-right: 0.35rem; letter-spacing: 0.03em; }
  /* clock/weather/action are already in the topbar chips; give the land the room */
  .hint { display: none; }
  /* icon-first on phones: drop text labels, keep the aria-label */
  .hud-extras .mob-icon-btn { padding: 0; width: 44px; }
  .hud-extras .mob-icon-btn .mob-txt { display: none; }
  /* extras: one row; if teammates add more than fit, it scrolls sideways
     inside itself (scroll-snap) instead of widening the page */
  .dock .hud-extras {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    gap: 0.3rem;
    padding: 3px 0; /* room for the bestiary 'new' dot */
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .dock .hud-extras::-webkit-scrollbar { display: none; }
  .dock .hud-extras > * { flex: 0 0 auto; scroll-snap-align: start; }
}

/* Touch-size targets: >= 44x44 CSS px for every dock/HUD button. */
@media (max-width: 900px) and (pointer: coarse), (max-width: 560px) {
  .acts button, .zoom button, .hud-extras button { min-height: 44px; min-width: 44px; }
  .dock .hud-extras button { min-height: 44px; min-width: 44px; } /* beats per-button min-widths */
  .speed input[type="range"] { height: 44px; margin: 0; }
  .gk-hint { width: 44px; height: 44px; }
}

/* Pressed feedback (touch only). js/mobile.js adds .pressed on pointerdown. */
@media (pointer: coarse) {
  .acts button, .zoom button, .hud-extras button, .gk-hint {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .acts button.pressed, .zoom button.pressed, .hud-extras button.pressed, .gk-hint.pressed,
  .acts button:active, .zoom button:active, .hud-extras button:active {
    transform: scale(0.94);
    opacity: 0.8;
    border-color: rgba(185, 245, 180, 0.7);
    color: var(--glow);
    background: linear-gradient(180deg, rgba(185, 245, 180, 0.18), rgba(185, 245, 180, 0.06));
    transition-duration: 0.05s;
  }
}
/* reduced motion: html.gl-rm is set by js/mobile.js from GloopLand.reducedMotion()
   (falls back to prefers-reduced-motion) */
@media (pointer: coarse) {
  html.gl-rm .acts button.pressed, html.gl-rm .zoom button.pressed, html.gl-rm .hud-extras button.pressed, html.gl-rm .gk-hint.pressed,
  html.gl-rm .acts button:active, html.gl-rm .zoom button:active, html.gl-rm .hud-extras button:active { transform: none; transition: none; }
}

/* Boat/ride controls (created by js/mobile.js; touch only, shown while boating
   or riding). Joystick bottom-left, action bottom-right, inside .field so they
   sit above the dock and never cover it. */
.gl-joy, .gl-action { position: absolute; z-index: 4; touch-action: none; -webkit-user-select: none; user-select: none; }
.gl-joy[hidden], .gl-action[hidden] { display: none; }
.gl-joy {
  left: max(16px, calc(env(safe-area-inset-left) + 12px));
  bottom: 16px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(12, 16, 22, 0.35), rgba(12, 16, 22, 0.62));
  border: 1px solid rgba(236, 230, 218, 0.18);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.gl-joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(185, 245, 180, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: transform 0.12s ease-out;
}
.gl-joy.is-active .gl-joy-knob { transition: none; border-color: rgba(185, 245, 180, 0.85); box-shadow: 0 0 0 4px rgba(185, 245, 180, 0.12), 0 4px 14px rgba(0, 0, 0, 0.4); }
.gl-action {
  right: max(16px, calc(env(safe-area-inset-right) + 12px));
  bottom: 28px;
  width: 76px;
  height: 76px;
  padding: 0;
  border-radius: 50%;
  color: var(--glow);
  background: radial-gradient(circle at 50% 35%, rgba(185, 245, 180, 0.3), rgba(12, 16, 22, 0.7));
  border: 1px solid rgba(185, 245, 180, 0.55);
  box-shadow: 0 0 0 4px rgba(185, 245, 180, 0.08), 0 8px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gl-action::after {
  content: '';
  display: block;
  width: 26px;
  height: 26px;
  margin: auto;
  border-radius: 50%;
  border: 2px solid currentColor;
}
.gl-action.pressed, .gl-action:active { transform: scale(0.92); opacity: 0.85; background: radial-gradient(circle at 50% 35%, rgba(185, 245, 180, 0.45), rgba(12, 16, 22, 0.7)); }
.gl-action:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }
/* keep the thoughts panel clear of the pad while it is showing */
html.has-vehicle-pad .thoughts { bottom: 160px; max-height: 24%; }
/* the log overlays the land: let it scroll, but a pinch there must not zoom the page */
@media (pointer: coarse) { .thoughts { touch-action: pan-y; } }
html.gl-rm .gl-joy-knob { transition: none; }
html.gl-rm .gl-action.pressed, html.gl-rm .gl-action:active { transform: none; }
/* short boating field on phones (css/boat.css v6 .field.boat-short): the one-line strip ends
   ~102px down and the minimap ~168px down, so a smaller pad at the bottom edge clears both */
@media (max-width: 560px) {
  html.has-vehicle-pad .field.boat-on.boat-short .gl-joy { bottom: 8px; width: 112px; height: 112px; }
  html.has-vehicle-pad .field.boat-on.boat-short .gl-joy-knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  html.has-vehicle-pad .field.boat-on.boat-short .gl-action { bottom: 8px; width: 60px; height: 60px; }
}
/* phones, boat or mammoth pad showing (not the short boating field, where css/boat.css parks the log
   in the top row): the log sits at bottom:160px and can climb into the minimap (.mm-wrap: right 0.8rem,
   6.5rem wide), so end it 8px left of the minimap column */
@media (max-width: 560px) {
  html.has-vehicle-pad .field:not(.boat-short) .thoughts { right: calc(0.8rem + 6.5rem + 8px); width: auto; }
}
/* phones: the pack row (gloop.js chips; fruit.js + craft.js add more) stays ONE line and scrolls
   sideways inside itself, so a full pack can't wrap to 5-6 rows and squeeze the game area */
@media (max-width: 560px) {
  .pack { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; touch-action: pan-x; }
  .pack::-webkit-scrollbar { display: none; }
  .pack > * { flex: 0 0 auto; white-space: nowrap; }
}
