/* ==========================================================================
   LAYOUT — intestazione, menu, sezioni, griglie, piè di pagina
   In WordPress: header.php / footer.php oppure le parti di modello
   "header" e "footer" dell'editor a blocchi.
   ========================================================================== */

/* --- Intestazione ----------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--color-border);
}
/* Filo sfumato con i colori dell'alba del logo */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--gradient-alba);
  opacity: .85;
}

.site-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--color-text);
  text-decoration: none;
}
.brand:hover { color: var(--color-text); }
/* Logo ufficiale: quadrato, mostrato intero, senza ritagli né arrotondamenti */
.brand__logo {
  flex: none;
  width: var(--logo-header);
  height: var(--logo-header);
  outline: 1px solid rgba(11, 26, 46, .08);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand__tag {
  margin-top: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--color-brand-text);
}
@media (max-width: 560px) {
  :root { --logo-header: 48px; --header-h: 72px; }
  .brand__name { font-size: 1rem; }
}

/* --- Menu principale -------------------------------------------------------- */
.site-nav { display: flex; align-items: center; gap: var(--space-5); }

.site-nav__list {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__list a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav__list a:hover { background: var(--gray-100); color: var(--color-primary); }
/* v0.8: con il selettore a tre lingue, tra 1101 e 1279 px le voci si avvicinano leggermente */
@media (min-width: 1101px) and (max-width: 1279px) {
  .site-nav { gap: var(--space-3); }
  .site-nav__list a { padding-left: 0.6rem; padding-right: 0.6rem; }
}
/* v0.12: con le voci Articoli e Newsletter (9 voci) il menu si compatta ancora tra 1101 e 1199 px */
@media (min-width: 1101px) and (max-width: 1199px) {
  .site-nav { gap: var(--space-2); }
  .site-nav__list a { padding-left: 0.42rem; padding-right: 0.42rem; font-size: 0.92rem; }
}
.site-nav__list a[aria-current="page"] {
  color: var(--color-primary);
  box-shadow: inset 0 -2px 0 var(--color-primary);
  border-radius: 0;
}

/* Voci di pagine non ancora sviluppate */
.site-nav__list a[data-pending] { color: var(--color-text-muted); }
.site-nav__list a[data-pending]::after {
  content: "presto";
  margin-left: 0.35rem;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: var(--gray-100);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  vertical-align: 0.15em;
}
.site-nav__list a[data-pending]:lang(en)::after { content: "soon"; }

/* --- Sottomenu «Networking» (v0.4.1) ----------------------------------------
   Desktop: si apre al passaggio del mouse, con il pulsante freccia (clic, Invio,
   Spazio) o quando il fuoco è dentro la voce; Esc lo chiude.
   Smartphone: le tre specializzazioni sono sempre visibili sotto «Networking».
   Senza JavaScript funziona con :hover e :focus-within. */
.site-nav__list > li { position: relative; }
.has-sub { display: flex; align-items: center; }
.site-nav__list .has-sub.is-section > .site-nav__parent { color: var(--color-primary); }
.subnav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 32px;
  margin-left: -0.45rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}
.subnav-toggle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--transition);
}
.subnav-toggle:hover { color: var(--color-primary); background: var(--gray-100); }
.subnav-toggle[aria-expanded="true"]::before { transform: translateY(2px) rotate(-135deg); }
.site-nav__sub {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  display: none;
  min-width: 16rem;
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.site-nav__sub a { padding: 0.55rem 0.75rem; }
.site-nav__sub a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--color-primary); border-radius: 0; }
@media (min-width: 1101px) {
  .has-sub:hover > .site-nav__sub,
  .has-sub:focus-within > .site-nav__sub,
  .has-sub.is-open > .site-nav__sub { display: block; }
  .has-sub.is-closed > .site-nav__sub { display: none; }
}

.lang-switch {
  display: flex;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.lang-switch a {
  padding: 0.25rem 0.42rem;   /* v0.8: tre lingue (IT | EN | 中文) nello stesso spazio */
  white-space: nowrap;
  border-radius: 999px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-decoration: none;
}
.lang-switch a:hover { color: var(--color-primary); }
.lang-switch a[aria-current="true"] { background: var(--color-dark); color: #fff; }

/* Pulsante menu (smartphone) */
.nav-toggle { display: none; }

@media (max-width: 1100px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
  }
  .nav-toggle__bar,
  .nav-toggle__bar::before,
  .nav-toggle__bar::after {
    position: relative;
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--color-text);
    transition: transform var(--transition), background var(--transition);
  }
  .nav-toggle__bar::before,
  .nav-toggle__bar::after { content: ""; position: absolute; left: 0; }
  .nav-toggle__bar::before { top: -6px; }
  .nav-toggle__bar::after { top: 6px; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bar { background: transparent; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bar::before { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle__bar::after { transform: translateY(-6px) rotate(-45deg); }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding: var(--space-3) var(--gutter) var(--space-5);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; max-height: calc(100vh - var(--header-h)); overflow-y: auto; }
  .site-nav__list { flex-direction: column; }
  .site-nav__list a { padding: 0.75rem 0.5rem; font-size: var(--fs-base); }
  .site-nav__list a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--color-primary); padding-left: 0.85rem; }
  .lang-switch { align-self: flex-start; }

  /* Sottomenu su smartphone: sempre visibile, rientrato sotto «Networking» */
  .has-sub { flex-wrap: wrap; }
  .has-sub > .site-nav__parent { flex: 1 1 auto; }
  .subnav-toggle { display: none; }
  .site-nav__sub {
    position: static;
    display: block;
    flex-basis: 100%;
    min-width: 0;
    padding: 0 0 0 var(--space-4);
    border: 0;
    border-left: 2px solid var(--color-border);
    margin-left: 0.5rem;
    box-shadow: none;
    background: transparent;
  }
  .site-nav__sub a { padding: 0.6rem 0.5rem; font-size: var(--fs-sm); }

  /* Senza JavaScript il menu resta visibile */
  .no-js .nav-toggle { display: none; }
  .no-js .site-nav { position: static; display: flex; box-shadow: none; border: 0; padding: 0 0 var(--space-4); }
  .no-js .site-header__inner { flex-wrap: wrap; }
}

/* --- Sezioni ---------------------------------------------------------------- */
.section { padding-block: var(--space-8); }
.section--alt { background: var(--color-bg-alt); }
.section--dark { background: var(--color-dark); color: var(--color-dark-text); }
.section--dark .eyebrow { color: var(--cyan-300); }
.section--tight { padding-block: var(--space-6); }

.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  margin-bottom: var(--space-6);
}
.section__head h2 { margin-bottom: var(--space-2); }
.section__head p { max-width: 62ch; margin: 0; color: var(--color-text-muted); }
.section--dark .section__head h2 { color: #fff; }
.section--dark .section__head p { color: var(--color-dark-muted); }

/* --- Griglie ---------------------------------------------------------------- */
.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid--3 { grid-template-columns: 1fr; } }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid--4 { grid-template-columns: 1fr; } }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: var(--space-7);
  align-items: start;
}
@media (max-width: 860px) { .split { grid-template-columns: 1fr; gap: var(--space-6); } }

/* --- Hero (homepage) -------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: var(--space-9) var(--space-8);
  background:
    radial-gradient(1100px 520px at 88% -10%, rgba(18, 181, 193, .24), transparent 60%),
    radial-gradient(800px 420px at -5% 115%, rgba(240, 162, 59, .16), transparent 60%),
    var(--navy-900);
  color: var(--color-dark-text);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/rete-sfondo.svg") center / cover no-repeat;
  opacity: .55;
  pointer-events: none;
}
.hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-7);
  align-items: center;
}
@media (max-width: 900px) { .hero__inner { grid-template-columns: 1fr; } }

.hero .eyebrow { color: var(--cyan-300); }
.hero h1 { max-width: 17ch; color: #fff; }
.hero h1 em { font-style: normal; color: var(--cyan-300); }
.hero .lead { max-width: 54ch; color: var(--color-dark-muted); }
.hero__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }

/* --- Intestazione delle pagine interne ------------------------------------- */
.page-header {
  position: relative;
  overflow: hidden;
  padding-block: var(--space-7) var(--space-7);
  background:
    radial-gradient(900px 380px at 100% 0%, rgba(18, 181, 193, .20), transparent 60%),
    var(--navy-900);
  color: var(--color-dark-text);
}
.page-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/rete-sfondo.svg") right center / cover no-repeat;
  opacity: .35;
  pointer-events: none;
}
.page-header .container { position: relative; }
.page-header h1 { margin-bottom: var(--space-3); color: #fff; }
.page-header p { max-width: 64ch; margin: 0; color: var(--color-dark-muted); font-size: var(--fs-lg); }
.page-header--compact { padding-block: var(--space-5); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--color-dark-muted);
}
.breadcrumb li + li::before { content: "/"; margin-right: 0.35rem; opacity: .6; }
.breadcrumb a { color: var(--cyan-300); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; color: #fff; }
.page-header--compact .breadcrumb { margin: 0; }

/* --- Piè di pagina ---------------------------------------------------------- */
.site-footer {
  padding-top: var(--space-8);
  background: var(--navy-950);
  color: var(--color-dark-muted);
  font-size: var(--fs-sm);
}
.site-footer__grid {
  display: grid;
  /* v0.12: la colonna Contatti si adatta agli indirizzi email (mai spezzati) */
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(max-content, 1fr);
  gap: var(--space-6);
}
@media (max-width: 1080px) { .site-footer__grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(max-content, 1fr); } .site-footer__grid > :first-child { grid-column: 1 / -1; } }
@media (max-width: 860px) { .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .site-footer__grid > :first-child { grid-column: 1 / -1; } }
@media (max-width: 520px) { .site-footer__grid { grid-template-columns: 1fr; } }

.site-footer h2 {
  margin-bottom: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
}
.site-footer ul { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.site-footer a { color: var(--color-dark-text); text-decoration: none; overflow-wrap: anywhere; }
.site-footer a[href^="mailto:"] { overflow-wrap: normal; white-space: nowrap; }   /* v0.12: indirizzi email su una riga */
.site-footer a:hover { color: var(--cyan-300); text-decoration: underline; }
.site-footer .brand,
.site-footer .brand:hover { color: #fff; text-decoration: none; }
.site-footer .brand__tag { color: var(--sun-300); }
.site-footer .brand__logo { outline-color: rgba(255, 255, 255, .12); }
.site-footer__claim { max-width: 34ch; margin-top: var(--space-4); }

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin-top: var(--space-7);
  padding-block: var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: var(--fs-xs);
}
.site-footer__bottom ul { display: flex; flex-wrap: wrap; gap: var(--space-4); }
