/* route96 — everything is night, everything is wet, nothing is interactive. */

:root {
  --ink: #05070c;
  --glass: #0a1018;
  --hud: #cfd8e3;
  --hud-dim: #5a6674;
  --signal: #f59bbb; /* the actual PTV route 70 colour */
  --seal: #04060a;
  --pad: clamp(14px, 2.4vw, 28px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--hud);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

/* ---- the view -------------------------------------------------------------- */

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #05070e;
}

/* Sodium light bleeding through wet glass, over the top of the scene. */
#bloom {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 28% at 18% 38%, rgba(255, 176, 92, 0.07), transparent 70%),
    radial-gradient(30% 22% at 78% 45%, rgba(150, 190, 255, 0.05), transparent 70%);
  mix-blend-mode: screen;
}

/* ---- glass ----------------------------------------------------------------- */

#reflection, #rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#reflection { mix-blend-mode: screen; opacity: 0.55; }
#rain { opacity: 0.85; }

#frame { position: fixed; inset: 0; pointer-events: none; }

/* Rubber window seal. Thick enough to read as a tram, thin enough to stay out
   of the way. */
.seal { position: absolute; background: var(--seal); }
.seal-t, .seal-b { left: 0; right: 0; height: clamp(18px, 4.5vh, 52px); }
.seal-l, .seal-r { top: 0; bottom: 0; width: clamp(14px, 3.5vw, 46px); }
.seal-t { top: 0; box-shadow: 0 3px 14px rgba(0,0,0,.9); }
.seal-b { bottom: 0; box-shadow: 0 -3px 14px rgba(0,0,0,.9); }
.seal-l { left: 0; box-shadow: 3px 0 14px rgba(0,0,0,.9); }
.seal-r { right: 0; box-shadow: -3px 0 14px rgba(0,0,0,.9); }

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(75% 65% at 50% 50%, transparent 40%, rgba(0,0,0,.72) 100%);
}

#grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: drift 700ms steps(3) infinite;
}
@keyframes drift {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-3%, 2%); }
  66%  { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

/* ---- hud ------------------------------------------------------------------- */

#hud, #status {
  position: fixed;
  z-index: 5;
  font-size: clamp(10px, 1.05vw, 13px);
  letter-spacing: 0.09em;
  text-transform: lowercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease 0.6s;
}
body.riding #hud, body.riding #status { opacity: 1; }

#hud {
  top: calc(var(--pad) + clamp(18px, 4.5vh, 52px));
  left: calc(var(--pad) + clamp(14px, 3.5vw, 46px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-row { display: flex; align-items: center; gap: 10px; }
.route-badge {
  background: var(--signal);
  color: #000;
  font-weight: 600;
  padding: 1px 7px;
  letter-spacing: 0.02em;
}
.dim { color: var(--hud-dim); }
.tiny { font-size: 9px; letter-spacing: 0.06em; }
.sep { opacity: 0.4; }

#status {
  bottom: calc(var(--pad) + clamp(18px, 4.5vh, 52px));
  left: calc(var(--pad) + clamp(14px, 3.5vw, 46px));
  right: calc(var(--pad) + clamp(14px, 3.5vw, 46px));
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.label { color: var(--hud-dim); margin-right: 9px; }
#next-stop {
  color: var(--hud);
  font-weight: 400;
  /* Stop names arrive from OSM as "Stop 31: Church Street"; keep them honest. */
  transition: opacity 0.5s;
}
#stop-line { font-size: clamp(12px, 1.5vw, 17px); }
#attrib { opacity: 0.45; margin-top: 4px; }

#progress {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  height: 2px;
  z-index: 6;
  background: rgba(255,255,255,.06);
  opacity: 0;
  transition: opacity 1.6s ease 0.6s;
}
body.riding #progress { opacity: 1; }
#progress-bar {
  height: 100%;
  width: 0;
  background: var(--signal);
  opacity: 0.55;
  transition: width 1.2s linear;
}

/* ---- departure board ------------------------------------------------------- */

#gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  background: #05070c;
  transition: opacity 0.9s ease, visibility 0.9s;
}
body.riding #gate { opacity: 0; visibility: hidden; }

.gate-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(34px, 9vh, 90px) var(--pad) 60px;
}
.gate-head { margin-bottom: clamp(26px, 5vh, 44px); }
#gate h1 {
  font-size: clamp(26px, 5.2vw, 50px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.gate-sub {
  color: var(--hud-dim);
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.07em;
  max-width: 46ch;
}

#lines { display: flex; flex-direction: column; }

.line-row {
  display: grid;
  grid-template-columns: 46px 1fr auto auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 4px;
  background: none;
  border: 0;
  border-bottom: 1px solid #161c26;
  color: var(--hud);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s, padding-left 0.16s;
}
.line-row:hover:not(:disabled) { background: #0c1119; padding-left: 12px; }
.line-row:focus-visible { outline: 1px solid var(--signal); outline-offset: -1px; }
.line-row.is-idle { cursor: default; opacity: 0.34; }

.line-ref {
  background: var(--line, #888);
  color: #000;
  font-weight: 600;
  text-align: center;
  padding: 2px 0;
  letter-spacing: 0.02em;
}
.line-name { color: var(--hud); }
.line-name .arrow { color: var(--hud-dim); margin: 0 4px; }
.line-riders { color: var(--signal); font-size: 10px; letter-spacing: 0.08em; }
.line-go {
  color: var(--hud-dim);
  font-size: 10px;
  letter-spacing: 0.16em;
}
.line-row:hover:not(:disabled) .line-go { color: var(--signal); }

.gate-fine { margin-top: 26px; color: #3a4453; font-size: 10px; letter-spacing: 0.1em; }

/* ---- leaving --------------------------------------------------------------- */

#leave {
  position: fixed;
  z-index: 7;
  top: calc(var(--pad) + 4px);
  right: var(--pad);
  background: none;
  border: 1px solid #222b38;
  color: var(--hud-dim);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 7px 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.8s ease 0.5s, color 0.2s, border-color 0.2s;
}
body.riding #leave { opacity: 1; }
#leave:hover { color: var(--hud); border-color: var(--hud); }

/* ---- chat ------------------------------------------------------------------ */

#chat {
  position: fixed;
  z-index: 7;
  right: var(--pad);
  bottom: calc(var(--pad) + 10px);
  width: min(310px, 46vw);
  display: flex;
  flex-direction: column;
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease 0.6s;
}
body.riding #chat { opacity: 1; pointer-events: auto; }

#chat-log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 30vh;
  overflow-y: auto;
  scrollbar-width: thin;
  font-size: 11px;
  line-height: 1.5;
  /* Older lines fade out rather than ending at a hard edge. */
  mask-image: linear-gradient(to bottom, transparent, #000 22%);
}
.msg { display: flex; gap: 8px; align-items: baseline; }
.msg-seat {
  color: var(--signal);
  flex: 0 0 auto;
  min-width: 1.4em;
  text-align: right;
  opacity: 0.8;
}
.msg-text { color: #b9c4d2; word-break: break-word; }
.msg.is-mine .msg-text { color: var(--hud); }
.msg.is-notice .msg-text { color: var(--hud-dim); font-style: italic; }

#chat-form { display: flex; align-items: center; gap: 8px; }
#chat-input {
  flex: 1;
  background: rgba(6, 10, 16, 0.62);
  border: 1px solid #1d2531;
  color: var(--hud);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  transition: border-color 0.2s;
}
#chat-input:focus { outline: none; border-color: var(--signal); }
#chat-input::placeholder { color: #46505f; }
#seat { flex: 0 0 auto; }

/* Dragging to look around should not select the HUD text. */
body.looking { user-select: none; }
#view { cursor: grab; touch-action: none; }
body.looking #view { cursor: grabbing; }

@media (max-width: 720px) {
  #chat { width: calc(100% - var(--pad) * 2); left: var(--pad); right: var(--pad); }
  #chat-log { max-height: 22vh; }
  #status { right: auto; max-width: 60%; }
}

@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
}

/* ---- landmark caption ------------------------------------------------------ */

/* Names the thing outside the window as you draw level with it. */
#landmark {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: calc(var(--pad) + 74px);
  transform: translate(-50%, 8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
}
#landmark.is-on { opacity: 1; transform: translate(-50%, 0); }

.lm-kind {
  color: var(--signal);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.lm-name {
  color: var(--hud);
  font-size: clamp(13px, 1.7vw, 17px);
  letter-spacing: 0.02em;
}
