/* ===========================================================================
   The wall-panel gallery

   Three pictures, chosen by their thumbnails: the design flat, the panel on a
   wall, and the two sheet formats drawn to scale. The slides are stacked in one
   frame of fixed proportion, so switching between them moves nothing on the
   page — only what is on top changes.
   ======================================================================== */

/* It stands where WooCommerce's gallery stood, in the product grid's left
   column. It does not borrow that class: wc-single-product.js initialises
   anything carrying it and would look for a flexslider that is not there. */
.single-product div.product .mf-pgal {
  grid-column: 1;
}

@media (max-width: 860px) {
  .single-product div.product .mf-pgal {
    margin-bottom: 1.25rem;
  }
}

.mf-pgal {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* The frame --------------------------------------------------------------- */

.mf-pgal__stage {
  position: relative;
  /* Stated here and on every image, so the column has its height before the
     first file lands and nothing below it moves when one does. */
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--paper-bright);
}

.mf-pgal__stage:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.mf-pgal__slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 1;
  transition: opacity 0.24s ease;
}

/* Leaving: still painted, so the two cross-fade rather than flashing the
   background between them. The script hides it when the fade is over. */
.mf-pgal__slide[data-mf-pgal-leaving] {
  opacity: 0;
  pointer-events: none;
}

.mf-pgal__slide[data-mf-pgal-entering] {
  opacity: 0;
}

.mf-pgal__slide picture,
.mf-pgal__img {
  display: block;
  width: 100%;
  height: 100%;
}

/* A room fills the frame; the design and the sheet are shown whole. */
.mf-pgal__slide[data-mf-pgal-role='interior'] .mf-pgal__img,
.mf-pgal__slide[data-mf-pgal-role='texture'] .mf-pgal__img {
  object-fit: cover;
}

/* The design is shown whole, and the catalogue's own file is a long strip —
   it will never fill a 3:2 frame. Rather than letterbox it, the slide is a
   mat: the sheet is laid on paper with a margin round it, the way a sample
   sits on a counter. */
.mf-pgal__slide[data-mf-pgal-role='design'] {
  display: flex;
  align-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: var(--paper);
}

.mf-pgal__slide[data-mf-pgal-role='design'] picture {
  height: auto;
}

.mf-pgal__slide[data-mf-pgal-role='design'] .mf-pgal__img {
  height: auto;
  max-height: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius-card) / 2);
  box-shadow: 0 2px 14px rgb(0 0 0 / 0.1);
}

.mf-pgal__caption {
  position: absolute;
  left: clamp(0.6rem, 2vw, 1rem);
  bottom: clamp(0.6rem, 2vw, 1rem);
  margin: 0;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  color: var(--text);
  font-size: var(--step--1);
  line-height: 1.3;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.14);
}

.mf-pgal__expand {
  position: absolute;
  right: clamp(0.6rem, 2vw, 1rem);
  top: clamp(0.6rem, 2vw, 1rem);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  color: var(--text);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.14);
}

.mf-pgal__expand .mf-icon {
  width: 1.05em;
  height: 1.05em;
}

/* The arrows: round, pale, a thin ring and a soft shadow, so they hold on a
   light slide and on a photograph. They are over the frame, not in a slide, so
   full screen (which copies a slide) does not carry them. */
.mf-pgal .mf-pgal__arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: rgb(247 246 243 / 0.92);
  color: var(--ink);
  box-shadow: 0 1px 8px rgb(20 21 24 / 0.2);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.mf-pgal .mf-pgal__arrow:hover,
.mf-pgal .mf-pgal__arrow:focus {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 12px rgb(20 21 24 / 0.3);
}

.mf-pgal__arrow--prev {
  left: clamp(0.5rem, 2vw, 0.8rem);
}

.mf-pgal__arrow--next {
  right: clamp(0.5rem, 2vw, 0.8rem);
}

@media (max-width: 560px) {
  .mf-pgal .mf-pgal__arrow {
    width: 2.2rem;
    height: 2.2rem;
  }
}

/* The thumbnails ---------------------------------------------------------- */

.mf-pgal__thumbs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.mf-pgal__thumbs li {
  margin: 0;
}

.mf-pgal__thumb {
  display: block;
  width: 4.5rem;
  height: 3.5rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius-card) / 2);
  background: var(--paper-bright);
  overflow: hidden;
  cursor: pointer;
  color: var(--text-muted);
}

.mf-pgal__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A bare <button> is filled dark on hover and focus further up the theme; a
   thumbnail keeps its own ground, so the drawing never lands on black. */
.mf-pgal__thumb,
.mf-pgal__thumb:hover,
.mf-pgal__thumb:focus,
.mf-pgal__thumb:active {
  background: var(--paper-bright);
  color: var(--text-muted);
}

.mf-pgal__thumb[aria-pressed='true'] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.mf-pgal__thumb:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* The sheet, drawn -------------------------------------------------------- */

.mf-sheet {
  display: block;
  width: 100%;
  height: 100%;
  padding: clamp(0.75rem, 3vw, 1.75rem);
  box-sizing: border-box;
  color: var(--text);
}

/* The slide holding the drawing is a mat of paper, like the design's. */
.mf-pgal__slide[data-mf-pgal-role='construction'] {
  background: var(--paper);
}

/* The same drawing, without a word in it, in the thumbnail. */
.mf-sheet--mini {
  padding: 0.3rem;
}

/* Full screen ------------------------------------------------------------- */

.mf-pfull {
  width: min(96vw, 1400px);
  max-width: 96vw;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--paper-bright);
  color: var(--text);
  overflow: hidden;
}

.mf-pfull::backdrop {
  background: rgb(0 0 0 / 0.72);
}

.mf-pfull__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
}

.mf-pfull__of {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--step--1);
}

.mf-pfull__body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(74vh, 70vw);
  background: var(--paper);
  touch-action: pan-y;
}

/* The slide is a copy of one that is stacked absolutely in the page's frame.
   Here it is the only thing in the box, so it is put back in the flow — left
   absolute it covers the bar with the close button on it. */
.mf-pfull__body > * {
  position: static;
  inset: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
}

.mf-pfull__body picture {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
}

.mf-pfull__body img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mf-pfull__body .mf-sheet {
  flex: 1 1 auto;
  min-height: 0;
}

.mf-pfull__body .mf-pgal__caption {
  position: static;
  flex: 0 0 auto;
  align-self: flex-start;
  margin: 0 0.6rem 0.6rem;
}

.mf-pfull__body .mf-pgal__expand {
  display: none;
}

.mf-pfull__nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
}

.mf-pfull__nav .mf-tool:first-child .mf-icon {
  transform: rotate(90deg);
}

.mf-pfull__nav .mf-tool:last-child .mf-icon {
  transform: rotate(-90deg);
}

@media (max-width: 700px) {
  .mf-pgal__thumb {
    width: 3.75rem;
    height: 3rem;
  }

  /* On a phone the frame is the page; a worded button on top of it covers
     the picture it is offering to enlarge. The icon says enough, and the
     word stays for a screen reader. */
  .mf-pgal__expand {
    padding: 0.45rem;
  }

  .mf-pgal__expand span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .mf-pgal__expand .mf-icon {
    width: 1.3rem;
    height: 1.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mf-pgal__slide {
    transition: none;
  }
}

/* Admin: the role of each picture ----------------------------------------- */

.mf-pgal-roles__row img {
  vertical-align: middle;
  border-radius: 3px;
}

/* ---------------------------------------------------------------------------
   The bare stage (body.mf-pgal-bare)

   The design picture of a panel shot square on a plain wall would sit as a
   picture on a mat on a stage: a rectangle in a rectangle in a rectangle. Here
   the stage's own background is the only one, and the picture is cut to the
   panel (the crop is this file's: the panel fills 80.9% x 78.9% of the frame,
   centred) and laid straight on it, with a light shadow of its own.
   ------------------------------------------------------------------------ */

body.mf-pgal-bare .mf-pgal__stage {
  background: var(--paper);
}

body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design'] {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
}

/* The rule above sets display, which would beat the hidden attribute the script
   puts on the slide that is not showing: the panel stayed over the room. */
body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design'][hidden] {
  display: none;
}

/* The shadow, on a box the size of the panel, under the picture. */
body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design']::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  height: 78%;
  aspect-ratio: 1015 / 989;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.16);
}

/* The picture is square, as tall as the stage allows: either the <picture>
   (when there is an AVIF beside the file) or the image itself is that square,
   and the crop is relative to it. */
body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design'] picture,
body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design'] > .mf-pgal__img {
  position: relative;
  z-index: 1;
  display: block;
  flex: none;
  height: 99%;
  width: auto;
  aspect-ratio: 1;
}

body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design'] picture .mf-pgal__img {
  width: 100%;
  height: 100%;
}

body.mf-pgal-bare .mf-pgal__slide[data-mf-pgal-role='design'] .mf-pgal__img {
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
  clip-path: inset(10.6% 9.4% 10.4% 9.6%);
}
