body[data-page="photos"] .page-main {
  min-height: auto;
  width: min(1400px, calc(100vw - 54px));
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 24px;
  padding: 74px 0 48px;
}

body[data-page="photos"] .page-main > * {
  width: 100%;
  max-width: none;
}

body[data-page="photos"] .site-footer {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  width: min(1400px, calc(100vw - 54px));
  margin: 0 auto;
  padding: 0 0 24px;
}

.photo-viewer {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.photo-status {
  margin: 0;
  min-height: 1.2em;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.photo-status.is-error {
  color: #ffc9c9;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 4px;
  gap: 14px;
  contain: layout style paint;
}

.photo-card {
  --photo-row-span: 28;
  grid-row: span var(--photo-row-span);
  position: relative;
  border: 1px solid rgba(242, 243, 234, 0.2);
  border-radius: 12px;
  background: rgba(16, 18, 22, 0.86);
  overflow: hidden;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: 320px 220px;
  transition:
    border-color 150ms ease,
    transform 150ms ease;
}

.photo-card:hover,
.photo-card:focus-visible {
  border-color: rgba(244, 246, 213, 0.7);
  transform: translateY(-2px);
  outline: none;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: rgba(5, 6, 7, 0.92);
}

.photo-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to top, rgba(5, 6, 8, 0.76), transparent);
  pointer-events: none;
}

.photo-card-label {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  z-index: 2;
  color: #ffffff;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  pointer-events: none;
}

.photo-carousel[hidden] {
  display: none;
}

.photo-carousel {
  position: fixed;
  inset: 0;
  z-index: 130;
}

.photo-carousel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 12, 0.64);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.photo-carousel-content {
  position: relative;
  z-index: 2;
  height: 100%;
  width: min(1400px, calc(100vw - 54px));
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
  gap: 22px;
  align-items: center;
  padding: 84px 0 26px;
}

.photo-back-button {
  position: fixed;
  top: max(14px, calc(env(safe-area-inset-top, 0px) + 8px));
  left: max(14px, calc(env(safe-area-inset-left, 0px) + 8px));
  z-index: 3;
  border: 1px solid rgba(242, 243, 234, 0.34);
  background: rgba(9, 11, 14, 0.9);
  color: var(--text-primary);
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.photo-back-button:hover,
.photo-back-button:focus-visible {
  border-color: rgba(244, 246, 213, 0.88);
  outline: none;
}

.photo-stage-shell {
  min-width: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 12px;
  align-items: center;
}

.photo-nav-button {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(242, 243, 234, 0.28);
  background: rgba(9, 11, 14, 0.84);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background-color 140ms ease;
}

.photo-nav-button:hover,
.photo-nav-button:focus-visible {
  border-color: rgba(244, 246, 213, 0.88);
  background: rgba(14, 17, 22, 0.96);
  outline: none;
}

.photo-nav-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.photo-stage {
  margin: 0;
  width: min(100%, var(--viewer-width, 100%));
  justify-self: center;
  border: 1px solid rgba(242, 243, 234, 0.24);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(6, 8, 10, 0.84);
}

.photo-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, var(--viewer-width, 100%));
  max-height: var(--viewer-height, calc(100vh - 238px));
  margin: 0 auto;
  object-fit: contain;
  background: rgba(5, 6, 7, 0.92);
}

.photo-stage-caption {
  margin: 0;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
  border-top: 1px solid rgba(242, 243, 234, 0.16);
}

.photo-meta {
  align-self: stretch;
  margin: 0;
  border: 1px solid rgba(242, 243, 234, 0.24);
  border-radius: 14px;
  background: rgba(8, 10, 13, 0.88);
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 150px);
}

.photo-meta-title {
  margin: 0 0 14px;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.photo-meta-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.photo-meta-row {
  margin: 0;
  padding: 0 0 10px;
  border-bottom: 1px solid rgba(242, 243, 234, 0.12);
}

.photo-meta-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.photo-meta-row dt {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.photo-meta-row dd {
  margin: 6px 0 0;
  color: var(--text-primary);
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

body.is-photo-carousel-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  body[data-page="photos"] .page-main {
    width: calc(100vw - 28px);
    gap: 16px;
    padding: 34px 0 18px;
  }

  body[data-page="photos"] .site-footer {
    width: calc(100vw - 28px);
    padding-bottom: 18px;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-rows: 3px;
    gap: 10px;
  }

  .photo-card-label {
    font-size: 0.66rem;
  }

  .photo-carousel-content {
    width: calc(100vw - 18px);
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 72px 0 14px;
  }

  .photo-stage-shell {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 6px;
  }

  .photo-nav-button {
    width: 44px;
    height: 44px;
  }

  .photo-stage img {
    max-height: calc(100vh - 184px);
  }

  .photo-stage-caption {
    font-size: 0.72rem;
    padding: 8px 10px;
  }

  .photo-meta {
    display: none;
  }

  .photo-back-button span {
    display: none;
  }
}
