/* Keep decorative rotations from making the document wider than the screen. */
html, body { overflow-x: clip; }
html:has(dialog[open]) { overflow: hidden; }
.header-actions, .header-action { flex-shrink: 0; }
.desktop-nav, .hero-copy, .product-info, .product-details,
.cart-items, .checkout-unavailable, .order-summary,
.footer-nav, .woocommerce-MyAccount-content { min-width: 0; }
.product-title, .product-details h1, .category-copy h3,
.summary-line > span, .woocommerce-MyAccount-content { overflow-wrap: anywhere; }

/* Match the Snap Mini photo format, including its existing responsive padding. */
.product-grid { grid-auto-rows: 1fr; }
.product-card { display: flex; flex-direction: column; }
.product-image-link img { aspect-ratio: 1; object-fit: contain; }
.product-card .product-info { flex: 1; }
.product-card .product-bottom { margin-top: auto; padding-top: 8px; }

/* A dialog's original top margin pushed its lower links below the viewport. */
.mobile-menu {
  inset: 12px;
  width: min(520px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: clamp(16px, 3dvh, 24px);
  overflow: auto;
  overscroll-behavior: contain;
}
.mobile-menu .dialog-head { gap: 12px; margin-bottom: 12px; }
.mobile-menu .dialog-head h2 { font-size: clamp(16px, 4.4vw, 20px); line-height: 1.3; }
.mobile-menu nav { gap: 0; }
.mobile-menu nav > a, .mobile-menu nav > button {
  min-width: 0;
  min-height: 44px;
  padding: 10px 0;
  font-size: clamp(14px, 3.8vw, 17px);
  line-height: 1.3;
}
.mobile-menu .small-copy { margin-top: 12px; font-size: 11px; line-height: 1.4; }
.mobile-menu .dialog-close { min-width: 44px; min-height: 44px; }

/* Short landscape screens need two columns instead of a scrolling list. */
@media (max-height: 560px) {
  .mobile-menu { width: min(680px, calc(100% - 24px)); padding: 12px; }
  .mobile-menu .dialog-head { margin-bottom: 6px; }
  .mobile-menu .dialog-head h2 { font-size: 16px; }
  .mobile-menu .dialog-close { min-width: 40px; min-height: 40px; }
  .mobile-menu nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
  .mobile-menu nav > a, .mobile-menu nav > button { min-height: 40px; font-size: 13px; padding-block: 6px; overflow-wrap: anywhere; }
  .mobile-menu .small-copy { margin-top: 6px; }
}

/* Fit the complete desktop introduction below the announcement and header. */
@media (min-width: 1024px) {
  .hero {
    min-height: calc(100svh - 125px);
    display: flex;
    flex-direction: column;
    padding-block: clamp(16px, 3svh, 40px) 16px;
  }
  .hero-grid { flex: 1; min-height: 0; gap: 32px; }
  .hero-copy { --od-gap: clamp(12px, 2.1svh, 24px); padding-bottom: 0; }
  .hero h1 { font-size: clamp(52px, min(6.1vw, 10.2svh), 96px); }
  .hero .actions { flex-direction: row; align-items: center; gap: 8px 12px; }
  .hero-art { width: min(100%, calc((100svh - 275px) * 1.5)); justify-self: center; padding-top: 16px; }
  .hero-scene { margin-top: 0; }
  .snap-control { margin-top: 16px; gap: 10px 14px; flex-wrap: wrap; }
  .snap-button { min-height: 48px; padding-block: 10px; }
  .hero-bottom { margin-top: 16px; }
}
@media (min-width: 1024px) and (max-height: 700px) {
  .hero { padding-block: 12px; }
  .hero-copy { --od-gap: 12px; }
  .hero h1 { font-size: clamp(44px, min(5.8vw, 9.4svh), 70px); }
  .hero-description { font-size: 16px; line-height: 1.5; }
  .hero-note { font-size: 12px; }
  .hero .btn { min-height: 48px; padding-block: 12px; }
  .hero-bottom { margin-top: 12px; }
}
@media (min-width: 1024px) and (max-height: 560px) {
  .hero { padding-block: 8px; }
  .hero-copy { --od-gap: 8px; }
  .hero h1 { font-size: clamp(40px, 8.8svh, 50px); }
  .hero-eyebrow { font-size: 10px; }
  .hero .little-sun .icon { width: 20px; height: 20px; }
  .hero-description { font-size: 15px; line-height: 1.45; }
  .hero .btn { min-height: 44px; padding-block: 10px; }
  .hero-art { width: min(100%, calc((100svh - 240px) * 1.5)); padding-top: 8px; }
  .snap-control { margin-top: 12px; }
  .snap-button { min-height: 44px; padding-block: 8px; font-size: 14px; }
  .hero-bottom { margin-top: 8px; font-size: 10px; }
}

@media (max-width: 479px) {
  .hero h1 { font-size: clamp(40px, 12.6vw, 60px); }
  .hero-eyebrow { font-size: 10px; }
  .hero .actions { gap: 8px; }
  .hero .btn { font-size: 13px; padding-inline: 16px; }
  .hero .btn-plain { padding-inline: 0; }
  .product-info { padding-inline: 0; }
  .product-bottom { flex-wrap: wrap; }
  .category-copy h3 { font-size: clamp(14px, 4.1vw, 18px); }
  .footer-top { column-gap: 16px; }
  .footer-nav h2 { overflow-wrap: anywhere; }
}
@media (max-width: 1023px) {
  /* Put products on the first screen, with the controls in a compact toolbar. */
  body:has(.catalog-page) .header-inner { min-height: 64px; }
  .catalog-page { padding-top: 8px; }
  .catalog-page .breadcrumbs,
  .catalog-page .page-heading .eyebrow,
  .catalog-page .page-heading > p { display: none; }
  .catalog-page .page-heading { display: block; margin-bottom: 8px; }
  .catalog-page .page-heading h1 { font-size: 28px; line-height: 1.2; }
  .catalog-page .category-tabs { gap: 6px; margin-bottom: 8px; }
  .catalog-page .chip { min-height: 36px; padding: 6px 12px; font-size: 12px; line-height: 1.3; }
  .catalog-page .catalog-layout {
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 8px 12px;
  }
  .catalog-page .filter-sidebar { grid-column: 1; grid-row: 1; }
  .catalog-page .filter-disclosure { border: 0; }
  .catalog-page .filter-disclosure > summary {
    width: 110px;
    min-height: 44px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    gap: 8px;
    font-size: 12px;
  }
  .catalog-page .filter-disclosure > summary .icon { width: 18px; height: 18px; }
  .catalog-page .filter-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-block: 12px;
  }
  .catalog-page .filter-fields > .field:first-child,
  .catalog-page .filter-fields > fieldset,
  .catalog-page .filter-fields > .small-copy { grid-column: 1 / -1; }
  .catalog-page .filter-fields .field { gap: 6px; }
  .catalog-page .filter-fields label, .catalog-page .filter-fields legend { font-size: 12px; }
  .catalog-page .filter-fields legend { margin-bottom: 8px; }
  .catalog-page .filter-fields input, .catalog-page .filter-fields select { min-height: 44px; padding: 8px 10px; }
  .catalog-page .filter-fields input { font-size: 16px; }
  .catalog-page .filter-fields select { font-size: 14px; }
  .catalog-page .filter-fields > .btn { min-height: 44px; align-self: end; padding: 10px 12px; }
  .catalog-page #catalog-results, .catalog-page .catalog-result-head { display: contents; }
  .catalog-page .catalog-result-head > p {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 12px;
  }
  .catalog-page .sort-label { grid-column: 2; grid-row: 1; min-width: 0; width: 100%; }
  .catalog-page .sort-caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .catalog-page .sort-label select { width: 100%; max-width: none; padding: 8px 10px; font-size: 12px; }
  .catalog-page .catalog-layout > #catalog-results > .product-grid,
  .catalog-page .catalog-layout > #catalog-results > .empty-state { grid-column: 1 / -1; }
  .catalog-page .product-image-link { padding: 32px 12px 12px; }
  .catalog-page .product-info { padding-top: 10px; --od-gap: 3px; }
  .catalog-page .product-title { font-size: 14px; line-height: 1.4; }
  .catalog-page .product-card .product-bottom { padding-top: 6px; }
  .catalog-page .filter-sidebar:has(.filter-disclosure[open]) { grid-column: 1 / -1; }
  .catalog-page .catalog-layout:has(.filter-disclosure[open]) .sort-label { grid-row: 2; }
  .catalog-page .catalog-layout:has(.filter-disclosure[open]) .catalog-result-head > p { grid-column: 1; align-self: center; }

  /* Keep stock and price together; the add button spans their two compact rows. */
  .product-card .product-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-rows: auto auto minmax(18px, 1fr) 24px;
    gap: 2px 8px;
    align-content: start;
    padding-top: 8px;
  }
  .product-card .product-title {
    grid-column: 1 / -1;
    min-height: 2.8em;
    font-size: 14px;
    line-height: 1.4;
  }
  .product-card .product-variant { grid-column: 1 / -1; font-size: 12px; line-height: 18px; }
  .product-card .product-availability { grid-column: 1; grid-row: 3; align-self: end; font-size: 11px; line-height: 18px; }
  .product-card .product-info .product-bottom { display: contents; }
  .product-card .price { grid-column: 1; grid-row: 4; font-size: 15px; line-height: 24px; }
  .product-card .add-button { grid-column: 2; grid-row: 3 / 5; align-self: end; }
}
@media (max-width: 1023px) and (max-height: 480px) and (orientation: landscape) {
  body:has(.catalog-page) .announcement { display: none; }
  .catalog-page .page-heading { display: none; }
  .catalog-page .category-tabs { margin-bottom: 8px; }
  .catalog-page .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .catalog-page .product-image-link { padding: 24px 8px 8px; }
  .catalog-page .product-image-link img { height: min(130px, calc(100svh - 230px)); aspect-ratio: auto; }
}
@media (max-width: 767px) {
  .faq-grid { grid-template-columns: minmax(0, 1fr); }
  .faq-grid > .od-stack { min-width: 0; }
  .faq-grid > .od-stack h2 br { display: initial; }
}

/* All overlays stay inside the dynamic viewport, including browser toolbars. */
.search-dialog { max-height: calc(100dvh - 24px); overscroll-behavior: contain; }
.search-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.search-dialog > .dialog-head, .search-dialog > .search-form { flex-shrink: 0; }
.search-results { max-height: min(52dvh, 420px); }
.search-dialog .search-results { min-height: 0; flex-shrink: 1; }
.lightbox { max-height: calc(100dvh - 24px); }
.toast { max-width: calc(100% - 24px); }

/* Reserve the same photo area for every aspect ratio and keep all views together. */
.product-page {
  --product-header: 125px;
  --gallery-thumb: 76px;
  --gallery-gap: 12px;
  --gallery-room: calc(100svh - var(--product-header) - 184px);
  padding-top: 16px;
}
.product-page .breadcrumbs { margin-bottom: 16px; }
.product-gallery { min-width: 0; container-type: inline-size; }
.product-main-image { width: 100%; min-width: 0; overflow: hidden; }
.product-main-image .gallery-open {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  height: min(100cqw, 560px, var(--gallery-room));
  padding: 16px;
}
.gallery-open > img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.gallery-open .zoom-hint { margin: 0; line-height: 20px; }
.gallery-thumbs {
  gap: var(--gallery-gap);
  margin-top: var(--gallery-gap);
  flex-wrap: wrap;
}
.gallery-thumb {
  flex: 0 0 var(--gallery-thumb);
  width: var(--gallery-thumb);
  height: var(--gallery-thumb);
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 1023px) {
  .product-page { --product-header: 117px; --gallery-thumb: 68px; }
}
@media (max-width: 767px) {
  .product-page {
    --product-header: 105px;
    --gallery-thumb: 64px;
    --gallery-room: calc(100svh - var(--product-header) - 164px);
  }
  .product-page .breadcrumbs { margin-bottom: 12px; }
  .product-main-image .gallery-open { padding: 12px; }
  .product-detail { row-gap: 24px; }
}
/* In phone landscape, place the extra views beside the photo. */
@media (max-width: 1023px) and (max-height: 480px) and (orientation: landscape) {
  .product-page {
    --gallery-thumb: clamp(40px, calc((100svh - var(--product-header) - 84px) / 3), 60px);
    --gallery-gap: 6px;
    --gallery-room: calc(100svh - var(--product-header) - 72px);
    padding-top: 8px;
  }
  .product-page .breadcrumbs { margin-bottom: 8px; }
  .product-gallery:has(.gallery-thumbs) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--gallery-thumb);
    gap: 12px;
  }
  .product-main-image .gallery-open { padding: 8px; gap: 6px; }
  .gallery-open .zoom-hint { font-size: 10px; line-height: 16px; }
  .product-gallery .gallery-thumbs { flex-direction: column; margin-top: 0; }
}
@media (max-width: 359px) {
  .product-page { --product-header: 121px; }
  .toast { flex-wrap: wrap; justify-content: center; }
  .color-picker .od-cluster { gap: 6px; }
  .color-option { font-size: 10px; }
  .faq-grid > .od-stack { padding-right: 88px; }
  .faq-grid h2 { font-size: 22px; }
  .faq-mascot { width: 80px; }
}
