/*
  BON GUSTO VENDING — responsive refinements
  Loaded after the approved stylesheets. This file changes layout behavior only;
  it intentionally preserves the existing desktop art direction and content.
*/

/* Prevent intrinsic grid/flex content from forcing the viewport wider. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.container,
main,
section,
article,
header,
footer,
.nav-wrap,
.hero-grid,
.split,
.cards-3,
.machine-grid,
.contact-layout,
.footer-grid {
  min-width: 0;
}

img,
svg,
video,
iframe {
  max-width: 100%;
}

h1, h2, h3, p, a, strong, span, small, label {
  overflow-wrap: break-word;
}

/* Preserve the approved floating WhatsApp control at the bottom-right on every device. */
.whatsapp-float {
  position: fixed !important;
  top: auto !important;
  right: max(20px, env(safe-area-inset-right)) !important;
  bottom: max(20px, env(safe-area-inset-bottom)) !important;
  left: auto !important;
  transform: none !important;
  z-index: 2147483000 !important;
}
.whatsapp-float:hover,
.whatsapp-float:focus-visible { transform: translateY(-3px) !important; }

/* Tablet navigation: keep the full link row only when it has real room. */
@media (max-width: 960px) {
  .topbar-right { display: none; }
  .topbar-inner { justify-content: center; text-align: center; }

  .nav-wrap {
    position: relative;
    height: 76px;
    gap: 12px;
  }

  .site-header.is-scrolled .nav-wrap { height: 68px; }

  .brand {
    min-width: 0;
    flex: 0 1 auto;
    gap: 9px;
  }

  .brand img {
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
  }

  .brand-copy strong { font-size: 1.12rem; }
  .brand-copy span { font-size: .54rem; }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    flex: 0 0 auto;
    cursor: pointer;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: -18px;
    right: -18px;
    width: auto;
    max-width: 100vw;
    max-height: calc(100dvh - 92px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 22px 22px;
    background: rgba(252,250,246,.985);
    border: 1px solid rgba(189,135,53,.16);
    border-top: 0;
    box-shadow: 0 18px 36px rgba(25,17,10,.13);
    backdrop-filter: blur(20px);
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    z-index: 80;
  }

  .nav.open { display: flex; }
  .nav a { padding: 12px 3px; font-size: .92rem; }
  .nav .nav-cta { margin-top: 9px; text-align: center; padding: 13px 15px !important; }
}

/* Tablet composition: stack editorial sections before they become crowded. */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: auto;
    gap: 8px;
    padding-top: 30px;
    padding-bottom: 52px;
  }

  .hero-copy {
    width: 100%;
    max-width: 760px;
    padding: 35px 0 12px;
  }

  .hero h1 {
    max-width: 720px;
    font-size: clamp(3rem, 8.2vw, 4.9rem);
    line-height: 1.02;
  }

  .hero-copy .lead { max-width: 680px; }

  .hero-machine-stage {
    width: min(100%, 610px);
    min-height: clamp(360px, 56vw, 470px);
    margin: 0 auto;
  }

  .hero-machine-stage:before { width: min(75vw, 370px); height: min(75vw, 370px); }
  .hero-machine-stage:after { width: min(68vw, 330px); height: min(68vw, 330px); }

  .section-head {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .section-head p { max-width: 680px; margin: 0; }
  .split { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .split-visual { min-height: clamp(280px, 52vw, 410px); }
  .contact-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .machine-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .machine-grid-three > .machine-card { min-width: 0; }
  .machine-grid-three .machine-photo { height: clamp(280px, 38vw, 345px); }
  .reference-logo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-solutions-section .cards-3 { grid-template-columns: minmax(0, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px; }
  .footer-grid > div:first-child { grid-column: 1 / -1; }
}

/* Phones and narrow tablets. */
@media (max-width: 680px) {
  .container { width: calc(100% - 32px); }
  .topbar { font-size: .62rem; letter-spacing: .035em; }
  .topbar-inner { min-height: 32px; padding: 5px 0; }

  .nav-wrap { height: 70px; }
  .site-header.is-scrolled .nav-wrap { height: 64px; }
  .brand img { width: 47px; height: 48px; }
  .brand-copy strong { font-size: 1.02rem; }
  .brand-copy span { margin-top: 4px; font-size: .49rem; letter-spacing: .22em; }
  .menu-toggle { min-height: 40px; padding: 8px 10px; font-size: .83rem; }
  .nav { left: -16px; right: -16px; max-height: calc(100dvh - 82px); }

  .hero-grid { padding-top: 18px; padding-bottom: 38px; }
  .hero-copy { padding: 30px 0 10px; }
  .hero h1 {
    font-size: clamp(2.45rem, 10.5vw, 3.8rem);
    letter-spacing: -.065em;
    line-height: 1.02;
    margin: 15px 0 18px;
  }
  .hero-copy .lead { font-size: .93rem; line-height: 1.7; }
  .hero-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 22px; }
  .hero-actions .btn { width: 100%; min-height: 48px; }
  .hero-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 25px; padding-top: 17px; }
  .hero-meta > div { min-width: 0; padding: 0 5px; }
  .hero-meta strong { font-size: clamp(1rem, 5vw, 1.3rem); }
  .hero-meta span { display: block; font-size: .62rem; line-height: 1.4; }

  .hero-machine-stage {
    width: 100%;
    min-height: clamp(300px, 88vw, 370px);
    margin-top: 4px;
  }
  .hero-machine-stage:before { width: min(75vw, 285px); height: min(75vw, 285px); }
  .hero-machine-stage:after { width: min(69vw, 260px); height: min(69vw, 260px); }
  .hero-machine-main { left: 2%; top: 2%; width: 55%; height: 78%; padding: 23px 11px 12px; }
  .hero-machine-side { right: 1%; bottom: 8%; width: 45%; height: 59%; padding: 22px 10px 10px; }
  .visual-note { right: 0; bottom: 0; max-width: 148px; padding: 9px 11px; }
  .visual-note strong { font-size: .78rem; }
  .visual-note span { font-size: .6rem; line-height: 1.35; }
  .photo-label { max-width: calc(100% - 12px); font-size: .44rem; letter-spacing: .1em; }

  .trust-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trust-item { min-width: 0; padding: 14px 9px; gap: 8px; }
  .trust-item strong { font-size: .92rem; }
  .trust-item span { font-size: .61rem; line-height: 1.35; }
  .trust-icon { width: 34px; height: 34px; flex: 0 0 34px; font-size: 1rem; }

  .section { padding: 62px 0; }
  .section-head { margin-bottom: 27px; }
  .section-head h2 { font-size: clamp(2rem, 8vw, 2.65rem); line-height: 1.06; }
  .section-head p, .section-intro { font-size: .9rem; line-height: 1.7; }
  .cards-3, .home-solutions-section .cards-3, .service-grid,
  .machine-grid, .machine-grid-three { grid-template-columns: minmax(0, 1fr); }
  .feature-card { min-width: 0; padding: 0 21px 24px; }
  .home-solutions-section .feature-card:nth-child(-n+3) .feature-media { height: clamp(245px, 72vw, 315px); }
  .home-solutions-section .feature-card:nth-child(-n+3) .feature-media img { padding: 16px 18px 20px; }
  .feature-card h3 { font-size: 1.2rem; }
  .feature-card p { font-size: .88rem; }
  .text-link { line-height: 1.45; }

  .machine-grid-three { gap: 18px; }
  .machine-grid-three .machine-photo { height: clamp(275px, 78vw, 340px); padding: 17px; }
  .machine-grid-three .machine-top { min-height: 0; padding: 22px 22px 18px; }
  .machine-grid-three .machine-top h2 { font-size: clamp(1.75rem, 7vw, 2.15rem); }
  .machine-grid-three .machine-body { padding: 21px 22px 24px; }
  .machine-body p { font-size: .88rem; line-height: 1.7; }
  .spec-row { align-items: flex-start; gap: 8px; font-size: .77rem; }
  .spec-row > span { flex: 1 1 42%; min-width: 0; }
  .spec-row > strong { flex: 1 1 58%; min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .machine-footnote { overflow-wrap: anywhere; }

  .split { gap: 25px; }
  .split-visual { min-height: 270px; }
  .split-note { left: 12px; right: 12px; bottom: 12px; max-width: none; padding: 13px 15px; }
  .check-list li { align-items: flex-start; font-size: .86rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .stats-grid > div:last-child { grid-column: 1 / -1; }
  .stats-grid strong { font-size: 2rem; }

  .photo-gallery-section { padding: 58px 0; }
  .photo-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 185px 135px 135px; gap: 9px; }
  .photo-gallery-card:first-child { grid-column: 1 / -1; grid-row: auto; }
  .photo-gallery-card { min-width: 0; }
  .photo-gallery-card figcaption { left: 11px; right: 11px; bottom: 10px; font-size: .69rem; }

  .reference-logo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .reference-logo-card { min-width: 0; min-height: 132px; padding: 12px 9px; }
  .reference-logo-mark { max-width: 100%; height: 56px; }
  .reference-logo-mark img { max-width: 100%; max-height: 52px; object-fit: contain; }
  .reference-logo-card strong { font-size: .72rem; line-height: 1.25; }
  .client-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .client-logo-mini { min-width: 0; min-height: 92px; padding: 10px; }
  .client-logo-mini img { max-width: 100%; max-height: 36px; object-fit: contain; }
  .client-logo-mini b { font-size: .69rem; overflow-wrap: anywhere; }

  .page-hero { padding: 49px 0 43px; }
  .page-hero h1 { font-size: clamp(2.35rem, 10vw, 3.2rem); line-height: 1.04; }
  .page-hero p { font-size: .92rem; line-height: 1.7; }
  .breadcrumb { font-size: .7rem; overflow-wrap: anywhere; }
  .service-photo, .references-photo { min-height: 290px; padding: 22px; background-attachment: scroll; }
  .service-photo h2, .references-photo span { font-size: clamp(1.9rem, 8vw, 2.6rem); }

  .contact-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .contact-panel, .contact-form { min-width: 0; padding: 22px 18px; }
  .contact-panel h2, .contact-form h2 { font-size: 1.65rem; }
  .contact-detail a, .contact-detail span { font-size: .93rem; overflow-wrap: anywhere; }
  .field input, .field textarea, .field select { width: 100%; min-width: 0; font-size: 16px; }
  .contact-form .btn { width: 100%; min-height: 48px; }

  .cta-band { padding: 45px 0; }
  .cta-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
  .cta-inner h2 { font-size: clamp(2rem, 8vw, 2.7rem); }
  .cta-inner .btn { width: 100%; margin-top: 0; }

  .footer { padding: 48px 0 22px; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 25px; padding-bottom: 30px; }
  .footer-grid > div:first-child { grid-column: auto; }
  .footer p { max-width: none; }
  .footer-bottom { display: flex; flex-direction: column; gap: 7px; }

  /* Keep the requested floating control fixed at the bottom-right on phones. */
  .whatsapp-float {
    position: fixed !important;
    top: auto !important;
    right: max(14px, env(safe-area-inset-right)) !important;
    bottom: max(14px, env(safe-area-inset-bottom)) !important;
    left: auto !important;
    width: 54px;
    min-width: 54px;
    height: 54px;
    padding: 0;
    transform: none !important;
    z-index: 2147483000 !important;
  }
  .whatsapp-float:hover,
  .whatsapp-float:focus-visible { width: 54px; transform: translateY(-2px) !important; }
  .whatsapp-logo { width: 28px; height: 28px; flex-basis: 28px; }
  .whatsapp-label { display: none; }
}

/* Very narrow phones: prioritize readable type and prevent card compression. */
@media (max-width: 360px) {
  .container { width: calc(100% - 28px); }
  .brand-copy strong { font-size: .96rem; }
  .menu-toggle { padding: 7px 8px; }
  .hero h1 { font-size: clamp(2.25rem, 10vw, 2.75rem); }
  .hero-meta { gap: 3px; }
  .hero-meta > div { padding-inline: 3px; }
  .hero-meta span { font-size: .57rem; }
  .trust-item { padding-inline: 7px; }
  .trust-item strong { font-size: .83rem; }
  .trust-item span { font-size: .57rem; }
  .product-table { display: block; width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .product-table thead, .product-table tbody { white-space: normal; }
  .product-table th, .product-table td { padding: 10px 8px; font-size: .69rem; overflow-wrap: anywhere; }
  .photo-gallery-grid { grid-template-rows: 160px 120px 120px; }
  .machine-grid-three .machine-photo { height: 270px; }
}

/* Mobile landscape: prevent the hero stage and expanded menu from consuming the screen. */
@media (max-width: 900px) and (orientation: landscape) {
  .nav { max-height: calc(100dvh - 78px); }
  .hero-grid { padding-top: 15px; padding-bottom: 26px; }
  .hero-copy { padding-top: 22px; }
  .hero-machine-stage { min-height: 320px; max-width: 540px; }
  .hero-machine-stage:before { width: 265px; height: 265px; }
  .hero-machine-stage:after { width: 235px; height: 235px; }
}

@media (prefers-reduced-motion: reduce) {
  .whatsapp-float { animation: none !important; transition: none !important; }
  .machine-photo img, .feature-media img, .photo-gallery-card img { transition: none !important; }
}

/* Homepage editorial gallery — larger, balanced mobile composition. */
.photo-gallery-grid {
  min-width: 0;
}
.photo-gallery-card {
  margin: 0;
  min-width: 0;
  width: 100%;
  min-height: 0;
}
.photo-gallery-card img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  object-position: center;
}
@media (max-width: 680px) {
  .photo-gallery-section {
    padding: 54px 0 60px;
  }
  .photo-gallery-section .section-head {
    margin-bottom: 25px;
  }
  .photo-gallery-section .section-head h2 {
    max-width: 100%;
    font-size: clamp(2.15rem, 9vw, 2.8rem);
    line-height: 1.04;
  }
  .photo-gallery-section .section-head p {
    margin-top: 13px;
    font-size: .91rem;
    line-height: 1.65;
  }
  .photo-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 250px 205px 205px;
    gap: 12px;
    width: 100%;
  }
  .photo-gallery-card:first-child {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .photo-gallery-card:nth-child(2),
  .photo-gallery-card:nth-child(3) {
    grid-column: span 1;
  }
  .photo-gallery-card:nth-child(4) {
    grid-column: 1 / -1;
  }
  .photo-gallery-card {
    border-radius: 20px;
  }
  .photo-gallery-card figcaption {
    left: 15px;
    right: 15px;
    bottom: 14px;
    font-size: .78rem;
    line-height: 1.4;
  }
  .photo-gallery-card figcaption small {
    font-size: .62rem;
    margin-bottom: 6px;
  }
}
@media (max-width: 380px) {
  .photo-gallery-grid {
    grid-template-rows: 220px 190px 190px;
    gap: 10px;
  }
  .photo-gallery-card { border-radius: 17px; }
  .photo-gallery-card figcaption {
    left: 12px;
    right: 12px;
    bottom: 11px;
    font-size: .72rem;
  }
}
