/*
 * AIO.CO.TH — Public website responsive alignment patch (2026-11-03)
 * Loaded after the original per-page CSS by app/render.php.
 * Applies to every legacy page without editing stored HTML, images, or CMS settings.
 */

/* Match the visual width and left/right edges of text and image sections. */
:root {
  --aio-page-gutter: 32px;
}

body .container,
body .hero-media,
body .banner-shell {
  box-sizing: border-box;
  width: min(var(--max, 1240px), calc(100% - var(--aio-page-gutter))) !important;
  max-width: min(var(--max, 1240px), calc(100% - var(--aio-page-gutter))) !important;
  margin-inline: auto;
}

/* All original artwork stays in its current path and retains its entire aspect ratio. */
main .hero-media > img,
main .banner-shell > img,
main .howto-media > img,
main .article-content img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: auto !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  object-position: center;
}

main .hero-media,
main .banner-shell,
main .howto-media,
main .article-content {
  min-width: 0;
  max-width: 100%;
}

main .howto-media { width: 100%; }

/* Never allow embedded media or long text to enlarge the viewport. */
main img,
main picture,
main svg,
main video,
main canvas,
main iframe { max-width: 100%; }

main :is(
  .intro-grid, .services-head, .service-grid, .process-shell, .process-head,
  .process-grid, .process-quick, .article-columns, .article-zone .container,
  .brand-grid, .care-grid, .case-grid, .review-grid, .faq-list,
  .link-hub-grid, .link-grid, .footer-grid
) { min-width: 0; max-width: 100%; }

main :is(
  .intro-grid, .services-head, .service-grid, .process-shell, .process-head,
  .process-grid, .process-quick, .article-columns, .brand-grid, .care-grid,
  .case-grid, .review-grid, .faq-list, .link-hub-grid, .link-grid
) > * { min-width: 0; }

main :is(h1, h2, h3, h4, p, a, li, strong, span, small) { overflow-wrap: anywhere; }

/* Tables must scroll inside their own box rather than forcing page-wide scrolling. */
main .compare-wrap,
main .article-content {
  min-width: 0;
  max-width: 100%;
}
main .compare-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
main .article-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
main pre,
main code { max-width: 100%; overflow-wrap: anywhere; }
main pre { overflow-x: auto; }

@media (max-width: 900px) {
  /* Defensive one-column layouts for tablets and narrow viewports. */
  main .intro-grid,
  main .services-head,
  main .process-grid,
  main .article-zone > .container,
  main .brands > .container,
  main .care > .container,
  main .cases > .container,
  main .reviews > .container,
  main .faq .container > div:first-child {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  :root { --aio-page-gutter: 20px; }

  .site-header,
  .site-header .nav,
  .site-header .brand,
  .site-header .nav-links { min-width: 0; }

  .site-header .nav { gap: 8px; }
  .site-header .brand { flex: 1 1 auto; max-width: calc(100% - 68px); }
  .site-header .brand span { min-width: 0; overflow-wrap: anywhere; }
  .site-header .menu-toggle { flex: 0 0 auto; }
  .site-header .nav.is-open .nav-links {
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .site-header .nav.is-open .nav-links a { min-width: 0; }

  main .hero-media,
  main .banner-shell { border-radius: 16px; }
  main .hero-media > img,
  main .banner-shell > img,
  main .howto-media > img { height: auto !important; }

  main .hero-float { max-width: calc(100% - 16px); }
  main .cta-row,
  main .contact-actions { max-width: 100%; }
  main .btn { min-width: 0; max-width: 100%; white-space: normal; }
}

@media (max-width: 430px) {
  :root { --aio-page-gutter: 16px; }
  main .article-content { padding-inline: 14px; }
  main .hero-float { max-width: calc(100% - 12px); }
}

@media (max-width: 350px) {
  .site-header .nav.is-open .nav-links { grid-template-columns: minmax(0, 1fr); }
}

/* Contextual keyword links in the long-form article, not call-to-action buttons. */
main .full-article .article-content a.aio-self-keyword {
  color: #0754b9;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: #7baeed;
  text-underline-offset: 0.17em;
  overflow-wrap: anywhere;
}
main .full-article .article-content a.aio-self-keyword:hover,
main .full-article .article-content a.aio-self-keyword:focus-visible {
  color: #043a82;
  text-decoration-color: currentColor;
}
main .full-article .article-content a.aio-self-keyword:focus-visible {
  outline: 2px solid #0754b9;
  outline-offset: 3px;
  border-radius: 2px;
}

/* AIO SEO: semantic article heading hierarchy, visual styles retained. */
/* One visible H1 is kept in the hero. Long-form chapters H2, topics H3, details H4. */
main .full-article .article-content h2.aio-article-chapter {
  font-size: clamp(1.22rem, 1.8vw, 1.58rem) !important;
  line-height: 1.34;
  margin: 22px 0 10px !important;
  padding-bottom: 10px;
  border-bottom: 2px solid #e7effc;
  color: #062b72;
  font-weight: 700;
}
main .full-article .article-content h3.aio-article-subheading {
  font-size: clamp(1.04rem, 1.4vw, 1.22rem) !important;
  line-height: 1.4;
  margin: 18px 0 8px !important;
  color: #07429b;
  font-weight: 700;
}
main .full-article .article-content h4.aio-article-detail {
  font-size: 1.125rem !important;
  line-height: 1.42;
  margin: 16px 0 8px !important;
  color: #24477d;
  font-weight: 700;
}
@media (max-width: 680px) {
  main .full-article .article-content h2.aio-article-chapter { font-size: 1.18rem !important; }
  main .full-article .article-content h3.aio-article-subheading { font-size: 1.02rem !important; }
  main .full-article .article-content h4.aio-article-detail { font-size: 1rem !important; }
}

/* Regional SEO discovery link: displays only when the province pages are published. */
.aio-local-discovery{padding:18px 20px;text-align:center;background:#ecf3ff;border-top:1px solid #d4e4ff}
.aio-local-discovery a{color:#174ba4;font-size:14px;font-weight:750;text-decoration:none}
.aio-local-discovery a:hover{text-decoration:underline}
