/*
 * Homepage report covers — native-scroll magazine spread.
 *
 * This layer expects the scene/stage wrappers around the existing three report
 * cards. The source cover images remain uncropped and every visible card part
 * remains inside its original link.
 */

.editorial-home .home-magazine-scene {
  --magazine-gap: clamp(24px, 4vw, 48px);
  --magazine-spread: var(--magazine-progress, 1);
  position: relative;
}

/* Keyboard users immediately receive the fully separated, readable state. */
.editorial-home .home-magazine-scene:focus-within {
  --magazine-spread: 1;
}

.editorial-home .home-magazine-stage {
  position: relative;
  z-index: 0;
  padding-block: clamp(8px, 1.2vw, 18px) clamp(13px, 1.6vw, 24px);
}

.editorial-home .home-magazine-scene .home-report-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: var(--magazine-gap);
  margin-top: clamp(26px, 3.3vw, 40px);
  overflow: visible;
}

.editorial-home .home-magazine-scene .home-report-card {
  position: relative;
  z-index: auto;
  min-width: 0;
  overflow: visible;
}

/* One anchor still owns the original cover, title, place, and read link. */
.editorial-home .home-magazine-scene .home-report-link {
  display: block;
  overflow: visible;
  color: var(--ink);
  text-decoration: none;
}

.editorial-home .home-magazine-scene .home-report-link:hover {
  color: var(--ink);
  opacity: 1;
  transform: none;
}

/* The paper treatment lives on the cover wrapper; the source image is intact. */
.editorial-home .home-magazine-scene .home-report-cover {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  overflow: visible;
  isolation: isolate;
  padding: clamp(2px, 0.28vw, 4px);
  background: #f8f7f2;
  box-shadow: 3px 7px 16px rgb(9 10 10 / 0.17);
  transform: rotate(0deg);
  transform-origin: center bottom;
  transition: none;
  animation: none;
  will-change: auto;
}

.editorial-home .home-magazine-scene .home-report-cover::before {
  position: absolute;
  z-index: 0;
  inset: 2px -3px -3px 2px;
  content: "";
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    #e1dfd8 0 1px,
    #f8f7f2 1px 3px
  );
  box-shadow: 2px 3px 7px rgb(9 10 10 / 0.12);
}

.editorial-home .home-magazine-scene .home-report-cover::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  pointer-events: none;
  box-shadow:
    inset 1px 0 rgb(255 255 255 / 0.74),
    inset -1px 0 rgb(73 70 60 / 0.14),
    inset 0 -1px rgb(73 70 60 / 0.16);
}

.editorial-home .home-magazine-scene .home-report-cover img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  object-fit: initial;
}

/* A readable no-JS state: complete covers, a restrained final fan, no crop. */
.editorial-home
  .home-magazine-scene
  .home-report-card:nth-child(1)
  .home-report-cover {
  z-index: 3;
  transform: rotate(-4deg);
}

.editorial-home
  .home-magazine-scene
  .home-report-card:nth-child(2)
  .home-report-cover {
  z-index: 2;
  transform: rotate(0deg);
}

.editorial-home
  .home-magazine-scene
  .home-report-card:nth-child(3)
  .home-report-cover {
  z-index: 1;
  transform: rotate(4deg);
}

/* Captions never join the scroll transform and retain three visible columns. */
.editorial-home .home-magazine-scene .home-report-caption {
  position: relative;
  z-index: 5;
  min-width: 0;
  padding-top: clamp(17px, 1.5vw, 22px);
  background: var(--white);
}

/*
 * On wide, sufficiently tall, motion-permitted viewports, JS updates only the
 * cover spread. The scene and stage remain in natural page flow: no pinning or
 * artificial scroll runway is required.
 */
@media (min-width: 900px) and (min-height: 600px) {
  /* Covers alone follow progress; captions and anchors stay in their columns. */
  .editorial-home
    .home-magazine-scene.magazine-motion
    .home-report-card:nth-child(1)
    .home-report-cover {
    transform: translate3d(
        calc((100% + var(--magazine-gap)) * (1 - var(--magazine-spread))),
        calc(-2px * (1 - var(--magazine-spread))),
        0
      )
      rotate(calc(-4deg - 4deg * (1 - var(--magazine-spread))));
    will-change: transform;
  }

  .editorial-home
    .home-magazine-scene.magazine-motion
    .home-report-card:nth-child(2)
    .home-report-cover {
    transform: translate3d(0, calc(1px * (1 - var(--magazine-spread))), 0)
      rotate(calc(1deg * (1 - var(--magazine-spread))));
    will-change: transform;
  }

  .editorial-home
    .home-magazine-scene.magazine-motion
    .home-report-card:nth-child(3)
    .home-report-cover {
    transform: translate3d(
        calc((-100% - var(--magazine-gap)) * (1 - var(--magazine-spread))),
        calc(2px * (1 - var(--magazine-spread))),
        0
      )
      rotate(calc(4deg + 4deg * (1 - var(--magazine-spread))));
    will-change: transform;
  }
}

/* The compact source-card rows remain the fallback for narrow or short viewports. */
@media (max-width: 899px), (max-height: 599px) {
  .editorial-home .home-magazine-scene .home-report-gallery {
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 26px;
    border-top: 1px solid var(--rule);
  }

  .editorial-home .home-magazine-scene .home-report-link {
    display: grid;
    grid-template-columns: clamp(98px, 30vw, 140px) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
    padding: 17px 0;
    border-bottom: 1px solid var(--rule);
  }

  .editorial-home .home-magazine-scene .home-report-cover,
  .editorial-home
    .home-magazine-scene
    .home-report-card:nth-child(n)
    .home-report-cover {
    width: 100%;
    padding: 2px;
    box-shadow: 2px 4px 9px rgb(9 10 10 / 0.13);
    transform: none;
  }

  .editorial-home .home-magazine-scene .home-report-caption {
    min-width: 0;
    padding-top: 1px;
    background: transparent;
  }

  .editorial-home .home-magazine-scene .home-report-caption h3 {
    font-size: clamp(18px, 4.9vw, 21px);
  }

  .editorial-home .home-magazine-scene .home-report-place {
    margin-top: 4px;
    font-size: 13px;
  }

  .editorial-home .home-magazine-scene .home-read-example {
    margin-top: 9px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .editorial-home .home-magazine-scene .home-report-link {
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 13px;
  }
}

/* Reduced motion keeps the complete covers static in normal page flow. */
@media (prefers-reduced-motion: reduce) {
  .editorial-home .home-magazine-scene .home-report-cover,
  .editorial-home
    .home-magazine-scene
    .home-report-card:nth-child(n)
    .home-report-cover {
    animation: none;
    transition: none;
    transform: none;
    will-change: auto;
  }
}

@media (min-width: 900px) and (min-height: 600px) and (prefers-reduced-motion: reduce) {
  .editorial-home
    .home-magazine-scene.magazine-motion
    .home-report-card:nth-child(n)
    .home-report-cover {
    transform: none;
  }
}
