.atha-kess3-case {
  --atha-yellow: #ffea00;
  --atha-panel: #262626;
  --atha-panel-muted: rgba(84, 89, 87, 0.92);
  --atha-text: #ffffff;
  --atha-radius: 16px;
  position: relative;
  width: 100%;
  min-height: 100svh;
  padding: 0;
  overflow: hidden;
}

/*
 * Quando lo shortcode vive in Elementor, il JS aggancia il blocco al
 * container che lo ospita. Il video diventa quindi un vero layer full-size
 * della sezione, senza il precedente max-width di 1200px.
 */
.atha-kess3-host {
  position: relative !important;
  overflow: hidden;
  isolation: isolate;
}

.atha-kess3-host > .elementor-element:not(.atha-kess3-widget) {
  position: relative;
  z-index: 2;
}

.atha-kess3-widget,
.atha-kess3-widget > .elementor-widget-container,
.atha-kess3-widget .elementor-shortcode {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

.atha-kess3-case.is-hosted {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.atha-kess3-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  overflow: hidden;
}

.atha-kess3-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 50%;
}

.atha-kess3-hotspots,
.atha-kess3-modals {
  position: absolute;
}

/*
 * Il layer hotspot viene dimensionato dal JS sulla superficie effettivamente
 * renderizzata da object-fit: cover. In questo modo gli hotspot restano
 * allineati anche quando la sezione ha un aspect ratio diverso dal video.
 */
.atha-kess3-hotspots {
  z-index: 4;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.atha-kess3-modals {
  z-index: 6;
  inset: 0;
  pointer-events: none;
}

.atha-kess3-hotspot,
.atha-kess3-hotspot:hover,
.atha-kess3-hotspot:focus,
.atha-kess3-hotspot:active {
  position: absolute;
  z-index: 4;
  display: block;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-indent: -9999px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  opacity: 1 !important;
  -webkit-tap-highlight-color: transparent;
}

/* Reset anti-tema su ::before (decorazione tema/Elementor). ::after è riservato al pallino (sotto). */
.atha-kess3-hotspot::before {
  content: none !important;
  display: none !important;
  background: transparent !important;
}

/*
 * Pallino centrale su ogni hotspot con pulse trasparente delicato. ::after (un solo pseudo-elemento)
 * centrato nel button, NON interattivo (pointer-events:none → hitbox del button invariata, nessun
 * impatto su AC theme-reset). Il pulse è un anello box-shadow che si espande e svanisce (delicato:
 * opacità bassa, 2.2s). !important coerente col blocco base anti-reset del tema.
 * Tuning da Elementor (widget/sezione, senza codice): dimensione `--attinta-kess3-hotspot-dot-size`
 * (default 9px), colore `--attinta-kess3-hotspot-dot-color` (default #ffee00). NB: l'anello di pulse
 * resta giallo (rgba fisso, max compatibilità) → cambiando solo il colore del pallino il pulse non lo
 * segue; per escludere il pallino da un singolo hotspot: `.atha-kess3-hotspot--<key>::after{display:none}`.
 */
.atha-kess3-hotspot::after {
  content: '' !important;
  display: block !important;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--attinta-kess3-hotspot-dot-size, 9px);
  height: var(--attinta-kess3-hotspot-dot-size, 9px);
  margin: 0 !important;
  transform: translate(-50%, -50%);
  border-radius: 50% !important;
  background: var(--attinta-kess3-hotspot-dot-color, #ffee00) !important;
  box-shadow: 0 0 0 0 rgba(255, 238, 0, 0.45);
  pointer-events: none;
  animation: atha-kess3-hotspot-pulse 2.2s ease-out infinite;
}

@keyframes atha-kess3-hotspot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 238, 0, 0.45); }
  70%  { box-shadow: 0 0 0 11px rgba(255, 238, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 238, 0, 0); }
}

/* Rispetta prefers-reduced-motion: pallino statico, nessun pulse (a11y; attenua il debito KESS3 §12). */
@media (prefers-reduced-motion: reduce) {
  .atha-kess3-hotspot::after {
    animation: none !important;
  }
}

.atha-kess3-hotspot:focus-visible {
  outline: 2px solid var(--atha-yellow) !important;
  outline-offset: 2px;
}

/*
 * Geometria !important come il blocco base sopra: un reset di tema `[type=button] { width: auto }`
 * (specificità (0,1,0), pari ai modificatori, ma caricato dopo) collasserebbe la larghezza → hitbox
 * nulla. Regressione: tests/E2E/kess3-theme-reset.det.spec.ts.
 */
.atha-kess3-hotspot--bench { left: 25.8% !important; top: 17.6% !important; width: 44.8% !important; height: 27.5% !important; }
.atha-kess3-hotspot--ecm   { left: 57.4% !important; top: 52.7% !important; width: 9% !important; height: 12.8% !important; }
.atha-kess3-hotspot--obd   { left: 57.9% !important; top: 61.3% !important; width: 9.9% !important; height: 26.3% !important; }
.atha-kess3-hotspot--usb   { left: 42.9% !important; top: 71.1% !important; width: 12.3% !important; height: 16.7% !important; }
.atha-kess3-hotspot--power { left: 30.4% !important; top: 55.3% !important; width: 8.3% !important; height: 32.7% !important; }
/* Hotspot secondario centrale (dispositivo KESS3) → apre la modal `bench` (SPEC 1.0.5). Coordinate di
   partenza al centro valigetta, rifinibili come gli altri modificatori. */
.atha-kess3-hotspot--bench-center { left: 44% !important; top: 42% !important; width: 12% !important; height: 20% !important; }

.atha-kess3-modal {
  position: absolute;
  z-index: 6;
  width: min(360px, calc(100% - 2rem));
  border: 1px solid var(--atha-yellow);
  border-radius: var(--atha-radius);
  overflow: hidden;
  background: var(--atha-panel);
  box-shadow: 0 1.25rem 2.5rem rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 14px, 0) scale(0.98);
  transform-origin: center;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
  pointer-events: none;
}

.atha-kess3-modal.is-active {
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0) scale(1);
  transition-delay: 0s;
  pointer-events: auto;
}

.atha-kess3-modal__header {
  position: relative;
  background: var(--atha-panel);
  padding: 16px;
}

.atha-kess3-modal__header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-top: 24px solid var(--atha-yellow);
  border-right: 24px solid transparent;
}

.atha-kess3-modal__close,
.atha-kess3-modal__close:hover,
.atha-kess3-modal__close:focus,
.atha-kess3-modal__close:active {
  position: absolute;
  top: 0.85rem;
  right: 0.9rem;
  width: 2.35rem;
  height: 2.35rem;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: var(--atha-yellow) !important;
  font-size: 1.7rem !important;
  line-height: 1 !important;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.atha-kess3-modal__close:focus-visible {
  outline: 2px solid var(--atha-yellow) !important;
  outline-offset: 2px;
}

.atha-kess3-modal__title {
  margin: 0;
  color: var(--atha-yellow);
  font-size: 1.5rem;
  line-height: 1.05;
  font-weight: 400;
}

.atha-kess3-modal__body {
  background: var(--atha-panel-muted);
  padding: 16px;
}

.atha-kess3-modal__text {
  margin: 0;
  color: var(--atha-text);
  font-size: 1rem;
  line-height: 1.35;
}

.atha-kess3-modal__small {
  margin: 0.75rem 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.88rem;
  line-height: 1.35;
}

.atha-kess3-modal__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 16px;
  padding: 6px 14px;
  background-color: var(--atha-yellow);
  color: #262626 !important;
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
}

.atha-kess3-modal__cta:hover,
.atha-kess3-modal__cta:focus-visible {
  text-decoration: none;
}

.atha-kess3-modal--bench { right: 18%; top: 15%; }
.atha-kess3-modal--ecm   { right: 15%; top: 35%; }
.atha-kess3-modal--obd   { right: 15.5%; bottom: 30%; }
.atha-kess3-modal--usb   { left: 33%; bottom: 18%; transform: translate3d(-50%, 14px, 0) scale(0.98); }
.atha-kess3-modal--usb.is-active { transform: translate3d(-50%, 0, 0) scale(1); }
.atha-kess3-modal--power { left: 13%; bottom: 33%; }

@media (max-width: 1024px) {
  .atha-kess3-modal { width: min(29rem, calc(100% - 1.5rem)); }
  .atha-kess3-modal--bench { left: 2%; top: 5%; }
  .atha-kess3-modal--ecm { right: 2%; top: 6%; }
  .atha-kess3-modal--obd { right: 1%; bottom: 14%; }
  .atha-kess3-modal--power { left: 1%; bottom: 13%; }
}

@media (max-width: 767px) {
  /* Su mobile il plugin NON forza un'altezza minima: l'altezza è controllata dall'editor Elementor
     (case `.is-hosted` → height:100% del container). Per il case standalone (non-hosted, es. fixture)
     l'altezza deriva dall'aspect-ratio reale del video → la valigia si vede intera, senza il crop di
     `object-fit: cover` che un box a 100svh imponeva. Reservation via aspect-ratio = §13 CLS-safe. */
  .atha-kess3-case {
    min-height: 0;
  }

  .atha-kess3-case:not(.is-hosted) {
    aspect-ratio: 1920 / 1258;
  }

  /*
   * Framing orizzontale del video SOLO su mobile: pan del crop `object-fit: cover` per rivelare la parte
   * del video tagliata dai lati (video landscape in box portrait). Il padding/posizione del widget
   * Elementor non ha effetto perché media/video sono `position: absolute; inset: 0`. Tunabile dall'editor
   * Elementor impostando la variabile sul widget/sezione (es. `selector { --attinta-kess3-object-x: 70%; }`;
   * 0% = mostra il lato sinistro, 100% = lato destro, 50% = centro/default → nessun cambio).
   * ⚠️ Sposta SOLO il video, non gli hotspot (posizionati in % del box) → gli hotspot si disallineano dalle
   * feature del case. Se servono hotspot allineati su mobile, vanno ri-tarati con override per-modificatore.
   */
  .atha-kess3-video {
    object-position: var(--attinta-kess3-object-x, 50%) 50%;
  }

  /*
   * Poster MOBILE dedicato (opzionale). Il video reale è landscape (1920×1258): in un box portrait
   * `object-fit: cover` ne ritaglia i lati. Marketing può impostare un'immagine PORTRAIT come poster
   * SOLO su mobile via la variabile `--attinta-kess3-mobile-poster` sul widget/sezione Elementor:
   *   selector { --attinta-kess3-mobile-poster: url("https://…/case-portrait.jpg"); }
   * L'immagine copre il video (overlay a z-index 1, SOPRA il video z-index 0 e SOTTO gli hotspot
   * z-index 4 → gli hotspot restano tappabili) e riempie QUALUNQUE altezza impostata in Elementor
   * (`background-size: cover`). Variabile NON impostata (default) → nessun overlay: resta il poster
   * landscape del <video> (comportamento invariato). L'immagine deve essere self-hosted, stesso dominio
   * (AC14 no-CDN): caricarla nella Libreria media di WordPress. Fit/posizione affinabili con
   * `--attinta-kess3-mobile-poster-fit` (default `cover`) e `--attinta-kess3-mobile-poster-position`
   * (default `center`); es. `--attinta-kess3-mobile-poster-fit: contain` per vedere l'intera immagine.
   */
  .atha-kess3-media::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background-image: var(--attinta-kess3-mobile-poster, none);
    background-size: var(--attinta-kess3-mobile-poster-fit, cover);
    background-position: var(--attinta-kess3-mobile-poster-position, center);
    background-repeat: no-repeat;
    pointer-events: none;
  }

  /*
   * Modal CENTRATE nella sezione su mobile (non più `fixed` in basso al viewport). `absolute` rispetto a
   * `.atha-kess3-modals` (inset:0 nella sezione) → centro del case via left/top 50% + translate(-50%,-50%).
   * Una sola modal aperta alla volta è già garantito dal controller (`activeHotspotId`, openModal chiude la
   * precedente). Il blocco selettori include i 5 modificatori per sovrascrivere le loro coordinate desktop.
   */
  .atha-kess3-modal,
  .atha-kess3-modal--bench,
  .atha-kess3-modal--ecm,
  .atha-kess3-modal--obd,
  .atha-kess3-modal--usb,
  .atha-kess3-modal--power {
    position: absolute;
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    width: min(360px, calc(100% - 2rem));
    max-width: calc(100% - 2rem);
    transform: translate3d(-50%, calc(-50% + 14px), 0) scale(0.98);
  }

  .atha-kess3-modal.is-active,
  .atha-kess3-modal--usb.is-active {
    transform: translate3d(-50%, -50%, 0) scale(1);
  }

  .atha-kess3-modal__header {
    padding: 1.5rem 3.5rem 1.1rem 1.65rem;
  }

  .atha-kess3-modal__body {
    padding: 1.35rem 1.65rem 1.5rem;
  }
}
