/**
 * ASOR — adattamento fluido a telefoni, tablet e desktop (tutte le pagine).
 * Override leggeri in coda ai CSS esistenti; nessuna modifica al markup.
 */

/* --- Base: tutti i viewport --- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

body .t3-wrapper {
  overflow-x: hidden;
  max-width: 100%;
}

img,
video,
iframe,
embed,
object,
svg {
  max-width: 100%;
  height: auto;
}

#t3-content img,
.item-page img,
.article-image img,
.blog .item-image img,
.acm-features img,
.chiamsub img,
.asor-numero-blu-img {
  max-width: 100% !important;
  height: auto !important;
}

#t3-content,
.item-page,
.ja-masthead-description,
.ja-masthead-title {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

#t3-content table,
.item-page table {
  max-width: 100%;
}

#t3-content pre,
.item-page pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Smartphone e tablet (fino a 991px, come Bootstrap del tema) --- */
@media (max-width: 991px) {
  .container,
  .container-fluid,
  .t3-mainbody.container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
  }

  /* Evita scroll orizzontale da menu con min-width: 880px (custom.css) */
  .t3-mainnav .t3-navbar .navbar-nav,
  .t3-mainnav .t3-megamenu .navbar-nav {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-wrap: wrap !important;
  }

  #t3-mainbody > .row {
    display: flex !important;
    flex-direction: column !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  #t3-content.t3-content,
  .t3-sidebar,
  .t3-sidebar-right {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    flex: 0 0 auto !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box !important;
  }

  #t3-content {
    order: 1 !important;
  }

  .t3-sidebar-right {
    order: 2 !important;
    margin-top: 28px !important;
  }

  /* Testata sottopagine */
  .wrap.t3-masthead .ja-masthead {
    height: auto !important;
    min-height: 150px !important;
    padding: 28px 12px !important;
    background-size: cover !important;
    background-position: center center !important;
    box-sizing: border-box !important;
  }

  .wrap.t3-masthead .ja-masthead .ja-masthead-detail {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 8px !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }

  .wrap.t3-masthead .ja-masthead .ja-masthead-detail::before {
    float: none !important;
    display: block !important;
    margin: 0 auto 14px !important;
    margin-left: auto !important;
    max-width: 90px !important;
    width: auto !important;
    height: auto !important;
  }

  .ja-masthead-title {
    font-size: clamp(26px, 7vw, 44px) !important;
    line-height: 1.15 !important;
    margin-top: 0 !important;
    word-break: normal !important;
  }

  .ja-masthead-description {
    font-size: clamp(14px, 3.6vw, 18px) !important;
    line-height: 1.5 !important;
    margin-top: 10px !important;
  }

  /* Articoli e blog */
  .item-page,
  #t3-content article {
    font-size: clamp(15px, 4vw, 17px) !important;
    line-height: 1.55 !important;
  }

  .item-page h2 {
    font-size: clamp(21px, 5.2vw, 28px) !important;
    line-height: 1.25 !important;
  }

  .item-page h3 {
    font-size: clamp(18px, 4.5vw, 22px) !important;
    line-height: 1.3 !important;
  }

  .item-page .pull-left,
  .item-page .pull-right {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 16px !important;
  }

  /* Sidebar CTA */
  .t3-sidebar .chiamsub {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .t3-sidebar .chiamsub .btn-chiam {
    display: inline-block !important;
    max-width: 100% !important;
    white-space: normal !important;
    line-height: 1.25 !important;
    padding: 12px 14px !important;
    box-sizing: border-box !important;
  }

  .t3-sidebar .asor-sidebar-numero .asor-numero-blu-img {
    max-height: 110px !important;
  }

  /* Fascia contatti / form */
  #ja-form,
  #ja-form .container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #ja-form .ja-contact-form,
  #ja-form .col-md-5 {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
  }

  #ja-form input,
  #ja-form textarea,
  #ja-form select,
  .form-list input,
  .form-list textarea,
  .form-list select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Footer: colonne in verticale */
  #t3-footer .asor-footer-grid > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin-bottom: 24px !important;
  }

  #t3-footer .acymailing_form,
  #t3-footer .acymailing_form table {
    width: 100% !important;
    max-width: 100% !important;
  }

  #t3-footer .acymailing_form input.inputbox {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* CTA in fondo pagina */
  nav.wrap.t3-navhelper .container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box !important;
  }

  /* Touch: tap più comodi su link e bottoni principali */
  .btn,
  .btn-chiam,
  nav.t3-navhelper a.btn-chiam {
    min-height: 44px !important;
    line-height: 1.3 !important;
  }

  /* Sezioni home con larghezze fisse legacy */
  html body #acm-features-129 .container,
  html body .slideshow .slider-content-inner {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* --- Telefoni piccoli (iPhone SE, Android compatti) --- */
@media (max-width: 480px) {
  .container,
  .t3-mainbody.container {
    padding-left: max(10px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(10px, env(safe-area-inset-right, 0px)) !important;
  }

  .wrap.t3-masthead .ja-masthead {
    min-height: 128px !important;
    padding: 22px 10px !important;
  }

  .ja-masthead-title {
    font-size: clamp(22px, 8vw, 32px) !important;
  }

  #t3-content table,
  .item-page table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #redim-cookiehint-bottom #redim-cookiehint {
    padding: 10px 12px !important;
    font-size: 14px !important;
  }
}

@media (max-width: 360px) {
  .ja-masthead-title {
    font-size: 22px !important;
  }

  .t3-sidebar .chiamsub h3 {
    font-size: 15px !important;
    line-height: 1.35 !important;
  }
}

/* --- Tablet (768–991): sidebar sotto il testo, larghezza piena --- */
@media (min-width: 768px) and (max-width: 991px) {
  .t3-sidebar-right {
    max-width: 520px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .item-page {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
}

/* --- Laptop / desktop medio (992–1199) --- */
@media (min-width: 992px) and (max-width: 1199px) {
  .t3-mainbody.container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }

  .t3-mainnav .t3-navbar .navbar-nav {
    min-width: 0 !important;
  }
}

/* --- Monitor grandi: contenuto leggibile, niente righe chilometriche --- */
@media (min-width: 1400px) {
  #t3-mainbody.container {
    max-width: 1320px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* --- Landscape su telefono: meno padding hero (solo home) --- */
@media (max-width: 991px) and (orientation: landscape) and (max-height: 500px) {
  html.itemid-101 #acm-slideshow-89 .slider-content,
  body.asor-home #acm-slideshow-89 .slider-content {
    padding-top: 120px !important;
    padding-bottom: 16px !important;
  }
}

/* --- Stampa --- */
@media print {
  .ja-topbar,
  #t3-header,
  .t3-sidebar,
  nav.t3-navhelper,
  #toTop,
  #redim-cookiehint-bottom {
    display: none !important;
  }

  #t3-content,
  .item-page {
    width: 100% !important;
    max-width: 100% !important;
  }
}
