/* Policy map: shared by the homepage story and the full /map/ page. */

.pm { position: relative; overflow: hidden; background: var(--map-ocean); touch-action: none; }
.pm--embed { touch-action: auto; }
.pm__svg { width: 100%; height: 100%; display: block; cursor: grab; }
.pm--embed .pm__svg { cursor: default; }
.pm__svg:active { cursor: grabbing; }
.pm__ocean { fill: var(--map-ocean); }
.pm__grat { fill: none; stroke: var(--map-grat); stroke-width: 1; vector-effect: non-scaling-stroke; }
.pm__land { fill: var(--map-land); stroke: var(--map-border); stroke-width: 0.9; vector-effect: non-scaling-stroke; }
.pm__borders { fill: none; stroke: var(--map-border); stroke-width: 0.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

.pm__pt { cursor: pointer; }
.pm__hit { fill: transparent; }
.pm__dot, .pm__ripple { transform-box: fill-box; transform-origin: center; }
.pm__dot { fill: var(--c); stroke: var(--map-land); stroke-width: 1.6; transition: transform 0.45s var(--ease-out), opacity 0.4s, fill 0.4s; }
.pm__ripple { fill: none; stroke: var(--c); stroke-width: 2; opacity: 0; }
.pm__pt:hover .pm__dot { transform: scale(1.45); }
.pm__pt.is-hidden { pointer-events: none; }
.pm__pt.is-hidden .pm__dot { transform: scale(0); opacity: 0; }
.pm__pt.is-selected .pm__dot { stroke: var(--ink); stroke-width: 2.4; transform: scale(1.6); }
.pm__pt.is-new .pm__ripple { animation: pm-ripple 1.3s var(--ease-out); }
@keyframes pm-ripple { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(4.2); } }
.pm.is-ghost .pm__dot { fill: transparent; stroke: var(--ink-2); stroke-opacity: 0.45; stroke-width: 1.2; }
.pm.is-ghost .pm__pt.is-hidden .pm__dot { transform: none; opacity: 1; }
.cat-1 { --c: var(--cat-1); } .cat-2 { --c: var(--cat-2); } .cat-3 { --c: var(--cat-3); }
.cat-4 { --c: var(--cat-4); } .cat-5 { --c: var(--cat-5); } .cat-6 { --c: var(--cat-6); }
@media (prefers-reduced-motion: reduce) { .pm__dot { transition: none; } }

.pm__tip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 280px;
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 0.95rem; line-height: 1.3;
}
.pm__tip[hidden] { display: none; }
.pm__tip span { color: var(--muted); }
.pm__tiptype { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.swatch { display: inline-block; }
.pm.is-error { display: grid; place-items: center; padding: 24px; text-align: center; }
.pm__error { margin: 0; color: var(--ink-2); max-width: 32ch; }

/* ---------- full-screen map page ---------- */
.page-map { overflow: hidden; }
.mapapp { position: relative; height: calc(100dvh - var(--header-h)); display: flex; }
.mapapp__map { position: relative; flex: 1; min-width: 0; }
.mapapp__map .pm { position: absolute; inset: 0; }

/* Overlays sit over open ocean: title over the North Pacific, key over the South Pacific. */
.mapapp__intro, .mapapp__legend {
  position: absolute; z-index: 3;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.mapapp__intro { left: 16px; top: 16px; max-width: calc(100% - 88px); padding: 14px 18px 12px; }
.mapapp__intro h1 { font-size: 1.5rem; margin: 0 0 2px; }
.mapapp__count { margin: 0; color: var(--ink-2); font-weight: 500; }
.mapapp__legend { left: 16px; bottom: 116px; width: 270px; padding: 10px 16px; }
.mapapp__legend:empty { display: none; }
.mapapp__legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mapapp__legend li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; font-size: 1rem; padding: 3px 0; }
.mapapp__legend b { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 700; }
.mapapp__legend .swatch, .mapapp__type .swatch, .mapapp__list .swatch, .pm__tip .swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--map-land); }

.mapapp__zoom { position: absolute; right: 16px; top: 16px; z-index: 3; display: grid; gap: 8px; }

.mapapp__timeline {
  position: absolute; z-index: 3; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: min(820px, calc(100% - 32px));
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 12px 10px 10px; box-shadow: var(--shadow);
}
.mapapp__play {
  width: 52px; height: 52px; border-radius: 999px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent);
  transition: transform 0.2s var(--ease-out), background-color 0.2s;
}
.mapapp__play:hover { background: var(--accent-ink); }
.mapapp__play:active { transform: scale(0.95); }
.mapapp__play .icon { width: 22px; height: 22px; }
.mapapp__play .i-pause, .mapapp__play.is-playing .i-play { display: none; }
.mapapp__play.is-playing .i-pause { display: block; }
.mapapp__slider { position: relative; padding: 0 11px; }
.mapapp__hist { display: block; width: 100%; height: 30px; cursor: pointer; }
.mapapp__hist rect { fill: var(--line-strong); transition: fill 0.3s; }
.mapapp__hist rect.is-on { fill: var(--teal); }
.mapapp__slider input { width: calc(100% + 22px); margin: 2px -11px 0; accent-color: var(--accent); display: block; height: 22px; }
.mapapp__ticks { position: relative; height: 16px; font-size: 0.8rem; color: var(--muted); }
.mapapp__ticks span { position: absolute; transform: translateX(-50%); top: 0; line-height: 1; }
.mapapp__ticks span:first-child { transform: none; }
.mapapp__ticks span:last-child { transform: translateX(-100%); }
.mapapp__year { font-weight: 800; font-size: 1.15rem; min-width: 7.2ch; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.mapapp__status {
  position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; text-align: center; gap: 4px; padding: 24px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.mapapp__status[hidden] { display: none; }
.mapapp__loading { display: grid; grid-template-columns: repeat(2, 22px); gap: 6px; justify-content: center; margin-bottom: 12px; }
.mapapp__loading span { width: 22px; height: 22px; border-radius: 6px; background: var(--teal); animation: tile-pulse 1.2s ease-in-out infinite; }
.mapapp__loading span:nth-child(2) { background: var(--accent); animation-delay: 0.15s; }
.mapapp__loading span:nth-child(3) { background: var(--ochre); animation-delay: 0.45s; }
.mapapp__loading span:nth-child(4) { background: var(--plum); animation-delay: 0.3s; }
@keyframes tile-pulse { 0%, 100% { transform: scale(0.75); opacity: 0.5; } 50% { transform: scale(1); opacity: 1; } }

/* side panels */
.mapapp__panel, .mapapp__list {
  position: absolute; z-index: 8; top: 0; bottom: 0; width: min(420px, 100%);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain;
  transition: transform 0.35s var(--ease-out);
}
.mapapp__panel { right: 0; transform: translateX(100%); padding: 24px 26px 32px; }
.mapapp__list { left: 0; right: auto; width: min(380px, 100%); border-left: 0; border-right: 1px solid var(--line); transform: translateX(-100%); }
.mapapp__panel.is-open, .mapapp__list.is-open { transform: none; }
.mapapp__close { position: sticky; top: 0; float: right; margin: -6px -8px 0 12px; }
.mapapp__type { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; color: var(--ink-2); }
.mapapp__panel h2 { font-size: 1.6rem; line-height: 1.15; margin-bottom: 6px; }
.mapapp__panel h2:focus { outline: none; }
.mapapp__place { color: var(--muted); margin-bottom: 16px; }
.mapapp__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 18px; padding: 14px 0; border-block: 1px solid var(--line); }
.mapapp__facts dt { font-size: 0.85rem; color: var(--muted); }
.mapapp__facts dd { margin: 0; font-weight: 700; line-height: 1.3; }
.mapapp__panel h3 { font-size: 1.05rem; margin: 18px 0 4px; }
.mapapp__panel p { font-size: 1.04rem; color: var(--ink-2); margin-bottom: 0; }
.mapapp__panel p.muted { color: var(--muted); font-style: italic; }
.mapapp__panelactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.mapapp__listhead { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.mapapp__listhead h2 { font-size: 1.3rem; margin: 0; white-space: nowrap; }
.mapapp__listhead span { color: var(--muted); font-weight: 500; }
.mapapp__list ul { list-style: none; margin: 0; padding: 6px 8px 24px; }
.mapapp__list button {
  width: 100%; display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; align-items: start; text-align: left;
  padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; cursor: pointer;
}
.mapapp__list button:hover { background: var(--bg-2); }
.mapapp__list .swatch { margin-top: 7px; }
.mapapp__list strong { display: block; font-size: 1rem; line-height: 1.3; }
.mapapp__list small { display: block; color: var(--muted); font-size: 0.9rem; }

/* Keep the controls clear of whichever side panel is open. */
@media (min-width: 761px) {
  .mapapp__timeline, .mapapp__zoom, .mapapp__intro, .mapapp__legend { transition: left 0.35s var(--ease-out), right 0.35s var(--ease-out), width 0.35s var(--ease-out); }
  .mapapp:has(.mapapp__panel.is-open) .mapapp__timeline { left: calc(50% - 210px); width: min(820px, calc(100% - 452px)); }
  .mapapp:has(.mapapp__panel.is-open) .mapapp__zoom { right: 436px; }
  .mapapp:has(.mapapp__list.is-open) .mapapp__timeline { left: calc(50% + 190px); width: min(820px, calc(100% - 412px)); }
  .mapapp:has(.mapapp__list.is-open) .mapapp__intro,
  .mapapp:has(.mapapp__list.is-open) .mapapp__legend { left: 396px; }
  .mapapp:has(.mapapp__list.is-open):has(.mapapp__panel.is-open) .mapapp__timeline { left: calc(50% - 20px); width: min(820px, calc(100% - 832px)); }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .mapapp:has(.mapapp__list.is-open):has(.mapapp__panel.is-open) .mapapp__timeline { display: none; }
}

@media (max-width: 760px) {
  .mapapp__intro { left: 12px; top: 12px; max-width: calc(100% - 80px); padding: 10px 14px 8px; }
  .mapapp__intro h1 { font-size: 1.2rem; }
  .mapapp__count { font-size: 0.98rem; }
  .mapapp__legend { left: 12px; right: 12px; bottom: 100px; width: auto; padding: 8px 12px; }
  .mapapp__legend ul { grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .mapapp__legend li { font-size: 0.86rem; grid-template-columns: 10px 1fr auto; gap: 6px; padding: 2px 0; }
  .mapapp__legend li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mapapp__zoom { right: 12px; top: 12px; }
  .mapapp__timeline { bottom: 12px; width: calc(100% - 24px); grid-template-columns: auto minmax(0, 1fr) auto; border-radius: 22px; gap: 10px; padding: 8px 10px; }
  .mapapp__year { display: none; }
  .mapapp__play { width: 46px; height: 46px; }
  .mapapp__listbtn { padding-inline: 12px; }
  .mapapp__panel, .mapapp__list {
    top: auto; left: 0; right: 0; width: 100%; max-height: 72%;
    border: 0; border-top: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
  }
  .mapapp__panel.is-open, .mapapp__list.is-open { transform: none; }
}
