/* ==========================================================
   入場の演出
   ・ページを開いたときに一度だけ、ロゴと題名を見せてから画面を開く（3秒弱）
   ・ふつうに出る（2026-11-22 平田さん決定）。画面の下の「入場の演出」を「なし」にすると、そのブラウザでは出ない
   ・どのブラウザでも動く作り（HTML-in-Canvas は使っていない）。動きを減らす設定の端末では出さない
   ・やめるとき: このファイルと intro.js を消し、index.html の「入場の演出」と書いた所を消す
   考え方: 色は画面と同じ（淡い青・濃紺・青）。暗い板で覆わない。斜めの合わせ目から左右に開く。
   順番: ロゴと題名が出る → 青い線が上から下りてくる → 線が文字に触れる手前で文字が消える → 線が下まで通り抜ける → 開く
         （線が題名の上を横切ると、文字に取り消し線を引いたように見えるので、触れる前に文字を消す。平田さんの指定）
   ========================================================== */

/* 切り替え（どの状態でも出す） */
.intro-switch { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.intro-switch span { font-weight: 700; color: var(--ink-2); margin-right: 4px; }
.intro-switch button {
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--ink-2); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px;
}
.intro-switch button[aria-pressed="true"] { background: var(--slab); color: #fff; border-color: transparent; }
.intro-switch .intro-replay { border-style: dashed; }

/* 幕（ふだんは無い） */
.intro { display: none; }
html.intro-on { overflow: hidden; }
html.intro-on .intro {
  display: block; position: fixed; inset: 0; z-index: 100; overflow: hidden; cursor: pointer;
  --seam-top: 60%; --seam-bottom: 40%; /* 合わせ目（右上から左下への斜めの線）が通る位置 */
  --ease-io: cubic-bezier(0.72, 0, 0.18, 1);
  --ease-out: cubic-bezier(0.16, 0.84, 0.3, 1);
}

/* 幕の左半分と右半分。画面の地と同じ色と斜めの帯 */
.intro-half {
  position: absolute; inset: 0; will-change: transform;
  background:
    linear-gradient(112deg, transparent 0 57%, rgba(42, 120, 214, 0.075) 57% 70%, transparent 70%),
    linear-gradient(112deg, transparent 0 21%, rgba(255, 255, 255, 0.6) 21% 30%, transparent 30%),
    #e9eef5;
}
.intro-half.a { clip-path: polygon(0 0, calc(var(--seam-top) + 1px) 0, calc(var(--seam-bottom) + 1px) 100%, 0 100%); } /* 1px だけ重ねて、合わせ目から下の画面が透けないようにする */
.intro-half.b { clip-path: polygon(var(--seam-top) 0, 100% 0, 100% 100%, var(--seam-bottom) 100%); }
.intro.run .intro-half.a { animation: intro-open-a 0.78s var(--ease-io) 2.0s both; }
.intro.run .intro-half.b { animation: intro-open-b 0.78s var(--ease-io) 2.0s both; }
@keyframes intro-open-a { to { transform: translate3d(-72vw, 0, 0); } }
@keyframes intro-open-b { to { transform: translate3d(72vw, 0, 0); } }

/* 合わせ目の青い線。左右の幕の両方に同じ線を持たせてある（幕の形で半分ずつ切り取られる）ので、
   閉じているあいだは1本に見え、開くと、それぞれの幕のふちに青い縁取りとして付いていく。上から下へ引かれる */
.intro-seam { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; clip-path: inset(0 0 100% 0); }
.intro-seam line { stroke: #2a78d6; stroke-width: 5; vector-effect: non-scaling-stroke; }
/* 線の動きは2段階:
     ① 文字が出ているあいだに上から下りてきて、文字のすぐ手前（--stop の高さ）でゆっくりになる
     ② 文字が消えたら、そのまま下まで一気に通り抜ける
   --stop（線が文字に触れる少し手前の高さ）は、画面の大きさに合わせて intro.js が測って入れる */
.intro.run .intro-seam { animation: intro-seam 0.9s linear 1.15s both; }
@keyframes intro-seam {
  0%   { clip-path: inset(0 0 100% 0); animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1); }
  61%  { clip-path: inset(0 0 calc(100% - var(--stop, 30%)) 0); animation-timing-function: cubic-bezier(0.6, 0, 0.3, 1); }
  100% { clip-path: inset(0 0 0 0); }
}
@keyframes intro-fade { to { opacity: 0; } }

/* まんなか: ロゴ・題名・ひとこと */
.intro-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -52%);
  display: flex; flex-direction: column; align-items: flex-start; width: max-content; max-width: 92vw;
  color: #0f1522; font-family: var(--font, system-ui, sans-serif);
}
.intro.run .intro-center { animation: intro-center-out 0.22s var(--ease-io) 1.48s both; }
@keyframes intro-center-out { to { opacity: 0; transform: translate(-50%, calc(-52% - 12px)); } }

.intro-logo { height: clamp(46px, 6vw, 72px); width: auto; display: block; margin: 0 0 clamp(10px, 1.6vw, 18px) 2px; opacity: 0; }
.intro.run .intro-logo { animation: intro-rise 0.6s var(--ease-out) 0.08s both; }
@keyframes intro-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* 題名は、下から1文字ぶんせり上がる（枠の外は見えない） */
.intro-title-clip { overflow: hidden; padding: 0 0.3em 0.08em 0; margin: 0 -0.3em 0 0; }
.intro-title {
  display: block; margin: 0; white-space: nowrap; font-weight: 800; line-height: 1.16; letter-spacing: 0;
  font-size: clamp(34px, 6.4vw, 88px); transform: translateY(112%) skewX(-7deg); transform-origin: 0 100%;
}
.intro.run .intro-title { animation: intro-title 0.62s var(--ease-out) 0.26s both; }
@keyframes intro-title { to { transform: translateY(0) skewX(-7deg); } }

/* 題名の下の青い帯。左から伸びる */
.intro-bar {
  height: clamp(6px, 0.9vw, 11px); width: 62%; margin-top: clamp(4px, 0.6vw, 8px); background: #2a78d6;
  transform: skewX(-30deg) scaleX(0); transform-origin: 0 50%;
}
.intro.run .intro-bar { animation: intro-bar 0.46s var(--ease-io) 0.52s both; }
@keyframes intro-bar { to { transform: skewX(-30deg) scaleX(1); } }

.intro-sub { margin: clamp(12px, 1.8vw, 22px) 0 0 2px; font-size: clamp(13px, 1.5vw, 19px); font-weight: 600; color: #3a4353; letter-spacing: 0.04em; opacity: 0; }
.intro.run .intro-sub { animation: intro-rise 0.46s var(--ease-out) 0.62s both; }

/* 押したら飛ばせる、の小さな案内 */
.intro-skip { position: absolute; right: 22px; bottom: 18px; font-size: 12px; color: #687182; opacity: 0; font-family: var(--font, system-ui, sans-serif); }
.intro.run .intro-skip { animation: intro-rise 0.4s linear 0.6s both, intro-fade 0.2s linear 1.48s forwards; }

/* 飛ばしたとき: すぐ消す */
.intro.skip { animation: intro-fade 0.16s linear both; pointer-events: none; }

/* 動きを減らす設定の端末では、演出そのものを出さない（intro.js でも止めているが念のため） */
@media (prefers-reduced-motion: reduce) { html.intro-on .intro { display: none; } html.intro-on { overflow: auto; } }
@media print { .intro, .intro-switch { display: none !important; } }
