/* A focused sample rack. Card transforms are driven by the material controller. */
.material-gallery-stage {
  --gallery-metal: #a9b0b1;
  --gallery-ink: #202b30;
  --gallery-muted: #626d71;
  height: calc(100svh - var(--header));
  min-height: 0;
  top: 0;
  display: grid;
  grid-template-columns: minmax(260px, 36%) minmax(0, 64%);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: 'heading gallery' 'copy gallery';
  align-items: start;
  gap: 28px 0;
  padding: clamp(28px, 5vh, 64px) 6vw;
  overflow: hidden;
  isolation: isolate;
  color: var(--gallery-ink);
  background: radial-gradient(ellipse at 74% 45%, #fff 0, #f0f1ee 52%, #e7eae7 100%);
}

.material-gallery-stage .material-heading {
  grid-area: heading;
  z-index: 4;
  padding: 0;
  min-width: 0;
  pointer-events: none;
}

.material-gallery-stage .material-heading .eyebrow {
  color: var(--gallery-muted);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: .18em;
}

.material-gallery-stage .material-heading h2 {
  margin: 12px 0 0;
  font: 400 clamp(28px, 3.2vw, 46px)/1.25 var(--serif);
  letter-spacing: .06em;
}

.material-gallery-stage .material-copy {
  grid-area: copy;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  position: relative;
  isolation: auto;
  z-index: 4;
  max-width: 410px;
  min-width: 0;
  min-height: 0;
  padding: 0 30px 0 0;
  background: none;
  box-shadow: none;
}

.material-gallery-stage .material-copy::before {
  display: none;
}

.material-gallery-stage .material-details {
  min-width: 0;
}

.material-gallery-stage .material-index {
  block-size: 1.5em;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: .12em;
  color: var(--gallery-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.material-gallery-stage .material-details h3 {
  block-size: 1.3em;
  margin: 8px 0 12px;
  font: 400 clamp(25px, 2.6vw, 36px)/1.3 var(--serif);
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.material-gallery-stage .material-details > p:not(.material-index) {
  max-width: 365px;
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--gallery-muted);
}

/* Reserve the same text slots for every material. The gallery's remaining
   grid row must not change when a description uses one line instead of two. */
.material-gallery-stage .material-details > #material-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  block-size: 3.5em;
  overflow: hidden;
}

.material-gallery-stage .material-details > p.material-difference {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  block-size: 5.25em;
  overflow: hidden;
  margin-top: 10px;
  color: var(--gallery-ink);
  -webkit-line-clamp: 3;
}

.material-gallery-stage .material-details dl {
  display: none;
}

.material-gallery-stage .material-palette {
  max-width: none;
  margin-top: 22px;
}

.material-gallery-stage .palette-heading {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  font-size: 14px;
  line-height: 1.5;
  block-size: 32px;
  min-block-size: 32px;
  white-space: nowrap;
}

.material-gallery-stage .palette-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.material-gallery-stage .palette-count { flex-shrink: 0; }

.material-gallery-stage .palette-count {
  margin: 0;
  font-size: 12px;
}

.material-gallery-stage .palette-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.material-gallery-stage .palette-thumbs .finish-thumb,
.material-gallery-stage .palette-more {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 2px;
}

.material-gallery-stage .finish-thumb img {
  border-radius: 0;
}

.material-gallery-stage .palette-more {
  background: #ffffff80;
  color: var(--gallery-ink);
  border-color: #9ea7aa;
  font-size: 14px;
}

.material-gallery-stage .selected-finish {
  display: block;
  min-height: 21px;
  block-size: 1.5em;
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.material-gallery-stage .material-controls {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 360px;
  min-width: 0;
  gap: 8px;
  margin-top: 18px;
}

.material-gallery-stage .material-controls > button {
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #b4bdbd;
  border-radius: 50%;
  padding: 0 0 3px;
  background: #ffffff80;
  font-size: 23px;
  line-height: 1;
}

.material-gallery-stage .material-controls > button:hover:not(:disabled) {
  border-color: var(--gallery-ink);
  background: #fff;
}

.material-gallery-stage .material-controls > div {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  max-width: none;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
}

.material-gallery-stage .material-controls > div::-webkit-scrollbar {
  display: none;
}

.material-gallery-stage .material-dot {
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: none;
}

.material-gallery-stage .material-dot::after {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #a7afb0;
  transition: width .25s ease, background .25s ease;
}

.material-gallery-stage .material-dot[aria-current=true]::after {
  width: 20px;
  border-radius: 4px;
  background: var(--gallery-ink);
}

.material-gallery-stage .material-hint {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--gallery-muted);
}

.material-gallery-stage .material-hint span {
  display: inline;
  margin-left: 8px;
}

.material-gallery-stage .material-deck {
  grid-area: gallery;
  position: relative;
  justify-self: stretch;
  align-self: stretch;
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  margin: 0;
  perspective: 1250px;
  perspective-origin: 50% 42%;
  transform-style: preserve-3d;
  overflow: visible;
  clip-path: inset(-32px -6vw -48px 0);
  touch-action: pan-y pinch-zoom;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  outline-offset: -4px;
}

.material-gallery-stage .material-deck.is-dragging {
  cursor: grabbing;
}

.material-gallery-stage .material-deck::before {
  content: '';
  position: absolute;
  left: 12%;
  right: 2%;
  bottom: 2%;
  height: 9%;
  border-radius: 50%;
  background: #5c676929;
  filter: blur(24px);
  pointer-events: none;
  transform: translateZ(-180px);
}

.material-gallery-stage .material-card {
  position: absolute;
  inset: auto;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(72%, 470px);
  height: min(84%, 580px);
  display: flex;
  flex-direction: column;
  border: 1px solid #b6bdbe;
  border-radius: 3px;
  background: var(--sample-color, #7b8383);
  box-shadow: 1px 3px 0 #d1d5d3, 4px 7px 0 #8f9796, 5px 12px 18px #26313522, 0 30px 48px #2631352e;
  overflow: visible;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform;
}

.material-gallery-stage .material-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid #87908f;
  border-radius: 3px;
  background: linear-gradient(115deg, #e2e5e1, #8b9593 42%, #d5d9d4 63%, #858e8c);
  transform: translate3d(4px, 5px, -5px);
  pointer-events: none;
}

.material-gallery-stage .material-swatch {
  position: absolute;
  inset: 0;
  min-height: 0;
  border-radius: 2px;
  overflow: hidden;
  transform: translateZ(1px);
}

.material-gallery-stage .material-swatch img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.material-gallery-stage .material-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(118deg, #ffffff26, transparent 34%, #00000005 62%, #ffffff1f);
  box-shadow: inset 0 0 0 1px #ffffff45;
  pointer-events: none;
}

.material-gallery-stage .material-card footer {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 4px;
  min-height: 86px;
  margin: 0;
  padding: 36px 20px 17px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(0deg, #142126b5, #14212630 72%, transparent);
  color: #fff;
  opacity: 1;
  transform: translateZ(2px);
  pointer-events: none;
}

.material-gallery-stage .material-card footer strong {
  min-width: 0;
  font: 400 22px/1.25 var(--serif);
  letter-spacing: .03em;
  color: #fff;
  text-shadow: 0 1px 4px #0006;
  block-size: 1.25em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.material-gallery-stage .material-card footer .material-finish-label {
  display: block;
  max-width: 100%;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: .02em;
  color: #ffffffe0;
  text-shadow: 0 1px 4px #0006;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  block-size: 1.4em;
}

.material-gallery-stage .material-select {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  width: 100%;
  min-height: 44px;
  padding: 16px;
  border: 0;
  border-radius: 2px;
  background: none;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-shadow: 0 1px 5px #000c;
  transform: translateZ(3px);
}

.material-gallery-stage .material-select:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -7px;
  box-shadow: inset 0 0 0 3px #23343b;
}

@media (max-width: 1000px) and (min-width: 801px) {
  .material-gallery-stage {
    grid-template-columns: minmax(260px, 40%) minmax(0, 60%);
    padding-inline: 4vw;
  }
  .material-gallery-stage .material-copy { padding-right: 12px; }
  .material-gallery-stage .material-card { width: 74%; }
  .material-gallery-stage .material-details > p.material-difference { display: none; }
}

@media (max-width: 800px) {
  .material-gallery-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: 'heading' 'gallery' 'copy';
    gap: 11px;
    padding: 18px 6vw 12px;
    background: radial-gradient(ellipse at 50% 34%, #fff 0, #f0f1ee 54%, #e7eae7 100%);
  }
  .material-gallery-stage .material-heading .eyebrow { font-size: 10px; }
  .material-gallery-stage .material-heading { text-align: center; }
  .material-gallery-stage .material-heading h2 { margin-top: 5px; font-size: 27px; }
  .material-gallery-stage .material-copy {
    align-self: stretch;
    max-width: none;
    width: 100%;
    padding: 0;
  }
  .material-gallery-stage .material-index { font-size: 11px; line-height: 1.4; block-size: 1.4em; }
  .material-gallery-stage .material-details h3 {
    margin: 4px 0 7px;
    font-size: 24px;
    line-height: 1.25;
    block-size: 1.25em;
  }
  .material-gallery-stage .material-details > p:not(.material-index) {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    max-width: none;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
  }
  .material-gallery-stage .material-details > #material-description { block-size: 3em; }
  .material-gallery-stage .material-details > p.material-difference { display: none; }
  .material-gallery-stage .material-palette { margin-top: 10px; }
  .material-gallery-stage .palette-heading { font-size: 14px; line-height: 1.4; }
  .material-gallery-stage .palette-thumbs { gap: 8px; margin-top: 7px; }
  .material-gallery-stage .selected-finish {
    font-size: 14px;
    line-height: 1.4;
    min-height: 20px;
    block-size: 1.4em;
    margin-top: 5px;
  }
  .material-gallery-stage .material-controls { max-width: none; margin-top: 6px; gap: 6px; }
  .material-gallery-stage .material-hint { display: none; }
  .material-gallery-stage .material-deck {
    width: calc(100% + 12vw);
    margin-inline: -6vw;
    min-height: 0;
    height: 100%;
    perspective: 1000px;
    perspective-origin: 50% 48%;
  }
  .material-gallery-stage .material-deck::before { left: 14%; right: 14%; bottom: -1%; filter: blur(15px); }
  .material-gallery-stage .material-card {
    width: min(67%, 360px);
    height: 92%;
    border-radius: 2px;
    box-shadow: 1px 2px 0 #d1d5d3, 3px 5px 0 #8f9796, 4px 9px 14px #26313522, 0 19px 24px #26313529;
  }
  .material-gallery-stage .material-card footer {
    min-height: 64px;
    padding: 27px 13px 11px;
    gap: 3px;
  }
  .material-gallery-stage .material-card footer strong { font-size: 19px; }
  .material-gallery-stage .material-card footer .material-finish-label { font-size: 11px; }
  .material-gallery-stage .material-select { padding: 11px; font-size: 11px; }
}

@media (max-width: 800px) and (max-height: 700px) {
  .material-gallery-stage { padding-top: 12px; padding-bottom: 8px; gap: 7px; }
  .material-gallery-stage .material-heading .eyebrow { font-size: 9px; }
  .material-gallery-stage .material-heading h2 { margin-top: 3px; font-size: 23px; }
  .material-gallery-stage .material-details h3 { margin: 3px 0 4px; font-size: 22px; }
  .material-gallery-stage .material-details #material-description { display: none; }
  .material-gallery-stage .material-palette { margin-top: 6px; }
  .material-gallery-stage .palette-thumbs { margin-top: 5px; }
  .material-gallery-stage .selected-finish { margin-top: 4px; }
  .material-gallery-stage .material-controls { margin-top: 3px; }
  .material-gallery-stage .material-card { height: 91%; }
}

/* Keep the rack and its controls visible when a phone is held sideways. */
@media (max-height: 500px) and (min-width: 601px) {
  .material-gallery-stage {
    grid-template-columns: minmax(0, 34%) minmax(0, 66%);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'heading gallery' 'copy gallery';
    padding: 12px 4vw 10px;
    gap: 8px 0;
  }
  .material-gallery-stage .material-heading { text-align: left; }
  .material-gallery-stage .material-heading .eyebrow { font-size: 9px; }
  .material-gallery-stage .material-heading h2 { margin-top: 3px; font-size: 23px; }
  .material-gallery-stage .material-copy { align-self: start; padding: 0 16px 0 0; }
  .material-gallery-stage .material-details .material-index,
  .material-gallery-stage .material-details #material-description,
  .material-gallery-stage .material-details > p.material-difference,
  .material-gallery-stage .selected-finish,
  .material-gallery-stage .material-hint { display: none; }
  .material-gallery-stage .material-details h3 { margin: 0 0 6px; font-size: 20px; }
  .material-gallery-stage .material-palette { margin-top: 6px; }
  .material-gallery-stage .palette-heading { font-size: 12px; }
  .material-gallery-stage .palette-thumbs { margin-top: 5px; }
  .material-gallery-stage .material-controls { margin-top: 7px; gap: 4px; }
  .material-gallery-stage .material-deck { width: 100%; margin: 0; height: 100%; }
  .material-gallery-stage .material-card { width: min(74%, 360px); height: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .material-gallery-stage .material-dot::after { transition: none; }
  .material-gallery-stage .material-card { will-change: auto; }
}

/* A physical sample: front, back and four thin edges share one local pose.
   The outer article keeps the gallery's existing scroll position and hit area. */
.material-gallery-stage .material-physical-card {
  background: none;
  border-color: transparent;
  box-shadow: none;
}
.material-gallery-stage .material-physical-card::before { display: none; }
.material-gallery-stage .material-solid {
  --sample-depth: 8px;
  position: absolute;
  inset: 0;
  border: 1px solid #b6bdbe;
  border-radius: 3px;
  background: var(--sample-color);
  box-shadow: 0 9px 14px #26313520, 0 25px 36px #26313527;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
  transition: transform .42s cubic-bezier(.22,1,.36,1);
}
.material-gallery-stage .is-current .material-solid {
  transform: rotateX(var(--material-tip-x, 0deg)) rotateY(var(--material-tip-y, 0deg));
}
.material-gallery-stage .is-dragging .is-current .material-solid { transition-duration: .08s; }
.material-gallery-stage .material-solid::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--sample-color);
  border: 1px solid #8e9796;
  border-radius: inherit;
  transform: translateZ(calc(-1 * var(--sample-depth)));
  pointer-events: none;
}
.material-gallery-stage .material-solid::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  transform: translateZ(4px);
  background: radial-gradient(ellipse at var(--material-light-x, 35%) var(--material-light-y, 18%), #ffffff70, #ffffff18 28%, transparent 65%);
  opacity: .48;
}
.material-gallery-stage .material-edge {
  position: absolute;
  display: block;
  background: linear-gradient(90deg, #929b9a, #d6dcda 28%, #8a9493 62%, #bec6c3);
  pointer-events: none;
  backface-visibility: hidden;
}
.material-gallery-stage .material-edge-left,
.material-gallery-stage .material-edge-right { top: 0; width: var(--sample-depth); height: 100%; }
.material-gallery-stage .material-edge-left { right: 100%; transform-origin: right center; transform: rotateY(-90deg); }
.material-gallery-stage .material-edge-right { left: 100%; transform-origin: left center; transform: rotateY(90deg); }
.material-gallery-stage .material-edge-top,
.material-gallery-stage .material-edge-bottom { left: 0; width: 100%; height: var(--sample-depth); }
.material-gallery-stage .material-edge-top { bottom: 100%; transform-origin: center bottom; transform: rotateX(90deg); }
.material-gallery-stage .material-edge-bottom { top: 100%; transform-origin: center top; transform: rotateX(-90deg); }
@media (max-width: 800px) {
  .material-gallery-stage .material-solid { --sample-depth: 6px; box-shadow: 0 7px 12px #26313520, 0 17px 24px #26313527; }
}
@media (prefers-reduced-motion: reduce) {
  .material-gallery-stage .material-solid,
  .material-gallery-stage .is-current .material-solid { transform: none; transition: none; }
  .material-gallery-stage .material-solid::after { opacity: .2; }
}
