/* Verdex — Riquadro di caricamento in primo piano e pillola «Cambia categoria» (shield-focus.js)
 * Ritmo lento e vellutato: 1300 ms su cubic-bezier(0.22, 1, 0.36, 1). Colori secondo il tema attivo (Chiaro, Sabbia
 * Calda, Notte) e Alto Contrasto. Nessun cambio a dimensioni, layout del computer o proporzioni dello smartphone:
 * la pillola è sovrapposta (position: fixed) e il bagliore usa solo ombre. */

:root {
  --fx-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fx-ms: 1300ms;
  /* Chiaro (predefinito) */
  --fx-ring: rgba(30, 58, 138, 0.30);
  --fx-glow: rgba(59, 130, 246, 0.20);
  --fx-zone-ring: rgba(30, 58, 138, 0.45);
  --fx-pill-bg: rgba(255, 255, 255, 0.97);
  --fx-pill-fg: #1E3A8A;
  --fx-pill-sub: #475569;
  --fx-pill-border: #CBD5E1;
  --fx-pill-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(30, 58, 138, 0.16);
  --fx-pill-hover: #F8FAFF;
  --fx-focus: #1E3A8A;
}
/* Computer (classe «pace-desk», <head> di index.html): bagliore e pillola rapidi (300 ms, bagliore 600 ms in tutto). */
html.pace-desk { --fx-ms: 300ms; }
html[data-ws-theme="sand"] {
  --fx-ring: rgba(30, 58, 138, 0.26);
  --fx-glow: rgba(180, 132, 60, 0.24);
  --fx-zone-ring: rgba(30, 58, 138, 0.40);
  --fx-pill-bg: rgba(250, 246, 238, 0.97);
  --fx-pill-fg: #1E3A8A;
  --fx-pill-sub: #5C5345;
  --fx-pill-border: #DDD0B8;
  --fx-pill-shadow: 0 1px 2px rgba(120, 83, 30, 0.10), 0 8px 24px rgba(120, 83, 30, 0.16);
  --fx-pill-hover: #FFFBF4;
  --fx-focus: #1E3A8A;
}
html[data-ws-theme="night"] {
  --fx-ring: rgba(79, 115, 217, 0.55);
  --fx-glow: rgba(79, 115, 217, 0.30);
  --fx-zone-ring: rgba(120, 150, 235, 0.65);
  --fx-pill-bg: rgba(17, 28, 51, 0.97);
  --fx-pill-fg: #EAF0FA;
  --fx-pill-sub: #A8B8D0;
  --fx-pill-border: rgba(148, 163, 184, 0.28);
  --fx-pill-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.40);
  --fx-pill-hover: #15223D;
  --fx-focus: #F59E0B;
}
html.high-contrast {
  --fx-ring: #000000;
  --fx-glow: rgba(0, 0, 0, 0);
  --fx-zone-ring: #000000;
  --fx-pill-bg: #FFFFFF;
  --fx-pill-fg: #000000;
  --fx-pill-sub: #000000;
  --fx-pill-border: #000000;
  --fx-pill-shadow: none;
  --fx-pill-hover: #FFFFFF;
  --fx-focus: #000000;
}

/* ---------- Bagliore all'arrivo sul riquadro (1300 ms per accendersi, 1300 ms per sfumare) ---------- */
/* Il riquadro conserva l'ombra del tema: l'anello usa solo il contorno (outline), che segue gli angoli arrotondati. */
@keyframes fx-spot-card {
  0%   { outline-color: rgba(0, 0, 0, 0); outline-offset: 0px; }
  50%  { outline-color: var(--fx-ring); outline-offset: 4px; }
  100% { outline-color: rgba(0, 0, 0, 0); outline-offset: 0px; }
}
@keyframes fx-spot-zone {
  0%   { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 0 0 rgba(0, 0, 0, 0); }
  50%  { box-shadow: 0 0 0 4px var(--fx-zone-ring), 0 8px 28px 2px var(--fx-glow); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 0 0 rgba(0, 0, 0, 0); }
}
#work-area.fx-spot { outline: 3px solid rgba(0, 0, 0, 0); animation: fx-spot-card calc(var(--fx-ms) * 2) var(--fx-ease) both; }
#work-area .fx-spot { animation: fx-spot-zone calc(var(--fx-ms) * 2) var(--fx-ease) both; }
@media (prefers-reduced-motion: reduce) {
  #work-area.fx-spot, #work-area .fx-spot { animation: none; }
}

/* ---------- Pillola «Cambia categoria» ---------- */
.fx-pill {
  position: fixed; z-index: 45; left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: inline-flex; align-items: center; gap: .5rem;
  max-width: min(calc(100vw - 1.5rem), 26rem); min-height: 44px;
  padding: .45rem 1rem .45rem .7rem; border-radius: 999px;
  background: var(--fx-pill-bg); color: var(--fx-pill-fg);
  border: 1px solid var(--fx-pill-border); box-shadow: var(--fx-pill-shadow);
  font: inherit; font-size: .95rem; font-weight: 700; line-height: 1.2; white-space: nowrap; cursor: pointer;
  -webkit-backdrop-filter: saturate(1.2) blur(8px); backdrop-filter: saturate(1.2) blur(8px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate3d(-50%, -10px, 0);
  transition: opacity var(--fx-ms) var(--fx-ease), transform var(--fx-ms) var(--fx-ease),
              visibility 0s linear var(--fx-ms), background-color 900ms var(--fx-ease), color 900ms ease,
              border-color 900ms var(--fx-ease), box-shadow 900ms var(--fx-ease);
}
.fx-pill.is-on {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translate3d(-50%, 0, 0);
  transition: opacity var(--fx-ms) var(--fx-ease), transform var(--fx-ms) var(--fx-ease),
              visibility 0s linear 0s, background-color 900ms var(--fx-ease), color 900ms ease,
              border-color 900ms var(--fx-ease), box-shadow 900ms var(--fx-ease);
}
.fx-pill:hover { background: var(--fx-pill-hover); }
.fx-pill:focus-visible { outline: 3px solid var(--fx-focus); outline-offset: 2px; }
.fx-pill-ico { display: inline-grid; grid-template-columns: repeat(2, 7px); gap: 2px; flex-shrink: 0; }
.fx-pill-ico > i { display: block; width: 7px; height: 7px; border-radius: 2px; background: currentColor; opacity: .9; }
.fx-pill-lbl { flex-shrink: 0; }
.fx-pill-cat {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--fx-pill-sub); font-weight: 600;
}
.fx-pill-cat::before { content: '·'; margin-right: .45rem; }
.fx-pill-cat[hidden] { display: none; }
html.high-contrast .fx-pill { border-width: 3px; -webkit-backdrop-filter: none; backdrop-filter: none; }
html.large-text .fx-pill { font-size: 1.05rem; }
@media (max-width: 379.98px) { .fx-pill-cat { display: none; } }
/* Con un esito aperto la pillola non copre mai «✕ Chiudi» (shield-focus.js, dodgeClose): se centrata arriverebbe sopra
   la sua colonna, si allinea a sinistra e si ferma prima, con un respiro fisso; i testi lunghi si accorciano con «…». */
.fx-pill.fx-dodge {
  left: var(--fx-dodge-left, .75rem);
  max-width: var(--fx-dodge-max, calc(100vw - 8rem));
  transform: translate3d(0, -10px, 0);
  gap: .4rem; padding: .4rem .75rem .4rem .6rem; font-size: .86rem;
}
html.large-text .fx-pill.fx-dodge { font-size: .95rem; }
.fx-pill.fx-dodge.is-on { transform: translate3d(0, 0, 0); }
.fx-pill.fx-dodge .fx-pill-lbl { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fx-pill.fx-dodge .fx-pill-cat { display: none; }   /* il nome della categoria è già nella testata del verdetto */
/* Vista dedicata della categoria con un esito aperto: su smartphone il nome della categoria (in alto a destra) non
   copre «✕ Chiudi»; resta il pulsante «← Torna alle categorie». */
@media (max-width: 639.98px) { html.fx-dodge-close.cv-open body > main > #cv-bar .cv-cat { display: none; } }
@media (prefers-reduced-motion: reduce) { .fx-pill, .fx-pill.is-on { transition: none; } }
@media print { .fx-pill { display: none !important; } }
html.printing-report .fx-pill { display: none !important; }

/* ---------- Zone di caricamento nei colori di Sabbia Calda ----------
   (Chiaro e Notte hanno già le loro tinte; qui l'azzurro freddo diventa avorio caldo con bordo sabbia.) */
html[data-ws-theme="sand"]:not(.high-contrast) #work-area .upload-zone { background-color: #FFFDF8; border-color: #C9B48F; }
html[data-ws-theme="sand"]:not(.high-contrast) #work-area .upload-zone:hover,
html[data-ws-theme="sand"]:not(.high-contrast) #work-area .upload-zone.is-dragging { background-color: #FFFBF4; border-color: #1E3A8A; }
html[data-ws-theme="sand"]:not(.high-contrast) #work-area .upload-zone.has-file { background-color: #F6EFE2; border-color: #1E3A8A; }
html[data-ws-theme="sand"]:not(.high-contrast) #panel-text.shot-mode > #zone-text { background-color: #FFFDF8; }
html[data-ws-theme="sand"]:not(.high-contrast) #panel-text.shot-mode > #zone-text:hover { background-color: #FFFBF4; }
html[data-ws-theme="sand"]:not(.high-contrast) #work-area .upload-zone .file-chip { background-color: #FAF6EE; border-color: #DDD0B8; }

/* ---------- Vista dedicata della categoria (shield-focus.js) ----------
   Al tocco su un'icona l'invito iniziale, le allerte e la griglia si richiudono (2200 ms su
   cubic-bezier(0.16, 1, 0.3, 1)) e il riquadro di verifica resta da solo in primo piano, con in cima il pulsante
   «← Torna alle categorie» sempre in vista. Le dimensioni del riquadro non cambiano (stessa larghezza su computer,
   stesse proporzioni su smartphone); i colori seguono il tema attivo tramite le variabili --fx-pill-*. */
html.cv-solo body > main > :is(#quick-guide, #sg-alerts, #tools-nav) { display: none !important; }

#cv-bar { display: none; }
html.cv-open body > main > #cv-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  position: -webkit-sticky; position: sticky; z-index: 30;
  top: var(--cv-top, calc(env(safe-area-inset-top, 0px) + 8px));
  pointer-events: none;   /* solo i due elementi ricevono i tocchi: il contenuto sotto resta utilizzabile */
}
.cv-back, .cv-cat {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: .5rem; min-width: 0; min-height: 44px;
  border-radius: 999px; border: 1px solid var(--fx-pill-border);
  background: var(--fx-pill-bg); box-shadow: var(--fx-pill-shadow);
  font: inherit; line-height: 1.2; white-space: nowrap;
  -webkit-backdrop-filter: saturate(1.2) blur(8px); backdrop-filter: saturate(1.2) blur(8px);
  transition: background-color 900ms var(--fx-ease), color 900ms ease, border-color 900ms var(--fx-ease), box-shadow 900ms var(--fx-ease);
}
.cv-back {
  flex: 0 0 auto; padding: .45rem 1.05rem .45rem .8rem;
  color: var(--fx-pill-fg); font-size: 1rem; font-weight: 800; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.cv-back:hover { background: var(--fx-pill-hover); }
.cv-back:active { transform: scale(.98); }
.cv-back:focus-visible { outline: 3px solid var(--fx-focus); outline-offset: 2px; }
.cv-arrow { font-size: 1.2em; line-height: 1; transform: translateY(-.04em); }
.cv-cat {
  flex: 0 1 auto; padding: .4rem .9rem .4rem .7rem;
  color: var(--fx-pill-sub); font-size: .92rem; font-weight: 700; box-shadow: none; cursor: default;
}
.cv-cat[hidden] { display: none; }
.cv-cat-ico { display: inline-flex; flex-shrink: 0; font-size: 1.2rem; color: var(--fx-pill-fg); }
.cv-cat-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Smartphone stretti: della categoria resta solo l'icona, così il pulsante «← Torna alle categorie» ha tutto lo spazio. */
@media (max-width: 359.98px) {
  .cv-cat { padding: .4rem .65rem; }
  .cv-cat-name { display: none; }
}
html.large-text .cv-back { font-size: 1.1rem; min-height: 48px; }
html.large-text .cv-cat { font-size: 1rem; }
html.high-contrast .cv-back, html.high-contrast .cv-cat { border-width: 3px; -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (prefers-reduced-motion: reduce) { .cv-back, .cv-cat { transition: none; } }
@media print { #cv-bar { display: none !important; } }
html.printing-report #cv-bar { display: none !important; }
