/* PONTILE — night-lagoon aesthetic: deep water greens, brass, pier-sign roundels */

:root {
  --abyss: #071518;
  --laguna: #0c2226;
  --water: #123138;
  --water-hi: #1a444d;
  --foam: #ece5d3;
  --foam-dim: #b3ac97;
  --brass: #c9a227;
  --brass-hi: #e8c95a;
  --rosso: #c8452e;
  --hairline: rgba(236, 229, 211, 0.14);
  --card: rgba(18, 49, 56, 0.55);
  font-size: 16px;
}

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

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 80% at 80% -10%, var(--water-hi) 0%, transparent 55%),
    radial-gradient(100% 70% at 10% 110%, #143b36 0%, transparent 60%),
    linear-gradient(175deg, var(--laguna) 0%, var(--abyss) 70%);
  background-attachment: fixed;
  color: var(--foam);
  font-family: "Instrument Sans", sans-serif;
  overflow-x: hidden;
}

/* grain overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.07;
  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.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 120px;
  position: relative;
  z-index: 1;
}

/* ---------- header ---------- */

header {
  padding: 56px 0 8px;
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.kicker {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--brass);
  display: flex;
  align-items: center;
  gap: 12px;
}

.kicker::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, var(--brass), transparent);
  opacity: 0.5;
}

h1 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-style: italic;
  font-size: clamp(3rem, 9vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 14px 0 6px;
}

h1 em {
  font-style: normal;
  color: var(--brass-hi);
}

h1.brand {
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--foam);
}

.tagline {
  color: var(--foam-dim);
  font-size: 0.95rem;
  max-width: 46ch;
}

.tagline em { color: var(--brass-hi); font-style: italic; }

.clock {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.85rem;
  color: var(--foam-dim);
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- acqua alta strip ---------- */

.acqua {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(18, 49, 56, 0.4);
  font-size: 0.85rem;
}

.acqua:empty { display: none; }

.tide-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  margin-right: 4px;
}

.tide-dot.tide-ok { background: #4caf7d; box-shadow: 0 0 8px rgba(76, 175, 125, 0.6); }
.tide-dot.tide-warn { background: var(--brass-hi); box-shadow: 0 0 8px rgba(232, 201, 90, 0.6); animation: pulse 1.6s ease-in-out infinite; }
.tide-dot.tide-alert, .tide-dot.tide-except { background: var(--rosso); box-shadow: 0 0 10px rgba(200, 69, 46, 0.8); animation: pulse 1s ease-in-out infinite; }

.acqua.tide-alert, .acqua.tide-except { border-color: rgba(200, 69, 46, 0.6); }
.acqua.tide-warn { border-color: rgba(201, 162, 39, 0.5); }

.tide-now b { color: var(--brass-hi); font-family: "Spline Sans Mono", monospace; font-weight: 500; }
.tide-trend { color: var(--brass); font-size: 0.95rem; margin-left: 4px; }

.acqua.tide-alert .tide-now b, .acqua.tide-except .tide-now b { color: var(--rosso); }

.tide-meta {
  color: var(--foam-dim);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.72rem;
}

.tide-meta b { color: var(--foam); font-weight: 500; }

/* acqua as expandable forecast */
.acqua-fold { width: 100%; }

.acqua-fold > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.acqua-fold > summary::-webkit-details-marker { display: none; }

.tide-chev {
  margin-left: auto;
  align-self: center;
  color: var(--brass);
  font-size: 0.8rem;
  transition: transform 0.25s;
}

.acqua-fold[open] .tide-chev { transform: rotate(180deg); }

.tide-chart {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.tide-svg { width: 100%; height: auto; display: block; overflow: visible; }

.tide-line {
  fill: none;
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* astronomical tide series (TASK-31): thin dashed foam line under the
   real CPSM forecast curve */
.tide-astro {
  fill: none;
  stroke: var(--foam-dim);
  stroke-width: 1.1;
  stroke-dasharray: 4 3;
  stroke-linejoin: round;
  opacity: 0.6;
}

/* astronomical night wash + twilight glyphs */
.tide-night { fill: #6f9fc0; opacity: 0.08; }
.tide-sun {
  font-size: 10px;
  fill: var(--foam-dim);
  opacity: 0.7;
}

/* draw the curve on open, like a rising tide filling in */
.acqua-fold[open] .tide-line {
  stroke-dasharray: 1;
  animation: tide-draw 1.1s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes tide-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

.tide-area { stroke: none; }
.acqua-fold[open] .tide-area { animation: tide-fade 0.9s 0.3s ease both; }
@keyframes tide-fade { from { opacity: 0; } to { opacity: 1; } }

.tide-band-warn { fill: var(--brass); opacity: 0.06; }
.tide-band-alert { fill: var(--rosso); opacity: 0.09; }

.tide-thresh { stroke-width: 1; stroke-dasharray: 5 4; opacity: 0.55; }
.tide-thlab { font-family: "Spline Sans Mono", monospace; font-size: 10px; opacity: 0.85; }
.tide-zero { stroke: var(--hairline); stroke-width: 1; }
.tide-day { stroke: var(--hairline); stroke-width: 1; opacity: 0.5; }
.tide-daylab {
  fill: var(--foam-dim);
  font-family: "Spline Sans Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tide-pt { fill: var(--brass-hi); }
.tide-ptlab { fill: #f0d78c; font-family: "Spline Sans Mono", monospace; font-size: 10px; font-weight: 500; }

/* night-side extremes: blue dot + cooler label to match the moonlit curve */
circle.tide-pt.tide-night-el { fill: #6f9fc0; }
text.tide-ptlab.tide-night-el { fill: #a9c7db; }
.tide-now-line { stroke: var(--foam); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.55; }
.tide-now-dot { fill: var(--rosso); stroke: var(--foam); stroke-width: 1.2; transform-box: fill-box; transform-origin: center; animation: tide-ping 1.8s ease-in-out infinite; }
@keyframes tide-ping { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.tide-nowlab { fill: var(--foam); font-family: "Spline Sans Mono", monospace; font-size: 10px; letter-spacing: 0.06em; }
.tide-ax { fill: var(--foam-dim); font-family: "Spline Sans Mono", monospace; font-size: 10px; }

.tide-legend {
  margin-top: 6px;
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.68rem;
  color: var(--foam-dim);
  letter-spacing: 0.04em;
}

.tide-legend a { color: var(--foam-dim); text-decoration: underline; text-underline-offset: 2px; }
.tide-legend a:hover { color: var(--brass-hi); }

/* mini-legend line swatches: solid brass = real CPSM forecast,
   dashed foam = astronomical series */
.tide-lg-swatch {
  display: inline-block;
  width: 16px;
  vertical-align: middle;
  margin: 0 5px 2px 0;
}
.tide-lg-real { border-top: 2px solid var(--brass-hi); }
.tide-lg-astro { border-top: 2px dashed var(--foam-dim); }

.cm-link {
  font-size: 0.72rem;
  color: var(--foam-dim);
  text-decoration: none;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.cm-link:hover { color: var(--brass-hi); opacity: 1; }

/* ---------- avvisi ACTV ---------- */

.alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.alerts:empty { display: none; }

.alert-item {
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 8px;
  background: rgba(201, 162, 39, 0.08);
  color: var(--foam);
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}

.alert-item[open] {
  background: rgba(201, 162, 39, 0.12);
  border-color: rgba(201, 162, 39, 0.55);
}

.alert-item > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.alert-item > summary::-webkit-details-marker { display: none; }

.alert-item > summary:hover { background: rgba(201, 162, 39, 0.08); border-radius: 8px; }

.alert-icon {
  color: var(--brass);
  flex-shrink: 0;
  font-size: 0.8rem;
}

.alert-text { flex: 1; }

.alert-date {
  color: var(--foam-dim);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.72rem;
  white-space: nowrap;
}

.alert-close {
  appearance: none;
  background: none;
  border: none;
  color: var(--foam-dim);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.alert-close:hover { color: var(--foam); background: rgba(255,255,255,0.1); }

.alert-body {
  padding: 10px 14px 12px 36px;
  font-size: 0.82rem;
  color: var(--foam-dim);
  line-height: 1.55;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-seg-h {
  display: block;
  color: var(--brass-hi);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.alert-seg-p { margin: 0; }

.alert-hl {
  font-style: normal;
  color: var(--foam);
  font-weight: 600;
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.78em;
}

.alert-stop {
  color: var(--brass-hi);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.alert-stop:hover { color: var(--foam); }

.alert-badge {
  font-size: 0.7rem;
  color: var(--brass);
  vertical-align: middle;
  margin-left: -4px;
  margin-right: 2px;
  flex-shrink: 0;
}

.dep.alerted { border-color: rgba(201, 162, 39, 0.35); }
.route-card.alerted { border-color: rgba(201, 162, 39, 0.35); }

/* ---------- waves divider ---------- */

.waves {
  margin: 26px 0 20px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='14' viewBox='0 0 60 14'%3E%3Cpath d='M0 8 Q15 0 30 8 T60 8' fill='none' stroke='%23c9a227' stroke-opacity='0.45' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  animation: drift 9s linear infinite;
}

@keyframes drift { to { background-position-x: 60px; } }

/* ---------- tabs ---------- */

nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 26px;
  animation: rise 0.7s 0.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

nav button {
  appearance: none;
  background: none;
  border: none;
  color: var(--foam-dim);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 18px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

nav button:hover { color: var(--foam); }

nav button.active { color: var(--brass-hi); }

nav button.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: var(--brass);
}

/* ---------- panels ---------- */

.panel { display: none; }
.panel.active { display: block; animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 22px;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 200px; }

.field label {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
}

select {
  appearance: none;
  width: 100%;
  background:
    linear-gradient(45deg, transparent 50%, var(--brass) 50%) calc(100% - 21px) calc(50% + 3px) / 6px 6px no-repeat,
    linear-gradient(-45deg, transparent 50%, var(--brass) 50%) calc(100% - 15px) calc(50% + 3px) / 6px 6px no-repeat,
    var(--card);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  color: var(--foam);
  font-family: "Instrument Sans", sans-serif;
  font-size: 1rem;
  padding: 13px 40px 13px 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}

select:hover, select:focus { border-color: var(--brass); outline: none; }

.btn {
  appearance: none;
  border: 1px solid var(--brass);
  background: transparent;
  color: var(--brass-hi);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 13px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn:hover { background: var(--brass); color: var(--abyss); }

.btn.ghost { border-color: var(--hairline); color: var(--foam-dim); }
.btn.ghost:hover { border-color: var(--brass); color: var(--brass-hi); background: transparent; }

.swap-btn {
  align-self: end;
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--foam);
  border-radius: 10px;
  width: 46px;
  height: 46px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.3s;
}

.swap-btn:hover { border-color: var(--brass); transform: rotate(180deg); }

/* ---------- favorites ---------- */

.favs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.favs .chip {
  appearance: none;
  border: 1px solid var(--hairline);
  background: rgba(201, 162, 39, 0.08);
  color: var(--foam);
  font-size: 0.82rem;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chip:hover { border-color: var(--brass); }

.chip .star { color: var(--brass-hi); font-size: 0.75rem; }

.chip .x {
  color: var(--foam-dim);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.7rem;
  padding-left: 3px;
}

.chip .x:hover { color: var(--rosso); }

/* ---------- departures board ---------- */

.board { display: flex; flex-direction: column; gap: 10px; }

.dep {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 14px 18px 14px 14px;
  backdrop-filter: blur(6px);
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: border-color 0.2s, transform 0.2s;
}

.dep:hover { border-color: rgba(201, 162, 39, 0.5); transform: translateX(3px); }

/* roundel: like ACTV pier-sign line discs */
.roundel {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  border: 2.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 -6px 12px rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.dep-icon { display: flex; align-items: center; gap: 2px; }

.dep-mid { min-width: 0; }

.dep-dest {
  font-size: 1.08rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dep-dest .arrow { color: var(--brass); font-weight: 400; }

.dep-via {
  display: inline-block;
  margin-left: 6px;
  font-family: "Fraunces", "Newsreader", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--foam-dim);
  letter-spacing: 0.01em;
  vertical-align: 1px;
}
.dep-via::before { content: ""; }

/* ---------- direction arrow (own column, roundel-scale) ---------- */
/* The arrow lives in its own grid column, right of the line roundel,
   sized to match visually (~42px next to a 54px roundel). No chrome —
   just the character in brass / sea-glass / muted-rosso, with a soft
   text-shadow to lift it off the dark background. Character is chosen
   for weight: heavy Unicode arrows (⇠⇢⇡⇣) beat the thin ← → glyphs. */
:root {
  --dir-brass: var(--brass-hi);
  --dir-lagoon: #7fc8b8;
  --dir-terra: #e08a67;
  --dir-unknown: var(--rosso);
}
.dep-arrow {
  min-width: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Fraunces", serif;
  font-weight: 900;
  font-size: 3.1rem;
  line-height: 1;
  color: var(--dir-brass);
  text-shadow: 0 0 14px rgba(232, 201, 90, 0.28);
  transition: transform 0.18s ease, text-shadow 0.18s ease;
  user-select: none;
}
.dep-arrow-left,
.dep-arrow-right { color: var(--dir-brass); }
.dep-arrow-up {
  color: var(--dir-lagoon);
  text-shadow: 0 0 14px rgba(127, 200, 184, 0.28);
}
.dep-arrow-down {
  color: var(--dir-terra);
  text-shadow: 0 0 14px rgba(224, 138, 103, 0.28);
}
.dep-arrow-unknown {
  color: var(--dir-unknown);
  font-style: italic;
  font-size: 1.5rem;
  opacity: 0.6;
  text-shadow: none;
}
.dep-arrow-empty {
  min-width: 46px;   /* keeps grid column aligned even when a row has no arrow */
}
.dep:hover .dep-arrow-right { transform: translateX(3px); }
.dep:hover .dep-arrow-left { transform: translateX(-3px); }
.dep:hover .dep-arrow-up { transform: translateY(-3px); }
.dep:hover .dep-arrow-down { transform: translateY(3px); }
@media (max-width: 480px) {
  .dep-arrow, .dep-arrow-empty { min-width: 36px; }
  .dep-arrow { font-size: 2.4rem; }
}

/* ---------- filter chips (big arrow / small destinations) ---------- */
/* One horizontal strip, no wrap. Each chip stacks: dominant arrow head
   on top, the two most-common landmarks in tiny caps below. The arrow
   is the hit target; the text is context. */
.board-filter {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 4px;
  margin: 4px 0 16px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.board-filter:empty { display: none; }
.board-filter::-webkit-scrollbar { height: 4px; }
.board-filter::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 4px; }

.dir-chip {
  flex: 1 1 0;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 8px 6px 6px;
  background: transparent;
  color: var(--foam);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  font-family: "Instrument Sans", sans-serif;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.dir-chip:hover {
  background: rgba(232, 201, 90, 0.05);
  border-bottom-color: rgba(232, 201, 90, 0.35);
}
.dir-chip-arrow {
  font-family: "Fraunces", serif;
  font-weight: 900;
  font-size: 2.5rem;
  line-height: 0.9;
  color: var(--brass-hi);
  text-shadow: 0 0 14px rgba(232, 201, 90, 0.35);
  transition: transform 0.15s ease;
}
.dir-chip-dests {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--foam-dim);
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}

/* per-direction arrow tint */
.dir-chip-up .dir-chip-arrow {
  color: var(--dir-lagoon);
  text-shadow: 0 0 14px rgba(127, 200, 184, 0.32);
}
.dir-chip-down .dir-chip-arrow {
  color: var(--dir-terra);
  text-shadow: 0 0 14px rgba(224, 138, 103, 0.32);
}
.dir-chip-unknown .dir-chip-arrow {
  color: var(--dir-unknown);
  font-style: italic;
  font-size: 2rem;
  text-shadow: none;
}
.dir-chip-all .dir-chip-arrow {
  color: var(--foam-dim);
  font-size: 1.8rem;
  text-shadow: none;
}
.dir-chip-all .dir-chip-dests {
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* active: brass underline + brass arrow with soft glow */
.dir-chip.active {
  border-bottom-color: var(--brass-hi);
  background: linear-gradient(180deg, transparent 40%, rgba(232, 201, 90, 0.10));
}
.dir-chip.active .dir-chip-arrow {
  transform: scale(1.08);
  filter: drop-shadow(0 0 8px rgba(232, 201, 90, 0.5));
}
.dir-chip.active .dir-chip-dests {
  color: var(--foam);
}

.dir-chip:focus-visible {
  outline: 2px solid var(--brass-hi);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (max-width: 480px) {
  .dir-chip { min-width: 62px; padding: 6px 4px 4px; }
  .dir-chip-arrow { font-size: 2rem; }
  .dir-chip-all .dir-chip-arrow, .dir-chip-unknown .dir-chip-arrow { font-size: 1.5rem; }
  .dir-chip-dests { font-size: 0.55rem; letter-spacing: 0.04em; }
}

.dep-sub {
  font-size: 0.8rem;
  color: var(--foam-dim);
  margin-top: 3px;
  font-family: "Spline Sans Mono", monospace;
}

.dep-plats {
  margin-top: 4px;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.8rem;
}
.dep-plats .plat {
  display: inline-block;
  min-width: 1.15rem;
  padding: 1px 5px;
  text-align: center;
  color: var(--foam-dim);
  border: 1px solid var(--foam-dim);
  border-radius: 3px;
  opacity: 0.55;
}
.dep-plats .plat-active {
  color: var(--foam);
  background: var(--brass);
  border-color: var(--brass);
  opacity: 1;
  font-weight: 700;
}

.dep-eta { text-align: right; }

.eta-min {
  font-family: "Spline Sans Mono", monospace;
  font-size: 1.85rem;
  font-weight: 500;
  color: var(--brass-hi);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.eta-min small { font-size: 0.75rem; color: var(--foam-dim); margin-left: 4px; }

.eta-time {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.75rem;
  color: var(--foam-dim);
  margin-top: 4px;
}

.dep.imminent .eta-min { color: var(--rosso); animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.45; } }

.night-tag {
  display: inline-block;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  padding: 2px 7px;
  border: 1px solid var(--brass);
  border-radius: 4px;
  color: var(--brass-hi);
  margin-left: 8px;
  vertical-align: 2px;
  font-family: "Spline Sans Mono", monospace;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--foam-dim);
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 1.3rem;
  border: 1px dashed var(--hairline);
  border-radius: 14px;
}

/* ---------- route results ---------- */

.route-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 12px;
  backdrop-filter: blur(6px);
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.route-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.route-head .roundel { width: 42px; height: 42px; font-size: 1rem; }

.route-meta { font-size: 0.85rem; color: var(--foam-dim); }

.route-meta strong { color: var(--foam); font-weight: 600; font-size: 1rem; display: block; }

.route-times { display: flex; flex-wrap: wrap; gap: 8px; }

.slot {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--foam);
  background: rgba(7, 21, 24, 0.4);
}

.slot b { color: var(--brass-hi); font-weight: 500; }

.slot .dur { color: var(--foam-dim); }

.route-sep {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foam-dim);
  margin: 18px 2px 10px;
}

.route-card.transfer .chg-arrow {
  color: var(--foam-dim);
  font-size: 1.1rem;
  margin: 0 -4px;
}

.route-legs { display: flex; flex-direction: column; gap: 6px; }

.route-legs .leg {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.route-legs .leg .roundel { width: 30px; height: 30px; font-size: 0.8rem; flex-shrink: 0; }

.leg-t { font-family: "Spline Sans Mono", monospace; color: var(--brass-hi); }

.leg-d { color: var(--foam-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.leg-change {
  font-size: 0.8rem;
  color: var(--foam-dim);
  padding-left: 40px;
  border-left: 2px dashed var(--hairline);
  margin-left: 14px;
}

.leg-change strong { color: var(--foam); font-weight: 600; }

/* ---------- line explorer ---------- */

.line-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }

.line-card {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  text-align: left;
  color: var(--foam);
  font-family: "Instrument Sans", sans-serif;
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.line-card:hover { border-color: var(--brass); transform: translateY(-3px); }

.line-card .roundel { width: 44px; height: 44px; font-size: 1.05rem; flex-shrink: 0; }

.line-card p { font-size: 0.8rem; color: var(--foam-dim); margin-top: 2px; }

/* ✈️ airport buses — flat departure board (same .dep rows as main board) */

.airport { margin-top: 32px; }
.airport-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-family: "Instrument Sans", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.airport-dep { grid-template-columns: auto 1fr auto; }
.airport-note { color: var(--foam-dim); font-size: 0.8rem; margin-top: 10px; font-style: italic; }

/* line detail: vertical pier diagram */

.line-detail { margin-top: 24px; }

.line-detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.line-detail-head h3 { font-family: "Fraunces", serif; font-size: 1.5rem; font-weight: 600; }

.line-stats {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.75rem;
  color: var(--foam-dim);
  margin-bottom: 20px;
  letter-spacing: 0.06em;
}

.diagram { position: relative; padding-left: 26px; }

.diagram::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--line-color, var(--brass));
  border-radius: 2px;
  opacity: 0.8;
}

.diagram .stop-row {
  position: relative;
  padding: 9px 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.diagram .stop-row::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--abyss);
  border: 3px solid var(--line-color, var(--brass));
}

.stop-row .dt {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.72rem;
  color: var(--foam-dim);
  min-width: 48px;
}

.stop-row .nm { font-size: 0.98rem; }
.stop-row .nm .richiesta { font-size: 0.78rem; opacity: 0.6; font-style: italic; }

.stop-row:first-child .nm, .stop-row:last-child .nm { font-weight: 700; color: var(--brass-hi); }

/* ---------- line map ---------- */

#line-map {
  height: 340px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  margin-bottom: 20px;
  background: var(--abyss);
  z-index: 1;
}

#line-map .leaflet-tile-pane { filter: saturate(0.8) brightness(0.9); }

.leaflet-tooltip {
  background: var(--laguna);
  color: var(--foam);
  border: 1px solid var(--brass);
  font-family: "Instrument Sans", sans-serif;
}

/* ---------- lines section (below panels) ---------- */

#lines-section { margin-top: 48px; }

[hidden] { display: none !important; }

/* line subpage */
.line-back {
  display: inline-block;
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--foam-dim);
  text-decoration: none;
  margin-bottom: 18px;
  transition: color 0.2s;
}

.line-back:hover { color: var(--brass-hi); }

.line-detail-head #fav-line-btn { margin-left: auto; }

/* per-variant route card */
.trasa {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: rgba(18, 49, 56, 0.35);
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

.trasa-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}

.trasa-dest { font-family: "Fraunces", serif; font-size: 1.15rem; font-weight: 600; color: var(--brass-hi); }

.trasa-meta { font-family: "Spline Sans Mono", monospace; font-size: 0.72rem; color: var(--foam-dim); }

details.rare {
  margin-top: 8px;
  border: 1px dashed var(--hairline);
  border-radius: 12px;
  padding: 4px 16px;
}

details.rare summary {
  cursor: pointer;
  padding: 12px 0;
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.78rem;
  color: var(--foam-dim);
  list-style: none;
}

details.rare summary::before { content: "▸ "; color: var(--brass); }
details.rare[open] summary::before { content: "▾ "; }
details.rare summary:hover { color: var(--brass-hi); }
details.rare .trasa { background: rgba(7, 21, 24, 0.4); }

/* ---------- saved-state fav buttons ---------- */

.btn.saved {
  border-color: var(--brass);
  background: rgba(201, 162, 39, 0.18);
  color: var(--brass-hi);
}

/* ---------- section labels ---------- */

.sec-label {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--foam-dim);
  margin: 4px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sec-label::after { content: ""; height: 1px; flex: 1; background: var(--hairline); }

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

footer {
  margin-top: 70px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  font-size: 0.78rem;
  color: var(--foam-dim);
  font-family: "Spline Sans Mono", monospace;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--brass);
  color: var(--abyss);
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.8rem;
  padding: 11px 20px;
  border-radius: 999px;
  z-index: 60;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .dep { grid-template-columns: auto auto 1fr auto; gap: 10px; padding: 12px; }
  .roundel { width: 44px; height: 44px; font-size: 1.05rem; }
  .eta-min { font-size: 1.5rem; }
  nav button { padding: 12px 12px; font-size: 0.7rem; }
}

.eink-link { color: var(--brass); text-decoration: none; border-bottom: 1px solid var(--brass); }
.eink-link:hover { color: var(--brass-hi); }

/* --- Info panel ---------------------------------------------------------- */
.info-block {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 8px;
}
.info-block > summary {
  cursor: pointer;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--brass-hi);
  letter-spacing: 0.01em;
  padding: 4px 0;
  list-style: none;
}
.info-block > summary::-webkit-details-marker { display: none; }
.info-block > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s ease;
  color: var(--brass);
}
.info-block[open] > summary::before { transform: rotate(90deg); }
.info-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.info-list li {
  line-height: 1.5;
  padding-left: 14px;
  border-left: 2px solid var(--water-hi);
  color: var(--foam);
  font-size: 0.98rem;
}
.info-list li strong { color: var(--brass-hi); font-weight: 600; }
.info-list a {
  color: var(--brass);
  text-decoration: none;
  border-bottom: 1px dotted var(--brass);
}
.info-list a:hover { color: var(--brass-hi); border-bottom-style: solid; }

/* ---------- D3: later departures (no relative "za X min") ---------- */
.dep.dep-later { opacity: 0.86; }
.dep.dep-later .dep-eta { align-self: center; }
.eta-time-solo {
  font-family: "Spline Sans Mono", monospace;
  font-size: 1.4rem;
  color: var(--brass-hi);
  font-weight: 500;
}

/* ---------- D4: line card blurb ---------- */
.line-blurb {
  font-family: "Instrument Sans", sans-serif;
  font-size: 0.78rem;
  color: var(--foam-dim);
  margin-top: 2px;
  line-height: 1.35;
}

/* ---------- D1/D2: key-stop summary diagram ---------- */
.diagram-key::before { opacity: 0.35; }
.diagram-key .stop-row .nm { color: var(--foam-dim); font-weight: 400; }
.diagram-key .stop-row.stop-key .nm { color: var(--foam); font-weight: 600; }
.diagram-key .stop-row:first-child .nm,
.diagram-key .stop-row:last-child .nm {
  color: var(--brass-hi);
  font-weight: 700;
}
.diagram-key .stop-row.stop-key::before {
  background: var(--line-color, var(--brass));
  border-color: var(--line-color, var(--brass));
}
.diagram-key .stop-row.stop-skip { padding: 4px 0; opacity: 0.55; }
.diagram-key .stop-row.stop-skip::before {
  width: 5px; height: 5px; border-width: 1px; opacity: 0.6;
}
.skip-nm {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.72rem;
  color: var(--foam-dim);
  font-style: italic;
}

.diagram-full-fold {
  margin-top: 6px;
  font-size: 0.78rem;
}
.diagram-full-fold > summary {
  cursor: pointer;
  color: var(--foam-dim);
  padding: 6px 0;
  list-style: none;
  border-top: 1px dashed rgba(255,255,255,0.08);
}
.diagram-full-fold > summary::marker,
.diagram-full-fold > summary::-webkit-details-marker { display: none; }
.diagram-full-fold > summary::before { content: "▸ "; color: var(--brass); }
.diagram-full-fold[open] > summary::before { content: "▾ "; }
.diagram-full-fold[open] > summary { color: var(--foam); }
.diagram-full { margin-top: 8px; }

/* trasa-head arrow tint (matches dep-dest arrow) */
.trasa-dest .arrow { color: var(--brass); font-weight: 400; }

/* language toggle (IT / PL) in kicker strip */
.lang-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--brass);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}
.lang-toggle button {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--brass);
  background: transparent;
  border: 0;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}
.lang-toggle button.active {
  background: var(--brass);
  color: #0c2226;
}
.lang-toggle button:not(.active):hover { color: var(--brass-hi); }
