/* =====================================================================
   Code Zero Sailing – widget "La rotta"
   Usa le variabili del sito (style.css): --deep --ink --sea --aqua --cream --sand --serif --sans
   ===================================================================== */

/* ---------------------------------------------------------------- MAPPA (comune) */
.cz-map { position: relative; background: var(--deep); overflow: hidden; }
.cz-map-svg { display: block; width: 100%; height: 100%; }
.cz-map::after { /* vignetta: il mare sfuma verso i bordi */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(6, 26, 36, .55) 100%);
}
.cz-compass { position: absolute; left: 22px; bottom: 20px; width: 54px; height: 54px; color: var(--aqua); opacity: .55; pointer-events: none; z-index: 1; }

/* niente vector-effect sulle linee tratteggiate: il tratteggio deve stare in unità mappa, come la barca
   (spessori impostati da rotta.js in base allo zoom) */
.cz-route-plan { fill: none; stroke: var(--aqua); stroke-opacity: .38; stroke-linecap: round; }
.cz-route-line { fill: none; stroke: var(--cream); stroke-linecap: round; stroke-linejoin: round; }
.cz-route-wake { fill: none; stroke: var(--white); stroke-opacity: .28; stroke-linecap: round; }

.cz-stop-dot { fill: var(--deep); stroke: var(--aqua); stroke-width: 1.6; vector-effect: non-scaling-stroke; transition: fill .4s, stroke .4s; }
.cz-stop.is-reached .cz-stop-dot { fill: var(--cream); stroke: var(--cream); }
.cz-stop-pulse { fill: none; stroke: var(--cream); stroke-width: 1.4; vector-effect: non-scaling-stroke; opacity: 0; transform-box: fill-box; transform-origin: center; }
.cz-stop.is-current .cz-stop-pulse { animation: cz-pulse 1.8s ease-out infinite; }
@keyframes cz-pulse { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(4.2); } }

.cz-stop-label { font-family: var(--sans); font-weight: 600; letter-spacing: .02em; fill: rgba(247, 246, 241, .58);
  paint-order: stroke; stroke: var(--deep); stroke-width: 3px; stroke-linejoin: round; transition: fill .4s; }
.cz-stop.is-reached .cz-stop-label { fill: var(--cream); }
.cz-stop.is-current .cz-stop-label { font-family: var(--serif); font-style: italic; font-weight: 400; }
/* in porto la barca sta sopra il pallino: il nome si sposta per restare leggibile (--k = unità mappa per px) */
.cz-stop-label { transition: fill .4s, transform .4s; }
.cz-stop.is-current .cz-stop-label[data-dir="r"] { transform: translateX(calc(var(--k, 1) * 16px)); }
.cz-stop.is-current .cz-stop-label[data-dir="l"] { transform: translateX(calc(var(--k, 1) * -16px)); }
.cz-stop.is-current .cz-stop-label[data-dir="b"] { transform: translateY(calc(var(--k, 1) * 12px)); }

.cz-zone-label { font-family: var(--serif); font-style: italic; fill: var(--cream); paint-order: stroke; stroke: var(--deep); stroke-width: 4px; }

.cz-boat-hull { fill: var(--white); stroke: var(--deep); stroke-width: 1.2; }
.cz-boat-sail { fill: var(--white); opacity: .92; }
.cz-boat-mast { fill: var(--ink); }
.cz-boat-halo { fill: var(--aqua); opacity: .16; }
.cz-boat-wake { fill: none; stroke: var(--white); stroke-opacity: .35; stroke-width: 1.2; stroke-linecap: round; }

/* ---------------------------------------------------------------- SLIDER MULTITAPPA (comune) */
.cz-slider { --p: 0%; }
.cz-slider-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.cz-counter { white-space: nowrap; font-family: var(--serif); font-size: 1rem; color: rgba(247, 246, 241, .6); }
.cz-counter strong { font-size: 1.9rem; font-weight: 400; color: var(--cream); margin: 0 4px; font-variant-numeric: tabular-nums; }
.cz-ctrl { display: flex; gap: 6px; }
.cz-ctrl button { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; cursor: pointer; color: var(--cream);
  background: transparent; border: 1px solid rgba(247, 246, 241, .25); border-radius: 50%; transition: background .25s, border-color .25s, color .25s, opacity .25s; }
.cz-ctrl button:hover:not(:disabled) { border-color: var(--cream); }
.cz-ctrl button:disabled { opacity: .3; cursor: default; }
.cz-ctrl button:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.cz-ctrl svg { width: 14px; height: 14px; fill: currentColor; }
.cz-ctrl [data-play] { background: var(--cream); color: var(--deep); border-color: var(--cream); }
.cz-ctrl [data-play] .i-pause, .cz-ctrl [data-play][aria-pressed="true"] .i-play { display: none; }
.cz-ctrl [data-play][aria-pressed="true"] .i-pause { display: block; }

.cz-track { position: relative; padding: 6px 0 34px; }
.cz-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 26px; margin: 0; background: transparent; cursor: pointer; position: relative; z-index: 2; touch-action: none; }
.cz-range:focus { outline: none; }
.cz-range::-webkit-slider-runnable-track { height: 2px; border-radius: 2px;
  background: linear-gradient(to right, var(--cream) 0 var(--p), rgba(247, 246, 241, .2) var(--p) 100%); }
.cz-range::-moz-range-track { height: 2px; background: rgba(247, 246, 241, .2); }
.cz-range::-moz-range-progress { height: 2px; background: var(--cream); }
.cz-range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -10px; border-radius: 50%;
  background: var(--cream); border: 5px solid var(--deep); box-shadow: 0 0 0 1px var(--cream), 0 4px 14px rgba(0, 0, 0, .35); transition: transform .2s; }
.cz-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--cream); border: 5px solid var(--deep); box-shadow: 0 0 0 1px var(--cream); }
.cz-range:active::-webkit-slider-thumb { transform: scale(1.15); }
.cz-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--cream), 0 0 0 5px rgba(118, 171, 182, .55); }

/* tacche: una per giorno, allineate al centro del cursore (22px) */
.cz-ticks { position: absolute; left: 11px; right: 11px; top: 32px; height: 30px; pointer-events: none; }
.cz-tick { position: absolute; left: var(--x); top: 0; transform: translateX(-50%); pointer-events: auto; cursor: pointer;
  padding: 4px 6px; background: none; border: 0; color: rgba(247, 246, 241, .5); font: inherit; }
/* pallino sulla linea (decorativo, sotto al cursore trasparente) */
.cz-tick::before { content: ""; position: absolute; left: 50%; top: -17px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  background: var(--deep); border: 1.5px solid rgba(247, 246, 241, .35); transition: background .3s, border-color .3s; pointer-events: none; }
.cz-tick.is-on::before { background: var(--cream); border-color: var(--cream); }
.cz-tick-num { display: block; font: 700 .64rem/1 var(--sans); letter-spacing: .08em; }
.cz-tick-name { display: none; }
.cz-tick.is-now { color: var(--cream); }
.cz-tick:hover { color: var(--cream); }
.cz-tick:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }

/* ---------------------------------------------------------------- 1. DESTINAZIONI */
.cz-voyage { background: var(--deep); color: var(--cream); }
.cz-stage { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(360px, 1fr); height: clamp(640px, 100svh, 920px); }
.cz-stage .cz-map { min-height: 0; }

.cz-panel { display: flex; flex-direction: column; padding: clamp(32px, 5vh, 60px) clamp(28px, 3.6vw, 60px); border-left: 1px solid rgba(255, 255, 255, .08); min-height: 0; }
.cz-panel .eyebrow { color: var(--aqua); margin: 0 0 14px; }
.cz-panel h2 { color: var(--cream); font-size: clamp(2rem, 2.6vw, 2.7rem); line-height: 1.12; margin: 0 0 22px; max-width: 16ch; }
.cz-panel h2 em { color: var(--aqua); }

.cz-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 clamp(18px, 3vh, 28px); }
.cz-tabs button { font: 700 .66rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: rgba(247, 246, 241, .7);
  background: transparent; border: 1px solid rgba(247, 246, 241, .22); padding: 11px 14px; cursor: pointer; transition: color .25s, background .25s, border-color .25s; }
.cz-tabs button:hover { color: var(--cream); border-color: rgba(247, 246, 241, .55); }
.cz-tabs button[aria-selected="true"] { background: var(--cream); color: var(--deep); border-color: var(--cream); }
.cz-tabs button:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }

.cz-voyage .cz-slider { margin-bottom: 14px; }

.cz-days[hidden] { display: none !important; }
.cz-days { list-style: none; margin: 0; padding: 0; display: grid; flex: 1 1 auto; min-height: 0; }
.cz-days > li { display: grid; grid-template-rows: auto auto auto 1fr; align-content: start; }
.cz-day-photo { position: relative; aspect-ratio: 16 / 10; overflow: hidden; margin: 0 0 16px; max-height: 28vh; width: 100%; }
.cz-day-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cz-day-kicker { font: 700 .66rem/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--aqua); }
.cz-days h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.7rem, 2.3vw, 2.3rem); line-height: 1.1; color: var(--cream); margin: 8px 0 10px; }
.cz-days h3 small { font-family: var(--sans); font-size: .9rem; letter-spacing: .04em; color: rgba(247, 246, 241, .6); margin-left: 8px; }
.cz-days p { margin: 0; color: rgba(247, 246, 241, .78); font-size: .96rem; line-height: 1.6; max-width: 46ch; }

/* Con JS: una sola scheda visibile, le altre sovrapposte */
.cz-voyage.is-live .cz-days > li { grid-area: 1 / 1; opacity: 0; transform: translateY(12px); transition: opacity .45s ease, transform .55s cubic-bezier(.2, .7, .2, 1); pointer-events: none; }
.cz-voyage.is-live .cz-days > li.is-active { opacity: 1; transform: none; pointer-events: auto; }
.cz-voyage.is-live .cz-days > li.is-active .cz-day-photo img { animation: cz-kenburns 6s ease-out both; }
@keyframes cz-kenburns { from { transform: scale(1.08); } to { transform: scale(1); } }

/* Senza JS: niente slider, tutte le tappe in elenco */
.cz-voyage:not(.is-live) .cz-slider, .cz-overview:not(.is-live) .cz-slider { display: none; }
.cz-voyage:not(.is-live) .cz-stage { grid-template-columns: 1fr; height: auto; }
.cz-voyage:not(.is-live) .cz-stage .cz-map { height: 70vh; }
.cz-voyage:not(.is-live) .cz-days { gap: 26px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

@media (max-width: 850px) {
  .cz-stage { grid-template-columns: 1fr; grid-template-rows: 52svh auto; height: auto; }
  .cz-panel { padding: 18px 20px 28px; border-left: 0; border-top: 1px solid rgba(255, 255, 255, .08); }
  .cz-panel .eyebrow, .cz-panel h2 { display: none; }
  .cz-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 16px; }
  .cz-tabs button { padding: 8px 6px; font-size: .56rem; line-height: 1.3; letter-spacing: .1em; }
  .cz-ctrl button { width: 38px; height: 38px; }
  .cz-day-photo { max-height: none; }
  .cz-days h3 { font-size: 1.6rem; }
  .cz-days p { font-size: .92rem; }
  .cz-compass { width: 40px; height: 40px; left: 14px; bottom: 12px; }
}

/* ---------------------------------------------------------------- 2. HOME */
.cz-overview { background: var(--deep); color: var(--cream); padding: clamp(80px, 9vw, 140px) 0; }
.cz-overview .eyebrow { color: var(--aqua); }
.cz-overview h2 { color: var(--cream); }
.cz-overview h2 em { color: var(--aqua); }
.cz-overview .section-head p { color: rgba(247, 246, 241, .75); }
.cz-overview-frame { width: min(100%, calc(80vh * 2060 / 1700)); margin: 40px auto 0; }
.cz-overview .cz-map { aspect-ratio: 2060 / 1700; width: 100%; border: 1px solid rgba(255, 255, 255, .08); }
.cz-overview .cz-map-svg { position: absolute; inset: 0; }
.cz-overview .cz-slider { border: 1px solid rgba(255, 255, 255, .08); border-top: 0; padding: 18px 26px 4px; }
.cz-overview .cz-tick-num { display: none; }
.cz-overview .cz-track { padding-left: 24px; padding-right: 24px; }
.cz-overview .cz-ticks { left: 35px; right: 35px; }
.cz-overview .cz-tick-name { display: block; font: 700 .6rem/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.cz-zone-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .08); border-top: 0; }
.cz-zone-link { display: block; padding: 24px 26px; background: var(--deep); color: var(--cream); text-decoration: none; transition: background .3s; }
.cz-zone-link:hover { background: #10333f; }
.cz-zone-link span { display: block; font: 700 .62rem/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--aqua); margin-bottom: 10px; }
.cz-zone-link strong { font-family: var(--serif); font-weight: 400; font-size: 1.45rem; }
.cz-zone-link em { display: block; font-style: normal; font-size: .85rem; color: rgba(247, 246, 241, .65); margin-top: 6px; }
@media (max-width: 850px) {
  .cz-zone-links { grid-template-columns: 1fr; }
  .cz-overview .cz-slider { padding: 16px 16px 4px; }
  .cz-overview .cz-tick-num { display: block; }
  .cz-overview .cz-tick-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cz-stop.is-current .cz-stop-pulse { animation: none; }
  .cz-days > li, .cz-days > li .cz-day-photo img { transition: none !important; animation: none !important; }
}
