:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #8ab4f8;
  --border: #2d3139;
  --card-hover: #22262e;
  --time-local: #ffffff;
  --offset: #7dd3a0;
  --badge-bg: rgba(138, 180, 248, 0.15);
  --focus: #8ab4f8;
  --map-ocean: #0e1219;
  --band-even: rgba(138, 180, 248, 0.07);
  --band-odd: rgba(138, 180, 248, 0.02);
  --band-utc: rgba(125, 211, 160, 0.1);
  --you-glow: rgba(138, 180, 248, 0.55);
  --selected-glow: rgba(125, 211, 160, 0.7);
  --bubble-rim: rgba(138, 180, 248, 0.35);
  --bubble-shine: rgba(255, 255, 255, 0.14);
  --wing-fade: rgba(15, 17, 21, 0.72);
}

[data-theme="light"] {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --accent: #1a73e8;
  --border: #dadce0;
  --card-hover: #f1f3f4;
  --time-local: #202124;
  --offset: #137333;
  --badge-bg: rgba(26, 115, 232, 0.12);
  --focus: #1a73e8;
  --map-ocean: #cfdbeb;
  --band-even: rgba(26, 115, 232, 0.09);
  --band-odd: rgba(26, 115, 232, 0.03);
  --band-utc: rgba(19, 115, 51, 0.1);
  --you-glow: rgba(26, 115, 232, 0.55);
  --selected-glow: rgba(19, 115, 51, 0.65);
  --bubble-rim: rgba(26, 115, 232, 0.4);
  --bubble-shine: rgba(255, 255, 255, 0.45);
  --wing-fade: rgba(248, 249, 250, 0.78);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.4;
  transition: background 0.2s, color 0.2s;
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  body,
  .controls button,
  .city-card,
  .copy-toast,
  .strip-marker,
  .strip-you,
  .strip-selected,
  .strip-track,
  .strip-recenter {
    transition: none !important;
  }

  .strip-track {
    transform: none !important;
  }
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

.container--footer {
  padding-top: 0.5rem;
  padding-bottom: 2.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

h1 {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: lowercase;
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.controls button,
.strip-recenter,
.strip-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.controls button:hover,
.strip-recenter:hover,
.strip-nav:hover {
  background: var(--card-hover);
}

.controls button:focus-visible,
.strip-recenter:focus-visible,
.strip-nav:focus-visible,
.time:focus-visible,
.city-card:focus-visible,
.strip-viewport:focus-visible,
.strip-marker:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ===== LOCAL CLOCK ===== */
.local {
  text-align: center;
  margin-bottom: 2.75rem;
  padding: 1.5rem 0 0.5rem;
  position: relative;
}

.time {
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--time-local);
  line-height: 1;
  margin-bottom: 0.6rem;
  cursor: pointer;
  border-radius: 8px;
  display: inline-block;
  min-width: 8ch;
}

.time:hover {
  opacity: 0.92;
}

.date {
  font-size: 1.25rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.tz-name {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 500;
}

.copy-toast {
  position: absolute;
  left: 50%;
  bottom: 0.25rem;
  transform: translateX(-50%);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--offset);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  pointer-events: none;
  transition: opacity 0.15s;
}

.copy-toast[hidden] {
  display: none;
}

/* ===== CITIES ===== */
.cities h2 {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.city-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.city-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
}

.city-card.is-local {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.city-card.is-selected {
  border-color: var(--offset);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--offset) 40%, transparent),
    0 0 0 1px color-mix(in srgb, var(--offset) 25%, transparent);
}

.city-name {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.local-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--badge-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.city-time {
  font-size: 1.45rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
}

.city-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.2em;
}

.city-date {
  text-transform: lowercase;
}

.offset {
  color: var(--offset);
  font-weight: 500;
  margin-left: auto;
}

/* ===== WORLD STRIP (footer fun feature) ===== */
.world-strip {
  margin: 1.5rem 0 0.5rem;
  padding: 1.25rem 0 0.5rem;
  border-top: 1px solid var(--border);
}

.strip-header {
  max-width: 960px;
  margin: 0 auto 0.85rem;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.strip-heading h2 {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.strip-hint {
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.85;
  margin-top: 0.15rem;
}

.strip-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.strip-recenter,
.strip-nav {
  flex-shrink: 0;
  font-size: 0.8rem;
}

.strip-nav {
  width: 2rem;
  padding-left: 0;
  padding-right: 0;
  font-size: 1.15rem;
  line-height: 1;
}

/* Stage: perspective “globe in the middle, flat wings” */
.strip-stage {
  --strip-h: clamp(260px, 52vw, 400px);
  position: relative;
  height: var(--strip-h);
  margin: 0 auto;
  max-width: 1100px;
  padding: 0 0.5rem;
  perspective: 1100px;
  perspective-origin: 50% 45%;
}

.strip-viewport {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* proximity only — mandatory snap fights seamless wrap */
  scroll-snap-type: x proximity;
  scroll-padding-inline: 50%;
  overscroll-behavior-x: contain;
  border-radius: 16px;
  background: var(--map-ocean);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  cursor: grab;
  /* Soft mask so edges feel farther / flatter */
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 10%,
    #000 90%,
    transparent 100%
  );
}

.strip-viewport:active {
  cursor: grabbing;
}

.strip-viewport::-webkit-scrollbar {
  height: 8px;
}

.strip-viewport::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

/*
  Triple world track for seamless wrap: [copy0][copy1][copy2]
  Each world is aspect-correct (~2:1 Plate Carrée).
*/
.strip-track {
  --bulge-origin: 50%;
  --bulge-scale: 1.06;
  display: flex;
  flex-direction: row;
  height: 100%;
  /* 3 worlds × ~2:1 height */
  width: calc(var(--strip-h) * 2.05 * 3);
  min-width: calc(100% * 1.5);
  user-select: none;
  -webkit-user-select: none;
  transform-origin: var(--bulge-origin) 50%;
  transform: scale(var(--bulge-scale)) translateZ(0);
  will-change: transform;
}

.strip-world {
  position: relative;
  flex: 0 0 calc(100% / 3);
  width: calc(100% / 3);
  height: 100%;
  overflow: hidden;
}

.strip-ocean {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 70% at 50% 50%, color-mix(in srgb, var(--map-ocean) 40%, #1a2740) 0%, var(--map-ocean) 70%),
    var(--map-ocean);
  pointer-events: none;
}

.strip-bands {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.strip-band {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.strip-band.is-even {
  background: var(--band-even);
}

.strip-band.is-odd {
  background: var(--band-odd);
}

.strip-band.is-utc {
  background: var(--band-utc);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--offset) 25%, transparent);
}

.strip-snap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  scroll-snap-align: center;
  pointer-events: none;
}

.strip-hour-label {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: 0.5;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.strip-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 2;
}

[data-theme="dark"] .strip-map {
  opacity: 0.5;
  filter: brightness(0) invert(1);
}

[data-theme="light"] .strip-map {
  opacity: 0.4;
  filter: brightness(0);
}

/* Fixed reticle in the globe center — “what am I looking at?” */
.strip-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  width: 1px;
  height: 42%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent,
    color-mix(in srgb, var(--accent) 55%, transparent) 20%,
    color-mix(in srgb, var(--accent) 55%, transparent) 80%,
    transparent
  );
  opacity: 0.55;
}

.strip-crosshair::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border: 1.5px solid color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Viewport-fixed globe bubble (the “3D” center) */
.strip-bubble {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: min(58%, calc(var(--strip-h) * 1.05));
  height: 96%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1.5px var(--bubble-rim),
    inset 18px 10px 36px rgba(255, 255, 255, 0.05),
    inset -22px -16px 40px rgba(0, 0, 0, 0.35),
    0 0 0 1px color-mix(in srgb, var(--border) 80%, transparent),
    0 12px 40px rgba(0, 0, 0, 0.28);
  background:
    radial-gradient(ellipse 55% 40% at 32% 28%, var(--bubble-shine), transparent 55%),
    radial-gradient(ellipse 80% 80% at 50% 55%, transparent 42%, rgba(0, 0, 0, 0.22) 100%);
}

.strip-bubble-shine {
  position: absolute;
  left: 18%;
  top: 14%;
  width: 38%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--bubble-shine), transparent 70%);
  opacity: 0.7;
  filter: blur(1px);
}

/* Flat wings — dim / compress the sides of the stage */
.strip-wing {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 5;
  width: 22%;
  pointer-events: none;
}

.strip-wing--left {
  left: 0.5rem;
  background: linear-gradient(
    90deg,
    var(--wing-fade) 0%,
    color-mix(in srgb, var(--wing-fade) 55%, transparent) 55%,
    transparent 100%
  );
  border-radius: 16px 0 0 16px;
}

.strip-wing--right {
  right: 0.5rem;
  background: linear-gradient(
    270deg,
    var(--wing-fade) 0%,
    color-mix(in srgb, var(--wing-fade) 55%, transparent) 55%,
    transparent 100%
  );
  border-radius: 0 16px 16px 0;
}

/* “You are here” vertical glow (per world copy) */
.strip-you {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--you-glow) 12%,
    var(--accent) 50%,
    var(--you-glow) 88%,
    transparent 100%
  );
  box-shadow: 0 0 14px 3px color-mix(in srgb, var(--accent) 45%, transparent);
  z-index: 4;
  pointer-events: none;
  transition: left 0.4s ease;
}

.strip-you-label {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 4px;
  padding: 0.08rem 0.35rem;
  white-space: nowrap;
}

.strip-selected {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--selected-glow) 15%,
    var(--offset) 50%,
    var(--selected-glow) 85%,
    transparent 100%
  );
  box-shadow: 0 0 12px 2px color-mix(in srgb, var(--offset) 40%, transparent);
  z-index: 3;
  pointer-events: none;
  transition: left 0.25s ease;
}

.strip-selected[hidden] {
  display: none;
}

.strip-markers {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.strip-marker {
  position: absolute;
  /* top/left set in JS from real lat/lon (Plate Carrée) */
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font: inherit;
  scroll-snap-align: center;
  z-index: 1;
}

.strip-marker.is-label-on,
.strip-marker.is-selected,
.strip-marker.is-local {
  z-index: 4;
}

.strip-marker-pin {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--bg) 50%, transparent),
    0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 2;
}

/* Soft target ring so the city point reads clearly on land */
.strip-marker-pin::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  opacity: 0.7;
  pointer-events: none;
}

/* Stem ties chip to pin so alignment is obvious */
.strip-marker-stem {
  position: absolute;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
  border-radius: 1px;
}

.strip-marker.is-label-on .strip-marker-stem {
  opacity: 1;
  visibility: visible;
}

.strip-marker-chip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.22rem 0.5rem 0.28rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 90%, transparent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 3;
}

.strip-marker.is-label-on .strip-marker-chip {
  opacity: 1;
  visibility: visible;
}

/* Lane 0: chip above pin with stem */
.strip-marker[data-lane="0"] .strip-marker-chip {
  bottom: calc(100% + 18px);
}

.strip-marker[data-lane="0"] .strip-marker-stem {
  bottom: 50%;
  height: 18px;
}

/* Lane 1: chip below pin with stem */
.strip-marker[data-lane="1"] .strip-marker-chip {
  top: calc(100% + 18px);
  bottom: auto;
}

.strip-marker[data-lane="1"] .strip-marker-stem {
  top: 50%;
  height: 18px;
}

.strip-marker-name {
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.15;
  color: var(--text);
  letter-spacing: 0.01em;
}

.strip-marker-time {
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.15;
}

.strip-marker:hover .strip-marker-pin,
.strip-marker:focus-visible .strip-marker-pin {
  transform: scale(1.3);
  background: var(--accent);
}

.strip-marker.is-local .strip-marker-pin {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
}

.strip-marker.is-selected .strip-marker-pin {
  border-color: var(--offset);
  background: var(--offset);
  box-shadow: 0 0 12px color-mix(in srgb, var(--offset) 55%, transparent);
  transform: scale(1.25);
}

.strip-marker.is-selected .strip-marker-chip {
  border-color: color-mix(in srgb, var(--offset) 45%, var(--border));
}

.strip-marker.is-selected .strip-marker-name {
  color: var(--offset);
}

.strip-marker.is-selected .strip-marker-stem {
  background: color-mix(in srgb, var(--offset) 65%, transparent);
}

.strip-marker.is-local .strip-marker-chip {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

/* ===== FOOTER ===== */
footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

footer p + p {
  margin-top: 0.3rem;
}

.credit {
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 1.25rem 1rem 1.5rem;
  }
  .time {
    font-size: 3.4rem;
  }
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  .city-card {
    padding: 0.85rem 0.9rem;
  }
  .city-time {
    font-size: 1.25rem;
  }
  .strip-header {
    padding: 0 1rem;
  }
  .strip-stage {
    --strip-h: clamp(240px, 62vw, 320px);
    padding: 0;
  }
  .strip-bubble {
    width: min(72%, calc(var(--strip-h) * 1.05));
  }
  .strip-wing {
    width: 16%;
  }
  .strip-marker-name {
    font-size: 0.65rem;
  }
  .strip-marker-time {
    font-size: 0.6rem;
  }
  .strip-track {
    width: calc(var(--strip-h) * 2.25 * 3);
  }
}

@media (min-width: 900px) {
  .strip-stage {
    --strip-h: 380px;
  }
  .strip-track {
    width: calc(var(--strip-h) * 2.05 * 3);
  }
}
