/* JTII-RESPONSIVE-ALL-PAGES-V1 | frontend-only, tablet and phone baseline */

/* Shared intrinsic sizing: avoid media causing page-wide horizontal scroll. */
@media (max-width: 1100px) {
  html { max-width: 100%; }
  body { max-width: 100%; }
  body, body * { box-sizing: border-box; }
  main, main > section, .site-main, .jtii-section { min-width: 0; }
  img, video, canvas { max-width: 100%; height: auto; }
  svg { max-width: 100%; }
  iframe, embed, object { max-width: 100%; }
  input, select, textarea, button { max-width: 100%; }
  .jtii-container, .jtii-header-inner,
  .jtii-news-v2 > .jtii-container,
  .jtii-section.jtii-news-v2 > .jtii-container {
    width: min(1290px, calc(100% - 40px)) !important;
    max-width: 1290px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  .jtii-header-inner { min-width: 0; }
  .jtii-brand { min-width: 0; }
  .jtii-brand-logo { max-width: min(235px, 44vw); height: auto; }
  .jtii-ref-hero-content, .jtii-ref-search-wrap,
  .jtii-ref-search, .jtii-ref-search-fields,
  .jtii-business-access-grid, .jtii-home-services-grid,
  .jtii-home-stats-v2-grid, .jtii-news-grid,
  .jtii-property-grid, .jtii-home-auction-grid,
  .jtii-home-ready-property, .jtii-home-ready-heading,
  .jtii-lf__wrap, .jtii-lf__main,
  .jtii-lf__contactbar-items {
    max-width: 100%; min-width: 0;
  }
  /* Overrule previous full-bleed styles for map; align it to News container. */
  .jtii-home-map-v3.jtii-home-map-v3 {
    width: min(1290px, calc(100% - 40px)) !important;
    max-width: 1290px !important;
    margin: 20px auto 28px !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  .jtii-home-map-v3.jtii-home-map-v3 .jhm3-inner {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px 0 !important;
    min-height: 0 !important;
    gap: 12px !important;
  }
  .jtii-home-map-v3 .jhm3-map img,
  .jtii-home-map-v3 .jhm3-map svg { max-width: 100% !important; }
  /* Forms used by property, auction, complaints and career plugins. */
  .jtii-ref-search-fields {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    gap: 10px !important;
  }
  .jtii-ref-keyword { grid-column: 1/-1; }
  .jtii-ref-search-submit { grid-column: 1/-1; width: 100%; }
  .jtii-ref-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .jtii-ref-tabs button { flex: 0 0 auto !important; white-space: nowrap; }
  :is(.jtii-property-filters,.jtii-filter-grid,.jtii-filters-grid,.jtii-listing-filters,.jtii-lelang-filters) {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    max-width: 100%;
  }
  .jtii-home-services-grid,
  .jtii-business-access-grid,
  .jtii-property-grid { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .jtii-news-v2 .jnews-track { grid-auto-columns: calc((100% - 14px)/2) !important; }
  .jtii-lf__main { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 700px) {
  .jtii-section-heading,
  .jtii-home-auction-heading,
  .jtii-home-ready-heading,
  .jtii-news-v2 .jnews-head {
    flex-wrap: wrap !important;
    gap: 12px !important;
  }
  .jtii-section-heading h2,
  .jtii-home-services-head h2 { font-size: clamp(25px, 6vw, 34px) !important; line-height: 1.18 !important; }
  .jtii-home-map-v3.jtii-home-map-v3 .jhm3-inner {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) !important;
    gap: 12px !important;
  }
  .jtii-home-map-v3 .jhm3-content,
  .jtii-home-map-v3 .jhm3-stats { padding: 0 !important; }
  .jtii-home-map-v3 .jhm3-map {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 2.65/1;
    min-height: 130px;
    overflow: visible !important;
  }
  .jtii-home-map-v3 .jhm3-map img,
  .jtii-home-map-v3 .jhm3-map svg { width: 100% !important; height: 100% !important; object-fit: contain !important; }
  .jtii-home-services-grid, .jtii-business-access-grid,
  .jtii-property-grid { gap: 14px !important; }
  .jtii-lf__contactbar-items { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 480px) {
  .jtii-container, .jtii-header-inner,
  .jtii-news-v2 > .jtii-container,
  .jtii-section.jtii-news-v2 > .jtii-container,
  .jtii-home-map-v3.jtii-home-map-v3 {
    width: calc(100% - 28px) !important;
    max-width: calc(100% - 28px) !important;
  }
  /* Navigation mobile behavior is handled by the existing theme JS. */
  .jtii-header-inner { gap: 8px !important; }
  .jtii-brand-logo { max-width: min(180px, 48vw) !important; }
  .jtii-header-cta { display: none !important; }
  .jtii-ref-search-fields { grid-template-columns: minmax(0,1fr) !important; gap: 8px !important; }
  .jtii-ref-keyword, .jtii-ref-search-submit { grid-column: auto !important; }
  .jtii-ref-search input,
  .jtii-ref-search select,
  main :is(input[type="text"],input[type="search"],input[type="email"],input[type="tel"],input[type="number"],input[type="date"],select,textarea) {
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 16px !important;
  }
  .jtii-ref-search select, .jtii-ref-search input,
  .jtii-ref-search-submit { width: 100% !important; }
  .jtii-home-services-grid, .jtii-business-access-grid,
  .jtii-property-grid,
  :is(.jtii-property-filters,.jtii-filter-grid,.jtii-filters-grid,.jtii-listing-filters,.jtii-lelang-filters) {
    grid-template-columns: minmax(0,1fr) !important;
  }
  .jtii-news-v2 .jnews-track { grid-auto-columns: 87% !important; }
  .jtii-news-v2 .jnews-image { height: 134px !important; }
  .jtii-news-v2 .jnews-content { min-height: 0 !important; }
  .jtii-news-v2 .jnews-actions { flex-wrap: wrap; }
  .jtii-home-map-v3 .jhm3-title { font-size: clamp(24px,7.5vw,30px) !important; }
  .jtii-home-map-v3 .jhm3-map { min-height: 112px; }
  .jtii-home-map-v3 .jhm3-row { grid-template-columns: minmax(0,105px) minmax(0,1fr) 39px !important; gap: 7px !important; }
  .jtii-home-map-v3 .jhm3-label { font-size: 10px !important; }
  .jtii-lf__main, .jtii-lf__contactbar-items { grid-template-columns: minmax(0,1fr) !important; }
  .jtii-lf__wrap, .jtii-lf__contactbar,
  .jtii-lf__bottom { min-width: 0; }
  .jtii-lf__bottom { flex-wrap: wrap; gap: 10px; }
  main h1, main h2, main h3, main h4, main p,
  main a, main strong { overflow-wrap: break-word; }
  main :is(button, select, input[type="submit"], .jtii-ref-search-submit) { min-height: 40px; touch-action: manipulation; }
  /* Wide tabular data stays readable through local horizontal scroll. */
  main table:not(.wp-calendar-table):not(.wp-block-calendar table) {
    display: block; width: 100%; max-width: 100%; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  main table:not(.wp-calendar-table) th,
  main table:not(.wp-calendar-table) td { overflow-wrap: break-word; }
}

@media (max-width: 359px) {
  .jtii-container, .jtii-header-inner,
  .jtii-news-v2 > .jtii-container,
  .jtii-section.jtii-news-v2 > .jtii-container,
  .jtii-home-map-v3.jtii-home-map-v3 {
    width: calc(100% - 24px) !important;
    max-width: calc(100% - 24px) !important;
  }
  .jtii-header-inner { gap: 6px !important; }
  .jtii-brand-logo { max-width: 145px !important; }
  .jtii-section-heading h2, .jtii-news-v2 .jnews-title { font-size: 25px !important; }
  .jtii-news-v2 .jnews-track { grid-auto-columns: 92% !important; }
  .jtii-home-map-v3 .jhm3-row { grid-template-columns: 91px minmax(0,1fr) 36px !important; gap: 5px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .jtii-news-v2 .jnews-track { scroll-behavior: auto !important; }
}
