/* tasks.css — task popup and all mini-game styles */

/* Stretches the blocking full-map popup across the game viewport above gameplay and HUD. */
#mapPopup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at center, rgba(160, 123, 79, 0.14), transparent 36%),
    rgba(16, 8, 6, 0.86);
  z-index: 24;
  pointer-events: all;
}

/* Gives the popup a full-screen canvas for the cover-fitted map image. */
#mapPopupPanel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Crops the oversized cover-fitted map so the viewport never shows black bars. */
#mapPopupViewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Keeps the cursor honest while direct pointer dragging pans the full-map image. */
#mapPopupViewport.is-dragging {
  cursor: grabbing;
}

/* Overlays the back button directly on the left of the map frame so it stays visible while maximized. */
#mapPopupClose {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: rgba(19, 12, 10, 0.82);
  border: 1px solid rgba(255, 236, 199, 0.32);
  border-radius: 999px;
  color: #f5e2c2;
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

/* Centers the SVG back icon inside the circular control. */
.map-popup-close-icon {
  width: 24px;
  height: 24px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Brightens the map popup back button on hover so it reads as interactive. */
#mapPopupClose:hover {
  color: white;
  background: rgba(45, 27, 21, 0.92);
}

/* Renders the map as a cover-fitted image that can be panned within its overflow bounds. */
#mapPopupImage {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  max-width: none;
  max-height: none;
  transform: translate(-50%, -50%);
  transform-origin: center;
  user-select: none;
  -webkit-user-drag: none;
}

/* Hides the previous popup image while a newly selected building interior loads. */
#mapPopupImage.is-loading {
  visibility: hidden;
}

#mapPopupInteriorWalkableDebug {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0.32;
  z-index: 1;
}

/* Pins the map overview marker above the cover-fitted city image. */
#mapPopupYouAreHere {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* Renders the tiny red locator dot in the map popup. */
#mapPopupYouAreHereDot {
  position: absolute;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d91821;
  box-shadow:
    0 0 0 1px rgba(255, 244, 240, 0.9),
    0 0 8px rgba(217, 24, 33, 0.5);
  transform: translate(-50%, -50%);
}

/* Stacks the label above the dot so the exact player position stays centered on the circle. */
#mapPopupYouAreHereBadge {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 56px;
  transform: translate(-50%, calc(-100% - 10px));
  padding: 4px 7px 5px;
  border-radius: 12px;
  background: rgba(34, 12, 10, 0.55);
  border: 1px solid rgba(255, 219, 210, 0.2);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(4px);
}

/* Keeps the locator text compact but readable over the map art. */
#mapPopupYouAreHereLabel,
#mapPopupYouAreHereLabelLine2 {
  display: block;
  color: #ffe9e5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.75),
    0 0 6px rgba(0, 0, 0, 0.35);
}

/* Hosts the interactive room marker highlights in the same source-image coordinate system. */
#mapPopupInteriorMarkerDebug {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 1;
  user-select: none;
}

.map-popup-interior-marker-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 50, 0.92);
  border: 4px solid #ffdd00;
  box-shadow: 0 0 24px rgba(255, 255, 50, 0.8);
  color: #111;
  font-size: 20px;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.map-popup-interior-marker-dot.is-closest-debug-marker {
  width: 46px;
  height: 46px;
  background: rgba(255, 79, 216, 0.96);
  border-color: #ffffff;
  box-shadow:
    0 0 0 6px rgba(255, 79, 216, 0.42),
    0 0 28px rgba(255, 79, 216, 0.9);
  line-height: 38px;
}

.map-popup-interior-marker-body-debug {
  position: absolute;
  display: block;
  border: 3px solid #00f6ff;
  border-radius: 12px;
  box-shadow:
    0 0 16px rgba(0, 246, 255, 0.86),
    inset 0 0 16px rgba(0, 246, 255, 0.18);
}

.map-popup-interior-marker-anchor-debug {
  position: absolute;
  display: block;
  width: 18px;
  height: 18px;
  border: 3px solid #00f6ff;
  border-radius: 50%;
  background: rgba(0, 20, 24, 0.85);
  box-shadow: 0 0 16px rgba(0, 246, 255, 0.86);
  transform: translate(-50%, -50%);
}

.map-popup-interior-marker-anchor-debug::before,
.map-popup-interior-marker-anchor-debug::after {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  background: #00f6ff;
  content: "";
  transform: translate(-50%, -50%);
}

.map-popup-interior-marker-anchor-debug::before {
  width: 26px;
  height: 3px;
}

.map-popup-interior-marker-anchor-debug::after {
  width: 3px;
  height: 26px;
}

/* Places the live interior player canvas in the popup image's natural coordinate space. */
#mapPopupInteriorPlayer {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  pointer-events: none;
  transform: translate(-50%, -100%);
  transform-origin: center bottom;
  z-index: 2;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.32));
}

/* Shows the exact foot collision area sampled against the room no-walk mask. */
#mapPopupInteriorFootDebug {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 4;
}

#mapPopupInteriorFootArea {
  position: absolute;
  left: 0;
  top: 0;
  border: 2px solid rgba(100, 255, 150, 0.92);
  border-radius: 50%;
  background: rgba(100, 255, 150, 0.16);
  box-shadow: 0 0 10px rgba(100, 255, 150, 0.35);
  transform: translate(-50%, -50%);
}

.map-popup-interior-foot-sample {
  position: absolute;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64ff96;
  box-shadow:
    0 0 0 1px rgba(10, 24, 12, 0.84),
    0 0 7px rgba(100, 255, 150, 0.72);
  transform: translate(-50%, -50%);
}

.map-popup-interior-foot-sample.is-blocked {
  background: #ff4a4a;
  box-shadow:
    0 0 0 1px rgba(34, 6, 6, 0.9),
    0 0 8px rgba(255, 74, 74, 0.78);
}

/* Anchors the mobile map-pan pad in the bottom-right corner of the popup. */
#mapPanPad {
  --touch-pad-size: min(32vw, 176px);
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: var(--touch-pad-size);
  height: var(--touch-pad-size);
  border-radius: 50%;
  pointer-events: all;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Reuses the same low-contrast joystick ring language for map panning. */
#mapPanPadRing {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 241, 218, 0.16);
  background:
    radial-gradient(circle at center, rgba(255, 214, 152, 0.03) 0 18%, rgba(12, 13, 20, 0.1) 19% 64%, rgba(12, 13, 20, 0.18) 65% 100%),
    linear-gradient(180deg, rgba(31, 18, 15, 0.12) 0%, rgba(11, 12, 18, 0.18) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Draws subtle cross guides through the map pan pad. */
#mapPanPadRing::before,
#mapPanPadRing::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(255, 241, 218, 0.08);
  transform: translate(-50%, -50%);
}

#mapPanPadRing::before {
  width: 1px;
  height: 74%;
}

#mapPanPadRing::after {
  width: 74%;
  height: 1px;
}

/* Marks the central dead zone for finer mobile panning control. */
#mapPanPadCenter {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 241, 218, 0.1);
  background: rgba(255, 241, 218, 0.02);
  box-shadow: inset 0 0 18px rgba(255, 241, 218, 0.04);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* Shows the current mobile pan direction with a warm thumb cap. */
#mapPanPadThumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #f9d6a4 0%, #b77d43 56%, #6f4426 100%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.24),
    0 6px 18px rgba(0, 0, 0, 0.38);
}

@media (pointer: fine), (orientation: portrait) {
  #mapPanPad {
    display: none !important;
  }
}

/* Popup container */
/* Centers the task popup and gives it the framed panel treatment used for mini-games. */
#taskPopup {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(180deg, rgba(62, 38, 28, 0.98), rgba(35, 21, 16, 0.98));
  border: 2px solid rgba(224, 197, 150, 0.58); border-radius: 16px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(255, 241, 212, 0.12);
  padding: 20px; min-width: 340px; z-index: 20; color: white;
}
/* Styles the title at the top of the task popup. */
#taskPopup h3 { text-align: center; margin-bottom: 12px; color: #ffe4bd; font-size: 18px; }
/* Positions the close button in the top-right corner of the task popup. */
#taskPopupClose {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; color: #c2a98b; font-size: 20px; cursor: pointer;
}
/* Brightens the close button on hover so it reads as interactive. */
#taskPopupClose:hover { color: white; }

/* Wiring task */
/* Centers the wiring task canvas and shows a precise cursor for drag connections. */
#wiringCanvas { display: block; margin: 0 auto; cursor: crosshair; }

/* Upload task */
/* Styles the rounded upload progress track inside upload tasks. */
#uploadProgress { height: 28px; background: #251712; border-radius: 999px; overflow: hidden; margin: 10px 0; }
/* Fills the upload progress track as the upload task advances. */
#uploadBar { height: 100%; background: linear-gradient(to right, #a6d076, #5b8e47); width: 0%; }

/* Calibrate task */
/* Styles the buttons used by the Simon-style calibration mini-game. */
.calibBtn {
  height: 54px; background: #4d3022; border: 2px solid #c49c70;
  border-radius: 10px; color: white; font-size: 18px; font-weight: bold;
  cursor: pointer; font-family: inherit; transition: background 0.1s;
}
/* Brightens calibration buttons when hovered. */
.calibBtn:hover { background: #68402d; }
