/* ==========================================================================
   WCAG-AAA-STANDARDS.CSS · REGOLAMENTO TECNICO DI ACCESSIBILITÀ WEB
   Linee Guida WCAG 2.2 Livello AAA Applicabili a Piattaforma Vendita Senza Video
   ========================================================================== */

/* ── 1.4.6 CONTRASTO RAFFORZATO (Almeno 7:1 normale, 4.5:1 grande) ── */
:root {
  --text-pure-white: #ffffff;
  --text-high-contrast: #f8fafc;
  --text-secondary-aaa: #cbd5e1; /* Luminanza rel: ~0.65 -> Contrasto > 12:1 su nero #000000 */
  --text-tertiary-aaa: #94a3b8;  /* Contrasto 8.2:1 su nero, oltre 7:1 */
  --accent-gold-aaa: #ffd700;    /* Luminanza rel: ~0.70 -> Contrasto 14.9:1 su nero */
  --accent-green-aaa: #00ff88;   /* Contrasto 15.2:1 su nero */
  --bg-deep-void: #000000;
  --bg-surface-card: #080c16;
  --focus-ring-color: #ffd700;
  --focus-ring-shadow: rgba(0, 0, 0, 0.95);
}

/* Corpo testo ad alto contrasto obbligatorio */
body {
  color: var(--text-high-contrast) !important;
  background-color: var(--bg-deep-void) !important;
}

/* Sostituzione dei grigi a basso contrasto con grigi certificati >= 7:1 su nero */
p, li, dd, dt, span, label, td, th {
  color: inherit;
}

.text-muted, .muted, small, .help-text, .field-desc, .footer-legal-p, .drawer-sub, .libri-sub-p {
  color: var(--text-secondary-aaa) !important;
}

/* ── 1.4.8 PRESENTAZIONE VISIVA ── */
/* Riga non oltre 80 caratteri, interlinea almeno 1.5, paragrafo staccato */
p, li, dd, blockquote {
  max-width: 75ch;
  line-height: 1.65 !important;
  margin-bottom: 1.25em;
  text-align: left !important; /* Nessun giustificato a blocco */
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3 !important;
  margin-bottom: 0.75em;
  text-align: left !important;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Testo ridimensionabile al 200% senza scroll orizzontale */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body, main, section, article, .container, .checkout-container, .libri-container {
  max-width: 100%;
  overflow-x: clip;
}

/* ── 2.4.1 SALTA AL CONTENUTO (Skip to Content) ── */
.skip-link {
  position: absolute;
  top: -120px;
  left: 20px;
  background: var(--accent-gold-aaa);
  color: #000000 !important;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 22px;
  border-radius: 8px;
  z-index: 999999;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.95);
  border: 2px solid #ffffff;
  transition: top 0.2s ease-in-out;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.skip-link:focus, .skip-link:focus-visible {
  top: 20px;
  outline: 3px solid #ffffff !important;
  outline-offset: 3px;
}

/* ── 2.4.12 & 2.4.13 FOCUS VISIBILE E NON OSCURATO ── */
:focus-visible {
  outline: 3px solid var(--focus-ring-color) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 5px var(--focus-ring-shadow) !important;
}

/* Evita che l'header sticky copra il focus o le ancore */
[id], section, article, h1, h2, h3, h4, .form-group, .protocol-card, .rail-pane {
  scroll-margin-top: 110px !important;
}

/* ── 2.5.5 TARGET SIZE (Almeno 44x44 pixel per tutti i comandi interattivi) ── */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="checkbox"],
input[type="radio"],
.btn,
.btn-card-buy,
.btn-libri-amz,
.btn-submit-order,
.site-menu-burger-btn,
.drawer-close-btn,
.rail-btn,
.breadcrumb-list a,
.drawer-links a {
  min-height: 44px;
  min-width: 44px;
}

/* Checkbox con target espanso tramite label */
.form-group label,
.order-bump-box label {
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ── 2.3.2 TRE FLASH E PREFERS-REDUCED-MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 2.4.8 BREADCRUMB POSIZIONALE PERCORSO ── */
.breadcrumb-nav {
  margin-bottom: 24px;
  padding: 10px 0;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 8px;
  font-size: 13.5px;
}

.breadcrumb-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  color: var(--text-secondary-aaa);
}

.breadcrumb-list a {
  color: var(--accent-gold-aaa);
  text-decoration: underline;
  padding: 4px 6px;
  border-radius: 4px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.breadcrumb-list a:hover {
  color: #ffffff;
}

.breadcrumb-list [aria-current="page"] {
  color: #ffffff;
  font-weight: 700;
}

/* ── 3.3.5 & 3.3.6 AIUTO E PREVENZIONE ERRORI FORM ── */
.form-group {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.field-help-text {
  font-size: 12.5px;
  color: var(--text-secondary-aaa);
  line-height: 1.5;
  margin-top: 2px;
}

.field-error-msg {
  font-size: 13px;
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
  border-left: 3px solid #ff6b6b;
  padding: 8px 12px;
  border-radius: 4px;
  margin-top: 6px;
  display: none;
  font-weight: 600;
}

.form-control[aria-invalid="true"] {
  border-color: #ff6b6b !important;
  background-color: rgba(255, 107, 107, 0.05) !important;
}

.form-control[aria-invalid="true"]:focus-visible {
  outline: 3px solid #ff6b6b !important;
}

/* Box di revisione pre-pagamento (Criterio 3.3.6) */
.order-review-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.order-review-modal.active {
  display: flex;
}

.order-review-card {
  background: #0b0f19;
  border: 2px solid var(--accent-gold-aaa);
  border-radius: 12px;
  max-width: 580px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
  color: #ffffff;
}
