/*
 * Calcolatore Edify - stile pubblico.
 * I colori vengono dai token --e-* di edify-theme.css (Aery, Sepia, Blue Marine);
 * i valori qui sotto sono solo il ripiego se il tema non è caricato.
 */
:root {
  --e-bg: #f7fafc; --e-surface: #ffffff; --e-surface-2: #eef4f9;
  --e-text: #1e2b37; --e-muted: #5f7184; --e-border: rgba(30, 43, 55, .12);
  --e-accent: #2f7bd1; --e-accent-hover: #1f63b3; --e-accent-soft: #e8f1fb; --e-accent-text: #ffffff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px -8px rgba(0, 0, 0, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wa: #1f8f4e;
  --wa-text: #1b7a43;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 1rem/1.6 var(--font);
  background: var(--e-bg);
  color: var(--e-text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--e-accent); }
a:hover { color: var(--e-accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
:focus-visible { outline: 3px solid var(--e-accent); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 50;
  background: var(--e-surface); color: var(--e-text); padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

/* ---- testata */
.topbar { border-bottom: 1px solid var(--e-border); background: var(--e-surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--e-text); }
.brand:hover { color: var(--e-text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--e-accent); color: var(--e-accent-text); font-weight: 700; font-size: 1.1rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: var(--e-muted); font-size: .8rem; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  text-decoration: none; color: var(--e-muted); padding: 6px 10px; border-radius: 999px; font-size: .92rem;
}
.topnav a:hover { color: var(--e-text); background: var(--e-surface-2); }

/* ---- intro */
.hero { padding: 28px 0 8px; max-width: 760px; }
.eyebrow { margin: 0 0 6px; color: var(--e-accent); font-weight: 600; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; }
.hero h1 { font-size: clamp(1.6rem, 4.6vw, 2.4rem); letter-spacing: -.02em; }
.intro { color: var(--e-muted); margin: 10px 0 0; font-size: 1.02rem; }

.banner {
  margin: 18px 0 0; padding: 12px 16px; border-radius: var(--radius-sm);
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
}
.banner-test { background: #fff3cd; color: #5c4400; border: 1px solid #f0d47a; }
.banner-test span { font-size: .9rem; }
.banner-error { background: #fde8e8; color: #7f1d1d; border: 1px solid #f5b5b5; }

/* ---- griglia */
.calc-grid { display: grid; gap: 24px; margin: 22px 0 40px; align-items: start; }
@media (min-width: 900px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; }
  .summary { position: sticky; top: 16px; }
}

/* ---- servizi */
.cat { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.cat legend { padding: 0; margin: 0 0 10px; width: 100%; }
.cat-title { font-size: 1.15rem; padding-bottom: 6px; border-bottom: 2px solid var(--e-accent-soft); }

.svc {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "check main price" ". qty qty";
  gap: 4px 12px; align-items: start;
  background: var(--e-surface); border: 1px solid var(--e-border); border-radius: var(--radius);
  padding: 14px 14px; margin-bottom: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.svc:hover { border-color: color-mix(in srgb, var(--e-accent) 45%, var(--e-border)); }
.svc.is-on { border-color: var(--e-accent); box-shadow: 0 0 0 1px var(--e-accent); }
.svc-check { grid-area: check; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--e-accent); cursor: pointer; }
.svc-main { grid-area: main; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.svc-name { font-weight: 600; }
.svc-desc { color: var(--e-muted); font-size: .9rem; line-height: 1.45; }
.svc-price { grid-area: price; text-align: right; display: flex; flex-direction: column; line-height: 1.25; white-space: nowrap; }
.svc-price strong { font-size: 1rem; }
.svc-price span { color: var(--e-muted); font-size: .8rem; }
.svc-qty { grid-area: qty; display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.svc-qty label { font-size: .88rem; color: var(--e-muted); }
.svc-qty input {
  width: 110px; font: inherit; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--e-border); background: var(--e-bg); color: var(--e-text);
}
.svc-qty input:focus { border-color: var(--e-accent); }
.js .svc:not(.is-on) .svc-qty { opacity: .7; }

@media (max-width: 480px) {
  .svc { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "check main" ". price" ". qty"; }
  .svc-price { text-align: left; flex-direction: row; gap: 8px; align-items: baseline; }
}

/* ---- riepilogo */
.summary-card {
  background: var(--e-surface); border: 1px solid var(--e-border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.summary h2 { font-size: 1.15rem; margin-bottom: 12px; }
.print-head { display: none; }
.summary-empty { color: var(--e-muted); margin: 0 0 12px; font-size: .95rem; }
.lines { list-style: none; margin: 0 0 12px; padding: 0; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--e-border); }
.line-name { min-width: 0; }
.line-name small { display: block; color: var(--e-muted); font-size: .8rem; }
.line-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.totals { margin: 0; }
.totals .row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.totals dt { color: var(--e-muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-discount dd, .row-discount dt { color: var(--wa-text); font-weight: 600; }
html[data-edify-theme="bluemarine"] { --wa-text: #6fdba2; }
.row-total { border-top: 2px solid var(--e-text); margin-top: 6px; padding-top: 10px !important; }
.row-total dt { color: var(--e-text); font-weight: 700; }
.row-total dd { font-size: 1.45rem; font-weight: 800; letter-spacing: -.01em; }
.min-note { font-size: .82rem; color: var(--e-muted); margin: 8px 0 0; }
.note { font-size: .85rem; color: var(--e-muted); margin: 14px 0; line-height: 1.5; }

.actions { display: grid; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 .95rem/1.2 var(--font); padding: 11px 16px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-block { width: 100%; margin-top: 14px; }
.btn-primary { background: var(--e-accent); color: var(--e-accent-text); }
.btn-primary:hover { background: var(--e-accent-hover); color: var(--e-accent-text); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: #17733e; color: #fff; }
.btn-outline { background: transparent; color: var(--e-text); border-color: var(--e-border); }
.btn-outline:hover { border-color: var(--e-accent); color: var(--e-text); }

.js .js-hide { display: none; }
.js-only { display: none; }
.js .js-only { display: inline-flex; }

/* ---- barra mobile */
.mobilebar { display: none; }
@media (max-width: 899px) {
  .mobilebar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--e-surface); border-top: 1px solid var(--e-border);
    box-shadow: 0 -6px 20px -10px rgba(0, 0, 0, .25);
  }
  .mobilebar-total { display: flex; flex-direction: column; line-height: 1.2; }
  .mobilebar-total span { font-size: .78rem; color: var(--e-muted); }
  .mobilebar-total strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
  .mobilebar .btn { padding: 9px 16px; }
  body { padding-bottom: 76px; }
}

/* ---- piè di pagina */
.site-footer { border-top: 1px solid var(--e-border); padding: 22px 0 28px; color: var(--e-muted); font-size: .88rem; }
.site-footer p { margin: 4px 0; }

/* ---- stampa / PDF: solo il riepilogo */
@media print {
  @page { margin: 16mm; }
  body { background: #fff !important; color: #000 !important; padding: 0 !important; font-size: 11pt; }
  .edify-strip, .topbar, .hero, .banner, .services, .mobilebar, .site-footer, .actions, .btn, .skip-link { display: none !important; }
  .calc-grid { display: block; margin: 0; }
  .summary { position: static; }
  .summary-card { border: 0; box-shadow: none; padding: 0; background: #fff; color: #000; }
  .print-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #000; font-size: 9.5pt; }
  .print-head strong { font-size: 14pt; }
  .summary h2 { font-size: 13pt; }
  .totals dt, .line-name small, .note, .min-note { color: #333 !important; }
  .row-total { border-top-color: #000; }
  .row-discount dd, .row-discount dt { color: #000; }
  a { color: #000; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
html { scroll-behavior: smooth; }

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