/* corridor - the Black Sea lane at the centre of today's peace talks.
   Ink-navy sea chart, cream, wheat gold. Nothing on screen that does not earn its place. */
:root {
  --ink: #0f1a24;
  --ink-soft: #5c6a72;
  --cream: #f3ecda;
  --cream-edge: rgba(38, 52, 64, 0.28);
  --deep: #0c141c;
  --accent: #d9a441;          /* wheat gold - the one bright action */
  --accent-deep: #b4832a;
  --ring: rgba(217, 164, 65, 0.35);
  --danger: #b03a2e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--deep); color: var(--cream);
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
#map { position: fixed; inset: 0; z-index: 1; }
.leaflet-container { background: #e8e6de; font: inherit; }
/* cool the tiles slightly, keep land warm */
.leaflet-tile-pane { filter: sepia(0.16) saturate(0.95) hue-rotate(-8deg) brightness(0.99); transition: filter 1.2s ease; }
/* prologue: the sea before dawn */
#map.pre-dawn .leaflet-tile-pane { filter: brightness(0.48) saturate(0.6) sepia(0.12); }

/* open-water wash: two slow breaths of deep blue */
#wash {
  position: fixed; inset: -20%; z-index: 4; pointer-events: none; opacity: 0.45;
  background:
    radial-gradient(ellipse 60% 45% at 25% 65%, rgba(28, 60, 84, 0.28), transparent 70%),
    radial-gradient(ellipse 55% 40% at 75% 35%, rgba(20, 44, 64, 0.24), transparent 70%);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-3%, -1.5%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.06); }
}
#vignette {  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(ellipse 118% 105% at 50% 46%, transparent 55%, rgba(12, 20, 28, 0.44) 100%);
}

/* attribution clears the brand, stays visible (required) */
.leaflet-top.leaflet-left .leaflet-control-attribution {
  margin-top: 46px; max-width: calc(100vw - 150px);
  background: rgba(12, 20, 28, 0.5); color: rgba(243, 236, 218, 0.8);
  font-size: 10px; line-height: 1.4; border-radius: 8px; padding: 2px 6px;
}
.leaflet-top.leaflet-left .leaflet-control-attribution a { color: rgba(243, 236, 218, 0.95); }
.leaflet-tooltip.port-label:before, .leaflet-tooltip.city-label:before { display: none; }
@media (max-width: 420px) {
  .leaflet-control-attribution { font-size: 9px !important; max-width: 62vw !important; }
}

#brand {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 18px; z-index: 20;
  pointer-events: none;
}
.brand-title {
  display: inline-block;
  font-family: var(--serif); font-style: italic;
  font-size: 17px; font-weight: 500; letter-spacing: 0.03em;
  color: var(--cream);
  background: rgba(12, 20, 28, 0.55); border-radius: 8px; padding: 2px 9px;
}

/* ---- the route rail: story progress as three stops ---- */
#rail {
  position: fixed; left: 14px; top: 50%; transform: translateY(-50%);
  z-index: 15; display: flex; flex-direction: column; gap: 34px;
  padding: 10px 6px; border-radius: 12px;
  background: rgba(12, 20, 28, 0.34); backdrop-filter: blur(3px);
}
.rail-stop { position: relative; display: flex; align-items: center; gap: 7px; }
.rail-stop:not(:last-child)::after {
  content: ""; position: absolute; left: 4px; top: 12px; width: 2px; height: 30px;
  background: rgba(243, 236, 218, 0.22);
}
.rail-stop i {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid rgba(243, 236, 218, 0.45); background: transparent;
  transition: all 0.5s var(--spring);
}
.rail-stop span {
  font-size: 10px; letter-spacing: 0.06em; color: rgba(243, 236, 218, 0.55);
  transition: color 0.4s ease;
}
.rail-stop.on i { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--ring); }
.rail-stop.on span { color: var(--cream); }
#rail.idle .rail-stop i { opacity: 0.35; }
@media (max-width: 420px) {
  .rail-stop span { display: none; }
  #rail { left: 8px; gap: 30px; padding: 8px 5px; }
  .rail-stop:not(:last-child)::after { height: 26px; }
}

/* ---- the caption card ---- */
#caption {
  position: fixed; z-index: 18;
  left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(560px, calc(100vw - 28px));
  background: var(--cream); color: var(--ink);
  border-radius: 18px; border: 1px solid var(--cream-edge);
  box-shadow: 0 12px 40px rgba(12, 20, 28, 0.45);
  padding: 14px 18px 12px;
  transition: opacity 0.45s ease, transform 0.45s var(--spring);
}
#caption.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(14px); }
.cap-text { font-family: var(--serif); font-size: 16.5px; line-height: 1.42; }
.cap-note { font-size: 11px; line-height: 1.4; color: var(--ink-soft); margin-top: 7px; font-style: italic; }
.cap-note:empty { display: none; }

#chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 9px; }
#chips.hidden { display: none; }
.chip {
  font-size: 12px; line-height: 1.3; color: var(--ink);
  background: rgba(217, 164, 65, 0.14); border: 1px solid rgba(180, 131, 42, 0.35);
  border-radius: 9px; padding: 6px 9px;
}
@media (max-width: 420px) { #chips { grid-template-columns: 1fr; } }

.cap-controls { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.fraction { flex: 1; text-align: center; font-size: 12px; color: var(--ink-soft); letter-spacing: 0.08em; }

.btn {
  font: 600 15px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  border-radius: 12px; border: none; cursor: pointer;
  min-width: 44px; min-height: 44px; padding: 0 16px;
  transition: transform 0.25s var(--spring), box-shadow 0.25s ease, background 0.25s ease;
}
.btn:active { transform: scale(0.95); }
.btn.primary {
  background: var(--accent); color: #20160a;
  box-shadow: 0 0 0 5px var(--ring), 0 6px 18px rgba(180, 131, 42, 0.4);
}
.btn.primary:hover { background: #e2b052; }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn.big { font-size: 17px; padding: 0 34px; min-height: 52px; }

/* ---- pills ---- */
#topRight { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px; z-index: 20; }
.pill-btn {
  font: 500 13px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--cream); background: rgba(12, 20, 28, 0.55);
  border: 1px solid rgba(243, 236, 218, 0.35); border-radius: 999px;
  padding: 9px 14px; cursor: pointer; min-height: 34px;
  transition: background 0.3s ease;
}
.pill-btn:hover { background: rgba(12, 20, 28, 0.75); }

/* ---- overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 20, 28, 0.55); backdrop-filter: blur(6px);
  padding: 20px;
}
.overlay.hidden { display: none; }
.card {
  background: var(--cream); color: var(--ink);
  border-radius: 20px; border: 1px solid var(--cream-edge);
  box-shadow: 0 24px 70px rgba(12, 20, 28, 0.6);
  padding: 28px 26px; max-width: 520px; width: 100%;
  max-height: min(82vh, 700px); overflow-y: auto;
}
.intro-card h1 {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: 34px; letter-spacing: 0.02em; margin-bottom: 14px;
}
.lede { font-size: 15.5px; line-height: 1.5; color: #2c3a44; margin-bottom: 10px; }
.intro-card .btn { margin-top: 14px; }
.hint-line { margin-top: 12px; font-size: 12px; color: var(--ink-soft); }

.ref-card h2 { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 24px; margin-bottom: 10px; }
.ref-note { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 8px; }
.ref-card ul { list-style: none; margin: 10px 0 14px; }
.ref-card li { font-size: 13.5px; line-height: 1.45; margin-bottom: 9px; padding-left: 14px; position: relative; }
.ref-card li::before { content: ""; position: absolute; left: 0; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-deep); }
.ref-card a { color: var(--accent-deep); }
.ref-card .btn { margin-top: 4px; }

/* ---- visual scenes ---- */
#stage { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.scene {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.6s ease;
  padding: 0 20px calc(150px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse 125% 105% at 50% 38%, #14222f 0%, var(--deep) 78%);
}
.scene.on { opacity: 1; }
.scene-inner { max-width: 620px; width: 100%; text-align: center; }
.scene-title {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: clamp(26px, 6vw, 40px); letter-spacing: 0.01em;
  color: var(--cream); margin-bottom: 8px;
  text-shadow: 0 2px 18px rgba(12, 20, 28, 0.65);
}
.scene-sub { font-size: 14px; color: rgba(243, 236, 218, 0.85); line-height: 1.5; margin-top: 8px; text-shadow: 0 1px 10px rgba(12, 20, 28, 0.7); }
.scene-note { font-size: 11.5px; line-height: 1.4; color: rgba(243, 236, 218, 0.55); margin: 12px auto 0; font-style: italic; text-align: center; max-width: 340px; }

/* the year it worked: a stream of voyages with the tonnage they carried */
.worked { margin: 18px auto 4px; max-width: 460px; }
.worked-num {
  font-family: var(--serif); font-size: clamp(44px, 11vw, 72px); font-weight: 500;
  color: var(--accent); line-height: 1; text-shadow: 0 2px 24px rgba(12, 20, 28, 0.7);
}
.worked-unit { font-size: 14px; color: rgba(243, 236, 218, 0.85); margin-top: 6px; }
.worked-stream { position: relative; height: 54px; margin: 22px auto 0; max-width: 420px; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.worked-stream::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  background: rgba(243, 236, 218, 0.25);
}
.w-ship {
  position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50% 50% 50% 4px; background: var(--accent);
  animation: sail linear infinite;
}
@keyframes sail {
  from { transform: translateX(-20px) rotate(-45deg); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  to   { transform: translateX(440px) rotate(-45deg); opacity: 0; }
}
.worked-stats { display: flex; justify-content: center; gap: 18px; margin-top: 18px; flex-wrap: wrap; }
.wstat { font-size: 12.5px; color: rgba(243, 236, 218, 0.8); }
.wstat b { display: block; font-family: var(--serif); font-size: 20px; font-weight: 500; color: var(--cream); }
.worked-end { margin-top: 16px; font-size: 12px; color: rgba(243, 236, 218, 0.6); font-style: italic; }
@media (prefers-reduced-motion: reduce) {
  .w-ship { animation: none; opacity: 1; }
  #wash { animation: none; }
}

/* ---- map story marks ---- */
.port-label, .city-label {
  font: 600 12px/1.2 -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--cream); background: rgba(12, 20, 28, 0.72);
  border-radius: 7px; padding: 3px 8px; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(12, 20, 28, 0.4);
}
.city-label { font-weight: 500; font-size: 11.5px; background: rgba(12, 20, 28, 0.55); }
.port-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2.5px solid #f3ecda; box-shadow: 0 0 12px var(--ring); }
.city-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cream); opacity: 0.9; }
.strike {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--danger); background: rgba(176, 58, 46, 0.35);
  animation: strikePulse 2.4s ease-out infinite;
}
@keyframes strikePulse {
  0% { box-shadow: 0 0 0 0 rgba(176, 58, 46, 0.5); }
  70% { box-shadow: 0 0 0 16px rgba(176, 58, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(176, 58, 46, 0); }
}
@media (prefers-reduced-motion: reduce) { .strike { animation: none; } }

/* the prologue ship and its wake */
.ship-mark {
  width: 13px; height: 13px; border-radius: 50% 50% 50% 4px;
  background: var(--cream); transform: rotate(-45deg);
  box-shadow: 0 0 12px rgba(243, 236, 218, 0.7);
}

/* landscape phones: dock the caption left */
@media (max-height: 500px) and (min-width: 640px) {
  #caption {
    left: 16px; transform: none; bottom: 14px;
    width: min(380px, 44vw);
  }
  #caption.hidden { transform: translateY(14px); }
  .scene { padding: 0 20px 30px calc(min(400px, 46vw)); }
}
@media (prefers-reduced-motion: reduce) {
  .leaflet-tile-pane, #caption, .scene { transition: none; }
  .btn { transition: none; }
}
