/* ============================================================
   bvi.wetterstein.ch — night-sail countdown
   Pure CSS/SVG scene, no runtime dependencies.
   ============================================================ */

:root {
  --gold: #e8b04b;
  --gold-dim: rgba(232, 176, 75, 0.32);
  --cream: #f4efe4;
  --muted: #a9a4c9;
  --muted-2: #7d78a3;
  --horizon: 58vh;
  /* celestial scene — driven per-minute by app.js (real Europe/Zurich time) */
  --night: 1;
  --glitter-x: calc(16% + clamp(28px, 4.5vw, 48px));
  --glitter-c: rgba(240, 230, 200, 0.13);
  --sky-0: #04071a;
  --sky-1: #081026;
  --sky-2: #101a3f;
  --sky-3: #232a56;
  --sky-4: #43335c;
  --sky-5: #6d3f5e;
  --sky-6: #8a4a52;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

html, body { height: 100%; }

body {
  background: #060a1c;
  color: var(--cream);
  font-family: var(--font-display);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- scene ---------------- */

.scene {
  position: fixed; inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(
    to bottom,
    #04061228 0%,
    transparent 100%
  );
}

.sky {
  position: absolute; inset: 0;
  background:
    linear-gradient(
      to bottom,
      var(--sky-0) 0%,
      var(--sky-1) 24%,
      var(--sky-2) 44%,
      var(--sky-3) 52%,
      var(--sky-4) 57.2%,
      var(--sky-5) 58.4%,
      var(--sky-6) var(--horizon),
      transparent var(--horizon)
    );
  transition: background 1.2s linear;
}

.stars {
  position: absolute; inset: 0 0 45% 0;
  opacity: var(--night);
  transition: opacity 1.2s linear;
}

.stars i {
  position: absolute;
  background: #dfe6ff;
  border-radius: 50%;
  animation: twinkle 4s linear infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.12; }
  50%      { opacity: 0.85; }
}

/* sun + moon are placed per-minute by app.js along a horizon-to-zenith arc
   (sun: sunrise→sunset, moon: sunset→next sunrise); opacity ramps at the horizon */

.moon {
  position: absolute;
  left: 16%;
  top: 9%;
  width: clamp(56px, 9vw, 96px);
  height: clamp(56px, 9vw, 96px);
  border-radius: 50%;
  box-shadow:
    0 0 42px 12px rgba(244, 235, 205, 0.30),
    0 0 120px 48px rgba(244, 235, 205, 0.12);
  opacity: 0;
  animation: moon-breathe 9s ease-in-out infinite;
  transition: left 1.1s linear, top 1.1s linear, opacity 1.1s linear;
}

.moon svg { width: 100%; height: 100%; display: block; border-radius: 50%; overflow: visible; }

.sun {
  position: absolute;
  left: 4%;
  top: 40vh;
  width: clamp(56px, 9vw, 96px);
  height: clamp(56px, 9vw, 96px);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fffce9 0%, #ffe9a8 46%, #ffcd74 100%);
  box-shadow:
    0 0 46px 14px rgba(255, 213, 138, 0.40),
    0 0 130px 54px rgba(255, 186, 100, 0.18);
  opacity: 0;
  transition: left 1.1s linear, top 1.1s linear, opacity 1.1s linear;
}

/* no position drift on first paint: app.js sets the real spot, then arms */
body:not(.ready) .moon,
body:not(.ready) .sun { transition: none; }

@keyframes moon-breathe {
  0%, 100% { box-shadow: 0 0 42px 12px rgba(244,235,205,.30), 0 0 120px 48px rgba(244,235,205,.12); }
  50%      { box-shadow: 0 0 52px 16px rgba(244,235,205,.38), 0 0 140px 56px rgba(244,235,205,.15); }
}

.islands {
  position: absolute;
  left: 0;
  top: calc(var(--horizon) - 72px);
  width: 100%;
  height: 72px;
  display: block;
}

.beacon { animation: beacon 5s linear infinite; }

@keyframes beacon {
  0%, 82%, 100% { opacity: 0.15; }
  88%, 94%      { opacity: 1; filter: drop-shadow(0 0 6px #ffd98a); }
}

/* ---------------- sea ---------------- */

.sea { position: absolute; left: 0; right: 0; top: var(--horizon); bottom: 0; }

.glitter {
  position: absolute;
  left: var(--glitter-x);
  top: 0;
  width: clamp(56px, 9vw, 100px);
  height: 72%;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    180deg,
    var(--glitter-c) 0 2px,
    transparent 2px 9px
  );
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
  animation: glitter 3.4s ease-in-out infinite alternate;
  opacity: 0.8;
  transition: left 1.1s linear;
}

@keyframes glitter {
  from { opacity: 0.45; transform: translateX(-50%) scaleX(0.92); }
  to   { opacity: 0.9;  transform: translateX(-50%) scaleX(1.06); }
}

.wave {
  position: absolute;
  left: 0;
  width: 100%;
  overflow: hidden;
}

.wave svg {
  position: absolute;
  left: 0; top: 0;
  width: 200%;
  height: 100%;
  display: block;
}

.w1 { top: 0;      height: clamp(28px, 5vh, 48px);  fill: #182150; opacity: 0.85; }
.w2 { top: 3vh;    height: clamp(34px, 6vh, 58px);  fill: #131c42; }
.w3 { top: 6.5vh;  height: clamp(42px, 8vh, 72px);  fill: #0f1737; }
.w4 { top: 10.5vh; height: clamp(52px, 11vh, 96px); fill: #0a0f28; }

.w1 svg { animation: drift 29s linear infinite; }
.w2 svg { animation: drift 21s linear infinite; }
.w3 svg { animation: drift 15s linear infinite; }
.w4 svg { animation: drift 10s linear infinite; }

@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.wave svg path { fill: inherit; }
.w1 svg path { fill: #182150; }
.w2 svg path { fill: #131c42; }
.w3 svg path { fill: #0f1737; }
.w4 svg path { fill: #0a0f28; }

/* ---------------- boat ---------------- */

.boat {
  position: absolute;
  left: auto;
  right: 6%;
  top: calc(var(--horizon) - clamp(120px, 19vh, 185px));
  width: clamp(110px, 17vw, 185px);
  z-index: 1;
  animation: bob 6.5s ease-in-out infinite;
  transform-origin: 50% 92%;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
}

.boat svg { width: 100%; height: auto; display: block; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.6deg); }
  50%      { transform: translateY(-9px) rotate(1.8deg); }
}

.boat.heave { animation: heave 0.7s ease-in-out 1, bob 6.5s ease-in-out 0.7s infinite; }

@keyframes heave {
  0%   { transform: translateY(0) rotate(-2deg); }
  30%  { transform: translateY(-16px) rotate(-7deg); }
  60%  { transform: translateY(2px) rotate(4deg); }
  100% { transform: translateY(0) rotate(0); }
}

body.launched .boat { right: 10%; animation: sail-off 9s ease-in-out infinite; }

@keyframes sail-off {
  0%, 100% { transform: translateY(0) rotate(-2deg) translateX(0); }
  50%      { transform: translateY(-12px) rotate(2.5deg) translateX(-26px); }
}

/* ---------------- compass ---------------- */

.compass {
  position: absolute;
  right: 4vw;
  top: 5vh;
  width: clamp(84px, 12vw, 150px);
  opacity: 0.5;
}

.compass .rose {
  animation: spin 90s linear infinite;
  transform-origin: 50% 50%;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------- content ---------------- */

.content {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.1rem, 3.2vh, 2.1rem);
  text-align: center;
  padding: 8vh 1.2rem 24vh;
}

/* soft vignette so the type stays legible when the sky brightens by day */
.content::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
    ellipse 72% 58% at 50% 44%,
    rgba(4, 7, 20, 0.52),
    rgba(4, 7, 20, 0) 72%
  );
  pointer-events: none;
}

.overline {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 1.4vw, 0.8rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.9;
  text-shadow: 0 0 18px rgba(232, 176, 75, 0.35);
}

.title {
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 1.06;
  letter-spacing: 0.01em;
  text-shadow: 0 4px 34px rgba(0, 0, 0, 0.55);
}

.title em {
  font-style: italic;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(232, 176, 75, 0.4);
}

.subtitle {
  font-family: var(--font-mono);
  font-size: clamp(0.72rem, 1.6vw, 0.95rem);
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.subtitle #ship-time { color: var(--cream); }

/* ---------------- countdown ---------------- */

.countdown { width: min(760px, 94vw); }

.tiles {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: clamp(0.4rem, 1.6vw, 1rem);
}

.tile {
  flex: 1 1 0;
  max-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: clamp(0.7rem, 2vw, 1.2rem) 0.5rem;
  background: rgba(8, 12, 30, 0.55);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  backdrop-filter: blur(9px) saturate(1.15);
  -webkit-backdrop-filter: blur(9px) saturate(1.15);
  box-shadow:
    inset 0 1px 0 rgba(244, 239, 228, 0.08),
    0 12px 30px rgba(2, 4, 14, 0.45);
}

.num {
  font-family: var(--font-mono);
  font-size: clamp(1.9rem, 7.4vw, 4rem);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--cream);
  text-shadow: 0 0 22px rgba(244, 239, 228, 0.22);
}

.num.tick { animation: tick 0.45s ease-out; }

@keyframes tick {
  0%   { transform: translateY(-14%); opacity: 0.25; filter: brightness(1.6); }
  100% { transform: translateY(0);    opacity: 1;    filter: brightness(1); }
}

.label {
  font-family: var(--font-mono);
  font-size: clamp(0.55rem, 1.3vw, 0.72rem);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.sep {
  align-self: center;
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 4.6vw, 2.6rem);
  color: var(--gold);
  opacity: 0.55;
  padding-bottom: 1.4em;
}

/* ---------------- launched state ---------------- */

body.launched .tiles,
body.launched .voyage { display: none; }

.sail-away { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }

.sail-away[hidden] { display: none; }

body.launched .sail-away {
  display: flex;
  animation: glow-in 2.4s ease-out;
}

.sail-away p {
  font-size: clamp(1.5rem, 4.4vw, 2.6rem);
  font-weight: 600;
  line-height: 1.35;
  color: var(--cream);
  text-shadow: 0 0 34px rgba(232, 176, 75, 0.35);
}

.sail-away-boat {
  font-size: clamp(3rem, 9vw, 5rem);
  filter: drop-shadow(0 0 26px rgba(232, 176, 75, 0.5));
}

@keyframes glow-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------------- voyage strip ---------------- */

.voyage {
  width: min(560px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.route {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.port {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 64px;
}

.marker { font-size: 1.15rem; line-height: 1; filter: drop-shadow(0 0 10px rgba(232,176,75,.4)); }

.port-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.line {
  position: relative;
  flex: 1;
  height: 3px;
  margin-top: 0.55rem;
  background:
    repeating-linear-gradient(90deg,
      rgba(169, 164, 201, 0.55) 0 7px,
      transparent 7px 15px);
  border-radius: 2px;
}

.line-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(232,176,75,0.25), var(--gold));
  border-radius: 2px;
  box-shadow: 0 0 14px rgba(232, 176, 75, 0.55);
  transition: width 1s linear;
}

.mini-boat {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -62%);
  width: 30px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
  transition: left 1s linear;
}

.mini-boat svg { width: 100%; height: auto; display: block; }

.progress-text {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 1.5vw, 0.8rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- footer / splash ---------------- */

.footer {
  position: fixed;
  left: 0; right: 0;
  bottom: 1.1rem;
  z-index: 2;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-2);
  pointer-events: auto;
}

.footer a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted-2); }
.footer a:hover { color: var(--gold); border-color: var(--gold); }

.splash {
  position: fixed;
  z-index: 1;
  width: 140px;
  height: 46px;
  margin: -23px 0 0 -70px;
  border: 2px solid rgba(236, 228, 201, 0.55);
  border-radius: 50%;
  transform: scale(0.12);
  opacity: 0.9;
  pointer-events: none;
  animation: splash 1.05s ease-out forwards;
}

@keyframes splash {
  to { transform: scale(1); opacity: 0; }
}

/* ---------------- small screens ---------------- */

@media (max-width: 560px) {
  :root { --horizon: 62vh; }

  .content { padding-bottom: 27vh; }

  .tiles {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .sep { display: none; }

  .tile { flex: 1 1 42%; }

  /* tuck the yacht into open water below the voyage strip */
  .boat {
    left: calc(50% - 38px);
    right: auto;
    top: calc(var(--horizon) + 16px);
    width: 76px;
  }

  .compass { display: none; }

  .route { gap: 0.5rem; }
  .port { min-width: 48px; }
}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  .wave svg,
  .boat,
  .moon,
  .glitter,
  .compass .rose,
  .beacon,
  .stars i,
  .num.tick {
    animation: none !important;
  }
}
