/* ============================================================
   Calcolatore "Quanto butti?" — estende styles.css e blog.css
   ============================================================ */

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.calc-main { max-width: 760px; margin: 0 auto; padding: 0 20px 80px; }

.calc-hero { text-align: center; margin: 28px auto 36px; }
.calc-hero h1 { font-size: clamp(2.1rem, 5.2vw, 3.2rem); }
.calc-hero h1 em { font-style: normal; color: var(--primary); }

/* ---------- scheda del calcolatore ---------- */

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: clamp(22px, 4vw, 36px);
  box-shadow: var(--shadow-md);
}

.calc-q { border: 0; padding: 0; margin: 0 0 30px; }
.calc-q legend {
  font-weight: 700;
  font-size: 1.08rem;
  line-height: 1.35;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.calc-q legend small { font-weight: 500; color: var(--ink-3); font-size: 0.85rem; }

.calc-n {
  flex: none;
  width: 26px; height: 26px;
  display: inline-grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 800;
  transform: translateY(2px);
}

/* opzioni: pill selezionabili, target ≥44px */
.calc-opts { display: flex; flex-wrap: wrap; gap: 10px; }
.calc-opts label { position: relative; cursor: pointer; }
.calc-opts input { position: absolute; opacity: 0; width: 0; height: 0; }
.calc-opts span {
  display: block;
  min-width: 56px;
  min-height: 46px;
  padding: 12px 20px;
  border: 2px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--bg);
  font-weight: 600;
  font-size: 0.97rem;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.calc-opts label:hover span { border-color: var(--primary); }
.calc-opts input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.calc-opts input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 3px; }
.calc-opts-wide span { min-width: auto; }

/* slider della spesa */
.calc-spend {
  display: block;
  font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
input[type="range"] {
  width: 100%;
  height: 34px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px; background: var(--surface-alt);
}
input[type="range"]::-moz-range-track {
  height: 8px; border-radius: 999px; background: var(--surface-alt);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px; height: 30px; margin-top: -11px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: var(--shadow-cta);
}
input[type="range"]::-moz-range-thumb {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: var(--shadow-cta);
}
input[type="range"]:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; border-radius: 999px; }

.calc-hint { font-size: 0.86rem; color: var(--ink-3); margin-top: 4px; }

.calc-go { width: 100%; margin-top: 6px; }

/* ---------- risultato ---------- */

.calc-result {
  /* l'header sticky copriva il numero grande all'arrivo dello scroll */
  scroll-margin-top: 96px;
  margin-top: 34px;
  padding-top: 32px;
  border-top: 2px dashed var(--border-strong);
  animation: calcIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.calc-result:focus { outline: none; }

@keyframes calcIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.calc-result-label { text-align: center; color: var(--ink-2); font-size: 1rem; }
.calc-euro {
  text-align: center;
  font-size: clamp(3.2rem, 12vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.02;
  color: var(--primary);
  margin: 6px 0 10px;
}
.calc-result-sub { text-align: center; color: var(--ink-2); font-size: 0.98rem; margin-bottom: 26px; }

/* barra di confronto con la media */
.calc-bar { margin-bottom: 12px; }
.calc-bar-track {
  position: relative;
  height: 14px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
/* tacca al 50% = media italiana */
.calc-bar-track::after {
  content: "";
  position: absolute; left: 50%; top: -4px; bottom: -4px;
  width: 3px; background: var(--ink); border-radius: 2px;
}
.calc-bar-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.calc-bar-fill.over { background: var(--primary); }

.calc-bar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-3);
  margin-top: 8px;
}

.calc-compare {
  text-align: center;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 30px;
}

/* leve personalizzate */
.calc-levers h3 { font-size: 1.15rem; margin-bottom: 14px; }
.calc-levers ul { list-style: none; display: grid; gap: 12px; margin-bottom: 32px; }
.calc-levers li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.lever-t { font-weight: 700; margin-bottom: 5px; }
.lever-d { color: var(--ink-2); font-size: 0.93rem; line-height: 1.5; margin-bottom: 8px; }
.calc-levers a { font-weight: 700; font-size: 0.9rem; color: var(--primary-dark); text-decoration: none; }
.calc-levers a:hover { text-decoration: underline; }

/* CTA verso l'app */
.calc-cta {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--r-xl);
  padding: 30px 26px;
  text-align: center;
  margin-bottom: 20px;
}
.calc-cta-title { font-size: 1.32rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 10px; line-height: 1.2; }
.calc-cta p { color: rgba(255,255,255,0.9); font-size: 0.98rem; line-height: 1.55; max-width: 42ch; margin: 0 auto 20px; }
.calc-cta .btn { background: #fff; color: var(--ink); box-shadow: var(--shadow-md); }
.calc-cta .btn:hover { background: var(--bg); }
.calc-cta-note { font-size: 0.84rem !important; margin: 14px 0 0 !important; color: rgba(255,255,255,0.8) !important; }

.calc-share { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- metodo e testo sotto ---------- */

.calc-method { margin-top: 56px; }
.calc-method h2 { font-size: 1.5rem; margin: 40px 0 14px; scroll-margin-top: 90px; }
.calc-method p { margin-bottom: 16px; line-height: 1.7; color: #3D3129; }
.calc-method ol, .calc-method ul { margin: 0 0 18px; padding-left: 24px; }
.calc-method li { margin-bottom: 9px; line-height: 1.6; color: #3D3129; }
.calc-method li::marker { color: var(--primary); font-weight: 700; }
.calc-method a { color: var(--primary-dark); font-weight: 600; text-underline-offset: 3px; }
.calc-source { font-size: 0.88rem; color: var(--ink-3); }
.calc-source a { color: var(--ink-2); }

@media (max-width: 520px) {
  .calc-opts { gap: 8px; }
  .calc-opts span { padding: 12px 16px; font-size: 0.92rem; }
  .calc-share .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .calc-result { animation: none; }
  .calc-bar-fill { transition: none; }
}

/* ---------- tabelle dati (pagina dati) ---------- */

.table-wrap { overflow-x: auto; margin: 0 0 26px; }

.calc-method table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: 0.95rem;
  min-width: 420px;
}
.calc-method caption {
  caption-side: top;
  text-align: left;
  font-size: 0.82rem;
  color: var(--ink-3);
  padding: 0 0 8px;
  line-height: 1.4;
}
.calc-method thead { background: var(--surface-alt); }
.calc-method th, .calc-method td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.calc-method th { font-weight: 700; color: var(--ink); }
.calc-method tr:last-child td { border-bottom: none; }
.calc-method tbody tr:hover { background: rgba(222, 91, 52, 0.04); }
