/* Maps section: /maps index cards, /maps/<slug> key art header and viewer.
   Uses the site palette from style.css (dark theme only). */

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Key art header: the place's Roblox thumbnail, fading into the page ---- */
body.map-page-with-cover::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 61px; right: 0; left: 0;
  height: 340px;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 46% 40% at 50% 56%, rgba(5, 7, 12, 0.42), rgba(5, 7, 12, 0.08) 66%, transparent 100%),
    linear-gradient(180deg, rgba(17, 20, 29, 0.05) 0%, rgba(17, 20, 29, 0.2) 45%, rgba(17, 20, 29, 0.74) 78%, var(--bg) 100%),
    var(--map-key-art);
  background-position: center 42%;
  background-repeat: no-repeat;
  background-size: cover;
}
body.map-page-with-cover > main,
body.map-page-with-cover > .site-footer { position: relative; z-index: 1; }

.map-hero { text-align: center; padding: 70px 0 30px; }
.map-hero h1 { margin: 0 0 10px; font-size: 2.3rem; line-height: 1.15; }
.map-page-with-cover .map-hero { text-shadow: 0 2px 4px rgba(0, 0, 0, 0.96), 0 7px 24px rgba(0, 0, 0, 0.88); }
.map-hero-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; }
.map-hero-facts li {
  padding: 3px 10px; border-radius: 999px; font-size: 13px; color: rgba(232, 236, 244, 0.92);
  background: rgba(10, 13, 20, 0.62); border: 1px solid rgba(255, 255, 255, 0.12); text-shadow: none;
  backdrop-filter: blur(4px);
}
.map-hero-facts b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  body.map-page-with-cover::before { height: 300px; }
  .map-hero { padding: 54px 0 24px; }
  .map-hero h1 { font-size: 1.8rem; }
}

/* ---- Layer toggles ---- */
.map-viewer-shell { margin: 0 0 8px; }
.map-layers { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.map-layer-toggle {
  display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 4px 11px 4px 9px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-card);
  font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none;
  position: relative;
}
.map-layer-toggle:hover { background: var(--bg-card-hover); }
.map-layer-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.map-layer-toggle:has(input:checked) { color: var(--text); border-color: #3c4862; }
.map-layer-toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.map-layer-swatch { width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid currentColor; opacity: 0.55; flex: none; }
.map-layer-toggle:has(input:checked) .map-layer-swatch { opacity: 1; background: var(--swatch, var(--accent)); border-color: var(--swatch, var(--accent)); }
.map-layer-toggle-spawns { --swatch: #ef6f6f; }
.map-layer-toggle-portals { --swatch: #f5d8a9; }
.map-layer-toggle-areas { --swatch: #e8ecf4; }
.map-layer-toggle-quests { --swatch: #00aaff; }
.map-layer-toggle-services { --swatch: #fff019; }
.map-layer-toggle-npcs { --swatch: #96bec8; }
.map-layer-toggle-doors { --swatch: #c9d1de; }
.map-layer-toggle-arrivals { --swatch: #6fd66f; }
.map-layer-toggle-pois { --swatch: #ffc94d; }
.map-layer-toggle-pvp { --swatch: #ff5c5c; }
.map-layer-toggle-fishing { --swatch: #4fb3ff; }
.map-layer-toggle-mining { --swatch: #a9b8d6; }
.map-layer-toggle-gathering { --swatch: #8fdc6a; }

/* ---- Viewer ---- */
.map-viewer {
  position: relative;
  height: min(74vh, 780px);
  min-height: 380px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: radial-gradient(ellipse at center, #141a26 0%, #0b0e15 100%);
  touch-action: none;
  cursor: grab;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.map-viewer:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.map-viewer.is-dragging { cursor: grabbing; }
.map-viewer:fullscreen { border-radius: 0; height: 100%; border: 0; }
.map-viewer.is-expanded { position: fixed; inset: 0; z-index: 100; height: auto; border-radius: 0; border: 0; }
body.map-expanded { overflow: hidden; }
.map-noscript { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.map-missing { margin: 0; padding: 40px 20px; text-align: center; color: var(--text-dim); }

.map-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; --inv: 1; }
.map-stage.is-moving { will-change: transform; }
.map-base { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.map-shapes { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-shapes polygon { vector-effect: non-scaling-stroke; }
.map-points { position: absolute; inset: 0; pointer-events: none; }
.map-pt { position: absolute; transform: translate(-50%, -50%) scale(var(--inv)); pointer-events: auto; }

/* Monster spawn regions: one hue per monster. */
.map-spawn polygon {
  fill: hsla(var(--hue), 85%, 58%, 0.26);
  stroke: hsl(var(--hue), 90%, 66%);
  stroke-width: 1.5px;
  cursor: pointer;
  transition: fill 0.12s, stroke-width 0.12s;
}
.map-spawn:hover polygon, .map-spawn:focus polygon { fill: hsla(var(--hue), 85%, 58%, 0.5); stroke-width: 2.5px; }
.map-viewer.has-focus .map-spawn:not(.is-focus) polygon { fill: hsla(var(--hue), 30%, 50%, 0.08); stroke: hsla(var(--hue), 30%, 60%, 0.35); }
.map-spawn.is-focus polygon { fill: hsla(var(--hue), 90%, 60%, 0.5); stroke: #fff; stroke-width: 2.5px; }

/* Named areas */
.map-area { fill: rgba(232, 236, 244, 0.04); stroke: rgba(232, 236, 244, 0.55); stroke-width: 1.25px; stroke-dasharray: 5 4; pointer-events: none; }
.map-area-label {
  pointer-events: none; white-space: nowrap; font-size: 12px; font-weight: 750; letter-spacing: 0.04em;
  text-transform: uppercase; color: #fff4dc; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.9);
}
.map-viewer.is-zoomed-out .map-area-label { font-size: 10px; }

/* Zones */
.map-zone { stroke-width: 1.25px; pointer-events: visiblePainted; }
.map-zone-pvp { fill: rgba(255, 70, 70, 0.16); stroke: rgba(255, 92, 92, 0.8); }
.map-zone-safe { fill: rgba(111, 214, 111, 0.12); stroke: rgba(111, 214, 111, 0.8); stroke-dasharray: 4 3; }
.map-zone-fishing { fill: rgba(79, 179, 255, 0.2); stroke: rgba(79, 179, 255, 0.85); }

/* Portals */
.map-portal-area polygon { fill: rgba(245, 216, 169, 0.3); stroke: #f5d8a9; stroke-width: 2px; }
a.map-portal-area polygon { cursor: pointer; }
.map-portal { display: flex; align-items: center; gap: 4px; text-decoration: none; transform-origin: center; }
.map-portal { transform: translate(-11px, -50%) scale(var(--inv)); transform-origin: 11px 50%; }
.map-portal .map-icon { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9)); }
.map-portal-label {
  white-space: nowrap; padding: 1px 7px 1px 6px; border-radius: 6px; font-size: 12px; font-weight: 700;
  color: #1b1408; background: rgba(245, 216, 169, 0.94); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.map-portal:not(.is-link) .map-portal-label { background: rgba(26, 31, 44, 0.9); color: #f5d8a9; border: 1px solid rgba(245, 216, 169, 0.5); }
a.map-portal:hover .map-portal-label { background: #fff1d6; }
.map-portal.is-focus .map-portal-label, .map-portal-area.is-focus polygon { outline: none; stroke: #fff; stroke-width: 3px; }
.map-portal.is-focus .map-portal-label { box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(0, 0, 0, 0.7); }
.map-viewer.is-zoomed-out .map-portal-label { font-size: 11px; }

/* Minimap icons (game art) */
.map-icon { display: block; image-rendering: auto; pointer-events: auto; }
img.map-pt.map-icon { filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.85)); }
.map-dot { display: block; border-radius: 50%; border: 1px solid #000; box-sizing: border-box; }
.is-indoors { opacity: 0.5; }

/* Arrivals, points of interest, resource nodes */
.map-arrival { display: block; width: 11px; height: 11px; border: 1.5px solid #0b0e15; transform: translate(-50%, -50%) rotate(45deg) scale(var(--inv)); }
.map-arrival.is-arrival { background: #6fd66f; }
.map-arrival.is-respawn { background: #ffd34d; border-radius: 2px; }
.map-poi { display: block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #0b0e15; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6); }
.map-poi-treasureChest { background: #ffc94d; border-radius: 3px; }
.map-poi-treasureHuntChest { background: #ff9440; border-radius: 3px; }
.map-poi-firepit { background: #ff6b3d; }
.map-poi-escapeRope { background: #c7955f; }
.map-poi-dungeonMenu { background: #b98cff; }
.map-poi-itemBlessing { background: #5fe0e8; }
.map-poi-crafting { background: #3fcf9e; }
.map-node { display: block; width: 7px; height: 7px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.75); }
.map-node-mining { background: #a9b8d6; }
.map-node-gathering { background: #8fdc6a; }

/* Focus pin for "Show" links */
.map-pin {
  display: block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.7); pointer-events: none;
  animation: map-pin-pulse 1.4s ease-out infinite;
}
@keyframes map-pin-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.9), 0 0 0 2px rgba(0, 0, 0, 0.7); }
  100% { box-shadow: 0 0 0 18px rgba(255, 255, 255, 0), 0 0 0 2px rgba(0, 0, 0, 0.7); }
}
@media (prefers-reduced-motion: reduce) { .map-pin { animation: none; } }

/* Controls, focus note, tooltip */
.map-controls { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; flex-direction: column; gap: 6px; }
.map-control {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid #39435a; border-radius: 9px; background: rgba(20, 25, 36, 0.92); color: var(--text);
  font: 700 20px/1 "Inter", system-ui, sans-serif; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.map-control:hover { background: #253048; }
.map-control:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.map-control svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-focus {
  position: absolute; left: 10px; top: 10px; z-index: 3; display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 70px); padding: 6px 6px 6px 12px; border-radius: 10px;
  background: rgba(20, 25, 36, 0.94); border: 1px solid #39435a; font-size: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.map-focus[hidden] { display: none; }
.map-focus span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-focus button {
  flex: none; padding: 4px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-card);
  color: var(--text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.map-focus button:hover { background: var(--bg-card-hover); }
.map-tooltip {
  position: absolute; z-index: 4; max-width: 260px; padding: 7px 10px; border-radius: 9px; pointer-events: none;
  background: rgba(10, 13, 20, 0.95); border: 1px solid #39435a; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  font-size: 13px; line-height: 1.35; display: flex; flex-direction: column; gap: 1px;
}
.map-tooltip[hidden] { display: none; }
.map-tooltip.is-pinned { pointer-events: auto; }
.map-tooltip strong { color: var(--text); }
.map-tooltip-sub { color: var(--text-dim); font-size: 12px; }
.map-tooltip-action { margin-top: 3px; color: var(--accent); font-size: 12px; font-weight: 700; }
a.map-tooltip-action { padding: 4px 0 1px; }
.map-hint { margin: 8px 2px 0; color: var(--text-dim); font-size: 13px; }

/* ---- Sections under the map ---- */
.map-section { margin-top: 30px; }
.map-section h2 { margin: 0 0 12px; font-size: 1.25rem; }
.map-section h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--text-dim); font-weight: 650; }
.map-monster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 16px 14px; }
.map-monster { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 0; }
.map-show-button, .map-locate {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 28px; padding: 3px 9px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-card);
  color: var(--text); font-size: 12px; font-weight: 650; text-align: center;
}
.map-show-button:hover, .map-locate:hover { background: var(--bg-card-hover); border-color: #3c4862; }
.map-show-note { color: var(--text-dim); font-size: 12px; text-align: center; }
.map-travel { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 28px; }
.map-link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.map-link-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-card); }
.map-link-list li > a:first-child, .map-link-list li > span:first-child { font-weight: 650; }
.map-link-list li > span:first-child { color: var(--text); }
.map-characters { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-scroll > table.map-characters { width: 100%; }
.map-characters th, .map-characters td { padding: 7px 10px; border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
.map-characters thead th { border-top: 0; color: var(--text-dim); font-size: 12px; font-weight: 650; }
.map-characters tbody th { font-weight: 650; }
.map-character-locate { text-align: right; width: 1%; white-space: nowrap; }
.map-role {
  display: inline-block; margin: 1px 4px 1px 0; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 750;
  background: #263048; color: var(--text);
}
.map-role-shop { background: #3d3510; color: #fff3a3; }
.map-role-quest, .map-role-quest-turn-in { background: #0d3550; color: #9fdcff; }
.map-role-blacksmith { background: #43230f; color: #ffbf96; }
.map-role-taxi { background: #2e2e2e; color: #e8e8e8; }
.map-shop-name { color: var(--text); }
.map-indoors { color: var(--text-dim); font-size: 12px; }
.map-chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.map-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 14px; font-weight: 600;
}
.map-chip:hover { background: var(--bg-card-hover); }
.map-chip img { width: 48px; height: 27px; object-fit: cover; border-radius: 5px; display: block; }

/* ---- /maps index ---- */
.map-card-grid { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.map-card {
  display: flex; flex-direction: column; height: 100%; overflow: hidden; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.map-card:hover { background: var(--bg-card-hover); border-color: #3c4862; transform: translateY(-2px); }
.map-card-art { display: block; aspect-ratio: 16 / 9; background: #0b0e15; }
.map-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.map-card-body { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 12px; }
.map-card-name { font-weight: 750; font-size: 16px; }
.map-card-facts { color: var(--text-dim); font-size: 13px; }

/* ---- Monster page: where it spawns ---- */
.monster-spawn-maps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.monster-spawn-map {
  display: inline-flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 9px;
  border: 1px solid #665c56; background: rgba(12, 15, 22, 0.35); color: inherit; font-weight: 650; font-size: 14px;
}
.monster-spawn-map:hover { background: rgba(12, 15, 22, 0.55); }
.monster-spawn-map img { width: 56px; height: 32px; object-fit: cover; border-radius: 5px; display: block; }
.monster-spawn-map small { display: block; font-weight: 500; font-size: 12px; opacity: 0.75; }

/* Wheel hint (the page scrolls until the map is engaged) */
.map-wheel-hint {
  position: absolute; left: 50%; bottom: 14px; z-index: 3; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px; pointer-events: none; white-space: nowrap;
  background: rgba(10, 13, 20, 0.9); border: 1px solid #39435a; color: var(--text); font-size: 13px; font-weight: 600;
}
.map-wheel-hint[hidden] { display: none; }
@media (max-width: 640px) {
  .map-viewer { height: min(64vh, 560px); min-height: 320px; }
  .map-wheel-hint { white-space: normal; text-align: center; width: max-content; max-width: calc(100% - 28px); }
}

/* Spawn dots: visible only while their area is under ~16px on screen. */
.map-spawn-dot {
  display: block; width: 10px; height: 10px; border-radius: 50%;
  background: hsl(var(--hue), 90%, 62%); border: 1.5px solid rgba(0, 0, 0, 0.8);
  --dot-opacity: clamp(0, calc((16 - var(--sz) * var(--s, 1)) / 6), 1);
  opacity: var(--dot-opacity);
}
.map-viewer.has-focus .map-spawn-dot:not(.is-focus) { opacity: min(0.25, var(--dot-opacity)); filter: saturate(0.3); }
.map-spawn-dot.is-focus { border-color: #fff; }

/* Readable breadcrumb over bright key art */
.map-page-with-cover .breadcrumb a { color: #c9d8ff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.7); }
@media (max-width: 640px) {
  body.map-page-with-cover::before { height: 360px; }
  /* One swipeable row of layer chips instead of four wrapped rows. */
  .map-layers {
    flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding-right: 16px; padding-bottom: 2px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .map-layers::-webkit-scrollbar { display: none; }
  .map-layer-toggle { flex: none; }
}

/* Region tags (e.g. BADLANDS) on a map's header, card, and chips */
.map-tag {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.14em; line-height: 1.4; text-transform: uppercase;
  color: #ffe2c6; background: rgba(122, 26, 12, 0.88); border: 1px solid rgba(255, 128, 84, 0.65);
  text-shadow: none; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.map-hero-tags { margin: 0 0 10px; display: flex; justify-content: center; gap: 6px; }
.map-card-art { position: relative; }
.map-card-tag { position: absolute; left: 10px; top: 10px; z-index: 1; }
.map-tag-small { padding: 1px 7px; font-size: 10px; letter-spacing: 0.1em; box-shadow: none; }
