/* Open, light product gallery; loading never changes the image canvas size. */
.detail-page .gallery {
  gap: 0.65rem;
  overflow: visible;
  color: var(--ink-700);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.gallery__head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 2.3rem; padding: 0 0.15rem; }
.gallery__heading { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.8rem; min-width: 0; }
.gallery__heading > span:first-child { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; font-weight: 500; }
.gallery__heading .icon { color: var(--brand-orange); }
.gallery__selection { color: var(--ink-500); font-size: 0.75rem; }
.gallery__expand { display: inline-flex; align-items: center; gap: 0.35rem; flex: none; padding: 0.4rem 0.5rem; color: var(--ink-500); border: 1px solid var(--line); border-radius: 8px; font-size: 0.72rem; }
.gallery__expand:hover { color: var(--accent-700); border-color: var(--accent); background: var(--accent-soft); }
.gallery__expand:disabled { opacity: 0.4; cursor: default; }
.gallery__expand[hidden], .gallery [hidden] { display: none; }
.detail-page .gallery__stage { aspect-ratio: 1100 / 760; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-soft); }
.gallery__slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery__feedback { position: absolute; top: 0.75rem; inset-inline: 0.75rem; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; width: fit-content; max-width: calc(100% - 1.5rem); padding: 0.6rem 0.75rem; color: var(--ink-700); background: rgb(255 255 255 / 97%); border: 1px solid var(--line); border-radius: 9px; font-size: 0.75rem; line-height: 1.5; box-shadow: var(--sh-sm); }
.gallery[data-gallery-status="ready"] .gallery__feedback { display: none; }
.gallery[aria-busy="true"] .gallery__feedback::before { content: ""; flex: none; width: 0.75rem; height: 0.75rem; border: 2px solid #fb7b2240; border-top-color: var(--brand-orange); border-radius: 50%; animation: gallery-loading 0.8s linear infinite; }
.gallery__retry { flex: none; padding: 0.3rem 0.45rem; color: var(--accent-700); border: 1px solid var(--accent-ring); border-radius: 6px; font-size: 0.72rem; }
.gallery__retry:hover { color: var(--accent-600); background: var(--accent-soft); }
.detail-page .gallery__controls { position: static; display: flex; gap: 0.75rem; padding: 0 0.15rem; border: 0; }
.gallery__position { display: flex; align-items: center; justify-content: center; gap: 0.65rem; flex: 1; }
.detail-page .gallery__caption { padding: 0; color: var(--ink-700); background: none; border-radius: 0; box-shadow: none; font-size: 0.8rem; font-weight: 500; }
.detail-page .gallery__counter { position: static; padding: 0; color: var(--ink-500); background: none; border-radius: 0; backdrop-filter: none; font-size: 0.75rem; font-weight: 400; }
.detail-page .gallery__nav, .gallery-viewer .gallery__nav { color: var(--ink-700); background: var(--bg); border-color: var(--line); box-shadow: none; width: 2.3rem; height: 2.3rem; }
.detail-page .gallery__nav:hover, .gallery-viewer .gallery__nav:hover { color: var(--accent-700); background: var(--accent-soft); border-color: var(--accent); }
.gallery__nav:disabled { opacity: 0.35; cursor: default; }
.detail-page .gallery__thumbs { gap: 0.5rem; padding: 0.15rem; }
.detail-page .gallery__thumb { position: relative; aspect-ratio: 1100 / 760; min-width: 0; background: var(--bg-soft); border: 2px solid transparent; border-radius: 8px; opacity: 1; transition: border-color 0.16s ease, box-shadow 0.16s ease; }
.detail-page .gallery__thumb:hover { border-color: #fb7b2266; }
.detail-page .gallery__thumb.is-active { border-color: var(--brand-orange); box-shadow: 0 0 0 2px #fb7b2233; }
.gallery__thumb::after { content: attr(data-view-number); position: absolute; right: 0.25rem; bottom: 0.25rem; display: grid; place-items: center; width: 1.2rem; height: 1.2rem; color: var(--ink-700); background: rgb(255 255 255 / 92%); border: 1px solid var(--line); border-radius: 4px; font-size: 0.64rem; line-height: 1; font-weight: 500; pointer-events: none; }
.gallery__thumb.is-active::after { color: #fff; background: var(--accent-700); border-color: var(--accent-700); }
.detail-page .gallery__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-page .gallery__ph { color: var(--ink-500); }
.gallery :is(button):focus-visible, .gallery-viewer button:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 3px; }
/* Edge-to-edge viewer: the photograph keeps its full composition. */
body[data-page="product-detail"] .detail-page dialog.gallery-viewer {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none; margin: 0; padding: 0;
  overflow: hidden; color: #fff; background: #111315;
  border: 0; border-radius: 0; box-shadow: none; overscroll-behavior: none;
}
.gallery-viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
.gallery-viewer::backdrop { background: #111315; }
.gallery-viewer__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-width: 0; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
body[data-page="product-detail"] .detail-page .gallery-viewer .gallery-viewer__head h2 { min-width: 0; overflow: hidden; color: #eee; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; font-weight: 500; line-height: 1.5; }
body[data-page="product-detail"] .detail-page .gallery-viewer .gallery-viewer__close,
body[data-page="product-detail"] .detail-page .gallery-viewer .gallery__nav {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px;
  color: #fff; background: #ffffff12; border: 1px solid #ffffff26; border-radius: 50%; box-shadow: none;
}
body[data-page="product-detail"] .detail-page .gallery-viewer .gallery-viewer__close:hover,
body[data-page="product-detail"] .detail-page .gallery-viewer .gallery__nav:hover { color: #fff; background: #ffffff26; border-color: #ffffff66; }
body[data-page="product-detail"] .detail-page .gallery-viewer .gallery-viewer__stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: transparent; touch-action: none; }
.gallery-viewer__stage img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.gallery-viewer__controls { display: flex; justify-content: center; align-items: center; gap: 1.5rem; padding: 10px 16px; font-size: .8rem; font-variant-numeric: tabular-nums; }
.gallery-viewer__controls > span { min-width: 9rem; text-align: center; color: #d5d7d9; }
.gallery-viewer__thumbs { position: relative; display: flex; gap: 8px; width: max-content; max-width: 100%; min-width: 0; justify-self: center; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 3px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.gallery-viewer__thumbs::-webkit-scrollbar { display: none; }
.gallery-viewer__thumbs[hidden] { display: none; }
.gallery-viewer__thumb { flex: 0 0 76px; width: 76px; height: 52px; overflow: hidden; border: 2px solid transparent; border-radius: 5px; opacity: .55; transition: opacity .15s, border-color .15s; }
.gallery-viewer__thumb[aria-pressed="true"] { opacity: 1; border-color: #fb7b22; }
.gallery-viewer__thumb:hover { opacity: 1; }
.gallery-viewer__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 560px) {
  .gallery-viewer__head { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .gallery-viewer__thumb { flex-basis: 60px; width: 60px; height: 42px; }
  .gallery-viewer__controls { gap: 1rem; padding-block: 8px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .gallery-viewer[open] { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto; }
  .gallery-viewer__head { position: absolute; z-index: 2; top: 0; right: 0; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)); }
  .gallery-viewer__head h2 { display: none; }
  .gallery-viewer__stage { grid-column: 1 / -1; }
  .gallery-viewer__controls { grid-column: 2; grid-row: 2; gap: 8px; padding: 4px max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) 8px; }
  .gallery-viewer__controls > span { min-width: 7rem; }
  .gallery-viewer__thumbs { grid-column: 1; grid-row: 2; width: 100%; padding-block: 4px max(4px, env(safe-area-inset-bottom)); }
  .gallery-viewer__thumb { flex-basis: 48px; width: 48px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) { .gallery-viewer__thumb { transition: none; } }
@keyframes gallery-loading { to { transform: rotate(360deg); } }
@media (min-width: 961px) and (max-height: 799px) { .detail-media { position: static; } }
@media (max-width: 560px) {
  .gallery__head { padding: 0 0.15rem; }
  .gallery__heading { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
  .detail-page .gallery__thumbs { padding: 0.15rem; gap: 0.4rem; }
  .gallery__feedback { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .gallery[aria-busy="true"] .gallery__feedback::before { animation: none; } .detail-page .gallery__thumb { transition: none; } }

/* The product page keeps its existing gallery, option states and breakpoints. */
@media screen {
  body[data-page="product-detail"] .detail-page {
    --ink: #263b32;
    --ink-800: #263b32;
    --ink-700: #43564c;
    --ink-500: #626b61;
    --ink-400: #788575;
    --ink-300: #85917e;
    --bg: #fcfbf7;
    --bg-soft: #f1f2e9;
    --line: #e0e3d8;
    --line-strong: #cfd7c7;
    --accent: #c84704;
    --accent-600: #b63e04;
    --accent-700: #a9400d;
    --accent-soft: #f5ece1;
    --accent-ring: #c8470433;
    --brand-orange: #c84704;
    color: #263b32;
    background: #f8f7f2;
  }
  body[data-page="product-detail"] .detail-page :is(.product-heading h1,
    .detail-price__value, .size-editor__head h2, .config-section__copy > strong,
    .montage-card__label, .product-choice__title, .product-process__title,
    .product-process__step h3, .gallery-viewer__head h2, .color-modal__head h2) {
    color: #263b32;
  }
  body[data-page="product-detail"] .detail-page :is(.montage-card__hint,
    .product-choice__detail, .product-options__selection, .product-options__roof-note,
    .product-process__intro, .product-process__step p, .product-process__note p) {
    color: #626b61;
  }
  body[data-page="product-detail"] .detail-page :is(.product-options,
    .montage-card, .product-choice, .product-choice__surface, .gallery-viewer,
    .color-modal__panel, .quick-request__panel, .product-process__step) {
    color: #263b32;
    background: #fcfbf7;
    border-color: #e0e3d8;
    box-shadow: none;
  }
  body[data-page="product-detail"] .detail-page .product-choice--radio {
    background: transparent;
  }
  body[data-page="product-detail"] .detail-page :is(.gallery__stage,
    .gallery__thumb, .gallery-viewer__stage, .product-process,
    .product-process__visual, .color-picker__count) {
    background: #f1f2e9;
    border-color: #e0e3d8;
  }
  body[data-page="product-detail"] .detail-page .product-process__note {
    border-color: #e0e3d8;
  }
  body[data-page="product-detail"] .detail-page :is(.btn--primary) {
    color: #fff;
    background: var(--home-cta-gradient, linear-gradient(135deg, #dd5609, #bd3d03));
    border-color: #c84704;
    border-radius: 11px;
    box-shadow: none;
  }
  body[data-page="product-detail"] .detail-page .btn--primary:hover {
    color: #fff;
    background: var(--home-cta-gradient-hover, linear-gradient(135deg, #c84905, #a83202));
    border-color: #b63e04;
    box-shadow: none;
  }
  body[data-page="product-detail"] .detail-page :is(.btn--outline,
    .gallery__nav, .gallery__expand, .gallery__retry, .gallery-viewer__close,
    .stepper__btn, .size-presets__chip, .color-picker__trigger, .dialog-close) {
    color: #43564c;
    background: #fcfbf7;
    border-color: #cfd7c7;
    box-shadow: none;
  }
  body[data-page="product-detail"] .detail-page :is(.btn--outline,
    .gallery__nav, .gallery__expand, .gallery__retry, .gallery-viewer__close,
    .stepper__btn, .size-presets__chip, .color-picker__trigger, .dialog-close):hover {
    color: #263b32;
    background: #edf0e4;
    border-color: #aebca3;
    box-shadow: none;
  }
  body[data-page="product-detail"] .detail-page .montage-card:has(input:checked),
  body[data-page="product-detail"] .detail-page .product-choice[aria-pressed="true"],
  body[data-page="product-detail"] .detail-page .product-choice--radio > input:checked + .product-choice__surface,
  body[data-page="product-detail"] .detail-page .size-presets__chip.is-current {
    color: #263b32;
    background: #f5ece1;
    border-color: #c84704;
    box-shadow: inset 0 0 0 1px #c84704;
  }
  body[data-page="product-detail"] .detail-page :is(.montage-card__check,
    .product-choice__check) { color: #fff; background: #c84704; }
  body[data-page="product-detail"] .detail-page .gallery__thumb.is-active {
    border-color: #c84704;
    box-shadow: 0 0 0 2px #c8470433;
  }
  body[data-page="product-detail"] .detail-page .detail-bar {
    color: #263b32;
    background: #fcfbf7f5;
    border-color: #e0e3d8;
    box-shadow: 0 -6px 24px #263b3214;
  }
  body[data-page="product-detail"] .detail-page .detail-bar__info small {
    color: #626b61;
  }
  body[data-page="product-detail"] .detail-page .configurator-guide__panel {
    color: #263b32;
    background: #fcfbf7;
    border-color: #e0e3d8;
    box-shadow: 0 24px 64px #263b3226;
    scrollbar-color: #aebca3 #fcfbf7;
  }
  body[data-page="product-detail"] .detail-page .configurator-guide__head h2 {
    color: #263b32;
  }
  body[data-page="product-detail"] .detail-page :is(.configurator-guide__head > p:last-child,
    .configurator-guide__note) { color: #626b61; }
  body[data-page="product-detail"] .detail-page .configurator-guide__message strong {
    color: #a9400d;
  }
  body[data-page="product-detail"] .detail-page .configurator-guide__close {
    color: #43564c;
    background: #fcfbf7;
    border-color: #cfd7c7;
  }
  body[data-page="product-detail"] .detail-page .configurator-guide__close:hover {
    color: #263b32;
    background: #edf0e4;
    border-color: #aebca3;
  }
  body[data-page="product-detail"] .detail-page :is(.product-process__eyebrow,
    .product-process__number, .product-process__note .icon) { color: #a9400d; }
  body[data-page="product-detail"] .detail-page :is(a, button, input, select, summary):focus-visible,
  body[data-page="product-detail"] .detail-page .montage-card:has(input:focus-visible),
  body[data-page="product-detail"] .detail-page .product-choice--radio > input:focus-visible + .product-choice__surface {
    outline-color: #b94005;
  }
}

/* Long covering names can wrap inside the existing illustrated option cards. */
@media screen and (max-width: 768px) {
  body[data-page="product-detail"] .detail-page :is(.product-choice__title,
    .product-choice__detail, .montage-card__text) { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
}
@media screen and (max-width: 600px) {
  body[data-page="product-detail"] .detail-page .detail-bar__info { flex: 1; }
  body[data-page="product-detail"] .detail-page .detail-bar__info strong { overflow-wrap: anywhere; }
  body[data-page="product-detail"] .detail-page .detail-bar .btn {
    flex: 0 1 60%;
    min-width: 0;
    max-width: 60%;
    padding-inline: .75rem;
    white-space: normal;
    text-align: center;
  }
}
