.page-photography {
  margin: 0;
  font: 18px/1.5 'SuisseIntl', Arial, sans-serif;
  --photography-gutter: 24px;
  --photography-measure: 892px;
  --photography-ease: cubic-bezier(.23, 1, .32, 1);
}

.page-photography *, .page-photography *::before, .page-photography *::after {
  box-sizing: border-box;
}

.photography-nav {
  max-width: 900px;
  margin-inline: auto;
  padding: 30px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.photography-home {
  display: grid;
  place-items: center start;
  width: 44px;
  height: 48px;
  font-size: 42px;
  line-height: 1;
  letter-spacing: -.05em;
  text-decoration: none;
}

.photography-nav .theme-toggle {
  position: static;
}

.photography-skip {
  position: fixed;
  inset: 8px auto auto 8px;
  z-index: 50;
  padding: 8px 14px;
  background: var(--bg);
  transform: translateY(-160%);
}

.photography-skip:focus {
  transform: translateY(0);
}

.photography-intro, .country-intro {
  max-width: 640px;
  margin: 74px auto 56px;
  padding-inline: var(--photography-gutter);
}

.photography-intro {
  margin-bottom: 28px;
}

.photography-intro h1, .country-intro h1 {
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -.03em;
  margin: 0;
}

.photography-intro p {
  margin: 24px 0 0;
  line-height: 1.65;
  white-space: pre-line;
  text-wrap: pretty;
}

.stamp-sheet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 232px));
  justify-content: center;
  align-items: start;
  gap: 40px clamp(28px, 8vw, 96px);
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--photography-gutter) 72px;
  list-style: none;
}

.stamp-sheet > li {
  min-width: 0;
}

.stamp-sheet > li:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  width: calc((100% - clamp(28px, 8vw, 96px)) / 2);
  justify-self: center;
}

.stamp-link {
  display: grid;
  justify-items: center;
  gap: 12px;
  align-content: start;
  text-decoration: none;
}

.stamp {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / .12));
}

.stamp-flag {
  display: block;
  width: 26px;
  height: 18px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.country-gallery {
  max-width: var(--photography-measure);
  margin-inline: auto;
  padding: 0 var(--photography-gutter) 80px;
}

.country-intro {
  max-width: none;
  padding-inline: 0;
  margin-bottom: 46px;
}

.places-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
}

.places-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.photo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 44px;
  margin: 0 auto 58px;
}

.photo-row--portrait {
  max-width: 560px;
}

.photo-print {
  min-width: 0;
  margin: 0;
}

.photo-open {
  display: block;
  color: inherit;
  cursor: zoom-in;
}

.photo-print img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--soft);
}

.photo-print figcaption,
.photo-viewer figcaption {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
}

.photo-viewer-count {
  color: var(--caption);
  font-size: 14px;
  line-height: 1.45;
}

.photo-print figcaption {
  padding-top: 10px;
}

.photography-empty {
  color: var(--muted);
}

.photo-viewer {
  width: min(calc(100% - 40px), 1080px);
  height: min(88vh, 860px);
  height: min(88svh, 860px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: clamp(10px, 2vw, 18px);
  overflow: hidden;
  overscroll-behavior: contain;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 18px 60px rgb(0 0 0 / .24);
}

.photo-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.photo-viewer::backdrop {
  background: rgb(0 0 0 / .76);
}

.photo-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.photo-viewer-count {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.photo-viewer button {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.photo-viewer button:hover,
.photo-viewer button:active {
  background: var(--soft);
}

.photo-viewer button:focus-visible {
  outline-offset: -3px;
}

.photo-viewer .photo-viewer-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-inline: 12px;
  font-size: 14px;
}

.photo-viewer figure {
  display: grid;
  grid-template:
    "photo photo photo" minmax(0, 1fr)
    "previous caption next" 46px /
    44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 7px 8px;
  min-width: 0;
  min-height: 0;
  margin: 0;
}

.photo-viewer-stage {
  grid-area: photo;
  align-self: stretch;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(6px, 1.4vw, 14px);
  background: var(--highlight);
  border: 1px solid var(--border);
  border-radius: 14px;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.photo-viewer-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  border-radius: 6px;
}

@supports (width: 1cqh) {
  .photo-viewer-stage { container-type: size; }
  .photo-viewer-image {
    width: min(100cqw, calc(100cqh * var(--photo-ratio, 1)));
    height: min(100cqh, calc(100cqw / var(--photo-ratio, 1)));
  }
}

.photo-viewer-status {
  position: absolute;
  inset: 50% 12px auto;
  margin: 0;
  transform: translateY(-50%);
  color: var(--caption);
  font-size: 14px;
  text-align: center;
}

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

.photo-viewer figcaption {
  grid-area: caption;
  overflow-wrap: anywhere;
}

.photo-viewer .photo-viewer-arrow {
  padding: 0;
  font-size: 21px;
}

.photo-viewer [data-prev] { grid-area: previous; }
.photo-viewer [data-next] { grid-area: next; }

html:has(.photo-viewer) { scrollbar-gutter: stable; }

html:has(.photo-viewer[open]) {
  overscroll-behavior: none;
  overflow: hidden;
}

@media (min-width: 620px) {
  .photo-row--pair {
    grid-template-columns: minmax(0, var(--first)) minmax(0, var(--second));
    gap: 18px;
  }
}

@media (max-width: 600px) {
  .page-photography { --photography-gutter: 20px; }
  .photography-nav { padding: 20px 24px 0; }
  .photography-intro, .country-intro { margin-top: 26px; }
  .photography-intro { margin-bottom: 19px; }
  .photography-intro h1, .country-intro h1 { font-size: 28px; }
  .photography-intro p { margin-top: 16px; font-size: 17px; }
  .stamp-sheet { row-gap: 28px; }
  .stamp-link { gap: 8px; }
  .country-intro { margin-bottom: 32px; }
  .photo-row { gap: 40px; margin-bottom: 40px; }
  .photo-print figcaption, .photo-viewer figcaption { font-size: 13px; }
  .photo-viewer {
    width: calc(100% - 16px);
    padding: 7px;
    border-radius: 17px;
  }
  .photo-viewer-stage { border-radius: 11px; }
}

@media (prefers-reduced-motion: no-preference) {
  .photo-viewer[open] {
    animation: show-photo-viewer 160ms ease-out;
  }
  .photo-viewer-status:not([hidden]) {
    animation: show-photo-viewer 140ms 180ms backwards;
  }
  @keyframes show-photo-viewer {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

@media (prefers-reduced-motion: no-preference) {
  .stamp {
    transform-origin: center 85%;
    transition: transform 180ms var(--photography-ease);
  }

  .stamp-link:focus-visible .stamp {
    transform: translateY(-4px) rotate(-1deg);
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .stamp-link:hover .stamp {
    transform: translateY(-4px) rotate(-1deg);
  }
}
