:root {
  --space: #0b1430;
  --cream: #f6efe1;
  --ink: #3e2f24;
  --gold: #ffd27a;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--space);
  color: var(--cream);
  font-family: var(--sans);
}

#map {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1px 1px at 12% 22%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 14%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 64% 72%, #fffa 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 84%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 58%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 62%, #fff8 50%, transparent 51%),
    radial-gradient(ellipse at 50% 40%, #16224a, var(--space) 70%);
}

/* --- scene ------------------------------------------------------------ */

#scene {
  position: fixed;
  inset: 0;
  z-index: 2;
  will-change: transform;
}
#scene[hidden] { display: none; }
#scene svg { width: 100%; height: 100%; display: block; }

#scene #portal { cursor: pointer; }
#scene #portalGlow { opacity: 0; transition: opacity .6s; }
#scene.portal-ready #portalGlow { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }

/* train: the poles outside slide past (one pole spacing per loop, so it repeats seamlessly) */
#scene .passing { animation: passing .9s linear infinite; }
@keyframes passing { to { transform: translateX(-220px); } }

#scene .steam path { animation: rise 3.2s ease-in-out infinite; }
#scene .steam path + path { animation-delay: 1.4s; }
@keyframes rise {
  0% { opacity: 0; transform: translateY(10px); }
  40% { opacity: .7; }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* --- arrival pulse ------------------------------------------------------ */

#pulse {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 30px 12px #ffd27a99;
  z-index: 1;
  animation: pulse 1.1s ease-out;
}
#pulse[hidden] { display: none; }
@keyframes pulse {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- chrome ------------------------------------------------------------- */

#brand {
  position: fixed;
  top: 16px;
  left: 20px;
  z-index: 5;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: .02em;
  opacity: 0;
  transition: opacity 1s;
  text-shadow: 0 1px 8px #0008;
}
#brand.shown { opacity: .85; }

#intro {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px 9vh;
  text-align: center;
  pointer-events: none;
  transition: opacity 1.2s;
}
#intro.gone { opacity: 0; }
#intro.gone * { pointer-events: none !important; }
/* a soft dusk behind the title so it reads over a bright, full-window globe */
#intro::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(1000px, 130vw);
  height: 62vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 55% at 50% 72%, #0b1430e6 0%, #0b1430b3 40%, #0b143000 100%);
  z-index: -1;
  pointer-events: none;
}
#intro.compact::before { height: 26vh; background: radial-gradient(ellipse 30% 55% at 50% 88%, #0b143080 0%, #0b143000 100%); }
#intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(44px, 9vw, 88px);
  letter-spacing: -.01em;
  text-shadow: 0 2px 6px #0b1430cc, 0 4px 30px #0b1430;
}
.tagline {
  margin: 6px 0 28px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 3vw, 24px);
  text-shadow: 0 1px 4px #0b1430, 0 2px 16px #0b1430;
}
#intro button.ghost { background: #0b1430d9; border-color: #f6efe199; }
#intro button.ghost:hover { background: #16224a; }
#intro button.link { opacity: .95; text-shadow: 0 1px 6px #0b1430; }
#go {
  pointer-events: auto;
  font: 600 17px var(--sans);
  color: var(--ink);
  background: var(--gold);
  border: 0;
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
  box-shadow: 0 0 40px #ffd27a55;
  transition: transform .2s, opacity .3s;
}
#go:hover { transform: scale(1.04); }
#go:disabled { opacity: .4; cursor: default; transform: none; }
.loading { margin: 14px 0 0; font-size: 14px; opacity: .7; }

#place {
  position: fixed;
  left: 20px;
  bottom: 40px;
  z-index: 3;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s, transform 1s;
  color: var(--ink);
  text-shadow: 0 0 12px var(--cream), 0 0 4px var(--cream);
}
#place.shown { opacity: 1; transform: none; }
.place-city { font-family: var(--serif); font-size: clamp(30px, 6vw, 48px); font-weight: 600; }
.place-meta { font-size: 15px; font-weight: 500; }

#card {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 3;
  width: min(560px, calc(100vw - 32px));
  margin: 0;
  padding: 22px 26px 18px;
  background: #fbf6ecee;
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 12px 40px #0004;
  transform: translate(-50%, 20px);
  opacity: 0;
  transition: opacity .8s, transform .8s;
}
#card.shown { opacity: 1; transform: translate(-50%, 0); }
.card-where { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .65; }
.card-text { margin: 8px 0 10px; font-family: var(--serif); font-size: clamp(19px, 2.6vw, 24px); line-height: 1.35; }
.card-when { font-size: 13px; opacity: .6; }

.metoo {
  margin-top: 12px;
  font: 500 14px var(--sans);
  color: var(--ink);
  background: #efe3cc;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.metoo:hover { background: #e8d8ba; }
.metoo:active { transform: scale(.96); }
.metoo .heart { color: #d9573f; font-size: 16px; }
.metoo .count { opacity: .55; margin-left: 2px; }
.metoo.on { background: #fbe0d6; }
.metoo.on .heart { animation: beat .5s; display: inline-block; }
@keyframes beat { 40% { transform: scale(1.4); } }

#hint {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  max-width: calc(100vw - 180px);
  padding: 9px 18px;
  border-radius: 18px;
  background: #0b1430b3;
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
}
#hint[hidden] { display: none; }
#hint.bump { animation: fadein .8s; }
@media (max-width: 560px) { #hint { top: 56px; max-width: calc(100vw - 32px); } }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -6px); } }

.maplibregl-ctrl-attrib { font-size: 11px; }

/* --- hide flow ------------------------------------------------------------ */

button.ghost {
  pointer-events: auto;
  margin-top: 12px;
  font: 500 15px var(--sans);
  color: var(--cream);
  background: #0b143066;
  border: 1px solid #f6efe166;
  border-radius: 999px;
  padding: 11px 24px;
  cursor: pointer;
  transition: background .2s, opacity .3s;
}
button.ghost:hover { background: #0b1430aa; }
button.ghost:disabled { opacity: .4; cursor: default; }
button.ghost.small { font-size: 13px; padding: 7px 14px; margin: 0; }
button.link {
  pointer-events: auto;
  margin-top: 10px;
  font: 500 14px var(--sans);
  color: inherit;
  opacity: .75;
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
button.link:hover { opacity: 1; }
button.link[hidden] { display: none; }

#actions {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 5;
  display: flex;
  gap: 8px;
}
#actions [hidden] { display: none; }
button.ghost.icon { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; }
button.ghost.icon svg { width: 18px; height: 18px; }

/* the steerable globe without the big title */
#intro.compact h1, #intro.compact .tagline { display: none; }
#intro.compact { padding-bottom: 5vh; }

/* hover label on a light */
.tip .maplibregl-popup-content {
  background: #fbf6ecf2;
  color: var(--ink);
  border-radius: 12px;
  padding: 9px 12px;
  box-shadow: 0 8px 24px #0005;
  font: 13px/1.35 var(--sans);
}
.tip .maplibregl-popup-content b { display: block; font: 600 15px var(--serif); margin-bottom: 2px; }
.tip .maplibregl-popup-content span { font-family: var(--serif); font-style: italic; opacity: .8; }
.tip .maplibregl-popup-tip { border-top-color: #fbf6ecf2; border-bottom-color: #fbf6ecf2; }
.maplibregl-canvas { outline: none; }

.panel {
  position: fixed;
  left: 50%;
  z-index: 6;
  width: min(460px, calc(100vw - 32px));
  padding: 24px 24px 18px;
  background: #fbf6ecf2;
  color: var(--ink);
  border-radius: 20px;
  box-shadow: 0 16px 50px #0006;
}
.panel[hidden] { display: none; }
.panel h2 { margin: 0 0 4px; font: 600 24px var(--serif); }
.panel .sub { margin: 0 0 14px; font-size: 14px; opacity: .65; }

#leave { top: 50%; transform: translate(-50%, -50%); animation: rise-in .5s ease-out; }
#leave[data-step="scene"] { top: auto; bottom: 24px; transform: translateX(-50%); }
#leave .step { display: none; }
#leave[data-step="write"] .step[data-step="write"],
#leave[data-step="locate"] .step[data-step="locate"],
#leave[data-step="scene"] .step[data-step="scene"] { display: block; }
@keyframes rise-in { from { opacity: 0; margin-top: 14px; } }

#cityInput {
  width: 100%;
  font: 17px var(--sans);
  padding: 12px 14px;
  border: 2px solid #e2d3b8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
#cityInput:focus { border-color: #e9b949; }
#cityList { list-style: none; margin: 8px 0 0; padding: 0; max-height: 40vh; overflow-y: auto; }
#cityList button {
  width: 100%;
  text-align: left;
  font: 15px var(--sans);
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
#cityList button:hover, #cityList button:focus { background: #f1e5cc; outline: none; }
#cityList span { opacity: .6; }
#cityList .empty { padding: 10px 12px; font-size: 14px; opacity: .6; }

.scenes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; max-height: 52vh; overflow-y: auto; }
.scenes button {
  text-align: left;
  font: 13px var(--sans);
  color: var(--ink);
  background: #f1e5cc;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.scenes button:hover { border-color: #e9b949; transform: translateY(-2px); }
.scenes b { display: block; font: 600 16px var(--serif); margin-bottom: 2px; }
.scenes span { opacity: .65; }

#writeText {
  width: 100%;
  resize: none;
  font: 19px/1.35 var(--serif);
  color: var(--ink);
  background: #fff;
  border: 2px solid #e2d3b8;
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}
#writeText:focus { border-color: #e9b949; }
.write-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.write-row .link { margin: 0; }
.write-count { margin-left: auto; font-size: 12px; opacity: .5; }
.write-preview { margin: 0 0 10px; font: italic 19px/1.35 var(--serif); }
button.gold {
  font: 600 15px var(--sans);
  color: var(--ink);
  background: var(--gold);
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
}
button.gold:disabled { opacity: .45; cursor: default; }

/* who has seen yours */
#seen {
  right: 24px;
  left: auto;
  top: 50%;
  transform: translate(16px, -50%);
  width: min(380px, calc(100vw - 32px));
  opacity: 0;
  transition: opacity .8s, transform .8s;
}
#seen.shown { opacity: 1; transform: translate(0, -50%); }
.seen-where p { margin: 0; font-size: 13px; font-weight: 600; opacity: .65; }
.seen-where blockquote { margin: 6px 0 14px; font: italic 18px/1.35 var(--serif); }
.seen-big { font: 600 20px var(--serif); }
#seenPeople, #seenCountries { display: inline-block; font-size: 44px; line-height: 1; }
#seenCountries { font-size: 26px; }
.seen-countries { font: 600 18px var(--serif); margin-top: 2px; }
#seenTicker { list-style: none; margin: 12px 0; padding: 0; min-height: 66px; font-size: 13px; }
#seenTicker li { padding: 3px 0; animation: fadein-plain .6s; }
#seenTicker li:not(:first-child) { opacity: .55; }
@keyframes fadein-plain { from { opacity: 0; } }
.seen-share { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.seen-share code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  background: #efe3cc;
  padding: 7px 10px;
  border-radius: 8px;
}
.seen-share .ghost.small { color: var(--ink); border-color: #c9b48f; background: none; }
button.gold.wide { width: 100%; padding: 12px; font-size: 16px; }
.demo-note { margin: 10px 0 0; font-size: 11px; opacity: .5; text-align: center; }

@media (max-width: 560px) {
  #seen { top: auto; bottom: 16px; right: 16px; transform: translateY(16px); }
  #seen.shown { transform: none; }
  #seenPeople { font-size: 34px; }
  .seen-where blockquote { font-size: 16px; margin-bottom: 8px; }
  #actions { top: 10px; right: 10px; }
}

/* locate step: one sub-view at a time */
#leave .loc { display: none; }
#leave[data-loc="finding"] .loc[data-loc="finding"],
#leave[data-loc="confirm"] .loc[data-loc="confirm"],
#leave[data-loc="search"] .loc[data-loc="search"] { display: block; }
.loc-status { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; font-size: 15px; }
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e2d3b8;
  border-top-color: #c9971f;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loc-lead { margin: 0; }
.loc-city { margin: 2px 0 6px; font: 600 24px var(--serif); }
#leave .loc .write-row .link { margin: 0; }
#leave .loc .write-row .gold { margin-left: auto; }

/* choosing between several gratitudes on one light */
.chooser .maplibregl-popup-content { padding: 12px 12px 8px; }
.chooser .maplibregl-popup-close-button { font-size: 18px; padding: 2px 8px; color: var(--ink); opacity: .6; }
.chooser ul { list-style: none; margin: 6px 0 0; padding: 0; }
.chooser li button {
  width: 100%;
  text-align: left;
  font: italic 14px/1.35 var(--serif);
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
}
.chooser li button:hover, .chooser li button:focus { background: #f1e5cc; outline: none; }
.chooser li button.seen { opacity: .55; }
.chooser li button.seen::after { content: "  ✓"; font-style: normal; color: #6f9a5c; }

/* card buttons */
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 12px; }
.card-actions .metoo { margin-top: 0; }
.card-actions .metoo[hidden] { display: none; }
button.quiet {
  font: 500 13px var(--sans);
  color: var(--ink);
  opacity: .6;
  background: none;
  border: 0;
  padding: 6px 4px;
  cursor: pointer;
}
button.quiet:hover { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
button.quiet[hidden] { display: none; }
.form-err { margin: 8px 0 0; min-height: 0; color: #b5452f; font-size: 14px; }
.form-err:empty { display: none; }
/* the honeypot: off-screen, not display:none (some bots skip hidden fields) */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
