/* ===========================================================================
   Cotoa 読込スライド  v2  ―  デザイン部 / 2026-08-24
   実装の根拠は SPEC.md。数値はすべてそちらに対応している。

   v2 の核:
     器（カード・ヘッダー・ステージ・フッター）の高さを先に確定させ、
     中身をその中に収める。v1 は逆で、内容量に器が振り回されて
     画像の縦位置が最大 125px ずれ、低い視口で 148px 溢れていた。
   =========================================================================== */

.cs-root {
  --navy:    #1A1A2E;
  --navy-2:  #0B1A38;
  --blue:    #1B4FD8;
  --blue-lt: #2E6BE6;
  --gold:    #C9A96E;   /* 装飾専用（グラデーション・暗色地のフォーカスリング） */
  --gold-ink:#856619;   /* クリーム地の文字・白文字の下地。対クリーム 5.06:1 / 白文字 5.37:1 */
  --gold-lt: #FFE6AE;
  --cream:   #FAF8F5;
  --muted:   #6B7280;

  --m:   clamp(12px, 3vw, 28px);            /* カード外周の余白 */
  --r:   clamp(14px, 2.2vw, 22px);          /* 角丸 */
  --pad: clamp(16px, 3.2vw, 30px);          /* 本文の内側余白 */
  --head-h: clamp(46px, 7vh, 58px);
  --foot-h: clamp(50px, 8vh, 62px);
  /* 本文枠は「いちばん中身の多いスライド（1枚目・実測370px）」に合わせて固定する。
     余った縦は画像に回す。こうすると
       ・本文の上端Yが全スライドで一致する（ズレ 0px）
       ・短いスライドの下の余白が減り、画像が大きくなって釣り合う  */
  --body-h: auto;

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: var(--m);
  background: rgba(11, 26, 56, .62);
  backdrop-filter: blur(6px);
  font-family: 'Noto Sans JP', 'BIZ UDPGothic', system-ui, -apple-system,
               'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  color: var(--navy);
  animation: cs-fade .28s ease both;
}
.cs-root[hidden] { display: none; }
.cs-root:focus { outline: none; }        /* 焦点の受け皿。枠は出さない */
@keyframes cs-fade { from { opacity: 0 } to { opacity: 1 } }

/* ══════════════════════════════════════════════ 器 ― 高さを必ず確定させる */
.cs-card {
  position: relative;
  /* 全画面ではなくポップアップ。読み込み中の案内であって、画面を占有しない。 */
  width: min(100% - var(--m), 440px);
  max-height: min(100dvh - var(--m) * 2, 660px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cream);
  border-radius: var(--r);
  box-shadow: 0 24px 70px rgba(11, 26, 56, .38);
}

/* ── ヘッダー（全スライド共通・高さ固定） */
.cs-head {
  /* ポップアップ幅(440px)ではスキップの逃げとキャンペーン帯で場所が足りず、
     キャッチが「こ…」まで潰れていた。高さを固定せず折り返しを許す。 */
  flex: 0 0 auto;
  min-height: var(--head-h);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 4px 10px;
  padding: 8px var(--pad);
  padding-right: clamp(62px, 11vw, 84px);      /* スキップボタンの逃げ */
  background: linear-gradient(135deg, var(--navy-2), #1E3A6E);
  color: #fff;
  overflow: hidden;
}
.cs-catch {
  margin: 0; font-weight: 700; letter-spacing: .04em;
  font-size: clamp(13px, 2vw, 16px);
  line-height: 1.4;
}
.cs-beta {
  flex: 0 0 auto;
  padding: 4px clamp(9px, 1.6vw, 13px);
  font-size: clamp(10px, 1.5vw, 12px); font-weight: 700; white-space: nowrap;
  color: #2B1E00;
  background: linear-gradient(135deg, var(--gold-lt), var(--gold));
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(201, 169, 110, .45);
}

/* ── スキップ */
.cs-skip {
  position: absolute; z-index: 3;
  /* 角丸に食い込まないよう、リング(2px+2px)ぶん内側に置く */
  top: calc((var(--head-h) - 44px) / 2);
  right: clamp(14px, 2vw, 20px);
  min-height: 44px; min-width: 44px;          /* タップ領域は 44px 以上 */
  padding: 0 clamp(13px, 2.2vw, 18px);
  font: inherit; font-size: clamp(12px, 1.6vw, 13.5px); font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 1.5px solid rgba(255, 255, 255, .55);
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.cs-skip:hover  { background: rgba(255, 255, 255, .3); }
.cs-skip:active { transform: scale(.96); }
.cs-skip:focus-visible { outline: 2px solid var(--gold-lt); outline-offset: 2px; }

/* ── ステージ（残り全部。全スライドを同じセルに重ねる） */
.cs-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ══════════════════════════════════════════════ スライド ― 縦位置を固定 */
.cs-slide {
  grid-area: 1 / 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto;   /* 画像=固定比率 / 本文=内容ぶん */
  align-content: start;
  opacity: 0; visibility: hidden;
  transition: opacity .34s ease;
}
.cs-slide.is-on { opacity: 1; visibility: visible; }

/* 画像。上端Yは常にステージ上端＝全スライドで一致する */
.cs-figure {
  min-height: 0; margin: 0; overflow: hidden;
  aspect-ratio: 16 / 10;          /* ポップアップ内で画像の高さを一定に保つ */
  background: #EEF4FF;
}
.cs-figure img {
  width: 100%; height: 100%; display: block;
  object-fit: cover;
  object-position: center 42%;            /* 顔がやや上寄りなので上を残す */
}

/* 本文。溢れるのはここだけ。器は動かさない */
.cs-body {
  min-height: 0;
  padding: var(--pad);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ══════════════════════════════════════════════ どのソフトの話か */
.cs-apps {
  display: flex; align-items: center; gap: 9px;
  min-height: 30px;                       /* 折り返しても見出しの位置を動かさない */
  margin-bottom: clamp(8px, 1.4vw, 12px);
}
.cs-apps-i { display: flex; flex: 0 0 auto; }
.cs-apps-i img {
  width: 26px; height: 26px; display: block;
  box-shadow: 0 1px 4px rgba(26, 26, 46, .20);   /* 角丸は原本に焼き込み済み。重ねない */
}
.cs-apps-i img + img { margin-left: -6px; }
.cs-apps-t { display: flex; flex-direction: column; min-width: 0; }
.cs-apps-t b { font-size: clamp(11px, 1.8vw, 13px); line-height: 1.35; }
.cs-apps-t small { font-size: clamp(9.5px, 1.5vw, 11px); color: var(--blue); font-weight: 700; }

/* ══════════════════════════════════════════════ 文字 */
.cs-title {
  margin: 0;
  font-size: clamp(18px, 3.2vw, 27px);
  font-weight: 700; line-height: 1.4; letter-spacing: .02em;
}
.cs-title .g { color: var(--gold-ink); }  /* 旧 --gold はクリーム地で 2.11:1（不適合） */

.cs-lead {
  margin: .55em 0 0;
  font-size: clamp(12px, 1.95vw, 14.5px);
  line-height: 1.78; color: var(--muted);
}

.cs-note {
  margin: clamp(8px, 1.4vw, 12px) 0 0;
  padding-left: 1em; text-indent: -1em;
  font-size: clamp(10.5px, 1.6vw, 12px);
  line-height: 1.65; color: var(--muted);
}

/* ══════════════════════════════════════════════ 手順（スライド4） */
.cs-steps { display: grid; gap: clamp(8px, 1.4vw, 12px); margin: clamp(10px, 1.8vw, 16px) 0 0; }
@media (min-width: 560px) { .cs-steps { grid-template-columns: 1fr 1fr; } }

.cs-step {
  position: relative;
  display: flex; align-items: center; gap: clamp(9px, 1.6vw, 13px);
  padding: clamp(10px, 1.8vw, 15px);
  padding-right: clamp(24px, 3.4vw, 32px);
  background: #fff;
  border-radius: calc(var(--r) * .65);
  box-shadow: 0 3px 12px rgba(26, 26, 46, .07);
}
.cs-step svg { flex: 0 0 auto; width: clamp(34px, 5.6vw, 44px); height: auto; }
.cs-step-n {
  position: absolute; top: 7px; right: 10px;
  font-size: clamp(12px, 1.9vw, 14px); font-weight: 700; color: var(--gold-ink);
}
.cs-step-t { font-size: clamp(12.5px, 2vw, 15px); font-weight: 700; line-height: 1.45; }
.cs-step-s { margin-top: 2px; font-size: clamp(10.5px, 1.6vw, 12px); color: var(--muted); }

.cs-tag {
  display: inline-block; margin-left: 6px; padding: 2px 8px;
  font-size: clamp(9.5px, 1.4vw, 11px); font-weight: 700;
  color: #fff; background: var(--gold-ink); border-radius: 999px; vertical-align: 2px;
}
.cs-only {
  margin: clamp(10px, 1.8vw, 15px) 0 0; text-align: center;
  font-size: clamp(17px, 3vw, 24px); font-weight: 700; color: var(--blue);
}

/* ══════════════════════════════════════════════ 別タブリンク（スライド1） */
/* ══════════════════════════════════════════════ 全アプリ一覧（スライド1） */
.cs-applist { display: grid; gap: clamp(7px, 1.2vw, 10px); margin-top: clamp(9px, 1.5vw, 13px); }
@media (min-width: 620px) { .cs-applist { grid-template-columns: 3fr 2fr; } }

.cs-applist-g {
  padding: clamp(8px, 1.4vw, 12px) clamp(10px, 1.8vw, 14px);
  background: #fff; border-radius: calc(var(--r) * .55);
  box-shadow: 0 2px 10px rgba(26, 26, 46, .06);
}
.cs-applist-h {
  font-size: clamp(9px, 1.4vw, 10.5px); font-weight: 700; letter-spacing: .03em;
  color: var(--blue); margin-bottom: 7px; line-height: 1.4;
}
.cs-applist-r { display: flex; gap: clamp(8px, 1.5vw, 13px); }
.cs-applist-i { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.cs-applist-i img { width: 32px; height: 32px; display: block; box-shadow: 0 1px 5px rgba(26, 26, 46, .16); }
.cs-applist-i em {
  font-style: normal; font-size: clamp(8.5px, 1.3vw, 10px);
  color: var(--muted); white-space: nowrap;
}

/* ══════════════════════════════════════════════ フッター（高さ固定） */
.cs-foot {
  flex: 0 0 var(--foot-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--pad);
  background: #fff;
  border-top: 1px solid rgba(26, 26, 46, .09);
}
.cs-dots { display: flex; gap: 0; }
.cs-dot {
  position: relative; overflow: hidden;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer;
}
.cs-dot:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.cs-dot::before {
  content: ""; position: absolute;
  left: 8px; top: calc(50% - 2.5px); width: 28px; height: 5px;
  border-radius: 3px; background: rgba(26, 26, 46, .16);
}
.cs-dot.is-done::before { background: rgba(27, 79, 216, .34); }
.cs-dot .bar {
  position: absolute; z-index: 1;
  left: 8px; top: calc(50% - 2.5px); width: 0; height: 5px;
  border-radius: 3px; background: var(--blue);
}
.cs-dot.is-on .bar { animation: cs-fill var(--cs-dur, 5.5s) linear forwards; }
@keyframes cs-fill { to { width: 28px; } }

.cs-status {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: clamp(10.5px, 1.5vw, 12px); color: var(--muted);
}
.cs-spin {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(27, 79, 216, .22); border-top-color: var(--blue);
  animation: cs-rot .8s linear infinite;
}
@keyframes cs-rot { to { transform: rotate(360deg) } }

/* ══════════════════════════════════════════════ 小さい画面 */
@media (max-width: 559px) {
  .cs-applist-g { display: flex; align-items: center; gap: 10px; }
  .cs-applist-h { margin: 0; flex: 0 0 auto; max-width: 44%; }
  .cs-applist-r { flex: 1 1 auto; justify-content: flex-end; }
  .cs-applist-i img { width: 28px; height: 28px; }
  .cs-status span:last-child { display: none; }
}

/* 背が低い視口 ― 器を詰め、画像を薄くして必ず収める */
@media (max-height: 640px) {
  .cs-root { --body-h: min(370px, 72%); --head-h: 44px; --foot-h: 46px; }
  .cs-title { font-size: clamp(16px, 2.8vw, 22px); }
}
@media (max-height: 520px) {
  .cs-root { --body-h: min(340px, 76%); --pad: clamp(12px, 2.4vw, 20px); }
}

/* ══════════════════════════════════════════════ 配慮 */
@media (prefers-reduced-motion: reduce) {
  .cs-root, .cs-slide { animation: none !important; transition: none !important; }
  .cs-dot .bar { animation: none !important; }
  .cs-dot.is-on .bar { width: 28px; }
  .cs-spin { animation: none; }
}
