/* ===================================================================
   effects.css — アニメーション & レスポンシブ
   =================================================================== */

/* ---- フェードイン ---- */
.fade-in { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s ease; }
.fade-in.visible { opacity: 1; transform: none; }

/* ---- HERO の浮遊アニメーションは廃止（主役7枚・ロゴエンブレムとも静止） ---- */

/* ---- HERO 背景カード（奥の中央から手前へ放射状に湧き出す／マスターデュエル風） ---- */
/* 主役7枚の後ろ(z-index:0)で、消失点(中央やや上)から手前へカードが流れてくる */
.hero-confetti {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  perspective: 700px; perspective-origin: 50% 45%;
}
/* 両面カードは2層構造。
   外側 .confetti-card … 移動(translateZ)＋フェード(opacity)を担当。
     opacity<1 や will-change:opacity は preserve-3d を flat に倒すので、
     回転と両面判定はここでは行わない（=フェードしても背面判定が壊れない）。
   内側 .cc-inner … preserve-3d で回転(rotateY/Z)。表裏が正しく切り替わる。
   表 cc-front / 裏 cc-back(=back.png)。Y軸90°超で表は backface-visibility:hidden
     で隠れ、180°回した裏面(本物のカード背面)が見える。 */
.confetti-card {
  position: absolute; left: 50%; top: 45%;
  opacity: 0;
  animation-name: mdMove; animation-timing-function: linear; animation-iteration-count: infinite;
}
/* 軽量化: HERO が画面外のときはアニメを停止（JSが .is-paused を付与） */
.hero-confetti.is-paused .confetti-card,
.hero-confetti.is-paused .cc-inner { animation-play-state: paused; }
.cc-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  animation-name: mdSpin; animation-timing-function: linear; animation-iteration-count: infinite;
}
.cc-face {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 4px; box-shadow: 0 6px 18px rgba(0,0,0,.5);
  object-fit: cover; backface-visibility: hidden;
}
.cc-back { transform: rotateY(180deg); }
/* 外側: translate(-50%,-50%) で中心を消失点へ。--ox/--oy の放射方向を保ったまま
   translateZ を奥(-1600px)→手前(520px)へ移動。手前ほど拡大・外側へ発散しフェードアウト。 */
@keyframes mdMove {
  0%   { transform: translate(-50%, -50%) translate3d(var(--ox, 0px), var(--oy, 0px), -1600px); opacity: 0; }
  14%  { opacity: 1; }
  96%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) translate3d(var(--ox, 0px), var(--oy, 0px), 520px); opacity: 0; }
}
/* 内側: 奥行きの左右回転(Y)＋面内回転(Z)。外側と同じ duration/delay で同期させる。 */
@keyframes mdSpin {
  0%   { transform: rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateY(var(--spinY, 360deg)) rotateZ(var(--spin, 360deg)); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-confetti { display: none; }
}

/* ---- CTA 発光パルス ---- */
@keyframes ctaPulse { 0%,100% { box-shadow: 0 0 0 1px rgba(95,240,231,.4), 0 8px 24px rgba(54,214,207,.28); } 50% { box-shadow: 0 0 0 1px rgba(95,240,231,.7), 0 8px 30px rgba(54,214,207,.5); } }
.install-btn { animation: ctaPulse 2.6s ease-in-out infinite; }
/* VDP2026クラファン系CTA は静止（点滅なし）。発光は style.css の静的 box-shadow で表現 */

/* ===================================================================
   レスポンシブ
   =================================================================== */

/* タブレット (≤991px) */
@media (max-width: 991px) {
  .header-cta-desktop { display: none; }
  .nav-toggle { display: flex; }

  .primary-nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: rgba(8,35,31,.98); border-bottom: 1px solid var(--c-line);
    padding: 12px 20px 24px; margin: 0;
    transform: translateY(-12px); opacity: 0; pointer-events: none;
    transition: transform .25s ease, opacity .25s ease;
    max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  }
  .primary-nav.open { transform: none; opacity: 1; pointer-events: auto; }
  .primary-nav > ul { flex-direction: column; align-items: stretch; gap: 0; width: 100%; }
  .primary-nav > ul li { border-bottom: 1px solid rgba(127,212,212,.12); }
  .primary-nav > ul a { display: block; padding: 14px 4px; font-size: 1rem; }
  .primary-nav li a.active::after { display: none; }
  .nav-inline-cta { display: inline-flex; margin-top: 16px; width: 100%; }

  .hero-stage { min-height: 380px; text-align: center; }
  .hero-copy { justify-self: center; align-self: end; text-align: center; max-width: 100%; }
  .hero-copy::before { inset: -20px -24px; background: radial-gradient(120% 100% at 50% 60%, rgba(8,35,31,.86) 30%, rgba(8,35,31,.4) 64%, transparent 80%); }
  .hero-cards { min-height: 360px; }
  .hero-badge { width: 108px; height: 108px; top: 0; bottom: auto; right: 8px; }
  .hb-num { font-size: 2.1rem; }

  /* 単一カラム時は商品画像→本文(説明＋CTA)の順（見出しはグリッド外で上部中央）。導線を正す */
  .cf-grid { grid-template-columns: 1fr; gap: 30px; }
  .cf-grid .cf-visual { order: -1; }
  .cf-visual-logo { width: 140px; right: 0; bottom: -16px; }
}

/* スマホ (≤767px) */
@media (max-width: 767px) {
  .section { padding: 56px 0; }

  /* HERO: 重ね合わせ→縦積み（エンブレム＋カード列 → コピーの順）に変更 */
  /* 固定ヘッダー回避分(72px)＋わずかな余白だけに詰めてロゴをヘッダー直下へ */
  .hero { padding-top: calc(var(--header-h) + 14px); }
  .hero-stage { display: flex; flex-direction: column; align-items: center; min-height: 0; gap: 4px; }
  .hero-copy { order: 2; position: relative; width: 100%; max-width: 340px; align-self: center; text-align: center; padding: 0 8px; }
  .hero-copy::before { display: none; }
  /* 背景プレート無効化のため水色が埋もれる→暗い影でコントラスト確保 */
  .hero-eyebrow { margin-bottom: 6px; text-shadow: 0 1px 8px rgba(8,35,31,.95), 0 0 4px rgba(8,35,31,.85); }
  .hero-title { font-size: 1.7rem; }
  .hero-lead { margin-top: 8px; font-size: .88rem; text-wrap: balance; }

  /* カードビジュアル: エンブレム（上の余白に独立配置）→ カード列（横一列スプレッド） */
  .hero-cards {
    order: 1; width: 100%; min-height: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 2px; padding-top: 6px;
  }
  /* ロゴエンブレム: カードに被せず列の上へ */
  .hero-logo-emblem {
    position: static; order: 1; transform: none; left: auto; top: auto;
    width: 130px; margin: 0 auto; display: block;
  }
  /* スマホは扇をやめ、上段4・下段3の整列グリッドに（PC扇との見え方差を解消） */
  .card-fan {
    order: 2; position: relative; width: 300px; height: auto;
    display: flex; flex-wrap: wrap; justify-content: center; align-content: center;
    gap: 8px; margin: 4px auto 0;
  }
  .fan-card {
    position: static; width: 66px; margin: 0; bottom: auto; left: auto;
    transform-origin: center; border-radius: 6px;
    box-shadow: 0 6px 14px rgba(0,0,0,.45);
  }
  /* PC扇の nth-child 回転を打ち消す（高い詳細度で確実に上書き） */
  .card-fan .fan-card:nth-child(n) { transform: none; }
  /* 下段3枚は中央寄せ（flexのjustify-content:centerで自動的に揃う） */

  /* 54体バッジ: エンブレム右側の余白に。文字が収まるよう拡大（重なり・見切れ解消） */
  .hero-badge { top: 0; right: -2px; left: auto; bottom: auto; width: 102px; height: 102px; }
  .hb-num { font-size: 2rem; }
  .hb-num small { font-size: .9rem; }
  .hb-label, .hb-sub { font-size: .55rem; }
  .hb-sub { margin-top: 1px; }

  .cf-visual { min-height: 300px; }
  .cf-visual > img:first-child { max-height: 380px; }
  .cf-pkg3d { --bw: 204px; --bh: 286px; --bd: 56px; }

  .hero-points { grid-template-columns: 1fr; gap: 12px; margin-top: 18px; }
  .hero-points li { flex-direction: row; text-align: left; padding: 14px 18px; }

  .usage-grid { grid-template-columns: 1fr; }
  .worlds-grid, .videos-grid { grid-template-columns: 1fr; }

  .cf-status-inner { flex-direction: column; align-items: flex-start; }
  .cf-status-btn { width: 100%; }
  .vdp-banner { flex-direction: column; align-items: flex-start; text-align: left; }
  .vdp-banner-btn { margin-left: 0; width: 100%; }

  /* アバターグリッド: 13列 → 6列。suit-start(各スート先頭)が列1へ折り返り、スート毎に改行される */
  .avatar-grid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .avatar-grid .joker-spacer { display: none; }
  /* JOKER専用行も6列にし、2枚を幅に対して左右対称（2列目・5列目）に配置 */
  .avatar-joker-row { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .avatar-joker-row .joker-1 { grid-column: 2; }
  .avatar-joker-row .joker-2 { grid-column: 5; }

  .lightbox-inner { flex-direction: column; gap: 16px; }
  .lightbox-meta { flex: 0 0 auto; text-align: center; align-items: center; }
  .lb-shot { align-self: center; }
  .lightbox-card img { width: 300px; max-width: 86vw; max-height: 62vh; }
}

/* 小型スマホ (≤400px) */
@media (max-width: 400px) {
  .avatar-grid { grid-template-columns: repeat(5, 1fr); }
  /* 5列時：各スート末尾のJQK(3枚)を1枚分右へ送り、2・3・4列目で中央寄せ（左に1枚分の空き） */
  .avatar-grid .jqk-start { grid-column: 2; }
  /* 5列時：JOKERは中央(3列目)を挟んで2・4列目で左右対称 */
  .avatar-joker-row { grid-template-columns: repeat(5, 1fr); }
  .avatar-joker-row .joker-1 { grid-column: 2; }
  .avatar-joker-row .joker-2 { grid-column: 4; }
  .hero-title { font-size: 1.55rem; }
}
