/* Framewalk — mobile / touch stylesheet.
   Load AFTER the inline styles in framewalk.html:
     <link rel="stylesheet" href="css/mobile.css">
   Layout reshaping lives under @media (max-width: 900px);
   touch affordances live under @media (pointer: coarse).
   Desktop with a mouse is untouched. */

/* ---------- always-on safety (harmless on desktop) ---------- */
body { overscroll-behavior: none; }
#canvas2d, #canvas3d { touch-action: none; }

/* ---------- injected drawer toggle (mobile.js creates #fwDrawerToggle) ---------- */
#fwDrawerToggle {
  position: fixed;
  top: 56px;            /* mobile.js re-anchors this just below #topbar */
  right: 10px;
  z-index: 41;          /* above the drawer (40), below modals (50) */
  width: 44px;
  height: 44px;
  display: none;        /* only visible under the mobile media query */
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(23, 27, 34, 0.92);
  color: #c6d0dd;
  border: 1px solid #313a49;
  font-size: 18px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#fwDrawerToggle:active { background: #2a3342; color: #fff; }

/* ---------- virtual joysticks (mobile.js creates + shows in walk mode) ---------- */
.fwStick {
  position: absolute;
  bottom: 24px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(127, 214, 164, 0.06);
  border: 1px solid rgba(127, 214, 164, 0.28);
  z-index: 6;
  display: none;        /* mobile.js toggles */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#fwStickL { left: 20px; }
#fwStickR { right: 20px; }
.fwStick::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(221, 228, 238, 0.35);
  pointer-events: none;
}
.fwStickNub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(221, 228, 238, 0.16);
  border: 1px solid rgba(221, 228, 238, 0.38);
  pointer-events: none;
}

/* ---------- touch affordances ---------- */
@media (pointer: coarse) {
  .toolbtn {
    width: 44px;
    height: 44px;
    font-size: 19px;
    touch-action: manipulation;
  }
  .tbtn {
    min-height: 40px;
    padding: 8px 12px;
    touch-action: manipulation;
  }
  .minibtn, .palbtn {
    min-height: 38px;
    touch-action: manipulation;
  }
  #stage {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  /* the hint talks about WASD + mouse — meaningless on touch (sticks appear instead) */
  #walkHint { display: none !important; }
}

/* ---------- small-screen layout ---------- */
@media (max-width: 900px) {

  #fwDrawerToggle { display: flex; }

  /* topbar: single scrollable row, slightly smaller buttons, logo kept */
  #topbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #topbar::-webkit-scrollbar { display: none; }
  #logo { flex: 0 0 auto; }
  #projName { width: 110px; flex: 0 0 auto; font-size: 16px; padding: 4px 8px; }
  #topbar .tbtn { flex: 0 0 auto; padding: 6px 9px; font-size: 11px; white-space: nowrap; }
  #topbar .sep { flex: 0 0 auto; }

  /* stage on top, toolbar docked at the bottom of #body */
  #body { flex-direction: column; }
  #stage { order: 0; }
  #toolbar {
    order: 2;
    width: 100%;
    height: auto;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-top: 1px solid #262c37;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #toolbar::-webkit-scrollbar { display: none; }
  #toolbar .gap { width: 12px; height: auto; flex: 0 0 auto; }
  .toolbtn { flex: 0 0 auto; width: 44px; height: 44px; }

  /* right panel becomes an off-canvas drawer sliding in over the stage */
  #rightPanel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 86vw);
    z-index: 40;
    transform: translateX(110%);
    transition: transform 0.26s ease;
    box-shadow: -14px 0 34px rgba(0, 0, 0, 0.5);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  #rightPanel.open { transform: translateX(0); }

  /* modals: comfortable on small screens */
  .modalCard {
    width: min(480px, 94vw);
    padding: 16px 16px 18px;
    max-height: 86vh;
    max-height: 86svh;
  }
  .modalCard input[type="password"],
  .modalCard input[type="text"],
  .modalCard textarea {
    font-size: 16px;   /* prevents iOS focus auto-zoom */
  }

  /* keep 3D mode buttons clear of the drawer toggle */
  #viewControls3d { top: 8px; }

  #statusbar { font-size: 11px; padding: 0 10px; gap: 10px; }
}
