/* touch.css — on-screen controls (touch.js) and the HUD rearrangement they
   need. Everything here is scoped to body.touch-mode or the touch elements, so
   a desktop browser renders exactly as before. */

#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 20;            /* above #ui-layer (10), below the menus */
  pointer-events: none;   /* only the buttons take touches; the canvas gets the rest */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#touch-controls[hidden] { display: none; }

.touch-btn,
.touch-sys {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  box-sizing: border-box;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #f4e6c0;
  font: 700 15px/1 'Segoe UI', system-ui, sans-serif;
  background: rgba(14, 18, 28, 0.55);
  border: 2px solid rgba(240, 192, 64, 0.55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
}

.touch-attack {
  font-size: 16px;
  background: rgba(150, 36, 28, 0.6);
  border-color: rgba(255, 170, 120, 0.7);
}

.touch-btn.is-held {
  border-color: #fff;
  transform: scale(0.94);
}

.touch-label { position: absolute; text-shadow: 0 1px 2px #000; }
.touch-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  pointer-events: none;
}
.touch-icon[hidden] { display: none; }

.touch-shade {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
}
.touch-cd {
  position: absolute;
  color: #fff;
  font-size: 16px;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
.touch-btn.on-cooldown .touch-shade { opacity: 1; }
.touch-btn.stage-active { border-color: #ffb84a; box-shadow: 0 0 10px rgba(255, 184, 74, 0.7); }
.touch-btn.is-locked { opacity: 0.35; }
/* Mirrors the desktop bar: ult dimmed until rage is full, build-up meters dim
   until full and ring orange when loaded. */
.touch-btn.rage-not-ready .touch-icon { filter: saturate(0.25) brightness(0.55); }
.touch-btn.rage-not-ready { border-color: rgba(180, 40, 40, 0.6); }
.touch-btn.stacks-charging .touch-icon { filter: saturate(0.75) brightness(0.9); }
.touch-btn.stacks-ready { border-color: #ff9030; box-shadow: 0 0 10px rgba(255, 144, 48, 0.7); }
/* Stack count pill, inside the circle (the button clips its overflow). */
.touch-stacks {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 12px;
  color: #ffd98a;
  background: rgba(0, 0, 0, 0.65);
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.touch-stacks[hidden] { display: none; }
.touch-stacks.ready { color: #fffaf0; background: rgba(255, 80, 20, 0.8); }

/* Minion (last hit) and tower buttons hugging the attack button. */
.touch-target {
  font-size: 10px;
  background: rgba(14, 18, 28, 0.7);
  border-color: rgba(255, 170, 120, 0.55);
}

/* ── Movement joystick ─────────────────────────────────────────────── */
/* The zone is the left part of the screen below the minimap and Menu/Score
   buttons. The base rests bottom-left and jumps to wherever the thumb lands. */
#touch-joy-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42%;
  top: calc(150px + env(safe-area-inset-top, 0px));
  pointer-events: auto;
  touch-action: none;
}
#touch-joy-base {
  position: absolute;
  left: calc(110px + env(safe-area-inset-left, 0px));
  bottom: calc(46px + env(safe-area-inset-bottom, 0px));
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;   /* left/top address the centre */
  border-radius: 50%;
  background: rgba(14, 18, 28, 0.28);
  border: 2px solid rgba(240, 192, 64, 0.3);
  pointer-events: none;
}
/* Resting position is given by bottom; the centre offset only applies once
   touch.js sets top on press. */
#touch-joy-zone:not(.is-active) #touch-joy-base { margin: 0 0 0 -62px; }
#touch-joy-zone.is-active #touch-joy-base {
  background: rgba(14, 18, 28, 0.4);
  border-color: rgba(240, 192, 64, 0.6);
}
#touch-joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(244, 230, 192, 0.55);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Release over this while aiming to drop the cast. Only there while aiming;
   top-right, above the ability arc, where Wild Rift keeps it. */
#touch-cancel {
  position: absolute;
  right: calc(120px + env(safe-area-inset-right, 0px));
  top: calc(12px + env(safe-area-inset-top, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font: 700 22px/1 sans-serif;
  color: #fff;
  background: rgba(60, 10, 10, 0.55);
  border: 2px solid rgba(255, 90, 90, 0.7);
  pointer-events: none;   /* hit-tested by touch.js; the held button owns the pointer */
}
#touch-controls.is-aiming #touch-cancel { display: flex; }
#touch-cancel.is-hot { background: rgba(200, 30, 30, 0.85); transform: scale(1.15); }

/* Menu (Escape) and scoreboard (hold Tab), top-left beside the minimap. */
.touch-sys {
  top: calc(8px + env(safe-area-inset-top, 0px));
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 12px;
}
.touch-menu  { left: calc(166px + env(safe-area-inset-left, 0px)); font-size: 20px; }
.touch-score { left: calc(212px + env(safe-area-inset-left, 0px)); }

/* ── HUD rearrangement ─────────────────────────────────────────────── */
/* The minimap moves to the top-left (the bottom-right corner belongs to the
   thumbs) and shrinks; minimap.js maps through getBoundingClientRect, so the
   new size needs nothing else. */
body.touch-mode #minimap-container {
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  bottom: auto;
  right: auto;
}
body.touch-mode #minimap-canvas {
  width: 150px;
  height: 124px;
}
body.touch-mode #perf-hud { top: 140px; }

/* The buttons carry the cooldowns and ward count, so the bar and pips would
   only be a second copy under the player's thumb. The stats panel stays,
   bottom-centre between the two thumbs, and smaller. */
body.touch-mode #ability-bar,
body.touch-mode #ward-panel { display: none; }
body.touch-mode #ui-layer {
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}
body.touch-mode .bottom-hud {
  transform: scale(0.7) translateX(-12%);
  transform-origin: bottom center;
}

/* Portrait leaves no room for the map, the stats and two thumbs. */
#touch-rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: #0b0e15;
  color: #f4e6c0;
  font: 700 16px/1.5 'Segoe UI', system-ui, sans-serif;
}
@media (orientation: portrait) {
  body.touch-mode #touch-rotate-hint { display: flex; }
}

/* The minimap takes its own touch gestures (minimap.js); without this the
   browser claims the drag as a page pan before they arrive. */
#minimap-canvas { touch-action: none; }

/* The canvas renders at device density in touch mode (global.render_scale),
   so its backbuffer is 2x its CSS box. Pin the box to the viewport — over
   whatever inline size the runner writes — so the extra pixels become
   sharpness rather than an oversized canvas. */
body.touch-mode #canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

/* A slot this champion does not have (touch.js hides it from ability:setup). */
.touch-btn[hidden] { display: none; }

/* ── Fullscreen ────────────────────────────────────────────────────── */
/* In game: the third button in the Menu/Score row. */
.touch-full { left: calc(258px + env(safe-area-inset-left, 0px)); font-size: 20px; }
.touch-sys[hidden] { display: none; }

/* In the menus: the last item of the top bar. Only ever created in touch mode. */
.menu-fullscreen {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  margin-left: 4px;
  border-radius: 8px;
  border: 1px solid rgba(240, 192, 64, 0.45);
  background: rgba(14, 18, 28, 0.6);
  color: #f4e6c0;
  font: 700 20px/1 'Segoe UI', system-ui, sans-serif;
  touch-action: manipulation;
  cursor: pointer;
}
.menu-fullscreen[hidden] { display: none; }

/* iPhone: no fullscreen API, so say how to get there instead. Menus only. */
#touch-install-hint {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 900;   /* over the menus, under the rotate hint */
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 8px 8px 14px;
  border-radius: 10px;
  background: rgba(11, 14, 21, 0.94);
  border: 1px solid rgba(240, 192, 64, 0.5);
  color: #f4e6c0;
  font: 600 13px/1.35 'Segoe UI', system-ui, sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}
#touch-install-hint[hidden] { display: none; }
.touch-install-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}
