/* Giorni, flotta e copertura nello stesso riquadro. */
.app { --fleet-yellow: #ffda38; --fleet-line: #b4d6ff27; }
.journey > .hero,
.journey:has(.car-fleet.multiple) > .hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  min-height: 0;
  margin: 18px -8px 20px;
  overflow: visible;
}
.hero .week-rail { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; padding-top: 0; gap: 5px; }
.hero .week-rail button { width: 100%; min-height: 54px; }
.fleet-panel { display: flex; flex-direction: column; max-height: 471px; box-sizing: border-box; min-width: 0; position: relative; border: 2px solid transparent; border-radius: 25px; overflow: hidden; }
.day-connector { z-index: 1; }
.day-connector path { stroke: var(--fleet-yellow); stroke-width: 2px; stroke-dasharray: none; stroke-dashoffset: 0; }
.fleet-panel .car-fleet {
  position: relative;
  inset: auto;
  display: grid;
  --fleet-base-height: 276px;
  height: calc(var(--fleet-base-height) * 1.2);
  min-width: 0; min-height: 0; flex-shrink: 1;
  width: 100%;
  pointer-events: auto;
  grid-template-columns: minmax(0, 1fr);
}
.fleet-panel .car-fleet.has-one-way { grid-template-columns: minmax(0, var(--side-share)) minmax(0, var(--main-cars)); }
.fleet-panel .car-fleet.only-one-way { grid-template-columns: minmax(0, 1fr); }
.one-way-cars { display: grid; grid-template-rows: repeat(2, minmax(0, 1fr)); min-width: 0; min-height: 0; border-right: 1px solid transparent; }
.only-one-way .one-way-cars { border-right: 0; }
.one-way-group { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 4px 2px; }
.one-way-group.out { grid-row: 1; }
.one-way-group.back { grid-row: 2; }
.one-way-group.out:has(+ .back) { border-bottom: 1px solid var(--fleet-line); }
.trip-label { text-align: center; color: #e5efff; font-size: 11px; line-height: 1.2; overflow-wrap: anywhere; }
.vehicle-grid { display: grid; grid-template-columns: repeat(var(--cars), minmax(0, 1fr)); min-width: 0; min-height: 0; }
.one-way-group .vehicle-grid { flex: 1; }
.both-cars { padding: 6px 2px; }
.vehicle-slot { display: flex; flex-direction: column; min-width: 0; min-height: 0; margin: 0; padding: 0 2px; }
.vehicle-slot + .vehicle-slot { border-left: 1px solid transparent; }
.vehicle-slot .vehicle {
  position: relative; inset: auto; flex: 1; min-height: 0; min-width: 0;
  width: 100%; height: auto; pointer-events: none;
}
.vehicle-slot .vehicle-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.vehicle-slot figcaption { text-align: center; font-size: 12px; line-height: 1.2; color: #edf4ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 0 4px; }
.one-way-group figcaption { font-size: 10px; }
.vehicle-slot .model-status { inset: 40% 0 auto; width: 100%; max-width: none; font-size: 11px; overflow-wrap: anywhere; }
.fleet-panel .hero-stats {
  position: relative; inset: auto; min-height: 0; flex-shrink: 0; padding: 8px 10px;
  display: block; text-align: center; font: inherit; font-size: 14px; font-weight: 400; line-height: 22px; font-variant-numeric: tabular-nums; white-space: nowrap;
  border: 0; border-top: 1px solid var(--fleet-line); border-radius: 0;
  background: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.journey > .rides { margin-top: 0; }
@media (max-width: 600px) {
  .journey > .hero,
  .journey:has(.car-fleet.multiple) > .hero { margin-block: 8px 12px; gap: 8px; }
  .hero .week-rail { gap: 4px; }
  .hero .week-rail button { min-height: 54px; }
  .fleet-panel .car-fleet { --fleet-base-height: 220px; }
  .fleet-panel .hero-stats { padding: 8px; }
}
@media (max-width: 360px) {
  .journey > .hero { margin-inline: -4px; }
  .fleet-panel .car-fleet { --fleet-base-height: 210px; }
  .fleet-panel .hero-stats { padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero .day-connector{ transition: none; }
}

/* Ingresso a tutta altezza, sosta isometrica e arrivo nella flotta. */
.fleet-intro { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.fleet-intro .vehicle { position: absolute; inset: 0; width: 100%; height: 100%; }
.fleet-intro .vehicle-canvas { position: absolute; inset: 0; }
.fleet-intro .model-status { pointer-events: auto; }

/* Il reveal riguarda il riquadro; il van in ingresso resta libero di muoversi. */
.fleet-panel::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, #699ddd25, #0c235a66);
  border: 1px solid #b4d6ff27; border-radius: inherit;
  box-shadow: 0 16px 35px #040d2835;
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  pointer-events: none; z-index: 0;
}
.fleet-panel::before,
.fleet-panel .hero-stats,
.fleet-panel .one-way-cars,
.fleet-panel .destination-sign,
.fleet-panel .both-cars {
  clip-path: inset(0 0 0 0);
  transition: clip-path 420ms cubic-bezier(.16, 1, .3, 1);
}
.fleet-panel:not(:has([data-phase="parked"]))::before,
.fleet-panel:not(:has([data-phase="parked"])) .hero-stats,
.fleet-panel:not(:has([data-phase="parked"])) .one-way-cars,
.fleet-panel:not(:has([data-phase="parked"])) .both-cars,
.fleet-panel:not(:has([data-phase="parked"])) .destination-sign,
.fleet-panel.closing::before,
.fleet-panel.closing .hero-stats,
.fleet-panel.closing .one-way-cars,
.fleet-panel.closing .destination-sign,
.fleet-panel.closing .both-cars { clip-path: inset(0 100% 0 0); }
.fleet-panel.closing::before,
.fleet-panel.closing .hero-stats,
.fleet-panel.closing .one-way-cars,
.fleet-panel.closing .destination-sign,
.fleet-panel.closing .both-cars { transition-duration: 200ms; }
@media (prefers-reduced-motion: reduce) {
  .fleet-panel::before, .fleet-panel .hero-stats,
  .fleet-panel .one-way-cars, .fleet-panel .destination-sign,
.fleet-panel .both-cars { transition: none; }
}

.hero .day-connector { clip-path: inset(0); transition: clip-path 200ms ease-out; }
.hero:has(.fleet-preview) .day-connector,
.hero:has(.fleet-panel.closing) .day-connector { clip-path: inset(0 100% 0 0); }
@media (prefers-reduced-motion: reduce) {
  .hero .day-connector { transition: none; }
}

.fleet-panel .car-fleet { padding-block: 34px 30px; box-sizing: border-box; }
.destination-sign {
  position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 16px); padding: 3px 10px;
  border: 1px solid #fff; border-radius: 3px; background: #087343; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 16px; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap;
}

.destination-sign.burger-sign { top: auto; bottom: 5px; }

/* Segnaletica stradale: solo i separatori verticali. */
.one-way-cars, .vehicle-slot { position: relative; overflow: hidden; }
.car-fleet { --road-motion: paused; --road-direction: normal; }
.car-fleet[data-phase="parked"] { --road-motion: running; }
.car-fleet[data-heading="down"] { --road-direction: reverse; }
.car-fleet[data-motion-paused="true"], .fleet-panel.closing .car-fleet { --road-motion: paused; }
.one-way-cars::after, .vehicle-slot + .vehicle-slot::after {
  content: ""; position: absolute; top: -20px; bottom: 0; width: 3px;
  background: repeating-linear-gradient(to bottom, #e5efff80 0 10px, transparent 10px 20px);
  pointer-events: none;
  animation: road-dashes 900ms linear infinite;
  animation-direction: var(--road-direction);
  animation-play-state: var(--road-motion);
}
.one-way-cars::after { right: 0; }
.vehicle-slot + .vehicle-slot::after { left: 0; }
.only-one-way .one-way-cars::after { content: none; }
@keyframes road-dashes { to { transform: translateY(20px); } }
@media (prefers-reduced-motion: reduce) {
  .one-way-cars::after, .vehicle-slot + .vehicle-slot::after { animation: none; }
}

/* Ogni van ha un ritmo e un’ampiezza propri, senza muovere nomi o divisori. */
.car-fleet[data-phase="parked"] .vehicle-slot[data-riding="true"] .vehicle.ready .vehicle-canvas {
  animation: van-ride var(--ride-duration) ease-in-out var(--ride-delay) infinite;
  animation-direction: var(--ride-cycle);
  animation-play-state: var(--road-motion);
}
@keyframes van-ride {
  0%, 100% { transform: translate(0, 0); }
  23% { transform: translate(var(--ride-x), calc(-1 * var(--ride-y))); }
  48% { transform: translate(calc(-.5 * var(--ride-x)), calc(.4 * var(--ride-y))); }
  71% { transform: translate(calc(-1 * var(--ride-x)), calc(-.6 * var(--ride-y))); }
}
@media (prefers-reduced-motion: reduce) {
  .car-fleet[data-phase="parked"] .vehicle-slot[data-riding="true"] .vehicle.ready .vehicle-canvas { animation: none; }
}

.seat-map { position: absolute; inset: 0; z-index: 1; opacity: 0; pointer-events: none; transition: opacity 180ms ease-out; }
.seat-map.visible { opacity: 1; }
.seat-marker { pointer-events: none; position: absolute; margin-left: calc(var(--seat-dot-size) / -2); margin-top: calc(var(--seat-dot-size) / -2); display: flex; flex-direction: column; align-items: center; }
.vehicle-canvas { --seat-dot-size: clamp(9px, calc(var(--van-width, 50px) * .3), 15px); }
.seat-marker > i { position: relative; z-index: 1; width: var(--seat-dot-size); height: var(--seat-dot-size); border-radius: 50%; border: 1px solid #21394a; background: #fff; }
.seat-marker.driver > i { background: #8a919b; }
.seat-marker.occupied > i { background: #21b967; border-color: #07472c; }
.seat-name {
  position: absolute; z-index: 2; top: var(--label-offset, calc(var(--seat-dot-size) + 3px));
  left: 50%; transform: translateX(-50%);
  width: max-content; max-width: none; padding: 2px; border: 1px solid #858b93;
  border-radius: 5px; background: rgb(80 85 92 / 50%); color: #fff;
  font-size: 12.75px; font-weight: 500; line-height: 16.5px;
  white-space: nowrap;
  box-shadow: 0 2px 4px #071a2b35;
}
.seat-marker:not(.driver)::after {
  content: ""; position: absolute; top: var(--seat-dot-size);
  height: var(--label-link, 3px); width: 2px; background: #fff;
}

@media (prefers-reduced-motion: reduce) { .seat-map { transition: none; } }

.labels-above .seat-marker:not(.driver)::after { top: auto; bottom: var(--seat-dot-size); }

/* Le etichette complete possono oltrepassare la corsia senza essere tagliate. */
.fleet-panel { overflow: visible; }
.one-way-cars, .vehicle-slot { overflow: visible; }
.one-way-cars::after, .vehicle-slot + .vehicle-slot::after { clip-path: inset(20px 0 0); }
.fleet-panel:not(.closing):has([data-phase="parked"]) .one-way-cars,
.fleet-panel:not(.closing):has([data-phase="parked"]) .both-cars { clip-path: inset(-48px); }

.journey > .journey-action { position: relative; z-index: 3; margin-bottom: 12px; }

/* Wizard: le stesse scelte per auto, passaggi e assenze. */
.wizard { max-height: calc(100dvh - 24px); overflow-y: auto; }
.wizard-identity { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; gap: 12px; }
.wizard-identity button { padding: 10px 0; color: #dbeaff; text-decoration: underline; text-underline-offset: 3px; }
.wizard-options { display: grid; gap: 8px; }
.wizard-options > button, .wizard-option { border: 1px solid #92b4dc66; border-radius: 10px; padding: 12px; min-height: 44px; text-align: left; color: #f3f7ff; background: #274a70; }
.wizard-options > button { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wizard .selected { border-color: #ffda38; background: #ffda38; color: #101e3d; }
.wizard-names { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.wizard-names button { overflow-wrap: anywhere; }
.wizard-seats { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 6px; }
.wizard-seats button { text-align: center; padding: 10px 0; font-size: 20px; }
.wizard-label { display: block; margin: 16px 0 8px; font-weight: 600; }
.wizard-hint { color: #dbeaff; font-size: 13px; line-height: 1.5; margin: 10px 0; }
.wizard button:disabled { opacity: .45; cursor: default; }
.wizard button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.wizard h2:focus { outline: none; }
.waiting-list { margin-top: 16px; font-size: 14px; }
.waiting-list h2 { font-size: 16px; margin-bottom: 8px; }
.waiting-list p { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-top: 1px solid #b4d6ff27; }

/* Auto piena: alone leggero sulla sagoma, senza illuminare le etichette. */
.drag-van.full canvas,
.vehicle-slot .vehicle-canvas:has(.seat-map.visible .seat-marker.occupied):not(:has(.seat-marker.free)) > canvas {
  filter: drop-shadow(0 0 5px rgb(54 220 125 / 55%));
}

button.seat-marker { pointer-events: auto; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
button.seat-marker:focus-visible { outline: none; }
button.seat-marker:focus-visible .seat-name { outline: 2px solid #fff; outline-offset: 2px; }
.seat-map:not(.visible) button.seat-marker { pointer-events: none; }

.fleet-panel .hero-stats.complete { color: #66ed9b; }

.wizard-context span { display: block; }

.wizard-context > span:first-child { color: #fff; font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.wizard-days button { text-transform: capitalize; }

.sleep-cloud { --sleep-x: var(--exhaust-x, 50%); --sleep-y: calc(var(--exhaust-y, 70%) - 34px); position: absolute; left: var(--sleep-x); top: var(--sleep-y); z-index: -1; pointer-events: none; }
.sleep-cloud span { position: absolute; font-size: 18px; font-weight: 700; color: #e5efff; opacity: 0; animation: sleepy-z 2.6s ease-out var(--sleep-delay) infinite; animation-play-state: var(--road-motion); }
@keyframes sleepy-z {
  0% { opacity: .9; transform: translate(0, 0) scale(1) rotate(-12deg); }
  100% { opacity: 0; transform: translate(30px, -70px) scale(1.333333) rotate(10deg); }
}
@media (prefers-reduced-motion: reduce) {
  .sleep-cloud span { animation: none; }
  .sleep-cloud span:first-child { opacity: .8; }
}

.page-identity { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; font-size: 14px; color: #dbeaff; }
.page-identity button { padding: 12px 4px; text-decoration: underline; text-underline-offset: 3px; }

.vehicle-canvas:has(.sleep-cloud) { isolation: isolate; }
.vehicle-canvas:has(.sleep-cloud) > canvas { position: relative; z-index: 1; }

/* Vista GAM: capienza per tratta, con gli stessi van e dati di PGL. */
.view-switch { display: flex; max-width: 260px; margin: 4px auto 0; padding: 4px; border: 1px solid #b4d6ff40; border-radius: 14px; background: #0c235a55; }
.view-switch button { flex: 1; min-height: 42px; border-radius: 10px; color: #e5efff; }
.view-switch button[aria-pressed="true"] { background: #ffda38; color: #101e3d; }
.drag-board { min-width: 0; position: relative; }
.drag-times { display: flex; gap: 8px; margin-bottom: 12px; }
.drag-times button { flex: 1; min-height: 42px; border: 1px solid #b4d6ff40; border-radius: 10px; color: #edf4ff; font-size: 13px; background: #244c7d80; }
.drag-times button[aria-pressed="true"] { background: #ffda38; color: #101e3d; border-color: #ffda38; }
.drag-lanes { display: grid; gap: 10px; }
.drag-lane { display: grid; grid-template-columns: 92px minmax(0,1fr); position: relative; min-height: 118px; padding: 8px; border: 1px solid #b4d6ff40; border-radius: 20px; transition: border-color 150ms, background-color 150ms; }
.drag-lane-title { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px; text-align: center; color: #edf4ff; }
.drag-lane-title strong { font-size: 14px; font-weight: 600; }
.drag-lane-title small { font-size: 11px; line-height: 1.4; }
.drag-lane-title b { font-size: 30px; font-weight: 600; line-height: 1.1; margin-top: 3px; }
.drag-lane.covered { border-color: #66ed9b70; }
.drag-lane.covered .drag-lane-title { color: #66ed9b; }
.drag-cars { display: grid; grid-template-columns: repeat(auto-fit,minmax(90px,1fr)); align-items: stretch; min-width: 0; gap: 6px; }
.drag-car { min-width: 0; padding: 5px 0; border-left: 1px dashed #b4d6ff50; }
.drag-car-handle { display: flex; width: 100%; flex-direction: column; align-items: center; padding: 0 4px; color: #edf4ff; }
.drag-car-handle > strong { font-size: 14px; overflow-wrap: anywhere; }
.drag-car-handle > small { font-size: 10px; white-space: nowrap; }
.drag-van { position: relative; width: 100%; height: 78px; pointer-events: none; }
.drag-van .vehicle, .drag-van .vehicle-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.drag-car-free { font-size: 11px; }
.drag-car-free b { font-size: 19px; font-weight: 600; }
.drag-empty-add { position: absolute; inset: 8px 8px 8px 108px; color: #c6e3ff40; font-size: 64px; line-height: 1; }
.drag-empty-add:enabled { color: #ffda3880; }
.drag-roster { margin: 16px 0 12px; }
.drag-roster h2 { font: inherit; font-size: 14px; margin: 0 0 8px; color: #e5efff; }
.drag-families { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.drag-family { display: flex; align-items: center; min-width: 0; min-height: 48px; padding: 0 10px; gap: 6px; border: 1px solid #b4d6ff35; border-radius: 12px; background: #305d8b55; }
.drag-family-name { flex: 1; min-width: 0; text-align: left; padding: 10px 0; font-size: 15px; overflow-wrap: anywhere; }
.drag-family-seats { font-size: 22px; color: #cbe2fc; }
.drag-family select { width: 44px; min-height: 42px; font: inherit; font-size: 22px; color: #ffda38; background: #173967; border: 0; border-radius: 8px; }
.drag-family.assigned { background: #2e668780; }
.drag-family.absent { background: #703c5555; }
.drag-family.mine, .drag-car.mine { border-color: #ffda38aa; }
.drag-board button[aria-pressed="true"]:not(.drag-times button) { color: #ffda38; }
.drag-board button.drag-family-name, .drag-board button.drag-car-handle, .drag-away-names button { touch-action: none; cursor: grab; }
.drag-away { min-height: 64px; border: 1px solid #f79eab70; border-radius: 16px; padding: 10px 12px; background: #722e4940; }
.drag-away-title { color: #ffccd4; font-size: 14px; min-height: 40px; }
.drag-away-names { display: flex; gap: 8px; flex-wrap: wrap; }
.drag-away-names > * { padding: 8px; border-radius: 8px; background: #813d574a; color: #ffe0e5; font-size: 14px; }
.drag-board .drag-over { background: #436d8d; outline: 2px solid #ffda38; outline-offset: 1px; }
.drag-ghost { position: fixed; z-index: 100; transform: translate(-50%,-120%); padding: 10px 16px; border-radius: 10px; background: #ffda38; color: #101e3d; font-weight: 600; box-shadow: 0 8px 24px #07152b66; pointer-events: none; }
.drag-error { position: fixed; z-index: 60; bottom: 20px; left: 50%; transform: translateX(-50%); width: min(420px,calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: #582d42; color: #fff; }
.drag-error button { min-width: 36px; min-height: 36px; font-size: 22px; }
.drag-board button:focus-visible, .view-switch button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-width:360px) {
  .drag-lane { grid-template-columns: 84px minmax(0,1fr); padding: 6px; }
  .drag-cars { grid-template-columns: repeat(auto-fit,minmax(78px,1fr)); }
  .drag-lane-title strong { font-size: 12px; }
  .drag-lane-title small { font-size: 10px; }
  .drag-empty-add { left: 96px; }
}
@media (prefers-reduced-motion:reduce) { .drag-lane { transition: none; } }

.drag-lane-title:disabled, .drag-away-title:disabled { opacity: 1; }
.drag-lane:not(:has(.drag-car)) { min-height: 98px; }

.page-refresh { display: block; margin: 12px auto 0; min-height: 44px; padding: 10px 24px; color: #e5efff; border: 1px solid #b4d6ff40; border-radius: 10px; background: #0c235a55; }
.page-refresh:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
