/* Home page: cover scales with scroll into the issue. Loaded after the cover
   and interior style blocks so these overrides win. */
html.home-issue {
  height: auto;
  min-height: 100%;
  background: var(--desk);
  scroll-padding-top: var(--nav-stack-h, var(--nav-h, 2.5rem));
  /* Override the bundled cover/interior `html{scroll-behavior:smooth}`.
     Smooth CSSOM scrolling fights a scroll-linked scale and makes wheel
     and scripted jumps feel stepped. Anchor clicks still use scroll-margin. */
  scroll-behavior: auto;
}
html.home-issue body {
  display: block;
  place-items: unset;
  margin: 0;
  padding: 0;
  min-height: 0;
  height: auto;
  color: var(--stock);
  font: 400 1rem/1.4 var(--gothic);
  background: radial-gradient(90% 70% at 50% 35%, #3a332c, var(--desk) 70%) var(--desk);
}
html.home-issue .skip {
  z-index: 40;
}

/* Two-line bar. The site nav always stays on the first line. --nav-mix is 0
   at the top (no backing bar, no issue row) and 1 after a short scroll
   (ink underlay under both lines, issue nav on the second line). Set on
   #top-nav only, never on :root. */
#top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  pointer-events: none;
}
#top-nav::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--nav-stack-h, 4.5rem);
  background: var(--ink, #1c1a17);
  opacity: var(--nav-mix, 0);
  pointer-events: none;
  transform-origin: top;
}
#top-nav .nav-site,
#top-nav .nav-issue {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  margin: 0;
  pointer-events: none;
}
#top-nav .nav-site {
  z-index: 2;
  opacity: 1;
  transform: none;
  padding: 8px 12px;
  max-width: none;
  color: var(--stock);
  font: 600 0.6875rem/1.3 var(--gothic);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: auto;
}
#top-nav .nav-site a { pointer-events: auto; }
#top-nav .nav-issue {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 2;
  opacity: var(--nav-mix, 0);
  transform: translateY(calc((1 - var(--nav-mix, 0)) * -6px));
  will-change: opacity, transform;
  max-width: min(1120px, 100%);
  margin: 0 auto;
  padding: 6px 12px 8px;
  justify-content: center;
  color: #dfd3bb;
  font: 14px/1.4 News, Georgia, serif;
  letter-spacing: 0;
  text-transform: none;
  flex-wrap: nowrap;
  gap: 8px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  white-space: nowrap;
}
#top-nav .nav-issue a {
  flex: 0 0 auto;
  white-space: nowrap;
}
#top-nav.is-issue .nav-issue,
#top-nav.is-issue .nav-issue a { pointer-events: auto; }
#top-nav:not(.is-issue) .nav-issue,
#top-nav:not(.is-issue) .nav-issue a { pointer-events: none; }

#top-nav .nav-issue a.is-current {
  color: #fff;
  border-bottom-color: #fff;
}

/* Stage: spacer (--stage-pad) so the sticky cover starts at the same top the
   bar occupies, then --scale-travel of scroll while the cover scales, then
   the cover at its final size. */
.cover-stage {
  position: relative;
  box-sizing: border-box;
  padding-top: var(--stage-pad, 0px);
  height: calc(
    var(--stage-pad, 0px) + var(--scale-travel, 0px) + var(--sticky-h, 100svh)
  );
}
.cover-sticky {
  position: sticky;
  top: var(--sticky-top, 0px);
  height: var(--sticky-h, 100svh);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: visible;
}
.cover-scale {
  width: var(--cover-final-w, 100%);
  height: var(--sticky-h, 100svh);
  transform-origin: top center;
  transform: translateY(var(--cover-ty, 0px)) scale(var(--cover-s, var(--s0, 1)));
  will-change: transform;
}
html.home-issue .cover-scale main#main {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
}

/* Layout the cover at the target (spread) width and scale it down so cqi type
   stays sharp, and so the layer is rasterized once at the large size.
   Shadow is static: animating box-shadow from a CSS variable forces a paint
   of the cover every frame. The static shadow lives on .cover, inside the
   transformed layer, so it scales with the cover at no extra cost. */
html.home-issue .cover {
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  border-radius: 2px;
  box-shadow:
    0 1px 1px rgb(0 0 0 / 0.35),
    0 8px 18px -6px rgb(0 0 0 / 0.5),
    0 28px 56px -18px rgb(0 0 0 / 0.55);
}

/* Interior follows at normal size. Top padding is the same gap the issue uses
   between spreads, so the handoff does not jump. Side padding matches the
   interior page so the 1120px issue lines up with the full-width cover. */
.issue-wrap {
  position: relative;
  z-index: 1;
  padding: 48px 25px 65px;
  color: var(--ink);
}
html.home-issue .issue-wrap .issue {
  max-width: 1120px;
  margin: 0 auto;
}
html.home-issue .spread,
html.home-issue .page,
html.home-issue .editor,
html.home-issue [id="contents"],
html.home-issue [id="from-the-editor"],
html.home-issue [id="the-best-part-is-no-part"],
html.home-issue [id="a-builders-lexicon"],
html.home-issue [id="robot-of-the-month"],
html.home-issue [id="vision-question-premise-decision"],
html.home-issue [id="honor-roll"] {
  scroll-margin-top: calc(var(--nav-stack-h, var(--nav-h, 2.5rem)) + 8px);
}

/* Compositor path: scale and nav opacity follow the root scroll timeline.
   Literal keyframe endpoints are written into #cover-kf by mm-early
   and cover-scroll layout() so WebKit can accelerate them. These
   var() rules are only a pre-JS fallback. */
@keyframes cover-scale-anim {
  from { transform: translateY(0px) scale(1); }
  to { transform: translateY(0px) scale(1); }
}
@keyframes nav-issue-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes nav-scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@supports (animation-timeline: scroll()) {
  html.scroll-timeline.has-scale .cover-scale {
    animation: cover-scale-anim linear both;
    animation-timeline: scroll(root);
    animation-range: 0px var(--scale-travel, 0px);
  }
  html.scroll-timeline #top-nav::before {
    animation: nav-scrim-in linear both;
    animation-timeline: scroll(root);
    animation-range: 0px var(--nav-range, 80px);
  }
  html.scroll-timeline #top-nav .nav-issue {
    animation: nav-issue-in linear both;
    animation-timeline: scroll(root);
    animation-range: 0px var(--nav-range, 80px);
  }
}

@media (max-width: 640px) {
  .issue-wrap {
    padding: 24px 0 40px;
  }
  html.home-issue .cover {
    border-radius: 0;
    box-shadow: none;
  }
  /* Site nav sits in its own band above the cover (desk shows behind it),
     with a safe-area inset for the notch. Desktop layout is unchanged.
     The two-tier ink bar still fades in over both lines on scroll. */
  #top-nav .nav-site {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top, 0px) 16px 0;
    height: calc(22px + env(safe-area-inset-top, 0px));
    min-height: calc(22px + env(safe-area-inset-top, 0px));
  }
  #top-nav .nav-site a {
    padding: 0 8px;
  }
  #top-nav .nav-issue {
    padding: 6px 14px 10px;
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.home-issue {
    scroll-behavior: auto;
  }
  #top-nav .nav-issue,
  #top-nav::before,
  .cover-scale {
    animation: none !important;
  }
  #top-nav .nav-issue {
    transform: none;
  }
  html.home-issue .cover-scale {
    transform: translateY(0px) scale(1);
  }
}
