*,
*:after,
*:before {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --left-pad: calc(48px + 2rem);
  --container-width: calc(100vw - 1rem - var(--left-pad));
  --column-one: calc(var(--container-width) * (1.2 / 3.2));
  --column-two: calc(var(--container-width) * (2 / 3.2));
  --col-one-height: min(70vh, calc((380 / 272) * var(--column-one)));
  --col-two-height: min(110vh, calc((1148 / 940) * var(--column-two)));
  --catch-up: calc(var(--col-two-height) - var(--col-one-height));
}

body {
  margin: 0;
  background: #e8e6e1;
  color: #0b0b0b;
  font-family:
    "SF Pro Text",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  overflow-x: hidden;
}

/* Header Bereich */
.photo-header {
  height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}

.back-link {
  color: #888;
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 2px;
  margin-bottom: 2rem;
  transition: color 0.3s ease;
}

.back-link:hover {
  color: #141413;
}

.header-title {
  font-family: "LibreCaslonDisplay-Regular";
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: 4px;
  margin: 0 0 1rem 0;
  text-shadow: 4px 5px 8px #1a1a1a54;
}

.header-sub {
  color: #c11111;
  font-style: italic;
  font-size: 1.2rem;
}

.header-sub-two {
  color: #323131;
  font-style: italic;
  font-size: 1rem;
}

/* Layout Raster (Desktop) */
main {
  display: flex;
  flex-direction: column;
  gap: 12rem;
  padding-bottom: calc(var(--catch-up) * 0.6);
}

.image-box {
  display: grid;
  gap: 2rem;
  padding: 1rem 2rem 1rem var(--left-pad);
  min-height: 100vh;
  grid-template-columns: 1.2fr 2fr;
}

section:nth-of-type(even) .image-box {
  grid-template-columns: 2fr 1.2fr;
}

/* Bilder & Blenden */
img {
  background: #1a1a1a;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
  mix-blend-mode: plus-lighter;
}

.swapper {
  height: var(--col-one-height);
  width: 100%;
  position: relative;
  border-radius: 6px;
  isolation: isolate;
  background: #000;
}

.swapper img {
  position: absolute;
  top: 0;
  left: 0;
}

.swapper img:first-of-type {
  opacity: 0;
}

.controller {
  height: var(--col-two-height);
  width: 100%;
  border-radius: 6px;
  background: #000;
}

/* Fortschrittsleiste */
.progress {
  position: absolute;
  height: min(100px, 15%);
  width: 4px;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  gap: 5%;
  z-index: 10;
}

.progress > div {
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.2);
  flex: 10;
  position: relative;
}

.progress div > div {
  position: absolute;
  top: 0;
  width: 100%;
  border-radius: 100px;
  height: 0%;
  background: white;
}

.progress > div:last-of-type {
  flex: calc(1 + (var(--flip, 0) * 99));
}

.swapper:first-of-type .progress {
  right: 12px;
}
.swapper:last-of-type .progress {
  left: 12px;
}

/* Bildunterschriften (Desktop) */
.caption {
  position: absolute;
  bottom: 100%;
  padding: 1rem 0;
  font-size: 0.8rem;
  width: 100%;
  text-transform: uppercase;
}

.caption h2 {
  font-size: 1.9rem;
  margin: 0 0 0.25rem 0;
  letter-spacing: 1px;
  color: #474646;
}

.caption p {
  margin: 0;
  color: #474646;
  font-size: 0.75rem;
}

.mobile-caption {
  display: none;
}

/* NATIVE CSS SCROLL ANIMATION (Desktop) */
@supports (animation-timeline: scroll()) {
  @property --flip {
    inherits: true;
    initial-value: 0;
    syntax: "<number>";
  }

  @keyframes fade {
    to {
      opacity: 0;
    }
  }
  @keyframes fill-up {
    to {
      height: 100%;
    }
  }
  @keyframes move {
    to {
      translate: 0 var(--catch-up);
    }
  }
  @keyframes flip {
    to {
      --flip: 1;
    }
  }

  .image-box {
    view-timeline: --container;
  }

  .swapper {
    animation:
      move both linear,
      flip both steps(1);
    animation-timeline: --container, view();
    animation-range:
      50vh calc(100vh + (var(--col-two-height) * 0.25)),
      cover 50% cover 50%;
  }

  .swapper img {
    animation: fade both linear;
    animation-timeline: view();
    animation-range: cover 45% cover 55%;
  }

  .swapper img:first-of-type {
    opacity: 1;
    animation-direction: reverse;
  }

  .progress div > div {
    animation: fill-up both linear;
    animation-timeline: --container;
  }
}

.photo-footer {
  padding: 4rem 2rem;
  text-align: center;
  color: #555;
  font-size: 0.8rem;
}

/* ==========================================================================
   PERFEKTE MOBIL-ANPASSUNG (SAUBERE REIHENFOLGE & OBERHALB GELEGENE TITEL)
   ========================================================================== */
@media (max-width: 768px),
  (max-width: 900px) and (hover: none) and (pointer: coarse) {
  main {
    gap: 3rem !important; /* Lücken zwischen Abschnitten komplett reduzieren */
  }

  .photo-header {
    height: auto;
    min-height: 370px;
    padding: 1.5rem 1rem;
  }

  .image-box {
    display: flex !important;
    flex-direction: column !important;
    padding: 1rem !important;
    min-height: auto !important;
    gap: 1.5rem !important;
  }

  .mobile-caption {
    display: block;
    padding: 0 1rem;
    margin: 0 0 0.5rem;
    text-transform: uppercase;
  }

  .mobile-caption h2 {
    color: #1a1a1a;
    font-size: 1.4rem;
    letter-spacing: 1px;
    margin: 0 0 0.2rem;
  }

  .mobile-caption p {
    color: #555555;
    font-size: 0.8rem;
    margin: 0;
  }

  /* .swapper wird als Flex-Container genutzt, um die Caption immer ganz nach oben zu erzwingen */
  .swapper {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    background: transparent !important;
    overflow: visible !important;
    animation: none !important; /* Deaktiviert störendes Desktop-Sticky-Scrollen auf Mobil */
  }

  /* Bilder im Swapper sauber unter dem Titel platzieren */
  .swapper img {
    position: relative !important;
    height: 320px !important;
    opacity: 1 !important;
    animation: none !important;
    mix-blend-mode: normal !important;
  }

  .swapper img:first-of-type {
    display: none !important; /* Verhindert doppelte Bildüberlagerung auf dem Handy */
  }

  .swapper img:first-of-type {
    display: block !important;
  }

  .controller {
    height: 320px !important;
  }

  /* Die Überschrift wird GARANTIERT über das jeweilige Bild gesetzt */
  .caption {
    display: none !important;
  }

  /* Mobile: lineare Galerie ohne Desktop-Animationen oder Überlagerungen */
  main {
    gap: 2.5rem !important;
    padding-bottom: 0 !important;
  }

  .photo-header {
    min-height: 360px;
  }

  .back-link {
    display: none;
  }

  .mobile-caption {
    padding: 0 1rem;
    margin: 0 0 1rem;
  }

  .image-box {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    min-height: 0 !important;
    padding: 0 1rem !important;
  }

  .caption,
  .progress {
    display: none !important;
  }

  .controller,
  .swapper {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    animation: none !important;
    transform: none !important;
    translate: none !important;
  }

  .controller {
    order: 1;
  }

  .swapper {
    order: 2;
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    overflow: visible !important;
  }

  .controller img,
  .swapper img,
  .swapper img:first-of-type {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: clamp(240px, 78vw, 380px) !important;
    margin: 0 !important;
    opacity: 1 !important;
    object-fit: cover !important;
    mix-blend-mode: normal !important;
    animation: none !important;
    transform: none !important;
  }

  .progress {
    display: none !important; /* Fortschrittsbalken auf Mobil ausblenden */
  }
}
