/*
 * Nova — foglio di stile unico, filosofia CSS Zen Garden:
 * HTML semantico + presentazione 100% qui, via design token (custom properties).
 * Cambiare tema = cambiare i token sotto [data-theme], senza toccare il markup.
 * Mobile-first (utenti da WebView WhatsApp). No utility-class.
 */

/* ---- Design token (tema "nova") ---- */
:root[data-theme="nova"] {
  --bg: #F5F2EC;
  --surface: #FFFFFF;
  --ink: #16243A;
  --muted: #51596A;
  --accent: #E0922F;
  --accent-ink: #16243A;
  --accent-hover: #C2761B;
  --border: #E6E0D4;
  --danger: #C0392B;
  --radius: 14px;
  --font-display: "Archivo", system-ui, sans-serif;
  --font-text: "IBM Plex Sans", system-ui, sans-serif;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  font: 16px/1.5 var(--font-text);
  color: var(--ink);
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem;
}
h1 { font-family: var(--font-display); font-weight: 800; letter-spacing: -.01em; }
a { color: var(--accent-hover); }

/* ---- Card centrale (form/messaggi) ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(22, 36, 58, .08);
  padding: clamp(1.5rem, 5vw, 2.25rem);
  width: 100%;
  max-width: 380px;
}
.card__eyebrow {
  font-size: .8rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-hover); margin: 0 0 .5rem;
}
.card__title { font-size: 1.35rem; margin: 0 0 .4rem; }
.card__lead { color: var(--muted); margin: 0 0 1.25rem; }

/* ---- Form ---- */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .95rem; }
.field input {
  width: 100%; padding: .8rem 1rem; font-size: 1rem; font-family: inherit;
  color: var(--ink); background: #FBFAF7;
  border: 1px solid #D8D2C4; border-radius: 10px; outline: none;
  min-height: 44px;
}
.field input:focus { border-color: var(--accent); background: var(--surface); }
.field__error { color: var(--danger); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  width: 100%; min-height: 48px; padding: .9rem 1.25rem;
  font: 600 1rem var(--font-text); cursor: pointer; text-decoration: none;
  border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }

.note { font-size: .8rem; color: var(--muted); margin-top: 1rem; }

/* ---- Viewer risorsa (PDF/video/audio) ---- */
body:has(.viewer-main) { display: block; padding: 0; place-items: initial; }
.viewer-main { width: 100%; display: flex; flex-direction: column; gap: .75rem;
  padding: 1rem clamp(.5rem, 3vw, 1.5rem); min-height: 100svh; box-sizing: border-box; }
.viewer-head { text-align: center; }
.viewer-head .card__title { font-size: 1.15rem; margin: 0; }
.viewer {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 4px 16px rgba(22,36,58,.08);
}
iframe.viewer, video.viewer { flex: 1; height: auto; min-height: calc(100svh - 90px); display: block; }
.viewer--audio { min-height: 0; height: auto; padding: 1rem; }

/* PDF.js: pagine canvas fit-to-width, scroll verticale */
.pdf { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pdf__page-wrap { position: relative; max-width: 900px; }
.pdf__page { display: block; width: 100%; height: auto;
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 2px 10px rgba(22,36,58,.10); }
/* layer link cliccabili sopra il canvas (annotazioni Link del PDF) */
.pdf__links { position: absolute; inset: 0; }
.pdf__links a { position: absolute; display: block; }
.pdf__loading { color: var(--muted); padding: 2rem; text-align: center; }

/* ====== Home Nova (vetrina, da Claude Design) ====== */
body:has(.nova) { display: block; padding: 0; place-items: initial; }
.nova { display: flex; flex-direction: column; min-height: 100svh; }
.nova a { text-decoration: none; }

.nv-header { position: sticky; top: 0; z-index: 50; background: rgba(245,242,236,.86);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nv-bar { max-width: 1180px; margin: 0 auto; padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.nv-logo { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); }
.nv-badge { width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--accent);
  display: grid; place-items: center; font: 800 19px var(--font-display); }
.nv-word { font: 800 20px var(--font-display); letter-spacing: -.01em; }
.nv-nav { display: flex; gap: 26px; flex-wrap: wrap; }
.nv-nav a { font-weight: 600; color: #3A4456; }

.nv-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent-hover); margin: 0 0 20px; }
.nv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.nv-hero { max-width: 1180px; margin: 0 auto; padding: clamp(40px,6vw,84px) 28px clamp(36px,5vw,56px); }
.nv-h1 { font: 800 clamp(34px,4.8vw,58px)/1.04 var(--font-display); letter-spacing: -.02em; margin: 0 0 20px; }
.nv-lead { font-size: 18px; line-height: 1.6; color: var(--muted); max-width: 560px; margin: 0 0 22px; }
.nv-trust { font-size: 14px; color: var(--muted); }

.nv-strip { border-block: 1px solid var(--border); background: #F0ECE2; }
.nv-strip__label { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #8A8472; }
.nv-strip > * { max-width: 1180px; margin: 0 auto; }
.nv-strip { padding: 24px 28px; text-align: center; }
.nv-strip__names { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; margin-top: 10px;
  font: 700 18px var(--font-display); color: #A7A292; }

.nv-section { max-width: 1180px; margin: 0 auto; padding: clamp(48px,6vw,80px) 28px; }
.nv-section__head { margin-bottom: 30px; }
.nv-h2 { font: 800 clamp(26px,3vw,36px) var(--font-display); letter-spacing: -.01em; margin: 0 0 8px; }
.nv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 22px; }
.nv-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; color: var(--ink);
  transition: transform .15s, box-shadow .15s; }
.nv-card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px rgba(22,36,58,.13); }
.nv-card__cover { color: #fff; padding: 20px; min-height: 150px; display: flex; flex-direction: column;
  justify-content: space-between; }
.nv-card__cat { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.nv-card__title { font: 800 20px/1.14 var(--font-display); }
.nv-card__body { padding: 20px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.nv-card__body p { margin: 0; flex: 1; color: var(--muted); font-size: 15px; line-height: 1.5; }
.nv-chip { align-self: flex-start; font-size: 14px; font-weight: 600; color: var(--ink);
  background: #FBEAD2; padding: 7px 13px; border-radius: 8px; }

.nv-steps { max-width: 1180px; margin: 0 auto; padding: 0 28px clamp(48px,6vw,72px);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 36px; }
.nv-step__n { font: 800 28px var(--font-display); color: var(--accent); display: block; margin-bottom: 10px; }
.nv-steps h3 { font: 700 19px var(--font-display); margin: 0 0 8px; }
.nv-steps p { font-size: 15px; line-height: 1.6; color: var(--muted); margin: 0; }

.nv-footer { background: var(--ink); color: #fff; margin-top: auto;
  padding: clamp(36px,5vw,56px) 28px; text-align: center; }
.nv-footer p { color: #AEB6C4; max-width: 460px; margin: 12px auto 0; font-size: 14px; line-height: 1.6; }
.nv-logo--light { justify-content: center; color: #fff; }
.nv-logo--light .nv-badge { background: var(--accent); color: var(--ink); }
.nv-footer__legal { color: #7E8798; font-size: 13px; }
.nv-footer__legal a { color: #C7CEDA; }

/* ====== Admin (plain Rails) ====== */
body:has(.admin) { display: block; padding: 2rem 1rem; place-items: initial; }
.admin { max-width: 820px; margin: 0 auto; }
.admin h1 { font: 800 1.5rem var(--font-display); }
.admin__notice { background: #FBEAD2; color: var(--accent-hover); padding: .6rem 1rem; border-radius: 8px; }
.admin__table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.admin__table th, .admin__table td { border: 1px solid var(--border); padding: .6rem .8rem; text-align: left; }
.admin__table th { background: #F0ECE2; }
.admin .field { max-width: 480px; }
.admin .btn { max-width: 240px; }
.btn--danger { background: #C0392B; color: #fff; border: 0; padding: .35rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.badge--chat { background: #D5F5E3; color: #1E8449; }
.badge--multi { background: #FBEAD2; color: var(--accent-hover); }
.admin__table .row--has-chat td { background: #FCFDF6; }
