/* Shared layout rules. Load AFTER styles.css or pages.css so desktop
   reference adjustments cannot override smaller-screen layouts. */
:root {
  font-size: 100%;
  --page-gutter: clamp(1.25rem, 4vw, 3rem);
}

[hidden] { display: none !important; }
.site-shell { overflow: clip; }

.page-hero { overflow: visible; z-index: 2; }

.button, .product-link, .send-button { min-height: 2.75rem; }
.button { max-width: 100%; white-space: normal; text-align: center; }
.icon-button, .social {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
}

.icon { flex-shrink: 0; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.skip-link { position: fixed; top: -8rem; left: 1rem; z-index: 1000; padding: 1rem; background: var(--paper); color: var(--ink); }
.skip-link:focus { top: 1rem; }
html { scroll-padding-top: calc(var(--site-header-height, 5rem) + 1rem); }

/* Readable copy and content-sized components at every width. */
.hero-description, .product-card p, .about-description, .about-copy .lead, .value-item p, .why-item p, .contact-row p { font-size: 1rem; }
.hero-eyebrow, .section-heading .eyebrow, .about-copy .eyebrow,
.industries .eyebrow, .values-label { font-size: .875rem; }
.features li, .product-link { font-size: .875rem; }
.stat dd, .about-stat span { font-size: .875rem; white-space: normal; }

.product-card h2 { white-space: normal; }
.product-card-body { min-height: 0; gap: .75rem; }
.product-card p { min-height: 0; }
.product-card p br, .desktop-break { display: none; }
.product-link { margin-top: auto; font-size: .875rem; text-align: left; }
.home-page .product-card h3 { font-size: 1.125rem; }
.home-page .product-card-body { flex: 1; }
.inner-page .product-card { display: flex; flex-direction: column; min-width: 0; }
.inner-page .product-card-body { flex: 1; }
.stat { height: auto; }
.industry { min-width: 0; padding-inline: 1rem; }
.industry span { white-space: normal; font-size: .875rem; }

.about-copy, .about-intro > *, .contact-row > * { min-width: 0; }

.contact-row a { overflow-wrap: anywhere; }

.about-stats { gap: 1rem; }
.about-stat span { max-width: none; }
.why { height: auto; }
.value-item, .why-item { min-width: 0; }

/* Category controls wrap; an empty filtered row takes no space. */
.products-page { min-height: 0; }
.filter-bar { flex-wrap: wrap; gap: .75rem; }
.filter-bar .filter-pill {
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 2.75rem;
  padding: .75rem 1.25rem;
  font-size: .875rem;
  line-height: 1.4;
}
.products-page.is-filtered .product-grid-primary,
.products-page.is-filtered .product-grid-secondary {
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 2rem;
}

/* The contact section uses document flow, including at desktop widths.
   Labels, long addresses and a resized textarea must be able to grow. */
.contact-page {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  min-height: 0;
  padding: 4rem 3.1rem;
  align-items: start;
}
.contact-details, .contact-form, .map-panel {
  position: static;
  flex: none;
  margin: 0;
  min-width: 0;
  width: 100%;
  height: auto;
}
.contact-details .contact-row { position: static; margin: 0 0 2rem; gap: 1rem; }
.contact-row h3 { font-size: 1rem; }
.contact-details .socials { position: static; margin: 0; flex-wrap: wrap; gap: .75rem; }
.contact-form h2 { position: static; margin: 0 0 1.5rem; font-size: 1.125rem; }
.contact-form form { position: static; width: 100%; height: auto; display: grid; gap: 1rem; }
.form-field { display: grid; gap: .5rem; min-width: 0; }
.form-field label { font-size: .875rem; line-height: 1.5; font-weight: 500; }
.contact-form .field {
  position: static;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  min-height: 3rem;
  margin: 0;
  padding: .75rem .875rem;
  font-size: 1rem;
  line-height: 1.5;
}
.contact-form textarea.field { min-height: 9rem; resize: vertical; }
.contact-form .send-button {
  position: static;
  width: auto;
  margin: .25rem 0 0;
  padding: .875rem 1.5rem;
  font-size: .875rem;
  justify-self: start;
}
.map-panel { min-height: 28rem; aspect-ratio: 3 / 4; align-self: stretch; }

/* Home-page dialogs also need room for enlarged text and mobile keyboards. */
.modal { max-width: calc(100% - 2rem); max-height: calc(100dvh - 2rem); }
.modal h2 { padding-right: 1rem; overflow-wrap: anywhere; }
.modal p, .search-field input, #contact-form input, #contact-form textarea { font-size: 1rem; }
.modal .eyebrow, .modal .prototype-note, .modal .search-caption, .search-result small { font-size: .75rem; }
#contact-form label { font-size: .875rem; }
.modal-close { width: 2.75rem; height: 2.75rem; top: .5rem; right: .5rem; }
.product-detail { grid-template-columns: minmax(0, .9fr) minmax(0, 1fr); }
.contact-dialog-details a { min-width: 0; overflow-wrap: anywhere; }

@media (min-width: 80rem) {
  .hero-art { top: -6.75rem; height: calc(100% + 6.75rem); }
  :root { font-size: clamp(1rem, calc((100vw - 32px) / 77.875), 1.2841rem); }
}

/* Content layouts below the desktop breakpoint. Header styles live in header.css. */
@media (width < 80rem) {
  body { padding: .75rem; }
  .site-shell { border-radius: 1rem; }

  .brand { gap: .5rem; }
  .brand-bottle { width: 1.25rem; height: 2.75rem; }
  .brand-name { font-size: 1.1875rem; }
  .brand-tagline { font-size: .5rem; }

  /* Content determines hero height; the statistics cannot collide with it. */
  .hero { height: auto; min-height: 0; }
  .hero-art { object-fit: cover; object-position: 65% center; }
  .hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #003723eb, #00372355 70%); z-index: -1; pointer-events: none; }
  .hero-content { position: relative; inset: auto; max-width: 43rem; padding: 4rem var(--page-gutter) 3rem; }
  h1 { font-size: clamp(2rem, 4.5vw, 3.125rem); }
  .hero-description { max-width: 27rem; }
  .hero-description br { display: none; }
  .hero-buttons { flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; }
  .statistics {
    position: relative;
    inset: auto;
    width: calc(100% - var(--page-gutter) * 2);
    height: auto;
    margin: 0 var(--page-gutter) -2rem;
    padding: 1.5rem .5rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
  }
  .stat { flex-direction: column; padding: 0 .5rem; gap: .75rem; text-align: center; }
  .stat > .icon { width: 1.75rem; height: 1.75rem; }
  .stat dt { font-size: 1.625rem; }
  .stat dd { margin-top: .375rem; line-height: 1.5; }
  .section-container { padding-inline: var(--page-gutter); }
  .products { padding-top: 5rem; padding-bottom: 3rem; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
  .product-image-button img { height: auto; aspect-ratio: 1.14; }
  .product-card-body { padding: 1rem; }
  .about { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; min-height: 0; }
  .about-image { height: 100%; min-height: 22rem; object-fit: cover; }
  .about-copy { padding-top: 0; }
  .features li { align-items: flex-start; }
  .features .icon { margin-top: .125rem; }
  .industries { padding-top: 3rem; }
  .industry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 1rem; }
  .industry, .industry:first-child { padding: 0; justify-content: flex-start; }
  .industry + .industry { border-left: 0; }
  .industry .icon { width: 1.75rem; height: 1.75rem; }

  .page-hero { height: auto; min-height: 0; }
  .page-hero .hero-photo { inset: 0 0 0 auto; width: 65%; height: 100%; object-fit: cover; }
  .page-hero::before, .page-hero::after { inset: 0; }
  .page-hero .page-hero-copy { position: relative; inset: auto; width: auto; max-width: 43rem; padding: 3rem var(--page-gutter); }
  .page-hero h1 { font-size: clamp(2rem, 4.5vw, 2.75rem); }
  .page-hero p { font-size: 1rem; }
  .page-hero p br { display: none; }
  .page-hero .breadcrumb { font-size: .875rem; }
  .about-intro { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; padding: 3rem var(--page-gutter); align-items: center; }
  .about-copy h2 { font-size: clamp(1.75rem, 3vw, 2.45rem); }
  .about-copy h2 br { display: none; }
  .about-building { height: auto; aspect-ratio: 1; margin: 0; }
  .about-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 2rem; gap: 1.5rem; }
  .about-stat { padding: 0; }
  .values, .why { padding: 3rem var(--page-gutter); }
  .values-grid, .why-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem 2rem; }
  .value-item, .why-item { min-height: 0; padding: 0 .5rem; }
  .value-item + .value-item::before, .why-item + .why-item::before { display: none; }
  .value-item p, .why-item p { max-width: 22rem; }
  .products-page { padding: 3rem var(--page-gutter); }
  .product-grid-primary, .product-grid-secondary,
  .products-page.is-filtered .product-grid-primary, .products-page.is-filtered .product-grid-secondary { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
  .inner-page .product-card img { height: auto; aspect-ratio: 1.14; object-fit: cover; }
  .product-grid-secondary .product-card-body { min-height: 0; }
  .contact-page { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3rem var(--page-gutter); gap: 2rem; }
  .map-panel { grid-column: 1 / -1; min-height: 0; height: 22rem; aspect-ratio: auto; }
}

@media (width < 48rem) {
  body { padding: 0; }
  .site-shell { border-radius: 0; }
  .hero { display: flex; flex-direction: column; }

  .hero-content { order: 1; padding-top: 2.5rem; padding-bottom: 2rem; }
  .hero-art { position: relative; inset: auto; order: 2; width: 100%; height: auto; max-width: 100%; aspect-ratio: 623 / 330; object-fit: cover; mask-image: linear-gradient(transparent, #000 20%); margin-top: -2rem; z-index: 0; }
  .hero::after { content: none; }
  .statistics { order: 3; margin-top: -1rem; grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 1.5rem; }
  .stat { grid-column: span 2; }
  .stat:nth-child(4) { grid-column: 2 / 4; }
  .stat:nth-child(5) { grid-column: 4 / 6; }
  .stat > .icon { display: none; }
  .stat:nth-child(4)::before { display: none; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about, .about-intro, .contact-page { grid-template-columns: minmax(0, 1fr); }
  .about-image { height: auto; min-height: 0; aspect-ratio: 1.5; }
  .about-building { aspect-ratio: 4 / 3; }
  .about-copy .lead { max-width: none; }
  .industry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .map-panel { height: 20rem; }
  .product-detail { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .product-detail > img { width: 100%; max-height: 16rem; object-fit: contain; background: #e7e3dc; }
}

@media (width < 40rem) {

  .hero-content h1 { font-size: clamp(1.875rem, 7vw, 2.75rem); }
  .hero-eyebrow { font-size: .75rem; }
  .section-heading { text-align: left; }
  .section-heading h2, .about h2 { font-size: 1.75rem; }
  .product-grid-primary, .product-grid-secondary,
  .products-page.is-filtered .product-grid-primary, .products-page.is-filtered .product-grid-secondary { grid-template-columns: minmax(0, 1fr); }
  .inner-page .product-card h2 { font-size: 1.375rem; }
  .contact-form .send-button { width: 100%; }
  .modal { width: calc(100% - 2rem); padding: 3.25rem 1.25rem 1.5rem; border-radius: .75rem; }
  .modal h2 { font-size: 1.75rem; padding-right: 0; }
  .contact-dialog-details { flex-direction: column; gap: 1rem; }
}

@media (width < 30rem) {
  .hero-buttons { flex-direction: column; align-items: stretch; }
  .statistics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statistics .stat { grid-column: auto; }
  .statistics .stat:nth-child(odd)::before { display: none; }
  .statistics .stat:last-child { grid-column: 1 / -1; }
  .values-grid { grid-template-columns: minmax(0, 1fr); }
  .product-grid { display: flex; gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 0; padding: .25rem .25rem .75rem; margin-inline: -.25rem; scrollbar-width: thin; }
  .home-page .product-card { flex: 0 0 85%; scroll-snap-align: start; }
  .mobile-product-controls { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-top: .75rem; font-size: .875rem; }
  .mobile-product-controls > div { display: flex; gap: .5rem; }
  .mobile-product-controls .icon-button { border: 1px solid var(--line); border-radius: 50%; }
  .mobile-product-controls .icon { width: 1.125rem; height: 1.125rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .mobile-product-controls { display: none !important; }
}
