/* Art Works page: framed paintings hung on a gallery wall */

.gallery-main {
  max-width: none;
  padding: 0;
}

.gallery-intro {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
}

.gallery-intro h1 {
  margin-bottom: 0.3rem;
}

.gallery-intro p {
  margin: 0;
  color: var(--muted);
}

/* The wall: warm off-white, slightly brighter toward the top like gallery lighting */
.gallery-wall {
  --art-h: 250px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255, 255, 255, 0.75), transparent 70%),
    linear-gradient(#f3f0ea, #ebe7df);
  border-top: 1px solid #e3ded4;
  border-bottom: 1px solid #ddd7cb;
  padding: 4.5rem 1.5rem 5rem;
}

.hang {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 4.5rem 4rem;
}

.artwork {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  isolation: isolate;
}

/* Soft pool of light on the wall above each painting */
.artwork::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -25%;
  right: -25%;
  top: -4rem;
  height: calc(var(--art-h) + 3rem);
  background: radial-gradient(closest-side, rgba(255, 253, 247, 0.9), rgba(255, 253, 247, 0));
  pointer-events: none;
}

/* Moulding: dark walnut with a faint highlight on the top-left edge */
.frame {
  padding: 11px;
  background: linear-gradient(135deg, #4b3627 0%, #2e2018 48%, #3b2a1f 100%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.16),
    inset -1px -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(30, 20, 10, 0.25),
    0 16px 26px -12px rgba(45, 32, 20, 0.45),
    0 34px 50px -28px rgba(45, 32, 20, 0.35);
}

/* Linen liner with a thin gold lip against the moulding */
.liner {
  padding: 7px;
  background: #ece5d6;
  box-shadow:
    0 0 0 2px #b4965c,
    inset 0 1px 3px rgba(0, 0, 0, 0.22);
}

.artwork .progressive-img {
  height: var(--art-h);
  aspect-ratio: var(--ar);
  background: #ddd6c8;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.artwork .progressive-img img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

/* Museum label */
.placard {
  margin-top: 1.4rem;
  padding: 0.35rem 0.8rem 0.4rem;
  background: #fbfaf7;
  box-shadow: 0 1px 2px rgba(40, 30, 20, 0.12);
  text-align: center;
  line-height: 1.35;
  max-width: 100%;
}

.placard-title {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink);
}

.placard-year {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (max-width: 960px) {
  .gallery-wall {
    --art-h: 210px;
  }

  .hang {
    gap: 3.5rem 3rem;
  }
}

@media (max-width: 640px) {
  .gallery-intro {
    padding: 1.75rem 1rem 1.25rem;
  }

  .gallery-wall {
    --art-h: 150px;
    padding: 3rem 0.75rem 3.5rem;
  }

  .hang {
    gap: 2.75rem 1.5rem;
  }

  .frame {
    padding: 7px;
  }

  .liner {
    padding: 4px;
    box-shadow:
      0 0 0 1.5px #b4965c,
      inset 0 1px 2px rgba(0, 0, 0, 0.22);
  }

  .placard {
    margin-top: 1rem;
    padding: 0.25rem 0.55rem 0.3rem;
  }

  .placard-title {
    font-size: 0.82rem;
  }
}

/* ---------- Clickable paintings ---------- */

.artwork {
  cursor: zoom-in;
}

.artwork .frame {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.artwork:hover .frame,
.artwork:focus-visible .frame {
  transform: translateY(-3px);
}

.artwork:focus-visible {
  outline: none;
}

.artwork:focus-visible .placard {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- Viewer: the clicked painting lifted onto a layer above the wall ---------- */

html.viewer-open {
  overflow: hidden;
}

/* The painting being viewed leaves an empty spot on the wall */
.artwork.lifted .frame {
  visibility: hidden;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 24, 19, 0.6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.3s ease;
  touch-action: pan-y;
}

.viewer[hidden] {
  display: none;
}

.viewer.is-open {
  opacity: 1;
}

/*
  --H is the painting's height. The framed painting fills 80% of the screen in
  whichever direction runs out first (the frame adds ~14.6% of --H around it,
  and ~4rem is left for the placard). Frame, lip and liner scale with --H, so
  it is the same frame as on the wall, just bigger.
*/
.viewer-art {
  --fw: 0.045; /* moulding, as a fraction of --H */
  --lw: 0.028; /* liner or mat */
  --edge: calc(2 * (var(--fw) + var(--lw)) + 0.016);
  --H: min(calc((80vh - 4rem) / (1 + var(--edge))), calc(80vw / (var(--ar) + var(--edge))));
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viewer-art .frame {
  padding: calc(var(--H) * var(--fw));
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.16),
    inset -1px -1px 0 rgba(0, 0, 0, 0.45),
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 30px 60px -20px rgba(0, 0, 0, 0.55);
}

.viewer-art .liner {
  padding: calc(var(--H) * var(--lw));
  box-shadow:
    0 0 0 calc(var(--H) * 0.008) #b4965c,
    inset 0 1px 4px rgba(0, 0, 0, 0.25);
}

.viewer-img {
  position: relative;
  height: var(--H);
  aspect-ratio: var(--ar);
  background: #ddd6c8;
}

.viewer-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.viewer-img::after {
  content: "";
  position: absolute;
  inset: 0;
}

.viewer-art .placard {
  margin-top: 1.25rem;
  opacity: 0;
  transition: opacity 0.25s ease 0.15s;
}

.viewer.is-open .viewer-art .placard {
  opacity: 1;
}

.viewer-btn {
  position: absolute;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.viewer-btn:hover {
  background: #fff;
}

.viewer-close {
  top: 1.25rem;
  right: 1.25rem;
  font-size: 1.6rem;
}

.viewer-prev,
.viewer-next {
  top: 50%;
  transform: translateY(-50%);
}

.viewer-prev {
  left: 1.25rem;
}

.viewer-next {
  right: 1.25rem;
}

@media (max-width: 640px) {
  /* Arrows move below the painting on phones */
  .viewer-prev,
  .viewer-next {
    top: auto;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    transform: none;
  }

  .viewer-prev {
    left: calc(50% - 3.5rem);
  }

  .viewer-next {
    right: calc(50% - 3.5rem);
  }
}
