/* SF Isometric — map-only page.
   The map owns the window; every control floats over it. */

:root {
  --ink: #101214;
  --paper: #0b0c0e;
  --line: rgba(255, 255, 255, .16);
  --chip: rgba(14, 16, 20, .72);
  --chip-ink: #eef1f4;
  --muted: rgba(238, 241, 244, .62);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--chip-ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.map-only { height: 100dvh; width: 100%; }

/* --- the map surface ------------------------------------------------------ */

.map-viewport {
  position: relative;
  overflow: hidden;
  height: 100%;
  width: 100%;
  background: #0b0c0e;
  cursor: grab;
  touch-action: none;             /* the viewport owns every gesture */
  user-select: none;
  -webkit-user-select: none;
}
.map-viewport.is-dragging { cursor: grabbing; }

.map-stage {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.map-viewport.is-animating .map-stage { transition: transform .48s cubic-bezier(.22, .61, .36, 1); }

.map-stage .quadrant {
  position: absolute;
  width: 512px;
  height: 512px;
  display: block;
  /* Below 100% the pieces are being DOWNSCALED, where nearest-neighbour drops pixels and
     aliases badly; smooth resampling is correct there. Above 100% they are magnified and
     nearest-neighbour is what keeps the pixel art crisp. .magnified is set by the viewer. */
  image-rendering: auto;
  z-index: 1;                     /* ABOVE the overview: a crisp piece always wins */
  pointer-events: none;           /* hit-testing happens against the grid in JS */
  user-select: none;
  -webkit-user-drag: none;
  background: transparent;
}
.map-stage.magnified .quadrant { image-rendering: pixelated; }

.map-stage .overview {
  position: absolute;
  top: 0; left: 0;
  display: block;
  z-index: 0;                     /* BASE layer: full-res pieces paint over it */
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: auto;          /* the overview is downscaled, so smooth is correct */
}

/* --- floating chrome ------------------------------------------------------ */

.map-controls {
  position: absolute;
  right: 12px; top: 12px;
  display: flex;
  gap: 6px;
  z-index: 3;
}
.map-controls button {
  font: inherit;
  font-size: 16px;
  line-height: 1;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  color: var(--chip-ink);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.map-controls button:hover { background: rgba(30, 34, 40, .85); }
.map-controls button:active { transform: translateY(1px); }

.map-readout, .map-hint, .map-facts {
  position: absolute;
  margin: 0;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--chip);
  color: var(--chip-ink);
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 3;
}
.map-readout { left: 12px; top: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.map-facts   { left: 12px; top: 40px; color: var(--muted); }
.map-hint    { left: 12px; bottom: 12px; color: var(--muted); }

/* the only chrome that is a link, so it takes pointer events back */
.map-credit {
  position: absolute;
  right: 12px; bottom: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .01em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  border: 1px solid var(--line);
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: background .15s, border-color .15s, color .15s;
}
.map-credit:hover {
  background: rgba(30, 34, 40, .92);
  border-color: rgba(255, 255, 255, .32);
  color: var(--chip-ink);
}

@media (max-width: 640px) {
  .map-hint { display: none; }
  .map-facts { display: none; }
  .map-readout { font-size: 10.5px; }
  .map-credit { font-size: 11px; padding: 5px 10px; }
}

/* --- quadrant lightbox ---------------------------------------------------- */

.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100dvh;
  width: 100%;
  height: 100%;
}
.lightbox::backdrop { background: rgba(6, 7, 9, .93); }
.lightbox figure {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
}
.lightbox img {
  max-width: min(92vw, 1024px);
  max-height: 78dvh;
  image-rendering: pixelated;
  border-radius: 8px;
  background: #14161a;
}
.lightbox figcaption {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.lightbox-close {
  position: absolute;
  right: 14px; top: 14px;
  width: 38px; height: 38px;
  font: inherit; font-size: 15px;
  color: var(--chip-ink);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}
