/* ================================================================
   MelodyLog — Composer map page
   Design language: ink + terracotta, glass panels over the map,
   16px frames, pill buttons, Emil-style motion (custom easings,
   entries from scale(.85), exit faster than entry, reduced-motion).
   ================================================================ */

.map-body .site-footer { display: none; }

.map-page {
  position: relative;
  height: calc(100dvh - 64px);   /* viewport minus the sticky header */
  overflow: hidden;
}
#map { position: absolute; inset: 0; z-index: 0; }
.leaflet-container { font-family: inherit; background: #a9d3e0; }

/* ---------- glass recipe (same as the site header) ---------- */
.glass {
  background: var(--header-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

/* ---------- filter panel (top-left) ---------- */
.map-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
  width: 318px;
  max-width: calc(100vw - 28px);
  padding: 14px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mp-search {
  position: relative;
  display: flex;
  align-items: center;
}
.mp-search > i {
  position: absolute;
  left: 12px;
  color: var(--ink-3);
  font-size: 0.85rem;
  pointer-events: none;
}
.mp-search input {
  width: 100%;
  padding: 0.5rem 2.1rem 0.5rem 2.3rem;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.mp-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.mp-clear {
  position: absolute;
  right: 8px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms var(--ease-out), background 160ms var(--ease-out);
}
.mp-clear:hover { background: var(--border-2); }
.mp-clear:active { transform: scale(0.94); }

.mp-row { display: flex; flex-direction: column; gap: 0.45rem; }
.mp-modes {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.mp-eras {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.mp-eras::-webkit-scrollbar { display: none; }
.mp-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mp-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out),
              border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.mp-pill-n { font-size: 0.7rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.mp-pill:hover { border-color: var(--ink-3); color: var(--ink); }
.mp-pill:active { transform: scale(0.97); }
.mp-pill.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.mp-pill.on .mp-pill-n { color: inherit; opacity: 0.62; }

.mp-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8f9d' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.8rem center;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.mp-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.mp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.mp-count {
  font-size: 0.82rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.mp-count:hover { color: var(--ink); }

/* ---------- status chip (empty / error) ---------- */
.map-chip {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 1;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  animation: chip-in 240ms var(--ease-out) both;
}
.map-chip[hidden] { display: none; }
@keyframes chip-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.96); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ---------- timebar (bottom-center) ---------- */
.timebar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: calc(100vw - 28px);
}
.tb-play {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 160ms var(--ease-out), background 160ms var(--ease-out);
}
.tb-play:hover { background: var(--accent); }
.tb-play:active { transform: scale(0.96); }
.tb-play.playing { background: var(--accent); }
.tb-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tb-speed {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.tb-speed:hover { border-color: var(--ink-3); }
.tb-speed:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tb-mid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: clamp(150px, 26vw, 460px);
}
.tb-year {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.tb-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--border-2);
  cursor: pointer;
  margin: 0;
}
.tb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(20, 21, 26, 0.3);
  transition: transform 160ms var(--ease-out);
}
.tb-slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.tb-slider::-webkit-slider-thumb:active { transform: scale(0.95); }
.tb-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(20, 21, 26, 0.3);
}
.tb-slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.tb-slider.off { opacity: 0.4; }
.tb-slider.off::-webkit-slider-thumb { background: var(--ink-3); }
.tb-slider.off::-moz-range-thumb { background: var(--ink-3); }
.tb-range {
  display: flex;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.tb-all {
  flex: 0 0 auto;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out),
              border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.tb-all:hover { color: var(--ink); border-color: var(--ink-3); }
.tb-all:active { transform: scale(0.97); }
.tb-all.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- marker pins: teardrop, portrait or initials ---------- */
.mc-pin-wrap { background: none; border: none; }
.pin {
  position: relative;
  width: 34px;
  height: 40px;
  animation: pin-in 320ms var(--ease-out) both;
}
.pin-head {
  position: absolute;
  top: 0;
  left: 2px;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(20, 21, 26, 0.3);
  overflow: hidden;
  transition: transform 160ms var(--ease-out);
}
.pin-head::after {   /* inner portrait: circular window, counter-rotated upright */
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background-image: var(--portrait, none);
  background-size: cover;
  background-position: center;
  transform: rotate(45deg);   /* circles are rotation-invariant; this rights the image */
}
.pin-head.ini {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pin-head.ini span { transform: rotate(45deg); }   /* text upright inside the tilted head */
.pin-head.ini::after { content: none; }
@keyframes pin-in {
  from { opacity: 0; transform: scale(0.85) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pin-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.85) translateY(5px); }
}
.mc-pin-wrap:focus-visible .pin-head { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- cluster bubbles: size ∝ √n, ink disc ---------- */
.mc-wrap { background: none; border: none; }
.mc-bubble {
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  border: 3px solid var(--surface);
  box-shadow: 0 4px 14px rgba(20, 21, 26, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  animation: bubble-in 240ms var(--ease-out) both;
}
@keyframes bubble-in {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- popup card: dark ink on any tiles ---------- */
.leaflet-popup-content-wrapper {
  background: #1b1c22;
  color: #e9e9ee;
  border-radius: 16px;
  box-shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.55);
}
.leaflet-popup-tip { background: #1b1c22; }
.leaflet-popup-content { margin: 14px 16px; line-height: 1.4; }
.cpop { display: flex; flex-direction: column; gap: 10px; }
.cpop-head { display: flex; align-items: center; gap: 10px; }
.cpop-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  background-color: #2a2c35;
}
.cpop-avatar-ini {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.cpop-head-meta { min-width: 0; }
.cpop-name { font-size: 0.98rem; font-weight: 700; line-height: 1.25; }
.cpop-chips { display: flex; gap: 0.35rem; margin-top: 3px; flex-wrap: wrap; }
.cpop-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: #a7abb8;
  white-space: nowrap;
}
.cpop-dates { display: flex; flex-direction: column; gap: 1px; }
.cpop-years {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.cpop-raw { font-size: 0.78rem; color: #8a8f9d; }
.cpop-works { font-size: 0.8rem; color: #a7abb8; }
.cpop-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: rgba(224, 134, 97, 0.14);
  color: #e08661;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.cpop-link:hover { background: rgba(224, 134, 97, 0.24); }
.cpop-link:active { transform: scale(0.98); }

/* ---------- close-up spotlight: pulsing ring on the important pin ---------- */
.pin.spot .pin-head {
  animation: spot-pulse 1s var(--ease-in-out) infinite;
}
@keyframes spot-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(20, 21, 26, 0.3), 0 0 0 0 rgba(200, 95, 61, 0.5); }
  50%      { box-shadow: 0 2px 8px rgba(20, 21, 26, 0.3), 0 0 0 16px rgba(200, 95, 61, 0); }
}

/* ---------- hover only on fine pointers ---------- */
@media (hover: hover) and (pointer: fine) {
  .mc-pin-wrap:hover .pin-head { transform: rotate(-45deg) scale(1.14); }
}

/* ---------- small screens ---------- */
@media (max-width: 680px) {
  .map-page { height: calc(100dvh - 56px); }
  .map-panel { top: 10px; left: 10px; right: 10px; width: auto; }
  .timebar {
    left: 10px;
    right: 10px;
    transform: none;
    gap: 0.6rem;
    padding: 8px 10px;
  }
  .tb-mid { min-width: 0; flex: 1; }
  .tb-year { font-size: 1.1rem; }
  .map-chip { bottom: 84px; }
}

/* ---------- reduced motion: instant pins, no pops ---------- */
@media (prefers-reduced-motion: reduce) {
  .pin, .mc-bubble, .map-chip { animation: none; }
  .pin-head { transition: none; }
  .pin.spot .pin-head { animation: none; box-shadow: 0 2px 8px rgba(20, 21, 26, 0.3), 0 0 0 3px rgba(200, 95, 61, 0.5); }
}
