/* Pagina di un Comune (layout "Comune"); mobile ricavato. */
@layer sections {
  /* ---------- Apertura ---------- */
  .comune-hero { padding: 48px 0 64px; }
  .comune-hero__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 48px; align-items: center; }
  .comune-hero__main { display: flex; flex-direction: column; gap: 28px; }
  .comune-hero__main .section-label:hover { color: #fff; }
  .comune-hero__title { font-weight: 700; font-size: clamp(64px, 8vw, 120px); line-height: 1; letter-spacing: -0.045em; }
  .comune-hero__text { max-width: 480px; font-weight: 500; font-size: 18px; line-height: 1.5; text-wrap: pretty; }
  .comune-hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

  /*
   * Mappa: stato finale nelle regole normali, stato iniziale nei keyframes "from" con fill "backwards":
   * i Comuni colorati, poi (0,9s) lo zoom sul Comune, gli altri tratteggiati, il bordo giallo che si disegna,
   * le etichette che compaiono. Solo CSS: senza JS o con movimento ridotto si vede subito lo stato finale.
   */
  .comune-map { position: relative; width: 100%; max-width: 620px; aspect-ratio: 251 / 300; justify-self: center; }
  .comune-map__svg { display: block; width: 100%; height: 100%; overflow: hidden; }
  .comune-map__zoom { transform: var(--zoom); animation: cm-zoom 1.4s cubic-bezier(.65, 0, .25, 1) .9s backwards; }
  .comune-map__shape {
    fill: rgb(255 255 255 / 0.03); stroke: rgb(255 255 255 / 0.35); stroke-width: 1; stroke-dasharray: 3 3;
    animation: cm-shape .8s ease .9s backwards;
  }
  .comune-map__shape--own { fill: var(--color-green-3); stroke: #fff; stroke-width: 1.2; stroke-dasharray: none; }
  .comune-map__trace { stroke: var(--color-accent); stroke-width: 2.5; stroke-dasharray: 1; stroke-dashoffset: 0; animation: cm-trace 1.6s ease-in-out 1.4s backwards; }
  .comune-map__fade { animation: cm-fade .6s ease backwards; }
  .comune-map__neighbor {
    position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
    font-weight: 600; font-size: 14px; color: rgb(255 255 255 / 0.8);
    &:hover { color: var(--color-accent); }
  }
  .comune-map__callout {
    position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
    padding: 8px 14px; border-radius: var(--radius-pill); background: var(--color-bg); color: var(--color-ink);
    font-weight: 700; font-size: 14px; box-shadow: 0 6px 16px rgb(2 31 23 / 0.3);
  }
  @keyframes cm-zoom { from { transform: none; } }
  @keyframes cm-shape { from { fill: var(--from); stroke: #fff; stroke-dasharray: none; } }
  @keyframes cm-trace { from { stroke-dashoffset: 1; } }
  @keyframes cm-fade { from { opacity: 0; } }
  @media (prefers-reduced-motion: reduce) {
    .comune-map__zoom, .comune-map__shape, .comune-map__trace, .comune-map__fade { animation: none; }
  }

  /* Foto ampia: sopra il bianco, per metà sul verde della Storia */
  .comune-foto { position: relative; z-index: 1; padding-top: 64px; }
  .comune-foto__media { height: clamp(260px, 34vw, 460px); }
  /* Video al posto della foto (campo comune_video): stesso riquadro, pulsante pausa in basso a destra */
  .comune-foto__media--video { position: relative; overflow: hidden; border-radius: var(--media-radius, var(--radius-l)); background: var(--color-primary-dark); }
  .comune-foto__video { display: block; width: 100%; height: 100%; object-fit: cover; }
  /* Il pulsante segue il ritaglio del riquadro che cresce allo scroll (scroll-grow) */
  .comune-foto__pause { right: calc(20px + var(--grow-x, 0%)); bottom: calc(20px + var(--grow-y, 0%)); }

  @media (max-width: 767px) {
    .comune-hero { padding: 40px 0 48px; }
    .comune-hero__grid { gap: 32px; }
    .comune-hero__title { font-size: clamp(52px, 15vw, 64px); }
    .comune-hero__text { font-size: 16px; }
    .comune-hero__actions .button { flex: 1 1 100%; }
    .comune-map__callout { padding: 6px 10px; font-size: 12px; }
    .comune-map__neighbor { font-size: 12px; }
    .comune-foto { padding-top: 32px; }
  }

  /* ---------- Storia ---------- */
  .comune-storia { margin-top: -180px; padding: 280px 0 var(--section-space); background: var(--color-mint); }
  .comune-storia__grid { align-items: start; }
  .comune-storia__head { display: flex; flex-direction: column; gap: 16px; }
  .comune-storia__text { max-width: 600px; display: flex; flex-direction: column; gap: 20px; line-height: 1.6; color: var(--color-ink-soft); text-wrap: pretty; }
  .comune-storia__lead { font-weight: 500; font-size: clamp(20px, 1.9vw, 24px); line-height: 1.45; letter-spacing: -0.03em; color: var(--color-ink); }
  .comune-storia__evidenza { font-weight: 700; color: var(--color-primary); }
  @media (max-width: 767px) {
    .comune-storia { margin-top: -120px; padding-top: 168px; }
  }

  /* ---------- Attività e news del Comune ---------- */
  .comune-attivita { padding: var(--section-space) 0 60px; }
  .comune-attivita__inner, .comune-news__inner { display: flex; flex-direction: column; gap: 40px; }
  .comune-attivita__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; }
  .comune-attivita__title { max-width: 640px; display: flex; flex-direction: column; gap: 20px; }
  .comune-news { padding: 60px 0 var(--section-space); }
  @media (max-width: 767px) {
    .comune-attivita__inner, .comune-news__inner { gap: 28px; }
    .comune-attivita__head { gap: 16px; }
  }
}
