/* ============================================================
   FINANZA DIGITALE v2 — HEADER + MEGA MENU
   Header sticky 68px, barra mega menu data-driven, pannelli
   full-width attaccati all'header (no ombra/raggio), scrim,
   ricerca a toggle, drawer mobile. Token --fd-*.
   ============================================================ */

.fd-header {
  position: sticky; top: 0; z-index: 1000;
  background: var(--fd-paper);
  border-bottom: 1px solid var(--fd-ink-100);
}
.fd-header__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 28px;
  height: 68px;
}
/* Barra header (e flyout di ricerca, per allinearsi) più larga del resto. */
.fd-header__bar.nw-container,
.fd-search-panel .nw-container { max-width: 1380px; }

/* logo */
.fd-header__logo { display: inline-flex; align-items: center; flex: 0 0 auto; }
.fd-header__logo a { display: inline-flex; align-items: center; line-height: 0; text-decoration: none; }
.fd-header__logo img,
.fd-header__logo .custom-logo { max-height: var(--fd-logo-h, 36px); width: auto; height: auto; display: block; }
.fd-logo { font-size: 21px; font-weight: 800; letter-spacing: -.02em; color: var(--fd-ink-900); line-height: 1; }
.fd-logo strong { color: var(--fd-green-600); font-weight: 800; }

/* nav bar — centrata tra logo e azioni */
.fd-nav { flex: 1 1 auto; min-width: 0; }
.fd-nav__list { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.fd-nav__item { position: static; }
/* reset esplicito: GeneratePress stila i <button> con sfondo navy (causava
   l'hover scuro). Forziamo trasparente + stati chiari. */
.fd-nav__link,
.fd-nav__link:focus {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--fd-ink-800);
  background: transparent; border: 0; box-shadow: none; cursor: pointer; text-decoration: none;
  padding: 10px 12px; border-radius: var(--fd-radius-sm);
  line-height: 1;
}
.fd-nav__link:hover,
.fd-nav__link:focus { color: var(--fd-green-700); background: var(--fd-green-50); }
.fd-nav__link svg { width: 15px; height: 15px; transition: transform var(--fd-dur-fast); }
.fd-nav__item--has-panel.is-open > .fd-nav__link { color: var(--fd-green-700); background: var(--fd-green-50); }
.fd-nav__item--has-panel.is-open > .fd-nav__link svg { transform: rotate(180deg); }
.fd-nav__link.is-current { color: var(--fd-green-700); }
.fd-nav__link:focus-visible { outline: 2px solid var(--fd-green-400); outline-offset: 2px; }

/* actions */
.fd-header__actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.fd-header__icon-btn {
  width: 40px; height: 40px; border-radius: var(--fd-radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--fd-ink-700); cursor: pointer;
}
.fd-header__icon-btn:hover { background: var(--fd-ink-50); color: var(--fd-green-700); }

/* Lente di ricerca come background-image (data-URI): niente <svg> nel DOM,
   immune al plugin che altera/strippa gli SVG inline dentro i bottoni. */
.fd-header__search-btn,
.fd-header__search-btn:hover {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%230f1e2e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='M21 21l-4.3-4.3'/></svg>");
  background-repeat: no-repeat; background-position: center; background-size: 20px 20px;
}
.fd-header__search-btn:hover { background-color: var(--fd-ink-50); }

/* focus/active: GeneratePress mette uno sfondo scuro sui <button>; lo annulliamo.
   background-color (non shorthand) per non cancellare l'icona di sfondo della lente. */
.fd-header__icon-btn:focus,
.fd-header__icon-btn:active,
.fd-header__burger:focus,
.fd-header__burger:active {
  background-color: transparent; box-shadow: none; outline: none;
}
.fd-header__icon-btn:focus-visible,
.fd-header__burger:focus-visible {
  outline: 2px solid var(--fd-green-400); outline-offset: 2px;
}
.fd-header__icon-btn svg { width: 20px; height: 20px; }

/* Le nostre icone sono stroke-based (fill:none). Alcuni plugin/ottimizzatori
   iniettano fill="#333" sugli SVG inline rompendole: forziamo fill:none via
   CSS (vince sull'attributo di presentazione). Logo SVG escluso. */
.fd-header svg,
.fd-drawer svg { fill: none; }
.fd-header__logo svg { fill: revert; }
.fd-header__cta,
.fd-header__cta:focus {
  display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 18px;
  border: 1px solid var(--fd-green-600); border-radius: var(--fd-radius-full);
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1;
  color: var(--fd-green-700); background: transparent; box-shadow: none;
  text-decoration: none; cursor: pointer;
  transition: all var(--fd-dur-fast);
}
.fd-header__cta:hover { background: var(--fd-green-600); color: #fff; }
.fd-header__burger {
  display: none;
  width: 40px; height: 40px; padding: 0; border-radius: var(--fd-radius-sm);
  align-items: center; justify-content: center;
  background: transparent; border: 0; box-shadow: none; cursor: pointer;
  color: var(--fd-ink-900);
}
.fd-header__burger svg { width: 24px; height: 24px; }

/* ============================================================
   MEGA PANEL — full-width attaccato all'header
   ============================================================ */
.fd-megapanel {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--fd-paper);
  border-top: 1px solid var(--fd-ink-100);
  border-bottom: 1px solid var(--fd-ink-100);
  animation: fd-megapanel-in 190ms cubic-bezier(.16, 1, .3, 1);
}
.fd-megapanel[hidden] { display: none; }
@keyframes fd-megapanel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fd-megapanel { animation: none; }
}
/* specificità .fd-megapanel ... per battere .nw-container di news.css (che
   azzerava il padding verticale sui single -> pannello attaccato alla barra).
   Colonne flex a riempimento: 2 -> 50/50, 3 -> terzi, allineate in alto. */
.fd-megapanel .fd-megapanel__inner {
  display: flex; gap: 48px; align-items: flex-start;
  max-width: 1240px; margin: 0 auto; padding: 32px 24px 40px;
}
.fd-megapanel__col { flex: 1 1 0; min-width: 0; }
.fd-megapanel__label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fd-ink-400); margin-bottom: 18px;
}
.fd-megapanel__label svg { width: 14px; height: 14px; color: var(--fd-ink-400); }

/* col 1 — categorie */
.fd-mm-cats { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fd-mm-cats a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin: 0 -10px; border-radius: var(--fd-radius-sm);
  text-decoration: none; color: var(--fd-ink-800); font-weight: 600; font-size: 15px;
  transition: background var(--fd-dur-fast), color var(--fd-dur-fast);
}
.fd-mm-cats a:hover { background: var(--fd-green-50); color: var(--fd-green-700); }
.fd-mm-cats__name { flex: 1 1 auto; }
.fd-mm-cats__count { font-size: 12px; font-weight: 700; color: var(--fd-ink-400); font-variant-numeric: tabular-nums; }
.fd-mm-cats a svg { width: 15px; height: 15px; color: var(--fd-ink-300); flex: 0 0 auto; }
.fd-mm-explore {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 700; color: var(--fd-green-700); text-decoration: none;
}
.fd-mm-explore svg { width: 16px; height: 16px; }
.fd-mm-explore:hover { text-decoration: underline; text-underline-offset: 3px; }

/* col 2 — in evidenza */
.fd-mm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fd-mm-list a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin: 0 -10px; border-radius: var(--fd-radius-sm);
  text-decoration: none; color: var(--fd-ink-800); font-weight: 600; font-size: 15px;
  line-height: 1.35; transition: background var(--fd-dur-fast), color var(--fd-dur-fast);
}
.fd-mm-list a:hover { background: var(--fd-green-50); color: var(--fd-green-700); }
.fd-mm-list a svg { width: 16px; height: 16px; color: var(--fd-green-600); flex: 0 0 auto; }
.fd-mm-list a span:not(.fd-mm-badge) { flex: 1 1 auto; }
.fd-mm-badge {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  color: var(--fd-green-700); background: var(--fd-green-50);
  border-radius: var(--fd-radius-full); padding: 2px 8px; flex: 0 0 auto;
}

/* col 3 — dal blog */
.fd-mm-blog { display: block; text-decoration: none; color: inherit; margin-bottom: 16px; }
.fd-mm-blog__thumb {
  display: block; aspect-ratio: 16/10; border-radius: var(--fd-radius-md); overflow: hidden;
  background: var(--fd-ink-75); margin-bottom: 12px;
}
.fd-mm-blog__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fd-mm-blog__title { font-size: 16px; font-weight: 700; color: var(--fd-ink-900); line-height: 1.3; }
.fd-mm-blog:hover .fd-mm-blog__title { color: var(--fd-green-700); }
/* "Guide utili" sotto la card */
.fd-mm-guide-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fd-ink-400); margin: 18px 0 2px;
}
/* link guide sotto l'ultimo post */
.fd-mm-guide { list-style: none; margin: 4px 0 0; padding: 0; }
.fd-mm-guide a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 0; border-top: 1px solid var(--fd-ink-100);
  font-size: 14px; font-weight: 700; color: var(--fd-ink-800); text-decoration: none;
  line-height: 1.3;
}
.fd-mm-guide a:hover { color: var(--fd-green-700); }
.fd-mm-guide a svg { width: 16px; height: 16px; color: var(--fd-ink-300); flex: 0 0 auto; }
.fd-mm-cta {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--fd-navy-2, #0e2349); color: #fff;
  border-radius: var(--fd-radius-md); padding: 16px 18px; text-decoration: none;
}
.fd-mm-cta__text { display: flex; flex-direction: column; gap: 2px; }
.fd-mm-cta__text strong { font-size: 15px; font-weight: 700; }
.fd-mm-cta__text span { font-size: 12px; color: rgba(255,255,255,.7); }
.fd-mm-cta svg { width: 20px; height: 20px; flex: 0 0 auto; }

/* ============================================================
   SCRIM
   ============================================================ */
.fd-scrim {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(8, 18, 38, .40);
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s;
}
.fd-scrim.is-open { opacity: 1; visibility: visible; }

/* ============================================================
   SEARCH FLYOUT (full-width attaccato all'header, smooth)
   ============================================================ */
.fd-search-panel {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--fd-paper);
  border-top: 1px solid var(--fd-ink-100);
  padding: 22px 0 24px;
  opacity: 0; visibility: hidden; transform: translateY(-10px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  pointer-events: none; z-index: 1001;
}
.fd-search-panel.is-open { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }

.fd-search-flyout {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--fd-ink-200); border-radius: var(--fd-radius-full);
  padding: 6px 6px 6px 20px; background: var(--fd-canvas);
  transition: border-color var(--fd-dur-fast), box-shadow var(--fd-dur-fast), background var(--fd-dur-fast);
}
.fd-search-flyout:focus-within { background: #fff; border-color: var(--fd-green-500); box-shadow: 0 0 0 3px var(--fd-green-100); }
.fd-search-flyout svg { fill: none; } /* immune all'iniettore di fill */
.fd-search-flyout__icon { color: var(--fd-ink-400); flex: 0 0 auto; display: inline-flex; }
.fd-search-flyout:focus-within .fd-search-flyout__icon { color: var(--fd-green-600); }
input.fd-search-flyout__input {
  flex: 1; min-width: 0;
  border: none !important; border-radius: 0 !important; box-shadow: none !important;
  outline: none; background: transparent;
  font: inherit; font-size: 17px; font-weight: 500; color: var(--fd-ink-900);
  padding: 12px 2px !important;
}
.fd-search-flyout__input::placeholder { color: var(--fd-ink-400); font-weight: 400; opacity: 1; }
/* Via la "X" nativa di clear del browser su input[type=search]: il testo si
   cancella da tastiera; il flyout si chiude cliccando fuori (scrim) o con Esc. */
.fd-search-flyout__input::-webkit-search-cancel-button,
.fd-search-flyout__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.fd-search-flyout__btn,
.fd-search-flyout__btn:focus {
  flex: 0 0 auto; border: 0; cursor: pointer; box-shadow: none; outline: none;
  background: var(--fd-green-600); color: #fff;
  font: inherit; font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  padding: 12px 28px; border-radius: var(--fd-radius-full);
  transition: background var(--fd-dur-fast), transform var(--fd-dur-fast);
}
.fd-search-flyout__btn:hover { background: var(--fd-green-700); }
.fd-search-flyout__btn:active { background: var(--fd-green-700); transform: translateY(1px); }

.fd-search-flyout__sug { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 4px 0; }
.fd-search-flyout__sug-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--fd-ink-400); }
.fd-search-chip {
  font-size: 13px; font-weight: 600; color: var(--fd-ink-700);
  background: var(--fd-ink-75); border: 1px solid var(--fd-ink-150);
  padding: 7px 14px 8px; border-radius: var(--fd-radius-full);
  text-decoration: none; transition: all var(--fd-dur-fast);
}
.fd-search-chip:hover { border-color: var(--fd-green-400); color: var(--fd-green-700); background: var(--fd-green-50); }

/* ============================================================
   MOBILE DRAWER
   ============================================================ */
.fd-drawer {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--fd-paper);
  display: flex; flex-direction: column;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.fd-drawer[hidden] { display: none; }
.fd-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px; padding: 0 20px; border-bottom: 1px solid var(--fd-ink-100);
  position: sticky; top: 0; background: var(--fd-paper);
}
/* scoped in .fd-drawer__head per battere GeneratePress button:not(.menu-toggle){font-weight:600} */
.fd-drawer__head .fd-drawer__close,
.fd-drawer__head .fd-drawer__close:hover,
.fd-drawer__head .fd-drawer__close:focus {
  color: var(--fd-ink-900); background: transparent;
  font-size: 30px; line-height: 1; font-weight: 400;
}
.fd-drawer__body { padding: 12px 20px 40px; }
.fd-acc { border-bottom: 1px solid var(--fd-ink-100); }
.fd-acc__head,
.fd-acc__head:hover,
.fd-acc__head:focus {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  font: inherit; font-size: 17px; font-weight: 700; color: var(--fd-ink-900);
  background: transparent; border: 0; box-shadow: none; padding: 16px 0; cursor: pointer;
}
.fd-acc__head svg { width: 20px; height: 20px; color: var(--fd-ink-400); transition: transform .2s ease; }
.fd-acc__head[aria-expanded="true"] svg { transform: rotate(180deg); }
.fd-acc__body { padding: 0 0 16px; }
.fd-acc__body[hidden] { display: none; }
.fd-drawer__list { list-style: none; margin: 0 0 4px; padding: 0; }
.fd-drawer__list a {
  display: flex; align-items: center; gap: 8px; padding: 10px 0 10px 24px;
  text-decoration: none; color: var(--fd-ink-700); font-weight: 500; font-size: 15px;
}
/* CTA del sottomenu (cardine + "Esplora X") come pill, separati da un divider */
.fd-drawer__ctas {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--fd-ink-100);
}
.fd-drawer__pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--fd-green-600); border-radius: var(--fd-radius-full);
  font-size: 13px; font-weight: 700; color: var(--fd-green-700); text-decoration: none;
}
.fd-drawer__pill:hover { background: var(--fd-green-50); }
.fd-drawer__fixed { display: flex; flex-direction: column; padding: 12px 0; }
.fd-drawer__fixed a { padding: 14px 0; font-size: 17px; font-weight: 700; color: var(--fd-ink-900); text-decoration: none; border-bottom: 1px solid var(--fd-ink-100); }
.fd-drawer__cta { margin-top: 20px; justify-content: center; width: 100%; }

body.fd-no-scroll { overflow: hidden; }

/* ============================================================
   NEWSLETTER MODAL (popup)
   ============================================================ */
.fd-modal {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.fd-modal[hidden] { display: none; }
.fd-modal__overlay { position: absolute; inset: 0; background: rgba(8, 18, 38, .55); animation: fd-modal-fade 200ms ease; }
@keyframes fd-modal-fade { from { opacity: 0; } to { opacity: 1; } }
.fd-modal__dialog {
  position: relative; z-index: 1;
  width: 100%; max-width: 460px;
  background: var(--fd-paper); border-radius: var(--fd-radius-lg);
  padding: 34px 34px 28px;
  box-shadow: 0 30px 80px -30px rgba(8, 20, 40, .5);
  animation: fd-modal-pop 180ms cubic-bezier(.16, 1, .3, 1);
}
@keyframes fd-modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.fd-modal__close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border: 0; background: none; cursor: pointer;
  color: var(--fd-ink-400); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.fd-modal__close:hover { background: var(--fd-ink-50); color: var(--fd-ink-700); }
.fd-modal__title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--fd-ink-900); margin: 0 8px 10px 0; line-height: 1.2; }
.fd-modal__desc { font-size: 15px; line-height: 1.6; color: var(--fd-ink-600); margin: 0 0 20px; }
.fd-modal__form { display: flex; flex-direction: column; gap: 12px; }
.fd-modal__form .fd-btn { width: 100%; }
.fd-modal__consent { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; line-height: 1.45; color: var(--fd-ink-500); }
.fd-modal__consent input { margin: 2px 0 0; flex: 0 0 auto; }
.fd-modal__consent a { color: var(--fd-green-700); text-decoration: underline; }
.fd-modal__fine { font-size: 12px; color: var(--fd-ink-400); margin: 12px 0 0; line-height: 1.5; }

/* ============================================================
   RESPONSIVE — sotto 1080px: hamburger + drawer
   ============================================================ */
@media (max-width: 1080px) {
  .fd-nav { display: none; }
  .fd-header__cta { display: none; }
  .fd-header__burger { display: inline-flex; }
  .fd-megapanel { display: none !important; }
}
@media (min-width: 1081px) {
  .fd-drawer { display: none !important; }
}
