/* Image switcher (spec §2, §6). Runs in the component's shadow DOM: site
   classes don't reach in, but the site's CSS variables and the inherited font
   do. Every colour is a site variable; fallbacks are the spec §2 values.
   Spacing not set by the spec comes from the L5 mockup. */

:host {
  display: block;
}

.image-switcher {
  color: var(--color-ink, #1a1a1a);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 1px solid var(--color-ink, #1a1a1a);
  outline-offset: 2px;
}

/* ---- inline mode (painting page) ---- */

.image-switcher__photo {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 600px;
  /* Vertical scrolling stays with the page; horizontal moves are swipes (F4). */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.image-switcher__thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.image-switcher__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid transparent;
  background: var(--color-wash, #f3f3f1);
}

.image-switcher__thumb[aria-pressed="true"] {
  border-color: var(--color-ink, #1a1a1a);
}

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

/* ---- viewer mode (price list) ---- */

.image-switcher__trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  cursor: zoom-in;
}

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

.image-switcher__viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
  background: var(--color-bg, #ffffff);
  color: var(--color-ink, #1a1a1a);
}

.image-switcher__close {
  align-self: flex-end;
  margin: var(--space-2, 8px);
  padding: 12px;
  font-size: var(--text-s, 14px);
  line-height: 1.5;
  color: var(--color-muted, #6b6a65);
}

.image-switcher__viewer .image-switcher__gallery {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 var(--space-3, 16px);
  box-sizing: border-box;
}

/* Close, thumbnails and caption take about 200px; the photo gets the rest. */
.image-switcher__viewer .image-switcher__photo {
  max-height: calc(100vh - 200px);
  max-height: calc(100dvh - 200px);
}

.image-switcher__viewer .image-switcher__thumbs {
  justify-content: center;
}

.image-switcher__viewer .image-switcher__thumb {
  width: 56px;
  height: 56px;
}

.image-switcher__caption {
  margin: 6px var(--space-3, 16px) 18px;
  text-align: center;
  font-size: var(--text-body, 16px);
  line-height: 1.6;
}

/* ---- ≤479 (Mobile portrait) ---- */

@media (max-width: 479px) {
  .image-switcher__photo {
    width: 100%;
    max-height: none;
  }

  /* In the viewer the photo must still fit the screen, so it keeps its cap. */
  .image-switcher__viewer .image-switcher__photo {
    width: auto;
    max-height: calc(100vh - 200px);
    max-height: calc(100dvh - 200px);
  }

  .image-switcher__trigger {
    width: 56px;
    height: 56px;
  }
}

