/* =========================================================
   NRG Company — Integrazioni tema WordPress
   Estende assets/style.css (design system) con i componenti
   necessari all'integrazione con WordPress: menu wp_nav_menu
   con sottomenu, contenuto "prose", area documenti, sedi, news.
   ========================================================= */

/* ---------- Nav come <ul> di wp_nav_menu ---------- */
.nav, .nav ul { list-style: none; margin: 0; padding: 0; }
.nav li { list-style: none; }
.nav li::marker { content: ""; }
.nav > li { position: relative; }
.nav > li > a,
.nav .menu-item > a { display: inline-flex; align-items: center; gap: 6px; }
.nav .menu-item-has-children > a::after {
  content: "▾"; font-size: .7em; opacity: .7; margin-left: 2px;
}
.nav .current-menu-item > a,
.nav .current_page_item > a,
.nav .current-menu-ancestor > a { color: var(--nrg-green); }

/* Sottomenu desktop */
.nav .sub-menu {
  position: absolute; top: calc(100% + 10px); left: 0;
  min-width: 240px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 10px;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: .18s ease; z-index: 60;
}
.nav .menu-item-has-children:hover > .sub-menu,
.nav .menu-item-has-children:focus-within > .sub-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.nav .sub-menu li a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: .92rem; font-weight: 600; color: var(--ink);
}
.nav .sub-menu li a:hover { background: var(--bg-soft); color: var(--nrg-green-dark); }

/* Voce esterna "Area Clienti" evidenziata */
.nav .menu-area-clienti > a { color: var(--nrg-green-dark); font-weight: 700; }

/* ---------- Prose (contenuto pagine testuali) ---------- */
.prose { max-width: 820px; }
.prose.wide { max-width: var(--maxw); }
.prose h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 34px 0 14px; }
.prose h3 { font-size: 1.28rem; margin: 26px 0 10px; }
.prose h4 { margin: 20px 0 8px; }
.prose p { color: var(--body); }
.prose ul, .prose ol { margin: 0 0 1rem 1.2rem; }
.prose ul li, .prose ol li { margin-bottom: 8px; }
/* Privacy: paragrafi etichettati (Finalità, Base giuridica, …) e sotto-liste */
.prose .deflabel { margin: .3rem 0; }
.prose .deflabel strong { color: var(--nrg-green-ink, #157f3c); }
.prose ul.sub { margin: .1rem 0 .7rem 1.4rem; list-style: circle; }

/* Esito invio form: box evidente in cima al modulo */
.form-alert { display: block; margin: 0 0 20px; padding: 14px 16px; border-radius: 12px; font-size: .95rem; line-height: 1.5; border: 1px solid transparent; }
.form-alert strong { display: block; margin-bottom: 2px; font-size: 1.02rem; }
.form-alert--ok { background: #e8f7ee; border-color: #bfe6cd; color: #12692f; }
.form-alert--error { background: #fdecea; border-color: #f2c4bf; color: #a3271c; }
.prose a { color: var(--nrg-green-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.prose a:hover { color: var(--nrg-green-dark); }
.prose > :first-child { margin-top: 0; }
.prose .lead { margin-bottom: 24px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

/* Layout con sidebar (es. Info e Documenti) */
.with-aside { display: grid; grid-template-columns: 1fr 320px; gap: 48px; align-items: start; }
.aside-box { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; position: sticky; top: 100px; }
.aside-box h4 { margin-bottom: 12px; }
.aside-box ul { list-style: none; }
.aside-box ul li { margin-bottom: 8px; }
.aside-box a { color: var(--nrg-green-dark); font-weight: 600; }

/* ---------- Info box / notice ARERA ---------- */
.notice {
  border-left: 4px solid var(--nrg-green); background: var(--bg-soft);
  border-radius: 12px; padding: 18px 22px; margin: 22px 0;
}
.notice.warn { border-left-color: var(--nrg-accent); }
.notice p:last-child { margin-bottom: 0; }

/* ---------- Area documenti (CPT documento) ---------- */
.doc-cat-head {
  display: flex; align-items: center; gap: 12px;
  margin: 40px 0 18px; padding-bottom: 12px; border-bottom: 2px solid var(--bg-soft-2);
}
.doc-cat-head h2 { font-size: 1.5rem; margin: 0; }
.doc-cat-head .cat-count { color: var(--muted); font-size: .9rem; font-weight: 600; }

.doc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.doc-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 20px; transition: .2s;
}
.doc-item:hover { border-color: var(--nrg-green); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.doc-item .doc-ico { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 11px; background: var(--bg-soft-2); color: var(--nrg-green-dark); display: grid; place-items: center; font-weight: 800; font-size: .7rem; }
.doc-item h3 { font-size: 1.02rem; margin-bottom: 4px; }
.doc-item p { font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.doc-item .dl { color: var(--nrg-green-dark); font-weight: 700; font-size: .85rem; }
.doc-item .dl.muted { color: var(--muted); font-weight: 600; }

/* Categorie hub (card indice Info e Documenti) */
.hub-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.hub-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; transition: .22s;
}
.hub-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: transparent; }
.hub-card .ico { width: 52px; height: 52px; border-radius: 13px; background: var(--bg-soft-2); color: var(--nrg-green-dark); display: grid; place-items: center; font-size: 1.5rem; margin-bottom: 14px; }
.hub-card h3 { margin-bottom: 6px; }
.hub-card p { color: var(--muted); font-size: .92rem; margin: 0; }

/* ---------- Sedi ---------- */
.sedi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px; }
.sede-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; }
.sede-card .pin { font-size: 1.6rem; }
.sede-card h3 { margin: 8px 0 4px; }
.map-embed { border: 0; width: 100%; height: 340px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* Mappa Leaflet + marker con logo */
#nrg-map { height: 460px; border-radius: var(--radius); box-shadow: var(--shadow-sm); z-index: 1; }
@media (max-width: 560px) { #nrg-map { height: 360px; } }
.nrg-badge {
  background: #fff; border-radius: 12px; padding: 8px 12px;
  box-shadow: 0 8px 20px -6px rgba(14,36,51,.5); position: relative; display: inline-block;
  border: 2px solid var(--nrg-green);
}
.nrg-badge img { height: 24px; width: auto; display: block; }
.nrg-badge::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 9px solid var(--nrg-green);
}
/* Popup del marker */
.leaflet-popup-content .nrg-pop { text-align: center; min-width: 170px; }
.nrg-pop strong { display: block; color: var(--nrg-navy); font-size: .95rem; }
.nrg-pop span { display: block; color: var(--muted); font-size: .84rem; margin: 3px 0 10px; }
.nrg-pop .nrg-dir {
  display: inline-block; background: var(--nrg-green); color: #fff !important;
  padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: .84rem; text-decoration: none;
}
.nrg-pop .nrg-dir:hover { background: var(--nrg-green-dark); }

/* ---------- News / blog ---------- */
.news-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.news-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: .22s; display: flex; flex-direction: column; }
.news-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.news-card .thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: linear-gradient(160deg, var(--nrg-green), var(--nrg-navy)); }
.news-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.news-card .body { padding: 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.news-card .date { font-size: .8rem; color: var(--muted); font-weight: 600; }
.news-card h3 { font-size: 1.1rem; }
.news-card .more { margin-top: auto; color: var(--nrg-green-dark); font-weight: 700; font-size: .9rem; }

/* ---------- Recensioni (Dicono di noi) ---------- */
.rating-hero { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; margin-bottom: 40px; }
.rating-hero .big { font-size: 3rem; font-weight: 800; color: var(--nrg-navy); line-height: 1; }
.rating-hero .stars { color: var(--nrg-accent); font-size: 1.3rem; letter-spacing: 2px; }

/* ---------- Feedback accessibilità ---------- */
.a11y-form .form-field { max-width: 620px; }

/* ---------- Skip link (accessibilità) ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--nrg-green); color: #fff; padding: 10px 18px; border-radius: 0 0 8px 0; font-weight: 700;
}
.skip-link:focus { left: 0; }

/* ---------- Hero pagina con immagine in evidenza ---------- */
.page-hero.has-image { background-size: cover; background-position: center; padding: 96px 0; }
.page-hero.has-image .breadcrumb { color: #d8e6ee; }

/* Immagine nel contenuto delle pagine */
.prose img { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.prose figure { margin: 22px 0; }
.prose .wp-block-image { margin: 22px 0; }

/* Blocco testo + immagine affiancati dentro le pagine */
.prose .split.nrg-split { margin: 44px 0; gap: 44px; align-items: center; }
.prose .nrg-split .split__media {
	min-height: 320px; border-radius: var(--radius);
	background: var(--bg-soft-2); background-size: cover; background-position: center;
	box-shadow: var(--shadow-sm);
}
.prose .nrg-split .split__text > :first-child { margin-top: 0; }
.prose .nrg-split .split__text h2 { margin-top: 0; }
@media (max-width: 960px) {
	.prose .nrg-split .split__media { min-height: 220px; }
}

/* ---------- Hero: foto + valutazione ---------- */
.hero-illustration { width: 100%; height: auto; display: block; }
.hero-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 16px; display: block; box-shadow: 0 18px 40px -22px rgba(0,0,0,.55); }
.hero-art .hero-trust { text-align: center; margin-top: 18px; }
.hero-art .hero-trust .stars { color: var(--nrg-accent); letter-spacing: 3px; font-size: 1.15rem; margin-bottom: 4px; }
.hero-art .hero-trust p { margin: 0; font-size: .95rem; color: var(--muted); }
.hero-art .hero-trust b { color: var(--nrg-navy); }

/* ---------- Fix: card offerte allineate ---------- */
.offers-grid { align-items: stretch; }
.offer-card { height: 100%; }
/* Blocchi ad altezza uniforme così le righe combaciano tra card affiancate */
.offer-card .type-badge { align-self: center; min-height: 1.9em; display: inline-flex; align-items: center; }
.offer-card .tagline { min-height: 4.9em; display: flex; align-items: center; justify-content: center; margin-bottom: 2px; }
.offer-card .oname { justify-content: center; min-height: 1.5em; }
.offer-card .sub { text-align: center; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.offer-card .price-row { min-height: 4.2em; justify-content: center; }
.offer-card .btn-detail { margin-top: auto; }

/* ---------- Fix: topbar leggibile su mobile ---------- */
@media (max-width: 640px) {
  .topbar { font-size: .8rem; }
  .topbar .container { height: auto; min-height: 40px; flex-wrap: wrap; gap: 2px 16px; padding-top: 7px; padding-bottom: 7px; }
  .topbar .topbar__contacts { gap: 2px 16px; }
  .topbar .topbar__contacts a[href^="mailto"] { display: none; } /* email troppo lunga: resta il telefono */
}

/* ---------- Fix: tabelle dettaglio offerta su mobile ---------- */
/* Codici lunghi (es. codice offerta) vanno a capo invece di allargare la tabella */
.spec-table th, .spec-table td { overflow-wrap: anywhere; word-break: break-word; }
/* Rete di sicurezza: scorrimento orizzontale se una tabella eccede */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 560px) {
  /* spec-table: etichetta sopra, valore sotto, a piena larghezza */
  .spec-table, .spec-table tbody, .spec-table tr { display: block; width: 100%; }
  .spec-table th, .spec-table td { display: block; width: 100% !important; }
  .spec-table th { background: var(--bg-soft-2); border-bottom: 0; }
  .spec-table td { padding-top: 6px; }
  .cost-table th, .cost-table td { padding: 9px 10px; font-size: .88rem; }
}

/* Focus visibile per accessibilità */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .filter-btn:focus-visible {
  outline: 3px solid var(--nrg-green); outline-offset: 2px;
}

/* ---------- WordPress core / editor ---------- */
.wp-caption img { border-radius: 12px; }
.aligncenter { margin-inline: auto; }
.aligncenter { text-align: center; }
figure { margin: 0 0 1rem; }

/* ---------- Sezione bianca loghi istituzionali (ARERA / Portale Offerte / UE) ---------- */
.gov-band {
  background: #fff; border-radius: var(--radius); padding: 28px 30px;
  margin-top: 40px; box-shadow: var(--shadow-sm);
}
.gov-band .gov-logos { display: flex; align-items: center; justify-content: center; gap: 44px; flex-wrap: wrap; }
.gov-band .gov-logos a { display: inline-flex; align-items: center; transition: .2s ease; }
.gov-band .gov-logos a:hover { opacity: .82; }
.gov-logo { width: auto; display: block; }
.gov-arera { height: 38px; }
.gov-po { height: 54px; }
.gov-ue-row { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); text-align: center; }
.gov-ue-row a { display: inline-block; transition: .2s ease; }
.gov-ue-row a:hover { opacity: .82; }
.gov-ue { height: auto; max-width: 100%; max-height: 92px; display: block; margin: 0 auto; }

@media (max-width: 640px) {
  .gov-band { padding: 22px 16px; }
  .gov-band .gov-logos { gap: 26px; }
  .gov-arera { height: 30px; }
  .gov-po { height: 42px; }
}

/* ---------- WhatsApp ---------- */
.topbar .tb-wa { color: #eafff2; }
@media (max-width: 640px) { .topbar .tb-wa { display: none; } } /* su mobile resta il bottone flottante */

.wa-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 95;
  width: 58px; height: 58px; border-radius: 50%; background: #25D366;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px -8px rgba(37,211,102,.65);
  transition: transform .18s ease;
}
.wa-float:hover, .wa-float:focus-visible { transform: scale(1.08); }
.wa-float svg { width: 32px; height: 32px; fill: #fff; }
@media (max-width: 640px) {
  .wa-float { width: 54px; height: 54px; right: 14px; bottom: 14px; }
  .wa-float svg { width: 30px; height: 30px; }
}

/* ---------- Cookie banner minimale ---------- */
#nrg-cookie {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 300;
  max-width: 760px; margin: 0 auto; background: var(--nrg-navy); color: #dbe7ee;
  border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow);
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
}
#nrg-cookie p { margin: 0; font-size: .9rem; flex: 1 1 320px; }
#nrg-cookie a { color: #fff; text-decoration: underline; }
#nrg-cookie .cookie-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
/* Voce CTA nel menu: nascosta su desktop (il bottone è già nell'header) */
.nav-cta-item { display: none; }

@media (max-width: 960px) {
  .with-aside, .doc-grid, .hub-grid, .sedi-grid, .news-grid { grid-template-columns: 1fr; }
  .aside-box { position: static; }

  /* Menu mobile: colonna a piena larghezza, voci allineate a sinistra */
  .nav.open { display: flex; align-items: stretch; padding: 4px 0 10px; gap: 0;
    max-height: calc(100vh - 118px); overflow-y: auto; }
  .nav.open > li { width: 100%; }
  .nav.open a { display: block; padding: 14px 24px; text-align: left; font-size: 1.02rem;
    border-bottom: 1px solid var(--line); }
  .nav.open .current-menu-item > a { color: var(--nrg-green); }
  .nav .menu-item-has-children > a::after { content: ""; }

  /* Sottomenu: sfondo soft e voci indentate */
  .nav .sub-menu {
    position: static; opacity: 1; visibility: visible; transform: none;
    box-shadow: none; border: 0; border-radius: 0; margin: 0; padding: 0;
    min-width: 0; background: var(--bg-soft);
  }
  .nav .sub-menu a { padding-left: 42px; font-weight: 500; color: var(--body); }
  .nav .sub-menu a::before { content: "› "; color: var(--nrg-green); font-weight: 700; }

  /* CTA dentro il menu mobile */
  .nav.open .nav-cta-item { display: block; padding: 16px 24px 4px; }
  .nav.open .nav-cta-item a { border: 0; text-align: center; color: #fff; padding: 14px 24px; }
}
@media (max-width: 560px) {
  .hub-grid, .doc-grid, .news-grid { grid-template-columns: 1fr; }
}
