/* Portfolio ergänzt ausschließlich das gemeinsame Keepmories-Designsystem. */
.portfolio-page .portfolio-intro { padding-top: clamp(32px, 5vw, 64px); padding-bottom: 48px; }
.portfolio-page .breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 48px; font-size: 12px; color: var(--text-leise); }
.portfolio-page .breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.portfolio-page .portfolio-intro .eyebrow { margin-bottom: 18px; color: var(--text-leise); }
.portfolio-page .portfolio-intro > p:last-child { max-width: 620px; margin-top: 24px; color: var(--text-leise); }
.portfolio-page h1 { overflow-wrap: anywhere; hyphens: auto; }
.portfolio-page .portfolio-categories { padding-bottom: var(--abschnitt); }
.portfolio-tiles, .album-tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 32px; }
.portfolio-tile { display: block; text-decoration: none; }
.portfolio-tile .image-frame { aspect-ratio: 3 / 2; }
.portfolio-tile .tile-heading { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; padding-top: 22px; }
.tile-heading h2 { font-size: clamp(34px, 3.3vw, 46px); }
.tile-heading > span { font-size: 12px; color: var(--text-leise); }
.portfolio-tile .tile-subtitle { margin-top: 10px; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-leise); }
.portfolio-tile:hover h2 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 8px; }
.portfolio-tile:focus-visible { outline-offset: 8px; }
.portfolio-page .portfolio-club { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--linie); font-size: 13px; color: var(--text-leise); }
.portfolio-page .gallery-section { padding-bottom: var(--abschnitt); }
.gallery-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; padding-block: 18px; margin-bottom: 22px; border-top: 1px solid var(--linie); font-size: 12px; color: var(--text-leise); }
/* BILDGALERIEN: hier Zielhöhe, Abstand und kleinste erkennbare Bildbreite pflegen.
   Album-/Kategoriekacheln behalten separat ihr bestehendes Titelbildformat. */
.gallery-grid {
  --galerie-zeilenhoehe: 250px;
  --galerie-abstand: 10px;
  --galerie-mindestbreite: 110px;
  position: relative; list-style: none; padding: 0; margin: 0;
}
/* Ohne JavaScript eine zugängliche Bildfolge im Originalformat. */
.gallery-grid > li + li { margin-top: var(--galerie-abstand); }
.gallery-photo { display: block; background: transparent; }
.gallery-photo img { width: 100%; height: auto; object-fit: contain; }
.gallery-photo:focus-visible { outline: 2px solid var(--tinte); outline-offset: 3px; }
/* JavaScript positioniert vollständige, gleich hohe Reihen ohne DOM-Umsortierung. */
.gallery-grid[data-justified] > li { position: absolute; margin: 0; }
.gallery-grid[data-justified] .gallery-photo { height: 100%; }
.gallery-grid[data-justified] .gallery-photo img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 1000px) {
  .gallery-grid { --galerie-zeilenhoehe: 200px; --galerie-abstand: 8px; }
}
@media (max-width: 600px) {
  .gallery-grid { --galerie-zeilenhoehe: 190px; --galerie-abstand: 8px; }
}
.gallery-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 24px; align-items: center; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--linie); }
.gallery-note { margin-bottom: 28px; padding: 16px 20px; border-left: 2px solid var(--stein); background: var(--flaeche); color: var(--text-leise); font-size: 12px; line-height: 1.8; max-width: 800px; }
.album-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.album-tiles .tile-heading h2 { font-size: clamp(30px, 3.3vw, 44px); }
.gallery-noscript { display: block; margin-bottom: 18px; color: var(--text-leise); font-size: 12px; }
/* contain zeigt vollständige Fotos; der Dialog übernimmt keine Rasterausschnitte. */
.portfolio-lightbox { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border: 0; background: rgba(20,20,20,.97); color: var(--papier); overscroll-behavior: contain; }
.portfolio-lightbox::backdrop { background: rgba(0,0,0,.9); }
.portfolio-lightbox[open] { display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 12px; }
.viewer-top, .viewer-bottom { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.viewer-button { display: grid; place-items: center; flex-shrink: 0; width: 48px; height: 48px; border: 1px solid var(--stein); background: transparent; color: var(--papier); font-size: 26px; line-height: 1; }
.viewer-button:hover { background: #3b3936; }
.viewer-stage { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-columns: 48px minmax(0,1fr) 48px; gap: 16px; align-items: center; }
.viewer-picture { position: relative; width: 100%; height: 100%; min-height: 0; display: grid; place-items: center; touch-action: pan-y pinch-zoom; }
.viewer-image { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.viewer-message { position: absolute; inset: auto 12px 12px; text-align: center; font-size: 12px; background: #1e1e1e; padding: 8px 12px; }
.viewer-bottom span { font-size: 12px; white-space: nowrap; }
@media (max-width: 900px) {
  .portfolio-tiles { gap: 32px 22px; }
}
@media (max-width: 760px) {
  .portfolio-page .breadcrumbs { margin-bottom: 32px; }
  .portfolio-page .portfolio-intro { padding-bottom: 36px; }
  .portfolio-tiles, .album-tiles { grid-template-columns: 1fr; gap: 40px; }
  .portfolio-tile .tile-heading { padding-top: 18px; }
  .portfolio-page .portfolio-intro h1 { font-size: clamp(48px,10vw,72px); }
  .viewer-stage { grid-template-columns: minmax(0,1fr); gap: 0; }
  .viewer-stage > .viewer-button { position: absolute; z-index: 1; bottom: 0; background: rgba(30,30,30,.8); }
  .viewer-stage > [data-viewer-prev] { left: 0; }
  .viewer-stage > [data-viewer-next] { right: 0; }
  .viewer-picture { padding-bottom: 60px; }
  .viewer-message { bottom: 72px; }
  .gallery-actions .button { width: 100%; }
}
@media (max-width: 420px) {
  .gallery-meta { font-size: 11px; }
}
@media (max-height: 480px) {
  .portfolio-lightbox[open] { gap: 6px; }
  .viewer-top .viewer-button { height: 44px; width: 44px; }
}

/* Ersten Wechsel zum Justified-Raster vor der sichtbaren Darstellung abschließen.
   Der frühe Marker entfällt bei DOM-Bereitschaft, Fehlern oder spätestens nach 4 s. */
html.km-gallery-pending .gallery-grid:not([data-justified]) { visibility: hidden; }

/* Variante A verdichtet den mobilen Albumkopf, das Galerieraster bleibt gleich. */
@media(max-width:760px){
 .portfolio-page .portfolio-intro{padding-block:20px 28px}
 .portfolio-page .breadcrumbs{margin-bottom:20px}
 .portfolio-page .portfolio-intro>p:last-child{margin-top:18px}
}
