/* ==========================================================================
   CHAPTER 02 | BEYOND THE GYM.  (approved 2026-11-25, mobile)
   One pinned stage. JS (js/ch02-beyond.js) maps scroll progress 0→1 to:
   background black→light grey, title parting, product entrance, 2.5D switch.
   ========================================================================== */

.beyond {
  /* ── Adjustable ───────────────────────────────────────────────
     --beyond-length : 区間全体の高さ（画面何枚分）。演出に使うのは −1画面分 */
  --beyond-length: 3.9;   /* 2026-12-01 段階4：5.4 → 3.9（固定 2.9画面。旧方式 ?motion=legacy は 5.4） */
  /* ── Hand-off from CHAPTER 01 ─────────────────────────────────
     --handoff-overlap : CHAPTER 02 が固定され始めてから CHAPTER 01 の固定が
                         終わるまでの重なり（画面何枚分）。この間、暗くなる
                         CHAPTER 01 の上にライトグレーが透明から重なっていく。 */
  --handoff-overlap: 0.5;
  --grey: #d9d8d4;                 /* light grey (SCENE 02–03 background) */
  --product-w: 90vw;
  --product-h: min(72vw, 46svh);
  /* Mobile: product centre measured against the always-visible height (svh), so the
     product + name group stays put in the visible area whether or not the browser
     toolbar is showing. Same 44% as before; PC overrides this below. */
  --product-y-ratio: 0.44;
  --product-y: calc(var(--vh-small) * var(--product-y-ratio));
  --name-gap: 38px;                /* product bottom → product counter (mobile) */

  position: relative;
  z-index: 1;
  height: calc(var(--vh-large) * var(--beyond-length));
  /* Pull CHAPTER 02 up so its pin begins while CHAPTER 01 is still pinned
     (removes the blank screen that used to slide in between the chapters). */
  margin-top: calc(var(--vh-large) * -1 * (1 + var(--handoff-overlap)));
  background: transparent;
  pointer-events: none;           /* the transparent hand-off never blocks CHAPTER 01 */
}

.beyond__stage {
  position: sticky;
  top: 0;
  height: var(--vh-large);
  overflow: hidden;
  contain: layout paint;
  isolation: isolate;
  background: transparent;         /* JS fades in --grey over the end of CHAPTER 01 */
  color: var(--c-white);           /* JS blends this to --c-ink */
}

/* ── SCENE 01: label + title ───────────────────────────────── */
.beyond__label {
  position: absolute;
  top: calc(var(--safe-top) + 26px);
  left: var(--gutter);
  z-index: 3;
  font: 500 11.5px/10.5px var(--font-text);
  letter-spacing: .24em;
  text-transform: uppercase;
  will-change: opacity;
}

.beyond__title {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 3;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-58%);
  font-family: var(--font-display);
  font-weight: 900;
  /* "THE GYM." (≈4.47em) spans the content width */
  font-size: calc((100vw - 2 * var(--gutter)) / 4.47);
  line-height: .84;
  letter-spacing: -.045em;
  text-transform: uppercase;
  pointer-events: none;
}
.beyond__line {
  display: block;
  white-space: nowrap;
  will-change: transform, opacity;
}

/* ── SCENE 02–03: products ─────────────────────────────────── */
.beyond__products {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.product {
  position: absolute;
  left: 50%;
  top: var(--product-y);
  width: var(--product-w);
  height: var(--product-h);
  margin: calc(var(--product-h) / -2) 0 0 calc(var(--product-w) / -2);
  transform-origin: 50% 50%;
  opacity: 0;
  will-change: transform, opacity;
}
.product__float {
  position: absolute;
  inset: 0;
  animation: product-float 5.6s ease-in-out infinite alternate;
}
.product__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  /* soft contact shadow kept close to the garment for a lifted, studio feel */
  filter: drop-shadow(0 18px 22px rgba(20, 20, 19, .16));
}
.product__shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -9%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(20, 20, 19, .30), rgba(20, 20, 19, 0));
  animation: shadow-float 5.6s ease-in-out infinite alternate;
}
.product__caption { display: none; }

@keyframes product-float {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(0, -2.2%, 0); }
}
@keyframes shadow-float {
  from { transform: scaleX(1);   opacity: 1; }
  to   { transform: scaleX(.9);  opacity: .75; }
}

/* ── Names ─────────────────────────────────────────────────── */
.beyond__ui {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 4;
  height: var(--vh-small);
  pointer-events: none;
}
.beyond__names {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--safe-bottom) + 30px);
  height: 4.2rem;
}
.beyond__name {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--c-ink);
  opacity: 0;
  will-change: transform, opacity;
}
.beyond__count {
  font: 500 11.5px/10.5px var(--font-text);   /* line box kept at 10.5px → names do not move */
  letter-spacing: .24em;
  color: rgba(20, 20, 19, .6);
}
.beyond__name-text {
  font-family: var(--font-display);
  font-weight: 900;
  /* the longest name, CREW NECK SWEAT (≈11em), fits the content width */
  font-size: min(calc((100vw - 2 * var(--gutter)) / 11.9), 4.5rem);
  line-height: .9;
  letter-spacing: -.035em;
  white-space: nowrap;
}

/* Product links (names → Shopify product pages). Layout is unchanged; JS enables taps only
   while a name is clearly shown, and CHAPTER 03 disables them while it covers this stage. */
.beyond__count .arrow-ne { margin-left: .9em; }
a.beyond__name { -webkit-tap-highlight-color: transparent; }
a.beyond__name::after {             /* larger, invisible tap area */
  content: '';
  position: absolute;
  inset: -14px -12px;
}
a.beyond__name:focus-visible { outline: 1px solid currentColor; outline-offset: 8px; }
.beyond.is-covered .beyond__name { pointer-events: none !important; }

/* Mobile: names sit directly under the product (top-anchored, identical for all three),
   instead of being pinned to the bottom edge of the screen. */
@media (max-width: 767px) {
  .beyond__names {
    top: calc(var(--product-y) + var(--product-h) / 2 + var(--name-gap));
    bottom: auto;
    height: auto;
  }
  .beyond__name {
    top: 0;
    bottom: auto;
  }
}

/* ── Tablet / PC ──────────────────────────────────────────── */
@media (min-width: 768px) {
  .beyond {
    --product-w: min(62vw, 760px);
    --product-h: min(46vw, 52svh);
    --product-y: 46%;
  }
  .beyond__title { font-size: calc((100vw - 2 * var(--gutter)) / 6); }
}
@media (min-width: 1024px) {
  .beyond {
    --product-w: min(44vw, 760px);
    --product-h: min(34vw, 58svh);
  }
  .beyond__label { top: calc(var(--safe-top) + 34px); font-size: 11px; }
  .beyond__names { bottom: 44px; }
}

/* ── Landscape PC (≥1024px wide, landscape only) ────────────────────────────
   区間を 4.5画面に短縮（タイミングは js/ch02-beyond.js の PC）。左右の商品を少し大きく、
   商品名と番号は中央の商品のすぐ下・左端にそろえて一体に見せる。
   CHAPTER 02 のラベルは固定ヘッダーのロゴと重ならない位置へ。
   商品名の文字サイズは CHAPTER 03 冒頭の写し（.detail__mirror-name）にも同じく効く。     */
@media (min-width: 1024px) and (orientation: landscape) {
  .beyond {
    --beyond-length: 3.5;   /* 段階4：4.5 → 3.5（固定 2.5画面。旧方式は 4.5） */
    --product-w: min(44vw, 780px);
    --product-h: min(34vw, 56svh);
    --product-y: 45%;
    --pc-name-gap: 30px;            /* product bottom → counter */
  }
  .beyond__label { top: calc(var(--safe-top) + 104px); font-size: 12px; }
  .beyond__names {
    top: calc(var(--product-y) + var(--product-h) / 2 + var(--pc-name-gap));
    left: calc(50% - var(--product-w) / 2);
    right: auto;
    bottom: auto;
    height: auto;
  }
  .beyond__name { top: 0; bottom: auto; }
  .beyond__name-text { font-size: min(3.6vw, 4.25rem); }

  /* Hover: the arrow lifts and a hairline draws under the name — nothing else */
  .beyond__name-text { position: relative; }
  .beyond__name-text::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10px;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: 0 50%;
  }
}
@media (min-width: 1024px) and (orientation: landscape) and (hover: hover) {
  a.beyond__name .arrow-ne,
  a.beyond__name .beyond__name-text::after { transition: transform .6s var(--ease-out); }
  a.beyond__name:hover .arrow-ne { transform: rotate(-45deg) translateX(4px); }
  a.beyond__name:hover .beyond__name-text::after { transform: scaleX(1); }
}

/* ── Static (reduced motion / no JS) ──────────────────────── */
/* 旧方式との比較（?motion=legacy）：段階4以前の区間の長さ */
.motion-legacy .beyond { --beyond-length: 5.4; }
@media (min-width: 1024px) and (orientation: landscape) {
  .motion-legacy .beyond { --beyond-length: 4.5; }
}

.beyond.is-static { height: auto; margin-top: 0; pointer-events: auto; }
.beyond.is-static .beyond__stage {
  position: relative;
  height: auto;
  overflow: visible;
  background: var(--grey);
  color: var(--c-ink);
  padding: 96px var(--gutter) 80px;
}
.beyond.is-static .beyond__label { position: static; margin-bottom: 24px; }
.beyond.is-static .beyond__title { position: static; transform: none; align-items: flex-start; margin-bottom: 48px; }
.beyond.is-static .beyond__products { position: static; display: grid; gap: 56px; }
.beyond.is-static .product {
  position: relative; left: auto; top: auto; margin: 0 auto;
  width: 100%; height: auto; aspect-ratio: 4 / 3; opacity: 1; transform: none;
}
.beyond.is-static .product__float,
.beyond.is-static .product__shadow { animation: none; }
.beyond.is-static .product__caption {
  display: block;
  position: absolute; left: 0; bottom: -28px;
  font: 500 11.5px/1 var(--font-text); letter-spacing: .24em;
}
.beyond.is-static .beyond__ui { display: none; }

@media (prefers-reduced-motion: reduce) {
  .product__float, .product__shadow { animation: none; }
  .beyond { margin-top: 0; }
}
