.gallery-page {
  position: relative;
  padding: 76px 0 104px;
  overflow: hidden;
  background:
    radial-gradient(circle at 84% 9%, rgba(184, 126, 88, 0.08), transparent 29rem),
    linear-gradient(135deg, #fbfaf7 0%, #f6f3ee 100%);
}

.gallery-page::before {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(0deg, rgba(69, 55, 43, 0.015) 0, rgba(69, 55, 43, 0.015) 1px, transparent 1px, transparent 4px);
  content: "";
  pointer-events: none;
}

.gallery-page .container { position: relative; z-index: 1; }

.gallery-grid {
  display: flex;
  align-items: flex-start;
  gap: 38px;
}

.gallery-column {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 42px;
  min-width: 0;
}

.gallery-card {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  margin: 0;
  break-inside: avoid;
  color: #24201d;
  background: transparent;
  isolation: isolate;
  transition: transform 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-card__sheet {
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(96, 78, 63, 0.2);
  border-radius: 0;
  background: #fffdf9;
}

.gallery-card__sheet--front {
  position: relative;
  z-index: 3;
  box-shadow: 0 12px 25px rgba(58, 46, 36, 0.13), 0 2px 5px rgba(58, 46, 36, 0.08);
  transition: box-shadow 360ms ease;
}

.gallery-card__sheet--back {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 0 11px 24px rgba(58, 46, 36, 0.17);
  pointer-events: none;
  transform-origin: center;
}

.gallery-card__sheet--back-1 {
  z-index: 2;
  transform: translate(9px, 10px) rotate(1.25deg);
}

.gallery-card__sheet--back-2 {
  transform: translate(-9px, 14px) rotate(-1.05deg);
}

.gallery-card__sheet-photo {
  flex: 0 0 auto;
  margin: 10px 10px 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #171614;
}

.gallery-card__sheet-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-card__sheet-caption {
  flex: 1 1 auto;
  min-height: 150px;
  background: #fffdf9;
}

.gallery-card:hover {
  z-index: 2;
  transform: translateY(-4px);
}

.gallery-card:hover .gallery-card__sheet--front {
  box-shadow: 0 19px 36px rgba(58, 46, 36, 0.17), 0 4px 8px rgba(58, 46, 36, 0.09);
}

.gallery-card__media {
  position: relative;
  margin: 10px 10px 0;
  overflow: hidden;
  background: #171614;
}

.gallery-card__cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #171614;
  cursor: zoom-in;
}

.gallery-card__cover--multi { aspect-ratio: 16 / 9; }
.gallery-card__cover--single { aspect-ratio: auto; }

.gallery-card__track {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
  width: max-content;
  height: 100%;
  background: #fff;
  transition: transform 1800ms cubic-bezier(0.18, 1.14, 0.32, 1);
  will-change: transform;
}

.gallery-card__track--instant { transition: none; }

.gallery-card__slide {
  flex: 0 0 auto;
  height: 100%;
  overflow: hidden;
  background: #171614;
}

.gallery-card__cover img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 500ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 300ms ease;
}

.gallery-card__cover--multi img {
  width: auto;
  height: 100%;
  max-width: none;
  object-fit: contain;
}

.gallery-card__cover--multi:hover img,
.gallery-card__cover--multi:focus-visible img { opacity: 1; transform: none; }
.gallery-card__cover--single img { aspect-ratio: auto; }

.gallery-card__cover--single:hover img,
.gallery-card__cover--single:focus-visible img { opacity: 0.94; transform: scale(1.018); }

.gallery-card__cover:focus-visible {
  outline: 3px solid rgba(var(--opto-base-rgb), 0.44);
  outline-offset: -3px;
}

.gallery-card__arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  color: #fff;
  background: rgba(20, 18, 16, 0.46);
  opacity: 0;
  cursor: pointer;
  transform: translateY(-50%);
  transition: opacity 220ms ease, background 220ms ease, transform 220ms ease;
}

.gallery-card__arrow svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.gallery-card__prev { left: 13px; }
.gallery-card__next { right: 13px; }

.gallery-card__media:hover .gallery-card__arrow,
.gallery-card__arrow:focus-visible { opacity: 1; }

.gallery-card__arrow:hover,
.gallery-card__arrow:focus-visible {
  outline: 0;
  background: rgba(20, 18, 16, 0.72);
  transform: translateY(-50%) scale(1.06);
}

.gallery-card__body {
  box-sizing: border-box;
  height: 150px;
  padding: 20px 23px 22px;
  overflow: hidden;
  background: #fffdf9;
}

.gallery-card__body h3 {
  overflow: hidden;
  min-height: 30px;
  margin: 0;
  color: #24201d;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card__meta {
  display: flex;
  align-items: center;
  min-height: 24px;
  margin-top: 4px;
  color: #91877d;
  font-size: 14px;
  line-height: 1.55;
}

.gallery-card__meta > span[aria-hidden="true"] {
  width: 1px;
  height: 14px;
  margin: 0 12px;
  background: rgba(96, 78, 63, 0.25);
}

.gallery-card__description {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  color: #6f655d;
  font-size: 15px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.gallery-viewer {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
}

.gallery-viewer[open] { display: grid; place-items: center; }

.gallery-viewer::backdrop {
  background: rgba(20, 18, 16, 0.72);
  backdrop-filter: blur(7px);
}

.gallery-viewer__panel {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 104px;
  width: min(1120px, calc(100vw - 72px));
  height: min(820px, calc(100vh - 72px));
  overflow: hidden;
  color: #f7f5f1;
  background: linear-gradient(145deg, #211f1c 0%, #121211 100%);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
}

.gallery-viewer__panel--single { grid-template-rows: 64px minmax(0, 1fr) 0; }

.gallery-viewer__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px 16px 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-viewer__header h2 {
  overflow: hidden;
  margin: 0;
  color: inherit;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-viewer__header span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.gallery-viewer__close,
.gallery-viewer__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  appearance: none;
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

.gallery-viewer__close {
  justify-self: end;
  width: 42px;
  height: 42px;
  background: transparent;
}

.gallery-viewer__close svg,
.gallery-viewer__nav svg {
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  pointer-events: none;
}

.gallery-viewer__close svg { width: 25px; height: 25px; }
.gallery-viewer__nav svg { width: 26px; height: 26px; }

.gallery-viewer__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 14px 68px;
  overflow: hidden;
  cursor: default;
  touch-action: pan-y;
}

.gallery-viewer__stage img {
  position: absolute;
  inset: 14px 68px;
  display: block;
  width: calc(100% - 136px) !important;
  height: calc(100% - 28px) !important;
  max-width: none;
  max-height: none;
  object-fit: contain;
  opacity: 1;
  transform: translateX(0) scale(var(--gallery-zoom, 1));
  transform-origin: center;
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-viewer__stage img.is-changing {
  opacity: 0;
  transform: translateX(10px) scale(var(--gallery-zoom, 1));
}

.gallery-viewer__stage.is-zoomed { cursor: zoom-out; }

.gallery-viewer__nav {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-50%);
  transition: background 180ms ease, transform 180ms ease;
}

.gallery-viewer__prev { left: 14px; }
.gallery-viewer__next { right: 14px; }

.gallery-viewer__close:hover,
.gallery-viewer__close:focus-visible,
.gallery-viewer__nav:hover,
.gallery-viewer__nav:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.55);
  outline-offset: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.gallery-viewer__nav:hover,
.gallery-viewer__nav:focus-visible { transform: translateY(-50%) scale(1.05); }

.gallery-viewer__thumbnails {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 19px;
  overflow-x: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
  scrollbar-width: thin;
}

.gallery-viewer__thumbnails[hidden] { display: none; }

.gallery-viewer__thumb {
  flex: 0 0 auto;
  width: 84px;
  height: 62px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 0;
  background: #292725;
  opacity: 0.58;
  cursor: pointer;
  transition: opacity 180ms ease, border-color 180ms ease, transform 180ms ease;
}

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

.gallery-viewer__thumb:hover,
.gallery-viewer__thumb:focus-visible {
  outline: 0;
  border-color: rgba(255, 255, 255, 0.5);
  opacity: 0.88;
}

.gallery-viewer__thumb[aria-current="true"] {
  border-color: #f4eee5;
  opacity: 1;
  transform: translateY(-2px);
}

@media (max-width: 767px) {
  .gallery-page { padding: 46px 0 72px; }
  .gallery-grid { display: block; }
  .gallery-column { display: contents; }
  .gallery-card { margin-bottom: 30px; }
  .gallery-card:hover { transform: none; }
  .gallery-card__media { margin: 8px 8px 0; }
  .gallery-card__sheet-photo { margin: 8px 8px 0; }
  .gallery-card__sheet-caption { min-height: 140px; }
  .gallery-card__body { height: 140px; padding: 17px 18px 19px; }
  .gallery-card__body h3 { font-size: 19px; }
  .gallery-card__arrow { display: none; }

  .gallery-viewer__panel {
    grid-template-rows: 58px minmax(0, 1fr) 88px;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .gallery-viewer__panel--single { grid-template-rows: 58px minmax(0, 1fr) 0; }
  .gallery-viewer__header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-height: 58px;
    padding: 8px 8px 8px 14px;
    gap: 8px;
  }
  .gallery-viewer__header h2 { font-size: 15px; }
  .gallery-viewer__stage { padding: 10px 8px; }
  .gallery-viewer__stage img {
    inset: 10px 8px;
    width: calc(100% - 16px) !important;
    height: calc(100% - 20px) !important;
  }
  .gallery-viewer__nav { display: none; }
  .gallery-viewer__thumbnails { gap: 8px; padding: 11px 10px 14px; }
  .gallery-viewer__thumb { width: 68px; height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-card__cover img,
  .gallery-card__track,
  .gallery-viewer__stage img,
  .gallery-viewer__thumb { transition: none; }
}
