/* On-screen touch controls - owned by src/ui/touchControls.js (driven by src/core/inputTouch.js).
   Period register to match the HUD: dark field-glass panels, brass rings, IM Fell SC labels.
   Sizes come from two custom properties written by TouchControls.layout():
     --tc-u  button unit in px (7.2% of the short side, 46-64 px)
     --tc-b  clearance above the HUD weapon panel (bottom right), in px
   No viewport units: on iPadOS WebKit vw / vh can disagree with the window. */

#ui-root > .tc { pointer-events: none; }
.tc {
  --tc-u: 58px;
  --tc-b: 120px;
  --tc-ink: #efe6d3;
  --tc-brass: #d8b25a;
  --tc-panel: rgba(16, 12, 9, 0.55);
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  overflow: hidden;
  color: var(--tc-ink);
  font-family: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.tc.on { display: block; }

/* ------------------------------------------------------------------ buttons */

.tc-btn {
  all: unset;
  box-sizing: border-box;
  position: relative;
  pointer-events: auto;
  touch-action: none;
  width: calc(var(--tc-u) * 0.85);
  height: calc(var(--tc-u) * 0.85);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: radial-gradient(circle at 50% 38%, rgba(48, 38, 28, 0.62), var(--tc-panel) 70%);
  box-shadow: inset 0 0 0 2px rgba(216, 178, 90, 0.72), inset 0 0 0 3.5px rgba(16, 12, 9, 0.55), 0 2px 8px rgba(0, 0, 0, 0.45);
  color: var(--tc-ink);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  opacity: 0.86;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.12s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.tc-btn.is-off { display: none; }
.tc-btn.is-down { transform: scale(0.93); opacity: 1; background: radial-gradient(circle at 50% 40%, rgba(216, 178, 90, 0.5), rgba(60, 44, 24, 0.7) 72%); }
.tc-btn.is-on { opacity: 1; color: #1b1611; text-shadow: none; background: radial-gradient(circle at 50% 38%, #ecd08a, #b8923f 75%); box-shadow: inset 0 0 0 2px #f1dc9e, 0 0 10px rgba(216, 178, 90, 0.55), 0 2px 8px rgba(0, 0, 0, 0.45); }
.tc-ico { display: block; width: 44%; height: 44%; }
.tc-ico svg { display: block; width: 100%; height: 100%; }
.tc-glyph { display: block; font-family: 'IM Fell DW Pica', Georgia, serif; font-size: calc(var(--tc-u) * 0.36); line-height: 1; }
.tc-lbl { display: block; font-size: calc(var(--tc-u) * 0.17); letter-spacing: 0.06em; line-height: 1; white-space: nowrap; }

/* ------------------------------------------------------------------ cluster (bottom right, above the weapon panel)
   Each button is placed by its centre (--x, --y: right / bottom offsets from the anchor, in units)
   and diameter (--d, units). */

.tc-cluster {
  position: absolute;
  right: calc(40px + env(safe-area-inset-right, 0px));  /* the HUD's off-screen markers run down the edge */
  bottom: var(--tc-b);
  width: 0;
  height: 0;
}
.tc-cluster .tc-btn {
  position: absolute;
  width: calc(var(--tc-u) * var(--d));
  height: calc(var(--tc-u) * var(--d));
  right: calc(var(--tc-u) * (var(--x) - var(--d) / 2));
  bottom: calc(var(--tc-u) * (var(--y) - var(--d) / 2));
}
/* kept under ~3.5 units so the HUD's aiming read-outs (wind, rear-sight card) above stay clear;
   Focus takes Jump's place while aiming */
.tc-b-fire { --x: 1.05; --y: 1.0; --d: 1.55; }
.tc-b-aim { --x: 2.75; --y: 0.75; --d: 1.15; }
.tc-b-reload { --x: 0.8; --y: 2.6; --d: 1.0; }
.tc-b-jump, .tc-b-focus { --x: 2.3; --y: 2.25; --d: 0.95; }
.tc-b-crouch { --x: 4.05; --y: 0.6; --d: 0.9; }
.tc-b-prone { --x: 3.85; --y: 1.75; --d: 0.9; }
.tc-b-spur { --x: 4.0; --y: 0.95; --d: 1.0; }
.tc-b-use { --x: 3.6; --y: 2.95; --d: 1.0; }
.tc-b-breath { --x: 5.0; --y: 2.7; --d: 0.95; }
.tc-b-rangeUp { --x: 5.25; --y: 1.6; --d: 0.8; }
.tc-b-rangeDown { --x: 5.25; --y: 0.6; --d: 0.8; }
.tc-b-fire .tc-ico { width: 46%; height: 46%; }
.tc-b-fire .tc-lbl { font-size: calc(var(--tc-u) * 0.2); }
.tc-b-fire { box-shadow: inset 0 0 0 2.5px rgba(216, 178, 90, 0.85), inset 0 0 0 4.5px rgba(16, 12, 9, 0.55), 0 2px 10px rgba(0, 0, 0, 0.5); }
.tc-b-jump .tc-ico { transform: rotate(180deg); }
.tc-b-prone .tc-ico { transform: rotate(-90deg); }
.tc-b-rangeUp .tc-lbl, .tc-b-rangeDown .tc-lbl { font-size: calc(var(--tc-u) * 0.15); }

/* ------------------------------------------------------------------ top right bar + satchel drawer */

.tc-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex;
  gap: 8px;
}
.tc-drawer {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px) + var(--tc-u) * 0.85);
  right: calc(20px + env(safe-area-inset-right, 0px) + var(--tc-u) * 0.85);
  display: none;
  flex-direction: column;
  gap: 8px;
}
.tc.is-drawer .tc-drawer { display: flex; }
.tc-top .tc-b-pause { order: 9; }
.tc-b-pause .tc-glyph { font-size: calc(var(--tc-u) * 0.3); }

/* ------------------------------------------------------------------ floating stick */

.tc-stick {
  position: absolute;
  left: 24%;
  top: 68%;
  width: calc(var(--tc-u) * 2.1);
  height: calc(var(--tc-u) * 2.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(circle, rgba(16, 12, 9, 0.12) 40%, rgba(16, 12, 9, 0.34) 72%);
  box-shadow: inset 0 0 0 2px rgba(216, 178, 90, 0.55);
  transition: opacity 0.2s ease;
}
.tc-stick.is-idle { opacity: 0.32; }
.tc-stick.is-live { opacity: 0.95; transition: none; }
.tc-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--tc-u) * 0.9);
  height: calc(var(--tc-u) * 0.9);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 38%, rgba(239, 230, 211, 0.55), rgba(120, 96, 60, 0.55) 75%);
  box-shadow: inset 0 0 0 2px rgba(216, 178, 90, 0.85), 0 2px 6px rgba(0, 0, 0, 0.5);
}
.tc-stick.is-sprint { box-shadow: inset 0 0 0 3px rgba(236, 208, 138, 0.95), 0 0 14px rgba(216, 178, 90, 0.45); }
.tc-stick.is-sprint .tc-knob { background: radial-gradient(circle at 50% 38%, #ecd08a, #b8923f 75%); }

/* ------------------------------------------------------------------ HUD while the touch controls show:
   the interaction prompt and weapon hint move from bottom right (under the Fire cluster) to bottom centre */
body.tc-on .hud-prompt, body.tc-on .hud-hint { right: auto; left: 50%; translate: -50% 0; text-align: center; }
