/* ==========================================================================
   Mental Momentum Mosaics — a gallery hallway
   Default (phones, reduced motion): a simple vertical gallery.
   Larger screens with motion on: scrolling walks you sideways down the hall.
   ========================================================================== */

.label--spaced { letter-spacing: 0.32em; }

html:has(dialog[open]) { overflow: hidden; }

.gallery { position: relative; }

.gallery__track {
  position: relative;
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 70%, #F5F4F1 100%);
}
.gallery__pieces { display: contents; }
.gallery__floor { display: none; }

/* ---------- Entrance + exit walls ---------- */

.bay--entrance {
  max-width: var(--max);
  margin-inline: auto;
  padding: clamp(3rem, 8vw, 6rem) var(--gutter) clamp(3rem, 8vw, 5rem);
}
.exhibit-title {
  margin-top: 1rem;
  font-size: clamp(3.5rem, 13vw, 11rem);
  line-height: 0.86;
}
.curator-note {
  max-width: 32rem;
  margin-top: 1.5rem;
  color: var(--muted);
}
.walk-prompt {
  margin-top: 2.25rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.walk-prompt span { display: inline-block; animation: nudge 2.4s ease-in-out infinite; }
.walk-prompt .walk-prompt__h { display: none; }
@keyframes nudge {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(0, 0.35rem); }
}

.bay--exit {
  padding: clamp(5rem, 14vw, 9rem) var(--gutter);
  text-align: center;
}
.exit-title { margin-top: 1rem; font-size: clamp(3rem, 10vw, 8rem); line-height: 0.9; }
.exit-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* ---------- A hung mosaic ---------- */

.bay--piece {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: calc(100svh - var(--header-h));
  padding: 4.5rem var(--gutter) 3rem;
  scroll-snap-align: center;
}

/* ceiling light fixture + its beam on the wall */
.bay--piece::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  width: 3.5rem;
  height: 0.85rem;
  border-radius: 0 0 0.5rem 0.5rem;
  background: #1C1C1C;
  transform: translateX(-50%);
}
.bay--piece::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 0;
  width: min(90vw, 56rem);
  height: 75%;
  background: radial-gradient(ellipse 48% 80% at 50% 0%, rgba(255, 236, 196, 0.6), rgba(255, 236, 196, 0.2) 45%, rgba(255, 236, 196, 0) 72%);
  transform: translateX(-50%);
  pointer-events: none;
}

.piece {
  position: relative;
  z-index: 1;
  transform-origin: 50% 60%;
}

.frame {
  display: block;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  border: 3px solid #111;
  background: #FFF;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.14), 0 26px 44px -18px rgba(0, 0, 0, 0.4);
  cursor: zoom-in;
  transition: box-shadow 0.3s var(--ease);
}
.frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 58svh;
}
.frame:hover { box-shadow: 0 2px 3px rgba(0, 0, 0, 0.14), 0 32px 54px -16px rgba(0, 0, 0, 0.48); }
.frame:focus-visible { outline-offset: 6px; }

/* ---------- Museum placard ---------- */

.placard {
  position: relative;
  z-index: 1;
  width: min(100%, 20rem);
  padding: 1rem 1.15rem 1.05rem;
  border: 1px solid #E2E2E2;
  background: #FFF;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  color: var(--text);
}
.placard__no {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.placard__title {
  margin-top: 0.2rem;
  font-family: inherit;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: none;
}
.placard__meta {
  display: flex;
  flex-direction: column;
  margin-top: 0.45rem;
  color: #4F4F4F;
  font-size: 1.0625rem;
  font-style: italic;
  line-height: 1.35;
}
.placard__reflection {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid #E5E5E5;
  font-size: 1.125rem;
  line-height: 1.35;
}

/* ---------- Progress line at the bottom of the screen ---------- */

.walk-progress {
  --p: 0;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s;
}
.walk-progress.is-visible { opacity: 1; visibility: visible; transition: opacity 0.3s; }
.walk-progress__bar {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(var(--p));
  transform-origin: left center;
}
.walk-progress__count {
  position: absolute;
  right: var(--gutter);
  bottom: 0.75rem;
  padding: 0.35rem 0.6rem 0.25rem;
  background: rgba(255, 255, 255, 0.92);
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Phones: snap one mosaic per screen ---------- */

@media (max-width: 47.99em) {
  html:has(.gallery) { scroll-snap-type: y proximity; }
}

/* ==========================================================================
   The sideways walk (larger screens, motion on)
   ========================================================================== */

@media (min-width: 48em) and (prefers-reduced-motion: no-preference) {
  .gallery__viewport {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow: clip;
  }
  .gallery__track {
    display: flex;
    align-items: stretch;
    width: max-content;
    height: 100%;
    background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 60%, #F3F2EF 86%);
    will-change: transform;
  }

  /* warm wood floor + baseboard, moving with you */
  .gallery__floor {
    display: block;
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 14%;
    border-top: 6px solid #EFEBE4;
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0) 22%),
      repeating-linear-gradient(90deg, #E8DAC4 0 180px, #DDCCB2 180px 182px, #E4D5BE 182px 360px, #DACAB0 360px 362px);
  }

  .bay {
    position: relative;
    flex: none;
    display: flex;
    height: 100%;
    padding-bottom: calc((100vh - var(--header-h)) * 0.14); /* room for the floor */
  }

  .bay--entrance {
    width: 100vw;
    max-width: none;
    margin: 0;
    flex-direction: column;
    justify-content: center;
    padding-inline: clamp(2rem, 8vw, 8rem);
  }
  .exhibit-title { font-size: clamp(4.5rem, 11vw, 11rem); }
  .walk-prompt .walk-prompt__h { display: inline-block; }
  .walk-prompt .walk-prompt__v { display: none; }
  .walk-prompt span { animation-name: nudge-x; }
  @keyframes nudge-x {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(0.5rem, 0); }
  }

  .bay--piece {
    flex-direction: row;
    align-items: center;
    gap: 0;
    min-height: 0;
    padding-inline: calc(16rem + 9vw);
    scroll-snap-align: none;
  }
  .bay--piece::after { height: 86%; }

  .frame img {
    max-width: min(44vw, 42rem);
    max-height: 50vh;
  }

  /* placard hangs to the right of the piece, at eye level */
  .bay--piece .placard {
    position: absolute;
    left: calc(100% - 16rem - 9vw + 2.75rem);
    top: calc(50% - 7%);
    width: 15rem;
  }

  .bay--exit {
    width: 100vw;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
}

/* ==========================================================================
   Full-screen viewer
   ========================================================================== */

.viewer {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: clamp(0.75rem, 2.5vw, 1.75rem);
  border: 0;
  background: #0B0B0B;
  color: #F4F1EC;
}
.viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1rem;
  animation: viewer-in 0.3s var(--ease);
}
.viewer::backdrop { background: #0B0B0B; }
@keyframes viewer-in { from { opacity: 0; } to { opacity: 1; } }

.viewer :focus-visible { outline-color: #fff; }

.viewer__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.viewer__count { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: 0.12em; }

.viewer__btn,
.viewer__arrow {
  min-height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.viewer__btn { padding: 0.6rem 1.1rem 0.45rem; }
.viewer__btn:hover,
.viewer__arrow:hover { border-color: var(--accent); background: var(--accent); }

.viewer__stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1.5rem);
  min-height: 0;
}
.viewer__arrow {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
}
.viewer__img {
  justify-self: center;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  box-shadow: 0 0 0 3px #000, 0 30px 60px rgba(0, 0, 0, 0.6);
}

.placard--dark {
  justify-self: center;
  width: min(100%, 34rem);
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #F4F1EC;
  text-align: center;
}
.placard--dark .placard__no { color: #FF5A6E; } /* brighter red reads on black */
.placard--dark .placard__meta { color: #C9C4BC; }
.placard--dark .placard__reflection { border-top-color: rgba(255, 255, 255, 0.18); }

@media (max-width: 40em) {
  .viewer__stage { grid-template-columns: minmax(0, 1fr); }
  .viewer__arrow { display: none; } /* swipe on phones */
  .placard--dark .placard__title { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .walk-prompt span { animation: none; }
}

/* ==========================================================================
   Panoramas (very wide mosaics): a full-width wall, placard underneath
   ========================================================================== */

.bay--wide .frame img { max-height: none; }
.bay--wide .placard { width: min(100%, 34rem); }

@media (min-width: 48em) and (prefers-reduced-motion: no-preference) {
  .gallery.is-walking .bay--wide {
    flex-direction: column;
    justify-content: center;
    gap: 1.75rem;
    padding-inline: 12vw;
  }
  .gallery.is-walking .bay--wide::after { width: min(96vw, 110rem); }
  .gallery.is-walking .bay--wide .frame img {
    width: min(76vw, 120rem);
    max-width: none;
    max-height: 46vh;
    object-fit: contain;
  }
  .gallery.is-walking .bay--wide .placard {
    position: static;
    width: min(76vw, 40rem);
    text-align: center;
  }
  .gallery.is-walking .bay--wide .placard__meta { align-items: center; }
}

/* full-screen viewer: the picture sits in its own pan area */
.viewer__pan {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 100%;
  min-height: 0;
}
.viewer__stage { height: 100%; }

/* on narrower screens, drag across a panorama instead of shrinking it */
@media (max-width: 64em) {
  .viewer--wide .viewer__pan {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-color: var(--accent) transparent;
  }
  .viewer--wide .viewer__img {
    width: auto;
    max-width: none;
    height: min(100%, 26rem);
    max-height: none;
  }
  .viewer--wide .viewer__count::after {
    content: "  \00B7  Drag to pan";
    color: #C9C4BC;
    font-size: 0.85em;
  }
}
