/* Shorelines — the interface sits lightly on top of the scene and steps
   aside when nobody is touching it. */
:root {
  --ink: #fff;
  --glass: rgba(12, 20, 34, 0.3);
  --line: rgba(255, 255, 255, 0.18);
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(16px, 3vw, 36px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
body {
  position: fixed; inset: 0; overflow: hidden;
  background: #0b1a2e; color: var(--ink);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}

#sea, #ghost { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#sea { touch-action: none; cursor: grab; transition: opacity 1.4s ease; }
#ghost { pointer-events: none; opacity: 0; }
.is-loading #sea { opacity: 0; }

/* Darkens the edges and the foot of the frame so type stays readable. */
.veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, rgba(4, 10, 22, 0.5), rgba(4, 10, 22, 0) 34%),
    linear-gradient(to bottom, rgba(4, 10, 22, 0.22), rgba(4, 10, 22, 0) 16%),
    radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.26) 100%);
}
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- type on the scene ---------- */
.brand {
  position: absolute; top: calc(var(--pad) + env(safe-area-inset-top, 0px)); left: var(--pad); margin: 0;
  font-size: 11px; letter-spacing: 0.42em; text-transform: uppercase; opacity: 0.82;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
  transition: opacity 0.9s ease;
}

.place {
  position: absolute; left: var(--pad); right: var(--pad);
  bottom: calc(var(--pad) + var(--safe-b) + 76px);
  pointer-events: none; text-shadow: 0 2px 26px rgba(0, 0, 0, 0.5);
  transition: opacity 0.45s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.place.is-changing { opacity: 0; transform: translateY(10px); }
.place p { margin: 0; }
.place__kind, .place__meta { font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase; }
.place__kind { opacity: 0.86; }
.place__name {
  margin: 0.1em 0 0.02em -0.03em; font-family: var(--serif); font-weight: 400;
  font-size: clamp(46px, 9.5vw, 132px); line-height: 0.95; letter-spacing: -0.01em;
  text-wrap: balance;
}
.place__region { font-family: var(--serif); font-style: italic; font-size: clamp(19px, 2.3vw, 30px); opacity: 0.95; }
.place__meta { margin-top: 1em !important; opacity: 0.66; font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
.ui { transition: opacity 0.9s ease, transform 0.9s ease; }
.is-idle .ui, .is-idle .brand { opacity: 0; pointer-events: none; }
.is-idle .place { opacity: 0.72; transform: translateY(58px); transition-duration: 1.2s; }
.is-idle #sea { cursor: none; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.dock {
  position: absolute; left: var(--pad); right: var(--pad); bottom: calc(var(--pad) + var(--safe-b));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px;
}
.pill, .times, .mixer {
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
}
.pill {
  display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 18px 0 14px; justify-self: start;
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: background 0.25s ease;
}
.pill:hover { background: rgba(12, 20, 34, 0.5); }
.pill__more { opacity: 0.62; padding-left: 10px; border-left: 1px solid var(--line); }

.times { display: flex; padding: 3px; gap: 2px; }
.times button {
  width: 40px; height: 38px; border-radius: 999px; display: grid; place-items: center; opacity: 0.72;
  transition: background 0.35s ease, color 0.35s ease, opacity 0.35s ease;
}
.times button:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.times button[aria-checked="true"] { background: #fff; color: #10203a; opacity: 1; }

/* The mixer floats above the sound button so it never widens the dock. */
.sound { justify-self: end; position: relative; }
.mixer { position: absolute; right: 0; bottom: calc(100% + 10px); }
.pill--sound[aria-expanded="true"] { background: rgba(255, 255, 255, 0.16); }
.mixer__mute {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; align-self: center;
  border: 1px solid var(--line); transition: background 0.25s ease;
}
.mixer__mute:hover { background: rgba(255, 255, 255, 0.14); }
.mixer__mute svg { width: 18px; height: 18px; }

.lang {
  position: absolute; top: calc(var(--pad) + env(safe-area-inset-top, 0px) - 12px); right: var(--pad);
  height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  font-size: 12px; letter-spacing: 0.12em; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}
.lang:hover { background: rgba(12, 20, 34, 0.5); }
.pill--sound .snd-on { display: none; }
.pill--sound[aria-pressed="true"] .snd-on { display: inline; }
.pill--sound[aria-pressed="true"] .snd-off { display: none; }
.pill--sound.is-inviting { animation: invite 2.6s ease-out 1.2s 4; }
@keyframes invite {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(255, 255, 255, 0); }
}

.mixer {
  border-radius: 20px; padding: 14px 18px 14px 14px; display: grid; gap: 12px 14px; width: 278px;
  grid-template-columns: auto 1fr;
}
.mixer__mute { grid-row: span 2; }
.mixer__info {
  grid-column: 2; justify-self: end; display: inline-flex; align-items: center; gap: 5px;
  margin: -4px -6px -6px 0; padding: 4px 6px; border-radius: 999px;
  font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.6; transition: opacity 0.2s ease, background 0.2s ease;
}
.mixer__info svg { width: 13px; height: 13px; }
.mixer__info:hover, .mixer__info[aria-expanded="true"] { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.credits-pop {
  position: absolute; right: 0; bottom: calc(100% + 8px); width: min(360px, calc(100vw - 2 * var(--pad)));
  padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(8, 15, 28, 0.72);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  font-size: 11px; line-height: 1.5; text-align: left; user-select: text;
}
.credits-pop[hidden] { display: none; }
.credits-pop span { display: block; }
.credits-pop span + span { margin-top: 6px; }
.credits-pop a { color: inherit; }
.mixer[hidden] { display: none; }
.mixer label { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 10px; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; }
.mixer input {
  --v: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: none; cursor: pointer;
}
.mixer input::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px; background: linear-gradient(to right, #fff var(--v), rgba(255, 255, 255, 0.28) var(--v));
}
.mixer input::-moz-range-track { height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.28); }
.mixer input::-moz-range-progress { height: 2px; border-radius: 2px; background: #fff; }
.mixer input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.mixer input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
/* Fingers need a bigger target than a mouse pointer. */
@media (pointer: coarse) {
  .mixer input { height: 36px; touch-action: none; }
  .mixer input::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -11px; }
  .mixer input::-moz-range-thumb { width: 24px; height: 24px; }
}

.step {
  position: absolute; top: 44%; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.step:hover { background: rgba(12, 20, 34, 0.5); }
.step--prev { left: var(--pad); }
.step--next { right: var(--pad); }

/* ---------- list of coasts ---------- */
.atlas {
  position: fixed; inset: 0 auto 0 0; margin: 0; height: 100%; max-height: none; width: min(430px, 100vw); max-width: none;
  padding: 0; border: 0; border-right: 1px solid var(--line); color: var(--ink); color-scheme: dark;
  background: rgba(8, 15, 28, 0.62);
  -webkit-backdrop-filter: blur(26px) saturate(1.2); backdrop-filter: blur(26px) saturate(1.2);
  user-select: none;
}
.atlas[open] { display: flex; flex-direction: column; animation: slide 0.5s cubic-bezier(0.2, 0.7, 0.2, 1); }
.atlas::backdrop { background: rgba(4, 8, 18, 0.28); }
@keyframes slide { from { transform: translateX(-28px); opacity: 0; } }
.atlas__head {
  display: flex; align-items: center; justify-content: space-between; flex: none;
  padding: calc(var(--pad) + env(safe-area-inset-top, 0px)) var(--pad) 14px;
}
.atlas__head p { margin: 0; font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.75; }
.atlas__close { width: 40px; height: 40px; margin-right: -10px; border-radius: 50%; display: grid; place-items: center; }
.atlas__close:hover { background: rgba(255, 255, 255, 0.12); }
.atlas__list {
  overflow-y: auto; padding: 0 var(--pad) calc(var(--pad) + var(--safe-b)); overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}
.atlas__item:focus-visible { outline: none; background: linear-gradient(to right, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)); box-shadow: -2px 0 0 #fff; }
.atlas__group { margin: 22px 0 6px; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.5; }
.atlas__item {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 14px; width: 100%; text-align: left;
  padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.atlas__item b { font-family: var(--serif); font-weight: 400; font-size: 27px; line-height: 1.1; transition: transform 0.3s ease; }
.atlas__item i { grid-column: 1; font-family: var(--serif); font-size: 16px; opacity: 0.7; }
.atlas__item em { grid-row: 1; grid-column: 2; font-style: normal; font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.55; }
.atlas__item:hover b, .atlas__item:focus-visible b { transform: translateX(6px); }
/* Audio credits at the very end of the list: small and quiet, scrolling with it. */
.atlas__credit {
  margin: 16px 0 0; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 9.5px; line-height: 1.4; opacity: 0.45; user-select: text;
}
.atlas__credit a { color: inherit; }
.atlas__credit span { display: block; }
.atlas__credit span + span { margin-top: 3px; }
.atlas__item[aria-current="true"] b::after { content: "  ·  " attr(data-here); font-family: var(--sans); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.6; vertical-align: middle; }

.noscript { position: absolute; inset: auto 0 45% 0; text-align: center; padding: 0 24px; font-family: var(--serif); font-size: 22px; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .dock { gap: 8px; }
  .pill { padding: 0 14px 0 12px; gap: 8px; }
  .pill__more, #soundLabel { display: none; }
  .pill--sound { padding: 0 13px; }
  .step { top: auto; bottom: calc(var(--pad) + var(--safe-b) + 64px); width: 40px; height: 40px; }
  .step--prev { left: auto; right: calc(var(--pad) + 48px); }
  .place { bottom: calc(var(--pad) + var(--safe-b) + 122px); }
  .place__kind, .place__meta { font-size: 10px; letter-spacing: 0.22em; }
  .is-idle .place { transform: translateY(104px); }
  /* Phones: the mixer becomes one full-width row above the dock, and the
     arrows and title move up to make room for it. */
  .sound { position: static; }
  .mixer {
    left: 0; right: 0; width: auto; bottom: calc(100% + 10px);
    grid-template-columns: auto 1fr 1fr; gap: 12px; padding: 2px 16px 2px 6px; border-radius: 999px;
  }
  .mixer__mute { grid-row: auto; }
  .mixer { grid-template-columns: auto 1fr 1fr auto; padding-right: 6px; }
  .mixer__info { grid-column: auto; margin: 0; width: 32px; height: 32px; padding: 0; justify-content: center; }
  .mixer__info svg { width: 17px; height: 17px; }
  .mixer__info span { display: none; }
  .credits-pop { left: 0; right: 0; width: auto; }
  .mixer label { grid-template-columns: auto 1fr; gap: 8px; font-size: 9px; letter-spacing: 0.16em; }
  .mixer-open .step { bottom: calc(var(--pad) + var(--safe-b) + 122px); }
  .mixer-open .place { bottom: calc(var(--pad) + var(--safe-b) + 180px); }
  .lang { height: 32px; padding: 0 12px; font-size: 11px; }
  .atlas { inset: auto 0 0 0; width: 100%; height: 82%; border-right: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; }
  @keyframes slide { from { transform: translateY(36px); opacity: 0; } }
}
@media (max-height: 520px) {
  .place__name { font-size: clamp(34px, 11vh, 64px); }
  .place__meta { display: none; }
  .step { top: 34%; }
}
/* ---------- Chinese ---------- */
:root:lang(zh) {
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
}
:lang(zh) .place__name { font-weight: 600; letter-spacing: 0.04em; font-size: clamp(42px, 8.5vw, 112px); }
:lang(zh) .place__region { font-style: normal; letter-spacing: 0.06em; }
:lang(zh) .place__kind, :lang(zh) .place__meta, :lang(zh) .pill, :lang(zh) .mixer label,
:lang(zh) .atlas__head p, :lang(zh) .atlas__group, :lang(zh) .atlas__item em { letter-spacing: 0.12em; }
:lang(zh) .place__kind, :lang(zh) .place__meta { font-size: 12px; }
:lang(zh) .atlas__item b { font-weight: 600; font-size: 24px; }
:lang(zh) .atlas__item i { font-style: normal; font-size: 14px; }
.lang:lang(en) { letter-spacing: 0.2em; }

@media (prefers-reduced-motion: reduce) {
  .ui, .place, .brand, #sea, .atlas[open] { transition-duration: 0.01s; animation: none; }
  .pill--sound.is-inviting { animation: none; }
}
