/* ヒーローの操作デモ（トップページ）。
   右クリック → Karuzip で解凍 → 進捗 → 文字化けの修復 までを 1 カットで回す。
   ステージ内部は絶対座標で組んであるが、カーソルエンジン（hero-sequence.js）は
   その座標を毎回 DOM から測り直す。だから下のレスポンシブ規則が列を落としても
   メニューを動かしても、JS 側の定数は 1 つも触らなくていい。
   行の高さとステージの高さは変えない。削るのは横方向だけ。 */

.hero-stage{position:relative}
/* 画面外・非表示タブでは JS の rAF を止める。CSS animation は別に回り続けるので一緒に止める。 */
.hero-demo[data-paused="1"],.hero-demo[data-paused="1"] *,.hero-demo[data-paused="1"] *::before,.hero-demo[data-paused="1"] *::after{animation-play-state:paused!important}
.hero-demo{position:relative;height:470px;overflow:hidden;border:1px solid var(--line);border-radius:14px;background:#fff;box-shadow:0 1px 2px rgba(29,38,50,.04),0 24px 60px -24px rgba(29,38,50,.22)}

/* エクスプローラ風クローム。44 + 34 + 30 = 108px でリストが始まる。 */
.demo-titlebar{display:flex;align-items:center;gap:10px;height:44px;padding:0 15px;border-bottom:1px solid var(--line);background:#fcfdfe}
.demo-dots{display:flex;gap:6px}
.demo-dots i{width:8px;height:8px;border-radius:50%;background:var(--line-strong)}
.demo-titlebar b{font-size:12.5px}
.demo-breadcrumb{display:flex;align-items:center;gap:7px;height:34px;padding:0 15px;border-bottom:1px solid var(--line);font-size:11.5px;color:var(--mute)}
.demo-breadcrumb svg{width:12px;height:12px;flex:none;fill:none;stroke:currentColor;stroke-width:2}
.demo-breadcrumb b{color:var(--ink2)}
.demo-columns{display:grid;grid-template-columns:1fr 104px 78px;gap:10px;align-items:center;height:30px;padding:0 15px;border-bottom:1px solid var(--line);background:#fff;font-size:10.5px;font-weight:700;letter-spacing:.06em;color:var(--mute)}
.demo-columns span:first-child{display:flex;align-items:center;gap:5px}
.demo-columns svg{width:9px;height:9px;fill:none;stroke:var(--blue);stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.demo-views{position:relative;height:362px}
.demo-views::after{content:'';position:absolute;right:5px;top:7px;width:3px;height:132px;border-radius:2px;background:var(--line-strong);opacity:.7}
.demo-view{position:absolute;inset:0;transition:opacity .5s ease,transform .58s cubic-bezier(.22,1,.36,1)}
.demo-view.is-hidden{opacity:0;transform:translateY(8px);pointer-events:none}

.demo-file{position:relative;display:grid;grid-template-columns:1fr 104px 78px;gap:10px;align-items:center;height:34px;padding:0 15px;font-size:13px}
/* --lit はカーソルの実座標から毎フレーム書き込まれる 0〜1。CSS は不透明度を計算するだけなので、
   通り過ぎた行が濃淡のグラデーションで尾を引く。 */
.demo-file::before{content:'';position:absolute;left:7px;right:7px;top:2px;bottom:2px;z-index:0;border-radius:7px;background:rgba(43,111,214,calc(var(--lit,0) * .085));pointer-events:none}
.demo-file>*{position:relative;z-index:1}
.hero-demo[data-sel="1"] .demo-file-target::before{background:#e6f0fc;box-shadow:inset 0 0 0 1px var(--line-tint);transition:background .22s ease,box-shadow .22s ease}
.demo-file-name{display:flex;align-items:center;gap:9px;min-width:0}
.file-icon{width:19px;height:19px;flex:none;display:grid;place-items:center;border:1px solid;border-radius:5px;font-family:var(--font-display);font-size:7.5px;font-weight:700}
.file-icon-zip{background:var(--tint);border-color:var(--line-tint);color:var(--blue)}
.file-icon-archive{background:#f4f6f9;border-color:var(--line);color:var(--mute)}
.file-icon-image{background:#eef7f1;border-color:#cfe6d8;color:var(--green)}
.demo-file-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.demo-file-type,.demo-file-size{font-size:11px;color:var(--mute);font-variant-numeric:tabular-nums}
.demo-hint{position:absolute;left:15px;right:15px;bottom:10px;display:flex;align-items:center;gap:9px;font-size:11px;color:var(--mute)}
.demo-hint-tag{display:inline-flex;align-items:center;flex:none;padding:4px 10px;border:1px solid var(--line-tint);border-radius:999px;background:var(--tint);font-size:10.5px;font-weight:700;color:var(--blue)}
.demo-hint span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* コンテキストメニュー。項目 34px、区切りは上下 margin 5px + 1px。この値がそのまま当たり判定のレンジになる。 */
.demo-menu{position:absolute;left:152px;top:230px;z-index:6;width:210px;padding:6px;border:1px solid var(--line);border-radius:10px;background:#fff;box-shadow:0 1px 0 rgba(255,255,255,.9) inset,0 22px 52px -14px rgba(29,38,50,.36),0 2px 6px rgba(29,38,50,.06);font-size:12.5px;opacity:0;transform:scale(.95) translateY(-5px);transform-origin:0 0;transition:opacity .2s ease,transform .3s cubic-bezier(.22,1,.36,1);pointer-events:none}
.hero-demo[data-menu="1"] .demo-menu{opacity:1;transform:none}
/* ステージが低くて下に開けないときは、クリック位置の上へ反転させる（measure() が付ける）。 */
.demo-menu[data-flip="1"]{transform-origin:0 100%;transform:scale(.95) translateY(5px)}
.demo-menu-item{position:relative;display:flex;align-items:center;gap:9px;height:34px;padding:0 11px;border-radius:6px;color:var(--ink2);background:rgba(29,38,50,calc(var(--lit,0) * .06))}
.demo-menu-item svg{width:13px;height:13px;flex:none;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;opacity:.7}
.demo-menu-chev{margin-left:auto;color:var(--mute)}
.demo-menu-sep{height:1px;margin:5px 8px;background:var(--line)}
.hero-demo[data-kz="1"] .demo-menu-karuzip{background:#e6f0fc;color:var(--blue-d);font-weight:700;transition:background .18s ease,color .18s ease}
.hero-demo[data-kz="1"] .demo-menu-karuzip svg{opacity:1}

/* カーソルは CSS transition を持たない。JS が毎フレーム transform と opacity を書く。 */
.demo-cursor{position:absolute;left:0;top:0;z-index:8;width:18px;opacity:0;will-change:transform;filter:drop-shadow(0 2px 4px rgba(29,38,50,.26))}
.demo-ripple{position:absolute;left:0;top:0;z-index:7;width:14px;height:14px;border:2px solid var(--blue);border-radius:50%;opacity:0;pointer-events:none}
.demo-ripple.is-active{animation:demo-ripple .52s ease-out}
@keyframes demo-ripple{0%{opacity:.8;transform:translate(var(--rx),var(--ry)) scale(.3)}100%{opacity:0;transform:translate(var(--rx),var(--ry)) scale(2.7)}}

/* 進捗ウィンドウ */
.demo-op{position:absolute;left:16px;right:16px;bottom:16px;z-index:5;padding:15px 17px;border:1px solid var(--line);border-radius:12px;background:#fff;box-shadow:0 -2px 6px rgba(29,38,50,.03),0 20px 48px -18px rgba(29,38,50,.3);opacity:0;transform:translateY(22px);transition:opacity .3s ease,transform .5s cubic-bezier(.22,1,.36,1)}
.hero-demo[data-op="run"] .demo-op,.hero-demo[data-op="done"] .demo-op{opacity:1;transform:none}
.demo-op-head{display:flex;align-items:center;gap:10px;margin-bottom:11px}
.demo-op-icon{width:20px;height:20px;flex:none;display:grid;place-items:center;border-radius:6px;background:linear-gradient(135deg,var(--blue-l),var(--blue));color:#fff;font-family:var(--font-display);font-size:10px;font-weight:700}
.demo-op-head b{font-size:12.5px}
.demo-op-state{position:relative;min-width:74px;height:15px;margin-left:auto;font-size:11px;font-weight:700;letter-spacing:.06em;color:var(--blue)}
.demo-op-state span{position:absolute;right:0;top:0;white-space:nowrap;opacity:0;transition:opacity .3s ease}
.demo-op-state .state-done{color:var(--green)}
.hero-demo[data-op="run"] .demo-op-state .state-live{opacity:1}
.hero-demo[data-op="done"] .demo-op-state .state-done{opacity:1}
/* 完了後はヘッダーと進捗バーの間を空けないよう、高さごと畳む。 */
.demo-op-now{height:0;margin-bottom:0;overflow:hidden;font-family:var(--font-mono);font-size:11px;line-height:15px;color:var(--mute);white-space:nowrap;text-overflow:ellipsis;opacity:0;transition:height .34s cubic-bezier(.22,1,.36,1),margin-bottom .34s cubic-bezier(.22,1,.36,1),opacity .24s ease}
.hero-demo[data-op="run"] .demo-op-now{height:15px;margin-bottom:7px;opacity:1}
.progress-track{position:relative;height:7px;overflow:hidden;margin-bottom:9px;border-radius:999px;background:#eaeff5}
.progress-fill{position:relative;display:block;width:3%;height:100%;overflow:hidden;border-radius:999px;background:linear-gradient(90deg,var(--blue-l),var(--blue))}
.progress-fill::after{content:'';position:absolute;inset:0;background:linear-gradient(100deg,transparent 22%,rgba(255,255,255,.6) 50%,transparent 78%);transform:translateX(-105%)}
.hero-demo[data-op="run"] .progress-fill::after{animation:demo-sheen 1.2s ease-in-out 2}
@keyframes demo-sheen{to{transform:translateX(105%)}}
.demo-op-meta{display:flex;justify-content:space-between;font-size:11.5px;color:var(--ink2);font-variant-numeric:tabular-nums}
.demo-op-meta b{font-family:var(--font-display);font-weight:700;color:var(--blue)}
.demo-op-slot{position:relative;height:0;overflow:hidden;opacity:0;transition:height .36s cubic-bezier(.22,1,.36,1),opacity .3s ease,margin-top .36s cubic-bezier(.22,1,.36,1)}
.hero-demo[data-slot="scan"] .demo-op-slot,.hero-demo[data-slot="done"] .demo-op-slot{height:19px;margin-top:10px;opacity:1}
.demo-op-slot>span{position:absolute;left:0;right:0;top:0;display:flex;align-items:center;gap:8px;font-size:11.5px;font-weight:700;opacity:0;transition:opacity .32s ease}
.demo-op-slot svg{width:11px;height:11px;flex:none;fill:none;stroke:currentColor;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
.demo-op-slot small{margin-left:auto;font-weight:600;color:var(--mute)}
.demo-op-scan{color:var(--amber)}
.demo-op-done{color:var(--blue)}
.hero-demo[data-slot="scan"] .demo-op-scan{opacity:1}
.hero-demo[data-slot="done"] .demo-op-done{opacity:1}
.demo-op-scan svg{animation:demo-spin 1.1s linear infinite}
@keyframes demo-spin{to{transform:rotate(360deg)}}

/* 文字化けの修復。判定中は枠が明滅し、確定すると走査線が左から右へ抜けながら正しい名前を開帳する。
   化け文字は実際に CP932 を UTF-8 で誤読した文字列（夏祭り → 螟乗律繧翫）。 */
.demo-name-box{display:inline-block;padding:3px 9px;border:1.5px solid var(--name-bad-line);border-radius:7px;background:var(--name-bad-bg);transition:background .45s ease,border-color .45s ease}
.hero-demo[data-slot="scan"] .demo-name-box{animation:demo-name-pulse 1.3s ease-in-out infinite}
.hero-demo[data-fix="1"] .demo-name-box{background:transparent;border-color:transparent;animation:none}
@keyframes demo-name-pulse{0%,100%{background:var(--name-bad-bg);border-color:var(--name-bad-line)}50%{background:#fff3df;border-color:#dcbe8c}}
.demo-name-swap{position:relative;display:inline-block;font-family:var(--font-mono);font-size:14px;line-height:1.35;letter-spacing:.02em;white-space:nowrap}
.name-bad{font-weight:700;color:var(--name-bad-fg);transition:opacity .3s ease}
.name-good{position:absolute;left:0;top:0;font-weight:700;color:var(--ink);white-space:nowrap;clip-path:inset(0 100% 0 0)}
.demo-scanline{position:absolute;left:0;top:-5px;bottom:-5px;width:2px;background:var(--blue);box-shadow:0 0 11px 2px rgba(43,111,214,.55);opacity:0}
.hero-demo[data-fix="1"] .name-bad{opacity:0}
.hero-demo[data-fix="1"] .name-good{animation:demo-name-reveal .9s cubic-bezier(.45,0,.2,1) forwards}
.hero-demo[data-fix="1"] .demo-scanline{animation:demo-scan .9s cubic-bezier(.45,0,.2,1)}
/* 2 行目は 1 行目から遅らせて、走査が 2 度通ったように読ませる。 */
.demo-view-result .demo-file:nth-child(2) .name-good,.demo-view-result .demo-file:nth-child(2) .demo-scanline{animation-delay:.18s}
@keyframes demo-name-reveal{to{clip-path:inset(0 0 0 0)}}
@keyframes demo-scan{0%{opacity:0;left:0}14%{opacity:1}86%{opacity:1;left:100%}100%{opacity:0;left:100%}}
.demo-view-result .demo-file{opacity:0;transform:translateY(9px);transition:opacity .44s ease,transform .5s cubic-bezier(.22,1,.36,1)}
.demo-view-result .demo-file:nth-child(2){transition-delay:.05s}
.demo-view-result .demo-file:nth-child(3){transition-delay:.1s}
.demo-view-result .demo-file:nth-child(4){transition-delay:.15s}
.demo-view-result .demo-file:nth-child(5){transition-delay:.2s}
.demo-view-result .demo-file:nth-child(6){transition-delay:.25s}
.hero-demo[data-view="out"] .demo-view-result .demo-file{opacity:1;transform:none}

/* ヒーローの 3 ステップ。デモの進行に合わせて .is-active / .is-done が移る。 */
.hero-steps{display:grid;max-width:440px;margin-top:34px}
.hero-step{display:grid;grid-template-columns:26px 1fr;column-gap:13px;align-items:start;padding:14px 0;border-top:1px solid var(--line)}
.hero-step:last-child{border-bottom:1px solid var(--line)}
.hero-step-num{width:26px;height:26px;display:grid;place-items:center;border:1px solid var(--line-strong);border-radius:50%;background:#fff;font-family:var(--font-display);font-size:11.5px;font-weight:700;color:var(--mute);transition:background .4s ease,border-color .4s ease,color .4s ease}
.hero-step.is-active .hero-step-num{background:var(--blue);border-color:var(--blue);color:#fff}
.hero-step.is-done .hero-step-num{background:var(--tint);border-color:var(--line-tint);color:var(--blue)}
.hero-step-text b{display:block;font-size:13px;font-weight:700;color:var(--mute);transition:color .4s ease}
.hero-step-text>span{display:block;margin-top:4px;font-size:12px;line-height:1.7;color:var(--mute);opacity:.75;transition:color .4s ease,opacity .4s ease}
.hero-step.is-active .hero-step-text b{color:var(--ink)}
.hero-step.is-active .hero-step-text>span{color:var(--ink2);opacity:1}
/* width ではなく transform で伸ばす。width を 2.8 秒 linear で変えると、その間ずっと layout が走る。 */
.hero-step-tick{grid-column:2;width:100%;height:2px;margin-top:10px;border-radius:2px;background:var(--blue);transform:scaleX(0);transform-origin:left center;transition:transform .5s ease}
.hero-step.is-active .hero-step-tick{transform:scaleX(1);transition:transform 2.8s linear}
.hero-step.is-done .hero-step-tick{transform:scaleX(1);background:var(--line-tint)}

/* --- 字幕ストリップ（モバイル専用）----------------------------------
   スマホでは 3 ステップのリストもフレーム内の進捗ウィンドウも消える。その役割は
   フレーム上端に接した 1 行に集約する：現在のステップ名と、進捗バーを兼ねる
   3 分割の罫線。フレーム側は操作を演じるだけでよくなる。 */
.demo-caption{display:none}
.demo-caption-row{display:flex;align-items:baseline;gap:10px}
.demo-caption-text{font-size:13px;font-weight:700;color:var(--ink);line-height:1.5}
.demo-caption-count{margin-left:auto;flex:none;font-family:var(--font-display);font-size:10.5px;font-weight:700;color:var(--mute);font-variant-numeric:tabular-nums}
.demo-caption-bar{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;margin-top:9px}
.demo-caption-bar span{display:block;height:2px;border-radius:2px;background:var(--line);overflow:hidden}
.demo-caption-bar i{display:block;height:100%;border-radius:2px;background:var(--blue);transform:scaleX(0);transform-origin:left center}

/* --- 狭い画面 ---------------------------------------------------------
   ステージの高さと行の高さは動かさない（動かすとエンジンが導く当たり判定の前提が変わる）。
   削るのは横方向だけで、メニューの新しい左端は resize のたびに測り直される。 */
@media(max-width:880px){
  /* 1 カラムに落ちたら、ステージが上のコピーに詰まらないよう間を空ける。 */
  .hero-stage{width:100%;max-width:570px;margin-top:14px;justify-self:center}
  .hero-steps{max-width:none}
}
@media(max-width:720px){
  .hero-stage{display:flex;flex-direction:column;max-width:none;margin-top:16px}
  .hero-steps{display:none}
  .demo-op{display:none}
  .demo-caption{display:block;flex:none;padding:11px 14px 12px;border:1px solid var(--line);border-bottom:0;border-radius:12px 12px 0 0;background:#fff}
  /* 5 行＋ヒントの余白だけ：108 + 204 = 312px。これで字幕とフレーム全体が
     844px のビューポートに、上のコピーごと収まる。 */
  .hero-demo{height:312px;border-radius:0 0 12px 12px}
  .demo-views{height:204px}
  .demo-view .demo-file:nth-child(n+6){display:none}
  /* 修復は「起きているところ」を見せる必要がある。判定中は琥珀で明滅し、走査線が
     左から右へ抜けながら正しい名前を開帳する。装飾でありながら説明でもある唯一の
     演出なので、モバイルでも残す。 */
  .hero-demo[data-fix="1"] .demo-name-box{background:var(--tint);border-color:var(--line-tint)}
}
@media(max-width:520px){
  .hero-stage{margin-left:-8px;margin-right:-8px}
  .hero-demo{border-radius:12px}
  .demo-caption{border-radius:12px 12px 0 0}
  .demo-columns,.demo-file{grid-template-columns:1fr 78px}
  .demo-columns span:nth-child(2),.demo-file-type{display:none}
  .demo-menu{left:104px;width:196px}
  .demo-name-swap{font-size:12px}
  .demo-hint span{display:none}
  .demo-op{left:12px;right:12px;bottom:12px;padding:13px 14px}
}
/* prefers-reduced-motion の分岐はデモには置かない。ここだけは全環境で同じシーケンスを回す
   （理由は hero-sequence.js の冒頭）。片側だけ transition/animation を切ると、
   カーソルは rAF で動いたまま状態遷移だけが瞬間で飛び、壊れて見える。 */
