/* Generali */
body {
  background-color: #f9f9f9;
  color: #333;
  font-family: "Times New Roman", Times, serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  font-size: 90%;
}

/* Footer */
footer {
  background-color: #333;
  color: #f9f9f9;
  font-size: 0.9rem;
  margin-top: 2rem;
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
}

/* link nel footer: niente blu, aspetto pulito */
footer a.footer-link {
  color: #f9f9f9;
  text-decoration: none;
  font-weight: 400;
}

footer a.footer-link:hover {
  text-decoration: underline;
}

/* riga “sito gestito da…” */
footer .footer-managed {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  opacity: 0.9;
}

/* area legale / privacy */
footer .footer-legal {
  margin-top: 0.75rem;
}

/* bottone Privacy Policy */
footer .footer-btn-legal {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(249,249,249,0.8);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: #f9f9f9;
  background: transparent;
  cursor: pointer;
}

/* hover carino ma sobrio */
footer .footer-btn-legal:hover {
  background: rgba(255,255,255,0.12);
  border-color: #ffffff;
}

/* forziamo anche lo stile del link iubenda interno */
footer .iubenda-embed {
  background: transparent !important;
  color: #f9f9f9 !important;
}

/* Header */
header {
  background: linear-gradient(to right, #222, #444);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  color: white;
  padding: 1rem 2rem;
}

#Biografia p {
  font-size: 12pt;
}


header h1 {
  font-size: 2.2rem;
  margin: 0;
}

/* Main */
main {
  background: white;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0,0,0,0.05);
  margin: auto;
  max-width: 1000px;
  padding: 2rem;
}

.bio-h2 {
  border-bottom: none !important;
}

main h2 {
  border-bottom: 2px solid #ccc;
  color: #222;
  font-size: 2rem;
  margin-bottom: 1rem;
  margin-top: 2rem;
  padding-bottom: 0.5rem;
}

main h3 {
  color: #222;
  font-size: 1.6rem;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

main img[alt^="Ritratto"] {
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  float: right;
  margin: 0 0 20px 20px;
  width: 240px;
}

/* Navbar */
nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin-top: 1rem;
  padding: 0;
}

nav a {
  background-color: #555;
  border-radius: 5px;
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  transition: background-color 0.3s;
}

nav a.active {
  background-color: #0077cc;
}

nav a:hover {
  background-color: #888;
}

.video-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.video-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  padding: 1rem;
  width: 320px;
  text-align: center;
}

.video-card iframe {
  width: 100%;
  height: 180px;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.video-card p {
  font-weight: bold;
  color: #222;
}

/* Card Orizzontale - Canale Principale */
.channel-horizontal {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin: 2rem auto;
  padding: 1rem;
  max-width: 800px;
  transition: background-color 0.3s ease;
  cursor: pointer;
}

.channel-horizontal:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.channel-horizontal a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.channel-logo {
  width: 120px;
  height: 120px;
  border-radius: 60px;
  object-fit: cover;
  margin-right: 1.5rem;
  flex-shrink: 0;
}

.channel-info {
  flex: 1;
}

.channel-info h3 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  color: #000000;
}

.channel-info p {
  margin: 0;
  font-size: 1rem;
  color: #333;
}

/* Channel Card Ridotta */
.channel-card {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 800px;
  height: 80px;
  margin: 1rem auto 2rem auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  overflow: hidden;
  cursor: pointer;
  transition: background-color 0.3s ease;
  text-decoration: none;
  color: inherit;
}

.channel-card:hover {
  background-color: rgba(0,0,0,0.05);
}

.channel-card a {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
  padding: 0 1rem;
}

.channel-thumb {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 1rem;
}

.channel-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.channel-card p {
  margin: 0;
  font-weight: bold;
  font-size: 1rem;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Figure e immagini */
figure {
  display: block;
  text-align: center;
  margin: 20px auto;
}

figure img.ritratto {
  display: block;
  margin: 0 auto;
  max-width: 250px;
  width: 100%;
  height: auto;
}

figure figcaption {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  font-style: italic;
  color: #555;
}

figure.ritratto-box {
  float: right;
  margin: 0 0 20px 20px;
  text-align: center;
  width: 240px;
}

figure.ritratto-box img {
  display: block;
  margin: 0 auto;
  width: 240px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

figure.ritratto-box figcaption {
  margin-top: 6px;
  font-size: 14px;
  font-style: italic;
  color: #555;
}

/* IDEE CARD (nuovo layout) */
.idee-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Card chiusa: deve “sembrare una card” */
.idee-card {
  display: grid;
  grid-template-columns: 1fr auto;   /* testo a sinistra, immagine a destra */
  grid-template-rows: auto auto;     /* riga 1: titolo+immagine, riga 2: contenuto */
  column-gap: 16px;
  row-gap: 10px;
  align-items: end;                   /* allinea il titolo alla base dell’immagine */
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 16px;
  width: 100%;
  cursor: pointer;
  transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
}

.idee-card:hover {
  border-color: rgba(0,0,0,0.18);
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  transform: translateY(-1px);
}

/* Titolo: in riga 1, colonna sinistra, allineato in basso */
.idee-card h3 {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
  align-self: end; /* baseline del titolo ≈ base dell’immagine */
}

/* Immagine “standard” (img diretto dentro .idee-card) */
.idee-card > img {
  grid-column: 2;
  grid-row: 1;
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  transition: width .25s ease, height .25s ease, transform .25s ease;
}

/* Variante “setting multistrato”: immagine avvolta in .card-right */
/* ==== FIX SPECIFICO: IDEE > "Setting multistrato" (immagine + didascalia) ==== */

/* 1) Assicura che il contenitore a destra sia sempre visibile e a destra */
.idee-card .card-right {
  grid-column: 2 !important;
  grid-row: 1 !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  /* annulla eventuali vecchie regole tipo display:none/position:absolute */
  position: static !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 2) Assicura che l'immagine sia mostrata e con dimensioni corrette */
.idee-card .card-right img {
  display: block !important;
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  margin: 0;
  /* annulla possibili eredità che la nascondono */
  max-width: none !important;
  max-height: none !important;
  transform: none !important;
}

/* 3) In stato espanso, l'immagine cresce un po' */
.idee-card.expanded .card-right img {
  width: 130px;
  height: 130px;
}

/* 4) Didascalia: mostrala solo quando la card è espansa, sotto l'immagine */
.idee-card .card-right .didascalia-img,
.idee-card .card-right .didascalia,
.idee-card .card-right figcaption {
  display: none;
  font-size: 12px;
  line-height: 1.2;
  color: #666;
  text-align: center;
  max-width: 140px; /* evita righe troppo lunghe, resta sotto l'immagine */
}
.idee-card.expanded .card-right .didascalia-img,
.idee-card.expanded .card-right .didascalia,
.idee-card.expanded .card-right figcaption {
  display: block;
}

/* 5) Allineamento del titolo alla base dell'immagine a destra */
.idee-card {
  display: grid;
  grid-template-columns: 1fr auto;  /* testo a sinistra, immagine a destra */
  grid-template-rows: auto auto;    /* riga1 titolo+immagine, riga2 contenuto */
  column-gap: 16px;
  row-gap: 10px;
  align-items: end;                  /* aggancia in basso la riga 1 */
}
.idee-card h3 {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  align-self: end;
}

/* 6) Contenuto collassato sotto (resta full width) */
.idee-card .idee-content {
  grid-column: 1 / -1;
  grid-row: 2;
  overflow: hidden;
  max-height: 0;
  padding: 0;
  transition: max-height .35s ease, padding .2s ease;
}
.idee-card.expanded .idee-content {
  max-height: 1800px;
  padding-top: 8px;
}
.tabella-didattica {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.tabella-didattica th,
.tabella-didattica td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: left;
}

.tabella-didattica th {
  background-color: #f5f5f5;
  font-weight: bold;
}

/* Caption immagine compatta */
.img-with-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: 15px;
  flex-shrink: 0;
}

.img-with-caption img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

.didascalia-img {
  font-size: 0.9rem;
  color: #888;
  margin-top: 4px;
  font-style: italic;
  text-align: center;
  line-height: 1;
}

/* Card a due lati */
.card-left {
  flex: 1;
}

.card-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: 15px;
  flex-shrink: 0;
}

.card-right img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

.card-right .didascalia-img {
  font-size: 0.7rem;
  color: #888;
  margin-top: 4px;
  font-style: italic;
  line-height: 1;
  text-align: center;
}

.idee-card.expanded .card-right {
  display: none;
}

/* === NAV COMPATTA A 3 BOTTONI === */
.mega-nav{
  position: relative;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  overflow: visible;
  z-index: 100;
}

.mega-nav .burger{ display:none !important; }

.mega-nav .top-level{
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 6px 0 0 0;
  padding: 0;
}
.mega-nav .top-level>li{
  flex: 1 1 0;
  position: relative;
  min-width: 0;
}

/* Bottoni principali */
.mega-nav .top-link{
  width: 100%;
  border: 0;
  color: #fff;
  font-weight: 700;
  letter-spacing: .2px;
  height: 36px;
  line-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mega-nav .top-link:hover{ filter: brightness(1.06); }
.mega-nav .top-link:active{ transform: translateY(1px); }
.mega-nav .top-link:focus-visible{ outline: 2px solid #fff; outline-offset: 2px; }

.gm--blue  .top-link{  background:#0d6efd; }
.gm--green .top-link{  background:#198754; }
.gm--red   .top-link{  background:#dc3545; }

/* === SUBMENU (finestra sotto i bottoni) — centrato, elastico, no overflow === */
.mega-nav .submenu{
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: none;

  background: #fff;
  padding: 14px 16px;                 /* un filo più respiro */
  border: 2px solid transparent;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.16);
  z-index: 9999;

  /* si allarga per contenere bottoni lunghi, ma non esce dal viewport */
  width: max-content;                 /* si adatta al contenuto */
  max-width: calc(100vw - 24px);      /* mai oltre i bordi schermo */
  box-sizing: border-box;

  overflow-x: auto;                   /* se serve, scroll orizzontale */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;  /* scroll fluido su mobile */
}
.mega-nav .has-submenu.open > .submenu{ display:block; }

/* Contenuto: più spazio tra bottoni */
.mega-nav .submenu ul{
  list-style: none;
  margin: 0;
  padding: 0;
  display: inline-flex;               /* tiene la riga “stretta” al contenuto */
  flex-wrap: wrap;                    /* permette andare a seconda riga se serve */
  gap: 16px 12px;                     /* ↑ più spazio tra bottoni (Y X) */
}

/* Bottoni interni: MAI andare a capo; niente ellipsis; padding maggiore */
.mega-nav .submenu a{
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: #222;
  text-decoration: none;
  padding: 12px 18px;                 /* ↑ padding verticale */
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;

  white-space: nowrap;                /* non va a capo */
  overflow: visible;                  /* lascia “espandere” il bottone */
  text-overflow: clip;                /* nessun ellipsis */
}
.mega-nav .submenu a:hover{ background:#f6f9ff; border-color: rgba(0,0,0,.22); }
.mega-nav .submenu a:active{ transform: scale(.98); }

/* bordo del pannello secondo il tasto attivo */
.gm--blue.open  > .submenu{ border-color:#0d6efd; }
.gm--green.open > .submenu{ border-color:#198754; }
.gm--red.open   > .submenu{ border-color:#dc3545; }

/* sicurezza: l’header non deve tagliare il pannello */
header{ position: relative; overflow: visible; }

/* === MOBILE: stesse regole, solo un po’ più comodo === */
@media (max-width:720px){
  .mega-nav .top-level{ gap: 6px; }
  .mega-nav .top-link{
    height: 34px;
    line-height: 34px;
    font-size: .95rem;
    padding: 0 8px;
  }

  /* pannello sempre centrato e dentro schermo */
  .mega-nav .submenu{
    max-width: calc(100vw - 16px);    /* un filo più stretto per evitare tagli */
    padding: 14px 16px;
  }

  /* bottoni più distanziati e facili da tappare */
  .mega-nav .submenu ul{ gap: 18px 12px; }
  .mega-nav .submenu a{
    padding: 14px 18px;               /* target touch migliore */
    font-size: 1rem;
  }
}

/* Riduci motion */
@media (prefers-reduced-motion: reduce){
  .mega-nav .top-link,
  .mega-nav .submenu a{ transition: none; }
}

/* Evita overflow laterale: allinea il pannello in base alla colonna */
.mega-nav .top-level > li:first-child.open > .submenu{
  /* BLU (sinistra): aggancia a sinistra del bottone */
  left: 0;
  right: auto;
  transform: none;
  max-width: min(980px, calc(100vw - 16px));
  overflow-x: auto;
}

.mega-nav .top-level > li:last-child.open > .submenu{
  /* ROSSO (destra): aggancia a destra del bottone */
  right: 0;
  left: auto;
  transform: none;
  max-width: min(980px, calc(100vw - 16px));
  overflow-x: auto;
}

.mega-nav .top-level > li:nth-child(2).open > .submenu{
  /* VERDE (centro): resta centrato */
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  max-width: min(980px, calc(100vw - 16px));
  overflow-x: auto;
}

/* === FIX DEFINITIVO: pannelli blu e rosso rientrano visivamente di più === */
:root{ --submenu-retract: 16px; } /* quanto rientrano: aumenta o riduci se serve */

/* BLU — sposta indietro verso sinistra */
.mega-nav .top-level > li:first-child.open > .submenu{
  left: calc(0px - var(--submenu-retract)) !important;
  right: auto !important;
  transform: none !important;
  max-width: calc(100vw - (var(--submenu-retract) * 2)) !important;
}

/* ROSSO — sposta indietro verso destra */
.mega-nav .top-level > li:last-child.open > .submenu{
  right: calc(0px - var(--submenu-retract)) !important;
  left: auto !important;
  transform: none !important;
  max-width: calc(100vw - (var(--submenu-retract) * 2)) !important;
}

/* VERDE resta centrato, nessuna modifica */
.mega-nav .top-level > li:nth-child(2).open > .submenu{
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  max-width: calc(100vw - (var(--submenu-retract) * 2));
}

/* === Nuovo colore: GIALLO === */
.gm--yellow .top-link{ background:#ffc107; color:#fff; }
.gm--yellow.open > .submenu{ border-color:#ffc107; }

/* === Layout a 4 bottoni: gestione bordi === */
:root{ --submenu-retract: 22px; } /* margine di sicurezza laterale */

/* 1) BLU (primo) – rientra dal bordo sinistro */
.mega-nav .top-level > li:first-child.open > .submenu{
  left: calc(0px - var(--submenu-retract)) !important;
  right: auto !important;
  transform: none !important;
  max-width: calc(100vw - (var(--submenu-retract) * 2)) !important;
}

/* 2) VERDE (secondo) – centrato come prima */
.mega-nav .top-level > li:nth-child(2).open > .submenu{
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  max-width: calc(100vw - (var(--submenu-retract) * 2)) !important;
}

/* 3) ROSSO (terzo) – anche lui centrato (ora non è più l'ultimo) */
.mega-nav .top-level > li:nth-child(3).open > .submenu{
  left: 50% !important;
  right: auto !important;
  transform: translateX(-60%) !important;
  max-width: calc(100vw - (var(--submenu-retract) * 2)) !important;
}

/* 4) GIALLO (ultimo) – rientra dal bordo destro */
.mega-nav .top-level > li:last-child.open > .submenu{
  right: calc(0px - var(--submenu-retract)) !important;
  left: auto !important;
  transform: none !important;
  max-width: calc(100vw - (var(--submenu-retract) * 2)) !important;
}

/* (opzionale) un filo più aria verticale tra bottoni del pannello */
.mega-nav .submenu ul{ gap: 16px 12px; }
.mega-nav .submenu a{ padding: 12px 18px; }