/* ============================================================
   VECCHIO CONIO — Design System "Carta & Inchiostro"
   Light, leggibile, pensato per integrare pubblicità
   ============================================================ */

:root {
  /* superfici */
  --bg: #F7F3EA;          /* crema caldo */
  --bg-alt: #FBF9F3;
  --surface: #FFFFFF;
  --surface-2: #F2ECDF;
  --border: #E5DCCB;
  --border-strong: #D2C4A9;

  /* testo */
  --ink: #1C1A17;         /* quasi nero, caldo */
  --ink-2: #4F4A40;
  --muted: #877E6C;

  /* brand */
  --accent: #0F6E5C;      /* verde conio */
  --accent-dark: #0A5142;
  --accent-soft: #E1EFEB;
  --gold: #B07D26;        /* oro per logo / dettagli */

  /* semantica: perdita (rosso) / guadagno (verde) */
  --loss: #C0392B;
  --loss-soft: #FBEBE8;
  --gain: #1E8E4E;
  --gain-soft: #E7F4EC;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 28px rgba(40,30,10,0.08);
  --shadow-lg: 0 20px 48px rgba(40,30,10,0.12);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--ink); }
.logo-symbol { font-family: var(--font-display); font-size: 1.7rem; color: var(--gold); line-height: 1; }
.logo-text { font-size: 1.05rem; font-weight: 400; letter-spacing: 0.01em; }
.logo-text strong { font-weight: 700; }

.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color var(--transition); }
.site-nav a:hover { color: var(--accent); }

main { flex: 1; }

/* ── Hero ── */
.hero { text-align: center; padding: 3rem 1.5rem 1.5rem; }
.hero-eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.9rem;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 900; line-height: 1.05; letter-spacing: -0.02em;
  color: var(--ink); margin-bottom: 0.9rem;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-subtitle { font-size: 1.05rem; color: var(--ink-2); max-width: 560px; margin: 0 auto; font-weight: 400; }

/* ── Layout a colonne (contenuto + pubblicità laterale) ── */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.5rem;
  align-items: start;
}
.layout-main { min-width: 0; }
.layout-aside { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 1.5rem; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .layout-aside { position: static; flex-direction: row; flex-wrap: wrap; }
}

/* ── Spazi pubblicitari ── */
.ad-slot {
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--bg-alt) 10px, var(--bg-alt) 20px);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  min-height: 90px;
}
.ad-banner { width: 100%; min-height: 100px; margin-bottom: 1.25rem; }
.ad-inline { width: 100%; min-height: 120px; margin: 1.5rem 0; }
.ad-side { width: 100%; min-height: 600px; flex: 1; }
@media (max-width: 980px) { .ad-side { min-height: 100px; } }

/* ── Due porte ── */
.door-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.door-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem;
  text-align: left; padding: 1.4rem; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all var(--transition); box-shadow: var(--shadow);
}
.door-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.door-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.door-icon { font-size: 1.9rem; line-height: 1; }
.door-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.door-desc { font-size: 0.82rem; color: var(--ink-2); line-height: 1.5; }

/* ── Intro guida del pannello ── */
.panel-intro {
  font-size: 0.95rem; color: var(--ink-2); line-height: 1.6;
  margin-bottom: 1rem; padding: 0 0.25rem;
}
.panel-intro strong { color: var(--ink); }
.panel-intro em { font-style: normal; color: var(--accent); font-weight: 600; }

/* ── Card calcolo ── */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calc-form { padding: 1.5rem; }

.seg-label, .field label, .wage-section-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}

.seg-toggle { display: flex; gap: 0.5rem; margin: 0.6rem 0 1.1rem; }
.seg-btn {
  flex: 1; padding: 0.65rem 1rem; background: var(--bg-alt);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--ink-2); font-family: var(--font-body); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.seg-btn:hover { border-color: var(--accent); }
.seg-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.form-row { display: grid; gap: 1rem; margin-bottom: 1rem; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field input, .field select {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem; color: var(--ink);
  font-family: var(--font-body); font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none; -webkit-appearance: none;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,110,92,0.14);
}
.field input::placeholder { color: var(--muted); }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23877E6C' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.9rem center; padding-right: 2.4rem; cursor: pointer;
}

.btn-calc {
  width: 100%; padding: 0.95rem 2rem; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm); font-family: var(--font-body);
  font-size: 1rem; font-weight: 700; letter-spacing: 0.02em; cursor: pointer;
  transition: background var(--transition), transform var(--transition); margin-top: 0.5rem;
}
.btn-calc:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-calc:active { transform: translateY(0); }

.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.7rem; text-align: center; }

/* ── Grafico ── */
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1rem; margin-top: 1.25rem;
}
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin-bottom: 0.25rem; flex-wrap: wrap; }
.chart-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.chart-hint {
  font-size: 0.74rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 100px; padding: 0.28rem 0.7rem; white-space: nowrap;
}
.chart-canvas-wrap { position: relative; height: 300px; margin-top: 0.5rem; touch-action: pan-y; }
.chart-loading { padding: 2rem; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ── Pannello dettaglio (click sul grafico) ── */
.detail { animation: fadeIn 0.3s ease; margin-top: 1.25rem; }
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.detail-headline { text-align: center; padding: 1.6rem 1.25rem 1.25rem; }
.detail-from { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.2rem; }
.detail-amount-small { font-family: var(--font-display); font-size: clamp(1.3rem,3.5vw,1.9rem); font-weight: 700; color: var(--ink-2); }
.detail-arrow { display: block; font-size: 1.3rem; color: var(--border-strong); margin: 0.35rem 0; }
.detail-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.2rem; }
.detail-amount-big {
  font-family: var(--font-display); font-size: clamp(2.3rem, 7vw, 3.8rem);
  font-weight: 900; color: var(--accent); line-height: 1; letter-spacing: -0.02em;
  animation: countUp 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes countUp { from { opacity: 0; transform: scale(0.96);} to { opacity:1; transform: scale(1);} }
.detail-subamount { font-size: 0.95rem; color: var(--ink-2); margin-top: 0.4rem; }

/* badge variazione (perdita/guadagno) */
.delta {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.8rem; padding: 0.4rem 0.9rem; border-radius: 100px;
  font-size: 0.92rem; font-weight: 700;
}
.delta.loss { background: var(--loss-soft); color: var(--loss); }
.delta.gain { background: var(--gain-soft); color: var(--gain); }
.delta .arrow { font-size: 0.85em; }

/* due letture */
.reading-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 0 1.25rem 1rem; }
.reading-card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem 1.1rem; }
.reading-tag { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.45rem; }
.reading-card p { font-size: 0.86rem; color: var(--ink-2); line-height: 1.55; }
.reading-card strong { color: var(--ink); }

/* confronto prezzo bene */
.price-compare { display: flex; align-items: center; justify-content: center; gap: 1.4rem; padding: 0.5rem 0 0.25rem; }
.price-col { text-align: center; }
.price-year { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.25rem; }
.price-value { font-family: var(--font-display); font-size: clamp(1.5rem,4.5vw,2.4rem); font-weight: 700; color: var(--ink-2); line-height: 1; }
.price-value.price-now { color: var(--accent); }
.price-arrow { font-size: 1.5rem; color: var(--border-strong); }

/* ore di lavoro (ponte) */
.workhours {
  margin: 0 1.25rem 1.25rem; padding: 1.1rem 1.3rem;
  background: var(--accent-soft); border: 1px solid rgba(15,110,92,0.2);
  border-radius: var(--radius-sm); display: flex; gap: 1rem; align-items: center;
}
.workhours-icon { font-size: 1.8rem; line-height: 1; }
.workhours-main { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.hours-compare { font-size: 0.95rem; color: var(--ink); margin-top: 0.25rem; }
.hours-compare .sep { color: var(--accent); margin: 0 0.45rem; }
.workhours-note { font-size: 0.72rem; color: var(--ink-2); margin-top: 0.3rem; }

/* hint ponte */
.bridge-hint {
  margin: 0 1.25rem 1.25rem; padding: 0.8rem 1rem; background: var(--bg-alt);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  font-size: 0.82rem; color: var(--ink-2);
}
.bridge-hint strong { color: var(--accent); }
.bridge-hint.active { border-style: solid; border-color: rgba(30,142,78,0.35); background: var(--gain-soft); color: var(--ink); }

/* fonte */
.detail-source {
  padding: 0.9rem 1.25rem 1.1rem; font-size: 0.72rem; color: var(--muted);
  border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.2rem;
}
.badge-estimate {
  align-self: flex-start; background: var(--loss-soft); color: var(--loss);
  border-radius: 4px; padding: 0.1rem 0.5rem; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.2rem;
}

/* condivisione */
.share-row { display: flex; gap: 0.6rem; padding: 0 1.25rem 1.25rem; }
.btn-share {
  flex: 1; padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong); background: var(--surface);
  color: var(--ink-2); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition);
}
.btn-share:hover { border-color: var(--accent); color: var(--accent); }
.btn-share.copied { border-color: var(--gain); color: var(--gain); }

/* errore */
.detail-error { padding: 1.5rem; text-align: center; color: var(--loss); font-size: 0.9rem; }

/* ── Info cards ── */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.5rem; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.info-card-icon { font-size: 1.4rem; margin-bottom: 0.6rem; }
.info-card h3 { font-size: 0.92rem; font-weight: 700; margin-bottom: 0.4rem; color: var(--ink); }
.info-card p { font-size: 0.8rem; color: var(--ink-2); line-height: 1.55; }

/* ── Testo SEO ── */
.seo-text { margin-top: 1.5rem; padding: 1.4rem 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.seo-text h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: var(--ink); margin-bottom: 0.7rem; }
.seo-text p { font-size: 0.88rem; color: var(--ink-2); line-height: 1.7; margin-bottom: 0.7rem; }
.seo-text p:last-child { margin-bottom: 0; }
.seo-text strong { color: var(--ink); font-weight: 600; }

/* ── Banner cookie ── */
.cookie-banner {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 200;
  max-width: 720px; margin: 0 auto;
  background: var(--ink); color: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 1rem 1.2rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.cookie-text { flex: 1; min-width: 220px; font-size: 0.85rem; line-height: 1.5; color: #efeae0; }
.cookie-text a { color: #8fd6c4; text-decoration: underline; }
.cookie-actions { display: flex; gap: 0.6rem; }
.cookie-btn { padding: 0.55rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 700; cursor: pointer; border: 1.5px solid transparent; }
.cookie-reject { background: transparent; border-color: rgba(255,255,255,0.35); color: #fff; }
.cookie-reject:hover { border-color: #fff; }
.cookie-accept { background: var(--accent); color: #fff; }
.cookie-accept:hover { background: var(--accent-dark); }
@media (max-width: 600px) { .cookie-actions { width: 100%; } .cookie-btn { flex: 1; } }

/* ── Pagina legale (privacy/cookie) ── */
.legal { max-width: 720px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.legal h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 900; line-height: 1.1; margin-bottom: 0.4rem; }
.legal .legal-updated { color: var(--muted); font-size: 0.85rem; margin-bottom: 2rem; }
.legal section { margin-top: 1.8rem; }
.legal h2 { font-size: 1.12rem; font-weight: 700; color: var(--accent); margin-bottom: 0.6rem; }
.legal h3 { font-size: 0.98rem; font-weight: 700; color: var(--ink); margin: 1rem 0 0.4rem; }
.legal p { color: var(--ink-2); line-height: 1.8; margin-bottom: 0.7rem; }
.legal ul { color: var(--ink-2); line-height: 1.75; margin: 0 0 0.9rem 1.2rem; }
.legal li { margin-bottom: 0.5rem; }
.legal strong { color: var(--ink); }
.legal a { color: var(--accent); text-decoration: underline; }
.legal .legal-back { margin-top: 2.5rem; font-weight: 600; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 1.5rem; text-align: center; font-size: 0.76rem; color: var(--muted); line-height: 1.8;
}
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1.25rem; margin-bottom: 0.9rem; }
.footer-nav a { color: var(--ink-2); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 980px) {
  .layout { padding: 1rem; }
  .info-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .site-header { padding: 0.85rem 1rem; }
  .hero { padding: 2rem 1rem 0.5rem; }
  .hero-subtitle { font-size: 0.98rem; }
  .layout { padding: 0.85rem; gap: 1rem; }

  /* Le due porte restano affiancate ma più compatte: scelta sempre visibile */
  .door-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .door-card { padding: 0.9rem 0.85rem; }
  .door-icon { font-size: 1.5rem; }
  .door-title { font-size: 0.95rem; line-height: 1.2; }
  .door-desc { display: none; }

  .form-row-2 { grid-template-columns: 1fr; }
  .reading-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .workhours { flex-direction: column; text-align: center; }
  .calc-form { padding: 1.1rem; }

  /* Target touch più comodi */
  .seg-btn { padding: 0.8rem 0.6rem; }
  .field input, .field select { padding: 0.85rem 0.9rem; font-size: 16px; }
  .btn-calc { padding: 1.05rem 1.5rem; }

  /* Grafico: un po' più basso ma con tap area piena */
  .chart-card { padding: 1rem 0.9rem 0.85rem; }
  .chart-canvas-wrap { height: 260px; }
  .chart-title { font-size: 1.05rem; }

  /* Dettaglio più arioso */
  .detail-headline { padding: 1.3rem 1rem 1rem; }
  .price-compare { gap: 1rem; }
  .reading-grid, .share-row, .price-compare { padding-left: 1rem; padding-right: 1rem; }
  .workhours, .bridge-hint { margin-left: 1rem; margin-right: 1rem; }
}

@media (max-width: 380px) {
  .door-title { font-size: 0.86rem; }
  .seg-toggle { flex-direction: column; }
}
