/* ============ TOKENS ============ */
:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #1a1a1a;
  --line: #e6e6e0;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --max: 64rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section-pad: clamp(4rem, 10vh, 8rem);

  --nav-h: 4rem;

  --easing: cubic-bezier(.2, .7, .2, 1);
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.6s var(--easing), color 0.6s var(--easing);
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; padding: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; margin: 0; }

/* ============ NAV ============ */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 100;
  transition: background 0.6s var(--easing), border-color 0.6s var(--easing);
}
.nav-brand {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}
.nav-list {
  display: flex; gap: clamp(0.75rem, 2.5vw, 2rem);
  align-items: center;
}
.nav-list a {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  position: relative;
  padding: 0.4rem 0;
  transition: color 0.3s var(--easing);
}
.nav-list a::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s var(--easing);
}
.nav-list a:hover { color: var(--fg); }
.nav-list a.active { color: var(--fg); }
.nav-list a.active::after { transform: scaleX(1); }

/* ============ SEGMENTS ============ */
.segment {
  display: none;
  min-height: calc(100vh - var(--nav-h));
  padding-top: var(--nav-h);
}
.segment.active { display: block; }

.seg-hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--section-pad) var(--gutter) calc(var(--section-pad) * 0.6);
}
.seg-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0 0 1.5rem;
}
.seg-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(2.75rem, 7vw, 5.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}
.seg-lede {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--muted);
  max-width: 36rem;
  margin: 0;
}

.seg-block {
  max-width: var(--max);
  margin: 0 auto;
  padding: calc(var(--section-pad) * 0.5) var(--gutter);
}
.seg-block h2 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  margin: 0 0 1.5rem;
  letter-spacing: -0.01em;
}
.placeholder-text {
  color: var(--muted);
  margin: 0;
  max-width: 42rem;
}

/* ============ MODAL FRAME ============ */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.3s var(--easing);
}
.modal-panel {
  position: relative;
  width: min(56rem, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  color: #111;
  border-radius: 4px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.4);
  animation: rise 0.4s var(--easing);
  padding: clamp(2rem, 5vw, 3.5rem);
  font-family: var(--font-sans);
}
.modal-close {
  position: absolute; top: 1rem; right: 1.25rem;
  width: 2rem; height: 2rem;
  font-size: 1.5rem; line-height: 1;
  color: inherit;
  opacity: 0.55;
  transition: opacity 0.2s var(--easing);
}
.modal-close:hover { opacity: 1; }

.modal-content h3 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}
.modal-content .m-tagline {
  color: #888;
  font-size: 0.9rem;
  margin: 0 0 2rem;
  letter-spacing: 0.02em;
}
.modal-content .m-text {
  font-size: 1rem;
  line-height: 1.75;
  margin: 0 0 1.5rem;
}
.modal-content .m-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1.25rem;
  margin: 2rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid rgba(0,0,0,0.08);
}
.modal-content .m-stat .m-stat-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 0.4rem;
}
.modal-content .m-stat .m-stat-value {
  font-size: 1.1rem;
  font-weight: 500;
}
.modal-content .m-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin-top: 2rem;
}
.modal-content .m-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f0f0ed;
  object-fit: cover;
  border-radius: 2px;
}
.modal-content .m-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 1rem;
}

/* ============ DATA-PARSE ERROR FALLBACK ============ */
.data-error {
  grid-column: 1 / -1;
  padding: 1.5rem 1.75rem;
  border: 1px solid #d4a04a;
  border-left: 4px solid #d4a04a;
  background: #fff8e8;
  color: #5a3d0a;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: left;
}
.data-error strong {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a5a14;
  display: block;
  margin-bottom: 0.5rem;
}
.data-error p { margin: 0.4rem 0; }
.data-error code {
  background: rgba(212, 160, 74, 0.15);
  padding: 0.05rem 0.3rem;
  border-radius: 2px;
  font-size: 0.85em;
}

/* ============ ICON GRID (shared photo cards) ============ */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: clamp(0.75rem, 1.6vw, 1.25rem);
}
.icon-card {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: #ddd;
  border: none;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.4s var(--easing),
    box-shadow 0.4s var(--easing);
}
.icon-card .icon-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transition: transform 0.7s var(--easing), filter 0.5s var(--easing);
  filter: saturate(0.92);
}
/* gradient scrim so label stays readable on any photo */
.icon-card::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 55%;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.7) 0%,
    rgba(0,0,0,0.35) 45%,
    rgba(0,0,0,0) 100%
  );
  pointer-events: none;
  transition: opacity 0.4s var(--easing);
}
.icon-card .icon-label {
  position: absolute;
  left: 1rem; right: 1rem; bottom: 0.9rem;
  z-index: 1;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 12px rgba(0,0,0,0.3);
}
.icon-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px -16px rgba(0,0,0,0.35);
}
.icon-card:hover .icon-img {
  transform: scale(1.06);
  filter: saturate(1);
}
.icon-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============ MODAL — PAGER MODE ============ */
.modal-panel[data-mode="pager"] {
  padding: 0;
  height: min(82vh, 760px);
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* propagate flex height through the .modal-content wrapper so the pager fills */
.modal-panel[data-mode="pager"] .modal-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.modal-panel[data-mode="pager"] .modal-close {
  z-index: 4;
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-pager {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.modal-pages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.modal-page {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.5s var(--easing),
    transform 0.55s var(--easing);
  pointer-events: none;
}
.modal-page.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.modal-page.previous {
  opacity: 0;
  transform: translateY(-40px);
}
.modal-page.next {
  opacity: 0;
  transform: translateY(40px);
}
.modal-page-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 36rem;
  padding: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 5vw, 3.5rem) clamp(2rem, 5vw, 3rem);
  margin: 0 auto;
}
.modal-page-inner h3 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

/* dot indicators */
.modal-pager-dots {
  flex: 0 0 auto;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
  padding: 1.1rem 1rem 1.4rem;
}
.pager-dot {
  width: 2rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.3s var(--easing);
}
.pager-dot:hover { opacity: 0.85; }
.pager-dot.active { opacity: 1; }
.pager-dot-mark {
  display: block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  transition: transform 0.3s var(--easing), background 0.3s var(--easing);
}
.pager-dot.active .pager-dot-mark {
  transform: scale(1.4);
}

/* scroll hint at bottom-right of pager */
.modal-pager-hint {
  position: absolute;
  right: 1.2rem;
  bottom: 3.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.5;
  pointer-events: none;
  animation: hint-bob 2.4s ease-in-out infinite;
  transition: opacity 0.4s var(--easing);
}
.modal-pager-hint.dismissed { opacity: 0; }
@keyframes hint-bob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(4px); }
}

/* ============ MODAL — MAP MODE ============ */
.modal-panel[data-mode="map"] {
  padding: 0;
}
.modal-map-wrap {
  position: relative;
  width: 100%;
  background: #c8ebff;       /* matches the ocean colour in Wikimedia location maps */
  overflow: hidden;
  line-height: 0;            /* eliminates inline-img baseline gap */
}
.modal-map {
  width: 100%;
  height: auto;
  display: block;
  /* slight desaturation so the photographic palette of the rest of the site
     stays consistent — country still reads as country, just less candy-coloured */
  filter: saturate(0.55) contrast(0.96);
}

.map-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  background: none;
  padding: 0;
  border: 0;
  width: 0;
  height: 0;
}
.marker-pulse {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(194, 85, 62, 0.35);
  animation: marker-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes marker-pulse {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.6; }
  80%  { transform: translate(-50%, -50%) scale(3.2); opacity: 0;   }
  100% { opacity: 0; }
}
.marker-dot {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #c2553e;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.25s var(--easing), background 0.25s var(--easing);
}
.map-marker:hover .marker-dot,
.map-marker:focus-visible .marker-dot,
.map-marker.pinned .marker-dot {
  transform: translate(-50%, -50%) scale(1.4);
}
.marker-name {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, calc(-50% + 14px));
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #1a1a1a;
  background: rgba(255,255,255,0.85);
  padding: 1px 6px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.25s var(--easing);
}

/* popup */
.marker-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% - 18px));
  width: 14rem;
  background: #fff;
  color: #1a1a1a;
  border-radius: 4px;
  box-shadow: 0 12px 32px -10px rgba(0,0,0,0.35);
  padding: 0.85rem 1rem;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform-origin: bottom center;
  transition:
    opacity 0.25s var(--easing),
    transform 0.3s var(--easing),
    visibility 0s linear 0.25s;
  z-index: 5;
}
.marker-popup::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
}
.map-marker.marker-flip-left .marker-popup {
  transform: translate(calc(-100% + 14px), calc(-50% - 18px));
  transform-origin: bottom right;
}
.map-marker.marker-flip-left .marker-popup::after {
  left: auto;
  right: 14px;
  transform: none;
}
.map-marker.marker-flip-right .marker-popup {
  transform: translate(-14px, calc(-50% - 18px));
  transform-origin: bottom left;
}
.map-marker.marker-flip-right .marker-popup::after {
  left: 14px;
  transform: none;
}

.map-marker:hover .marker-popup,
.map-marker:focus-visible .marker-popup,
.map-marker.pinned .marker-popup {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.25s var(--easing),
    transform 0.3s var(--easing),
    visibility 0s linear 0s;
  transform: translate(-50%, calc(-50% - 28px));
}
.map-marker.marker-flip-left:hover .marker-popup,
.map-marker.marker-flip-left:focus-visible .marker-popup,
.map-marker.marker-flip-left.pinned .marker-popup {
  transform: translate(calc(-100% + 14px), calc(-50% - 28px));
}
.map-marker.marker-flip-right:hover .marker-popup,
.map-marker.marker-flip-right:focus-visible .marker-popup,
.map-marker.marker-flip-right.pinned .marker-popup {
  transform: translate(-14px, calc(-50% - 28px));
}

/* popup-below variant: marker near top of map, popup hangs below instead */
.map-marker.marker-popup-below .marker-popup {
  top: 50%;
  transform: translate(-50%, calc(-50% + 18px));
  transform-origin: top center;
}
.map-marker.marker-popup-below .marker-popup::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #fff;
}
.map-marker.marker-popup-below:hover .marker-popup,
.map-marker.marker-popup-below:focus-visible .marker-popup,
.map-marker.marker-popup-below.pinned .marker-popup {
  transform: translate(-50%, calc(-50% + 28px));
}

.popup-title {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}
.popup-info {
  display: block;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #444;
}

/* ============ ANIMATIONS ============ */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ UTILITY ============ */
@media (max-width: 600px) {
  .nav-brand { display: none; }
}
