/* ============================================================
   JAVAVIA — live voyage dashboard
   Dark "ocean" nautical theme. Pure CSS, no external assets.
   ============================================================ */

:root {
  --bg-0: #04101f;
  --bg-1: #071b30;
  --bg-2: #0a2543;
  --card: rgba(13, 40, 68, 0.62);
  --card-brd: rgba(94, 168, 224, 0.18);
  --ink: #eaf4ff;
  --ink-dim: #9db8d4;
  --ink-faint: #6e8bab;
  --cyan: #38bdf8;
  --cyan-soft: #7dd3fc;
  --teal: #2dd4bf;
  --gold: #fbbf24;
  --coral: #fb7185;
  --violet: #a78bfa;
  --good: #34d399;
  --bad: #f87171;
  --radius: 18px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 15% -10%, #0e3357 0%, transparent 55%),
    radial-gradient(1100px 700px at 100% 0%, #0a2b4d 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 70%);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

code { font-family: var(--mono); }

/* ---------- animated ocean backdrop ---------- */
.ocean {
  position: fixed;
  inset: auto 0 0 0;
  height: 42vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  mask-image: linear-gradient(to top, #000 40%, transparent);
}
.wave {
  position: absolute;
  left: -50%;
  width: 200%;
  height: 100%;
  background-repeat: repeat-x;
  border-radius: 45%;
  opacity: 0.5;
  animation: drift linear infinite;
}
.wave1 { bottom: -68%; background: radial-gradient(120% 120% at 50% 0, rgba(56,189,248,.20), transparent 60%); animation-duration: 16s; }
.wave2 { bottom: -74%; background: radial-gradient(120% 120% at 50% 0, rgba(45,212,191,.14), transparent 60%); animation-duration: 24s; animation-direction: reverse; opacity: .4; }
.wave3 { bottom: -80%; background: radial-gradient(120% 120% at 50% 0, rgba(167,139,250,.10), transparent 60%); animation-duration: 32s; opacity: .35; }
@keyframes drift {
  from { transform: translateX(0) rotate(0deg); }
  to   { transform: translateX(25%) rotate(6deg); }
}

/* ---------- storm overlay ---------- */
.storm {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
  background: linear-gradient(180deg, rgba(4,10,20,.55), rgba(4,10,20,.15));
}
body.stormy .storm { opacity: 1; }
body.stormy { animation: rock 6s ease-in-out infinite; }
@keyframes rock {
  0%,100% { transform: rotate(-0.35deg); }
  50%     { transform: rotate(0.35deg); }
}
.rain {
  position: absolute; inset: -20% 0 0 0;
  background-image: repeating-linear-gradient(105deg,
      transparent 0 22px,
      rgba(180,210,240,.28) 22px 23px);
  background-size: 200px 200px;
  animation: rainfall .5s linear infinite;
}
@keyframes rainfall { to { background-position: -120px 240px; } }
.lightning {
  position: absolute; inset: 0;
  background: radial-gradient(60% 45% at 70% 20%, rgba(220,235,255,.9), transparent 60%);
  opacity: 0;
  animation: flash 7s steps(1) infinite;
}
@keyframes flash {
  0%, 92%, 100% { opacity: 0; }
  93% { opacity: .85; }
  94% { opacity: 0; }
  95% { opacity: .6; }
  96% { opacity: 0; }
}

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px clamp(16px, 3vw, 40px);
}
.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #0e3357, #072034);
  border: 1px solid var(--card-brd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.brand-text h1 {
  margin: 0;
  font-size: clamp(28px, 3.6vw, 46px);
  font-weight: 800;
  letter-spacing: 2px;
  line-height: 1;
  background: linear-gradient(90deg, #eaf4ff, var(--cyan-soft));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text h1 span { color: var(--cyan); -webkit-text-fill-color: var(--cyan); }
.tagline { margin: 6px 0 0; color: var(--ink-dim); font-size: clamp(12px, 1.3vw, 15px); }
.tagline strong { color: var(--cyan-soft); }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.connect-hint {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}
.ch-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 1px; }
.connect-hint code { color: var(--cyan-soft); font-size: 13px; font-weight: 600; }

.conn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.conn .dot { width: 9px; height: 9px; border-radius: 50%; }
.conn-live { color: var(--good); background: rgba(52,211,153,.10); border-color: rgba(52,211,153,.35); }
.conn-live .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: pulse 1.8s infinite; }
.conn-connecting { color: var(--gold); background: rgba(251,191,36,.10); border-color: rgba(251,191,36,.30); }
.conn-connecting .dot { background: var(--gold); animation: blink 1s steps(2) infinite; }
.conn-down { color: var(--bad); background: rgba(248,113,113,.10); border-color: rgba(248,113,113,.35); }
.conn-down .dot { background: var(--bad); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}
@keyframes blink { 50% { opacity: .3; } }

/* ---------- grid layout ---------- */
.grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  grid-template-areas:
    "status status"
    "hero   feed"
    "hero   ticker"
    "prov   ticker";
  gap: clamp(14px, 1.6vw, 22px);
  padding: 4px clamp(16px, 3vw, 40px) 24px;
  align-items: start;
}
.status-strip { grid-area: status; }
.hero { grid-area: hero; }
.feed-card { grid-area: feed; }
.ticker-card { grid-area: ticker; }
.provisions { grid-area: prov; }

/* ---------- card shell ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: clamp(16px, 1.8vw, 24px);
}
.card-eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--ink-dim);
  margin-bottom: 14px;
}
.concept {
  font-weight: 600; letter-spacing: .4px; text-transform: none;
  font-size: 11px;
  color: var(--cyan-soft);
  background: rgba(56,189,248,.12);
  border: 1px solid rgba(56,189,248,.28);
  padding: 2px 9px; border-radius: 999px;
  cursor: help;
}
.hint {
  margin: 14px 0 0;
  font-size: 12.5px; line-height: 1.5;
  color: var(--ink-faint);
}
.hint code { color: var(--cyan-soft); }
.hint strong { color: var(--ink-dim); }
.hint em { color: var(--violet); font-style: normal; font-weight: 600; }

/* ---------- status strip ---------- */
.status-strip {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: clamp(16px, 2vw, 32px);
}
.stops {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 0;
  padding: 0;
  position: relative;
}
.stops::before {
  content: "";
  position: absolute;
  top: 13px; left: 6%; right: 6%;
  height: 3px;
  background: linear-gradient(90deg, var(--card-brd), rgba(94,168,224,.30));
  border-radius: 3px;
  z-index: 0;
}
.stop {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 1; text-align: center;
}
.stop-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg-2);
  border: 3px solid rgba(94,168,224,.4);
  transition: all .5s ease;
}
.stop-num { font-size: 12px; font-weight: 700; color: var(--ink-faint); letter-spacing: .5px; }
.stop-name { font-size: 13px; color: var(--ink-dim); font-weight: 600; }
.stop.done .stop-dot { background: var(--teal); border-color: var(--teal); }
.stop.done .stop-num { color: var(--ink-dim); }
.stop.current .stop-dot {
  background: var(--cyan); border-color: var(--cyan-soft);
  box-shadow: 0 0 0 6px rgba(56,189,248,.18);
  animation: stopPulse 2s ease-in-out infinite;
}
.stop.current .stop-num { color: var(--cyan-soft); }
.stop.current .stop-name { color: var(--ink); }
.stop.advancing .stop-dot { animation: advance .7s ease; }
@keyframes stopPulse {
  0%,100% { box-shadow: 0 0 0 6px rgba(56,189,248,.16); }
  50%     { box-shadow: 0 0 0 11px rgba(56,189,248,.05); }
}
@keyframes advance {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* weather */
.weather { display: flex; flex-direction: column; }
.weather-main { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.weather-icon { font-size: clamp(38px, 4.5vw, 56px); line-height: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.weather-label { font-size: clamp(22px, 2.6vw, 34px); font-weight: 800; letter-spacing: 1px; }
.weather-note { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }
.weather.w-calm .weather-label { color: var(--gold); }
.weather.w-choppy .weather-label { color: var(--cyan-soft); }
.weather.w-storm .weather-label { color: var(--coral); }
.weather.w-storm { animation: shake 3.5s ease-in-out infinite; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }

/* ---------- hero / boat ---------- */
.hero-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.aboard {
  margin: 4px 0 0; font-size: clamp(30px, 4vw, 52px); font-weight: 800; line-height: 1;
}
.aboard .slash, .aboard #capacity { color: var(--ink-faint); font-weight: 600; }
.aboard .aboard-word { font-size: .45em; color: var(--ink-dim); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
#aboardCount { color: var(--cyan); }
.capacity-meter {
  flex: 1; min-width: 140px; max-width: 320px;
  height: 12px; border-radius: 999px;
  background: rgba(4,16,31,.7);
  border: 1px solid var(--card-brd);
  overflow: hidden;
}
.capacity-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  border-radius: 999px;
  transition: width .6s cubic-bezier(.22,1,.36,1);
}
.capacity-fill.full { background: linear-gradient(90deg, var(--gold), var(--coral)); }

.boat-stage { position: relative; margin-top: 22px; min-height: 200px; }
.boat {
  position: relative;
  animation: bob 5s ease-in-out infinite;
}
body.stormy .boat { animation: bob 2.2s ease-in-out infinite; }
@keyframes bob {
  0%,100% { transform: translateY(0) rotate(-.4deg); }
  50%     { transform: translateY(-8px) rotate(.4deg); }
}
.manifest {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 18px 20px 26px;
  min-height: 120px;
  align-content: flex-start;
  position: relative; z-index: 2;
}
.hull {
  position: relative;
  height: 46px;
  margin-top: -14px;
  background: linear-gradient(180deg, #0c3358, #08223c);
  border: 1px solid var(--card-brd);
  border-top: none;
  border-radius: 0 0 90px 90px / 0 0 60px 60px;
  box-shadow: inset 0 6px 18px rgba(0,0,0,.4);
  display: grid; place-items: center;
}
.hull-name {
  font-size: 12px; font-weight: 800; letter-spacing: 3px;
  color: var(--cyan-soft); opacity: .8; text-transform: uppercase;
}
.manifest-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--ink-faint); font-size: 15px; text-align: center; padding: 20px;
  pointer-events: none;
}
.manifest:not(:empty) + .hull + .manifest-empty,
.boat-stage.has-riders .manifest-empty { display: none; }

/* rider token */
.rider {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 68px;
  animation: boardIn .6s cubic-bezier(.22,1,.36,1);
}
.rider .av {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; color: #04101f;
  box-shadow: 0 6px 14px rgba(0,0,0,.4), inset 0 0 0 2px rgba(255,255,255,.25);
  position: relative;
}
.rider .av::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.10);
}
.rider .name {
  font-size: 11.5px; font-weight: 600; color: var(--ink-dim);
  max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@keyframes boardIn {
  from { opacity: 0; transform: translateX(40px) translateY(-6px) scale(.7); }
  to   { opacity: 1; transform: none; }
}
.rider.leaving { animation: departOut .8s ease forwards; }
@keyframes departOut {
  to { opacity: 0; transform: translateX(-40px) scale(.6); }
}
.rider.ghosting .av { animation: ghostFade 1.4s ease forwards; }
.rider.ghosting .name { color: var(--violet); }
@keyframes ghostFade {
  0%   { filter: none; }
  100% { filter: grayscale(1) brightness(1.6); background: transparent !important; color: transparent; box-shadow: none; }
}
.rider.ghosting .av::before {
  content: "👻"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 26px; opacity: 0; animation: ghostShow 1.4s ease forwards;
}
@keyframes ghostShow { 0%,40% { opacity: 0; } 100% { opacity: 1; } }
.rider .ghost-tag {
  font-size: 9.5px; color: var(--violet); font-weight: 600;
}

/* ---------- feed ---------- */
.feed-card, .ticker-card { display: flex; flex-direction: column; min-height: 0; }
.feed {
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  max-height: 46vh;
  padding-right: 6px;
  scroll-behavior: smooth;
}
.msg {
  background: rgba(8,26,46,.6);
  border: 1px solid var(--card-brd);
  border-left: 3px solid var(--cyan);
  border-radius: 10px;
  padding: 10px 13px;
  animation: msgIn .5s ease;
}
.msg.reply { margin-left: 26px; border-left-color: var(--violet); background: rgba(8,26,46,.4); }
.msg.reply::before {
  content: "↳"; color: var(--violet); font-weight: 700; margin-right: 6px;
}
.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg-av {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #04101f; flex-shrink: 0;
}
.msg-author { font-weight: 700; font-size: 13px; color: var(--ink); }
.msg-time { font-size: 11px; color: var(--ink-faint); margin-left: auto; }
.msg-text { font-size: 13.5px; line-height: 1.5; color: var(--ink-dim); white-space: pre-wrap; word-break: break-word; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.msg.deleting { animation: msgDelete .6s ease forwards; }
@keyframes msgDelete { to { opacity: .35; } }
.msg.deleted { border-left-color: var(--ink-faint); opacity: .5; }
.msg.deleted .msg-text { text-decoration: line-through; color: var(--ink-faint); font-style: italic; }
.msg.deleted .msg-text::after { content: " · message deleted"; text-decoration: none; font-size: 11px; }

.feed-empty, .ticker-empty {
  color: var(--ink-faint); font-size: 14px; text-align: center; padding: 30px 12px;
}
.feed:not(:empty) ~ .feed-empty,
.ticker:not(:empty) ~ .ticker-empty { display: none; }

/* ---------- ticker ---------- */
.ticker {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; max-height: 30vh; padding-right: 4px;
}
.tick {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px;
  background: rgba(8,26,46,.5);
  border: 1px solid var(--card-brd);
  border-radius: 999px;
  font-size: 13px;
  animation: tickIn .5s ease;
}
.tick .ic { font-size: 17px; }
.tick .who { font-weight: 700; color: var(--ink); }
.tick .what { color: var(--ink-dim); }
.tick .tt { margin-left: auto; font-size: 11px; color: var(--ink-faint); }
.tick.fading { animation: tickFade 1s ease forwards; }
.tick.t-wave { border-color: rgba(56,189,248,.3); }
.tick.t-horn { border-color: rgba(251,191,36,.3); }
.tick.t-board { border-color: rgba(52,211,153,.3); }
.tick.t-depart { border-color: rgba(167,139,250,.3); }
.tick.t-weather { border-color: rgba(251,113,133,.3); }
@keyframes tickIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes tickFade { to { opacity: .35; } }

/* ---------- provisions ---------- */
.prov-body { display: flex; align-items: center; gap: 16px; }
.prov-icon { font-size: 40px; }
.prov-text { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-dim); }
.prov-text strong { color: var(--cyan-soft); font-size: 1.15em; }
.prov-text code { color: var(--coral); font-weight: 600; }

/* ---------- floating toasts ---------- */
.toasts {
  position: fixed;
  right: clamp(16px, 3vw, 40px);
  bottom: 70px;
  z-index: 40;
  display: flex; flex-direction: column-reverse; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  background: rgba(10,37,67,.92);
  border: 1px solid var(--card-brd);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 15px; font-weight: 600;
  backdrop-filter: blur(10px);
  animation: toastIn .4s cubic-bezier(.22,1,.36,1), toastOut .5s ease forwards 3.6s;
}
.toast .ic { font-size: 22px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(60px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(60px); } }

/* ---------- footer ---------- */
.footer {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 40px) 22px;
  color: var(--ink-faint); font-size: 12.5px;
}
.footer strong { color: var(--ink-dim); }
.clock { font-family: var(--mono); color: var(--ink-dim); }

/* ---------- scrollbars ---------- */
.feed::-webkit-scrollbar, .ticker::-webkit-scrollbar { width: 8px; }
.feed::-webkit-scrollbar-thumb, .ticker::-webkit-scrollbar-thumb {
  background: rgba(94,168,224,.25); border-radius: 8px;
}
.feed::-webkit-scrollbar-track, .ticker::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "status"
      "hero"
      "feed"
      "ticker"
      "prov";
  }
  .feed { max-height: 50vh; }
}
@media (max-width: 620px) {
  .status-strip { grid-template-columns: 1fr; }
  .topbar-right { width: 100%; }
  .connect-hint { flex: 1; }
  .stop-name { display: none; }
  .aboard { font-size: 38px; }
}

/* ---------- big-screen / projector: scale everything up ---------- */
@media (min-width: 1600px) {
  html { font-size: 18px; }
  .card-eyebrow { font-size: 13px; }
  .msg-text, .tick, .prov-text { font-size: 15px; }
  .feed { max-height: 52vh; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  body.stormy { animation: none; }
}
