/*
 * НАШІ ІСПАНІЯ — hero map (T15). Provinces, Canary inset, pins, tooltip,
 * zoom controls, entrance animation. `.map-wrap` / `.map-online-badge`
 * shells live in custom.css. Wheel zoom is disabled in map.js so the page
 * keeps scrolling when the cursor is over the map.
 */

/* ------------------------------------------------------------------ */
/* SVG shell                                                           */
/* ------------------------------------------------------------------ */

.map-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1000 / 820;
  overflow: visible;
}

.map-wrap[data-interactive="1"] .map-svg {
  cursor: grab;
  touch-action: pan-y;
}

/* T31: once zoomed in, clip the drawing to its own box so provinces and
   pins never spill over the glass card; at zoom 1 overflow stays visible
   so edge pins and the pop animation are not cut. */
.map-svg.is-magnified {
  overflow: hidden;
  border-radius: 14px;
}

.map-wrap[data-interactive="1"] .map-svg.is-dragging {
  cursor: grabbing;
  touch-action: none;
}

.map-missing {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 48px 16px;
}

/* ------------------------------------------------------------------ */
/* Provinces + Canary inset                                            */
/* ------------------------------------------------------------------ */

.province {
  fill: rgba(255, 255, 255, .88);
  stroke: var(--blue);
  stroke-width: 1;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: center;
  transition: fill .18s ease, stroke-width .18s ease;
  animation: map-land-in .55s ease both;
}

/* T30b — sketchbook map: hatched sea, wobbly coast, hand-written labels,
   compass. The filter is desktop-only (pointer: fine) as a perf fallback —
   see docs/superpowers/specs/2026-09-04-t30-sketchbook-map-design.md. */
.sea-wave {
  fill: none;
  stroke: var(--ua-blue);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: .35;
}

@media (pointer: fine) {
  .map-sketch { filter: url(#pen-wobble); }
}

.map-label {
  font-family: "Caveat", cursive;
  font-size: 26px;
  font-weight: 700;
  fill: var(--ink);
  opacity: .55;
  pointer-events: none;
  transition: opacity .2s ease;
}

.map-compass {
  color: var(--ink);
  opacity: .5;
  pointer-events: none;
}

.map-landmark {
  color: var(--ink);
  opacity: .45;
  pointer-events: none;
  transition: opacity .2s ease;
}

.map-svg.is-zoomed .map-label,
.map-svg.is-zoomed .map-landmark {
  opacity: 0;
}

.province.has-businesses {
  cursor: pointer;
}

.map-wrap[data-interactive="1"] .province.has-businesses:hover {
  fill: var(--gold-soft);
  stroke: var(--gold-deep);
  stroke-width: 2;
}

.province.has-businesses:focus-visible {
  fill: var(--gold-soft);
  stroke: var(--gold-deep);
  stroke-width: 2;
  outline: none;
}

.inset-frame {
  fill: rgba(255, 255, 255, .7);
  stroke: rgba(20, 33, 61, .35);
  stroke-width: 1.25;
  rx: 8;
}

.inset-label {
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  font-weight: 600;
  fill: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Pins                                                                */
/* ------------------------------------------------------------------ */

.pin {
  cursor: pointer;
}

.pin:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 999px;
}

.pin-visual {
  transform-box: fill-box;
  transform-origin: center;
  animation: pin-pop .4s cubic-bezier(.34, 1.56, .64, 1) both;
}

/* T28b H3 — the hero map pin-pop stays paused until the map scrolls into
   view (motion.js sets/removes data-motion-hold on .map-wrap). */
.map-wrap[data-motion-hold] .pin-visual {
  animation-play-state: paused;
}

.pin-dot {
  fill: var(--ua-blue);
  opacity: .12;
  transition: opacity .15s ease;
}

/* T30b — sticker pins: ink-offset shadow behind a gold rounded-rect badge. */
.pin-shadow {
  fill: rgba(20, 33, 61, .35);
}

.pin-badge {
  fill: var(--gold);
  stroke: rgba(20, 33, 61, .55);
  stroke-width: 1;
  transition: fill .15s ease;
}

.map-wrap[data-interactive="1"] .pin:hover .pin-dot,
.pin:focus-visible .pin-dot {
  opacity: .22;
}

.map-wrap[data-interactive="1"] .pin:hover .pin-badge,
.pin:focus-visible .pin-badge {
  fill: var(--ua-yellow);
}

.pin-inner {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .18s var(--ease-emph, ease);
}

.map-wrap[data-interactive="1"] .pin:hover .pin-inner,
.pin:focus-visible .pin-inner {
  transform: rotate(-3deg) scale(1.06);
}

.pin-count {
  fill: var(--ink);
  font-family: var(--font-body, sans-serif);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.pin.is-cluster .pin-badge {
  fill: var(--blue-deep);
  stroke: var(--ink);
}

.pin.is-cluster .pin-count {
  fill: #FFFFFF;
}

/* ------------------------------------------------------------------ */
/* Tooltip — sticky-note, not dark SaaS bubble                         */
/* ------------------------------------------------------------------ */

.map-tooltip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  min-width: 160px;
  max-width: 240px;
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  color: var(--ink);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, .7));
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(20, 33, 61, .14);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
}

.map-tooltip[hidden] {
  display: none;
}

.map-tooltip.is-interactive {
  pointer-events: auto;
}

.map-tooltip-title {
  display: block;
  font-family: var(--font-heading, sans-serif);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .02em;
  margin-bottom: 4px;
}

.map-tooltip-categories {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: .9;
}

.map-tooltip-categories a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.map-tooltip-count {
  font-weight: 600;
  opacity: 1;
}

/* ------------------------------------------------------------------ */
/* Zoom controls (buttons only — no wheel)                             */
/* ------------------------------------------------------------------ */

.map-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.map-wrap[data-interactive="1"] .map-controls {
  display: flex;
}

.map-control-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, .7));
  background: rgba(255, 255, 255, .7);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: background-color .15s ease, box-shadow .15s ease;
}

.map-control-btn:hover {
  background: var(--gold);
  box-shadow: var(--shadow-hover);
}

.map-control-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Noscript fallback                                                   */
/* ------------------------------------------------------------------ */

.map-fallback {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 16px;
}

.map-fallback a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

.map-fallback a:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Mini mode                                                           */
/* ------------------------------------------------------------------ */

.map-wrap-mini .map-controls,
.map-wrap-mini .map-online-badge {
  display: none;
}

.map-wrap-mini .map-svg {
  max-width: 420px;
  margin: 0 auto;
}

/* ------------------------------------------------------------------ */
/* Entrance                                                            */
/* ------------------------------------------------------------------ */

@keyframes map-land-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pin-pop {
  from { opacity: 0; transform: scale(.35); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .province,
  .pin,
  .pin-visual,
  .pin-dot,
  .pin-badge,
  .map-control-btn,
  .map-wrap[data-interactive="1"] .map-svg {
    animation: none !important;
    transition: none !important;
  }
}
