/* ========================================
   土台 — 色と書体、プレイヤーの外枠、動画のキャンバス
   ----------------------------------------
   キャンバス（.stage）は 1280×720 の「動画の1コマ」として作り、JS が枠の幅に合わせて丸ごと拡大縮小する。
   だからキャンバスの中にはメディアクエリを書かない（要素ごとに縮むと、ある幅で文字だけ縮小が止まって図とずれる）。
   画面の幅で変わるのは、キャンバスの外（字幕・操作ボタン・注記）だけ。
   古い iPhone でも崩れないよう、CSS の入れ子（ネスト）は使わずに書く。
   ※ 構造は認定ずみの作例（chatgpt-or-claude-code）から写した。色と書体だけこの題材に替えている。
   ======================================== */

:root {
  --font-jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --font-en: "Inter", "Helvetica Neue", Arial, sans-serif;
  --page: #eef1ee;
  --paper: #f6f8f5;
  --paper-deep: #e2e9e4;
  --ink: #162b36;
  --ink-soft: #5d7077;
  --line: #d8e3e1;
  /* 二つを見分けるための色（製品のロゴ色ではない） */
  --wp: #2b6cb0;
  --wp-soft: #dbe8f5;
  --st: #c2703a;
  --st-soft: #f7e4d6;
  --key: #0e766d;
  --key-soft: #d9efe9;
  --warn: #b5442f;
  --good: #3f8f5f;
  --lime: #d9f3a5;
  --marker: #d9f3a5;
  --night: #102b38;
  /* この動画の二者（色は上の --wp / --st を意味で言い換えただけ。増やしていない） */
  --hojin: var(--wp);
  --hojin-soft: var(--wp-soft);
  --kojin: var(--st);
  --kojin-soft: var(--st-soft);
  /* 🚨 字幕帯のぶん、場面の下に空ける高さ。字幕の大きさを変えたらここだけ直す */
  --caption-size: 26px;
  --caption-line: 1.7em;            /* 1行ぶんの高さ = 26 x 1.7 = 44.2px */
  --caption-pad-y: 12px;
  --caption-gap: 26px;              /* 帯と画面の下端のすき間 */
  /* 🚨 下から上がってくる動き（rise）の移動量。場面の中身はこのぶん手前で止める。
     入れないと、上がりきる途中で字幕帯に潜る（2026-09-25 に実際にやった） */
  --rise: 28px;
  /* 帯の高さ(1行 + 上下padding) + すき間 + 動きの遊び。44.2 + 24 + 26 + 28 = 122px */
  --caption-space: 122px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
p,
ul,
ol,
figure,
pre {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-jp);
  -webkit-font-smoothing: antialiased;
}

/* 記事に iframe で埋め込まれたとき（JS が付ける）。
   高さは親が中身に合わせて広げるので、スクロールバーは出さない。 */
html.is-embedded {
  overflow: hidden;
}

.player {
  margin: 0 auto;
  padding: 24px;
  max-width: 1080px;
  display: grid;
  gap: 14px;
}

/* 枠。キャンバスと大きな再生ボタンを、同じマスに重ねる */
.frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  aspect-ratio: 16 / 9;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(22, 43, 54, 0.16), 0 0 0 1px rgba(22, 43, 54, 0.1);
  overflow: hidden;
}
.frame > * {
  grid-area: 1 / 1;
}

/* 動画の1コマ。場面・背景・進み具合の帯を、すべて同じマスに重ねる */
.stage {
  width: 1280px;
  height: 720px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-self: start;
  justify-self: start;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-jp);
  transform: scale(var(--scale, 1));
  transform-origin: 0 0;
  overflow: hidden;
}
.stage > * {
  grid-area: 1 / 1;
}

/* 背景：和紙の繊維に見える細かい点と、ゆっくり漂う二つの色の光 */
.backdrop {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background:
    radial-gradient(rgba(22, 43, 54, 0.07) 1.2px, transparent 1.4px) 0 0 / 26px 26px,
    radial-gradient(rgba(22, 43, 54, 0.05) 1px, transparent 1.2px) 13px 13px / 26px 26px;
  overflow: hidden;
}
.backdrop .blob {
  grid-area: 1 / 1;
  width: 640px;
  aspect-ratio: 1;
  border-radius: 50%;
  animation: drift 16s ease-in-out infinite;
}
.backdrop .blob-wp {
  margin: -280px 0 0 -240px;
  justify-self: start;
  align-self: start;
  background: radial-gradient(circle, rgba(43, 108, 176, 0.14), rgba(43, 108, 176, 0) 66%);
}
.backdrop .blob-st {
  margin: 0 -260px -300px 0;
  justify-self: end;
  align-self: end;
  background: radial-gradient(circle, rgba(194, 112, 58, 0.14), rgba(194, 112, 58, 0) 66%);
  animation-direction: reverse;
  animation-duration: 19s;
}

/* JS が --progress に 0〜1 を入れる。
   場面は動きの途中で重なり順の層を作るので、帯とボタンは z-index で必ず上に出す */
.progress {
  height: 6px;
  align-self: end;
  z-index: 1;
  background: rgba(22, 43, 54, 0.1);
}
.progress span {
  height: 100%;
  display: block;
  background: var(--ink);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
}

.big-play {
  padding-left: 8px;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  place-self: center;
  z-index: 1;
  background: var(--ink);
  color: #fff;
  font-size: 36px;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 12px 32px rgba(22, 43, 54, 0.32);
  cursor: pointer;
  transition: transform 0.2s var(--ease-out);
}
.big-play:hover {
  transform: scale(1.06);
}
.big-play[hidden] {
  display: none;
}

/* 字幕。🚨 キャンバス（.stage）の中に置く。
   2026-09-25 まで枠の外（プレイヤーの下）に出していたが、それだと MP4 に書き出したとき
   字幕が入らない。Ryuichi「基本は文字お越しを枠の中に入れてほしい」。

   🚨🚨 字幕は「1行」。2行になった時点でデザインが崩れる（2026-09-25 Ryuichi）。
   ・高さは1行ぶんで固定する（行数で高さが変わると絵にかぶる）
   ・white-space: nowrap で折り返さない。はみ出したら台本が長すぎるので台本を割る
   ・🚨 この帯はキャンバスの中にある。メディアクエリで字の大きさを変えないこと
     （変えると画面幅ごとに折り返しが変わり、MP4 と違う姿になる） */
.caption {
  /* 🚨 幅は文字の量ぶんだけ。全幅の白帯にすると絵を潰して邪魔になる（2026-09-25 Ryuichi） */
  justify-self: center;
  width: max-content;
  max-width: calc(100% - 80px);
  margin: 0 0 var(--caption-gap);
  padding: var(--caption-pad-y) 28px;
  height: calc(var(--caption-line) + var(--caption-pad-y) * 2);
  align-self: end;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: var(--caption-size);
  font-weight: 700;
  line-height: var(--caption-line);
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(22, 43, 54, 0.1), inset 0 0 0 1px var(--line);
}

/* 🚨 場面の中身が字幕帯にかぶらないよう、下に場所を空けておく。
   場面側で padding のショートハンドを書くときは、下を var(--caption-space) にする
   （0 にすると字幕と重なって読めなくなる） */
.scene {
  padding-bottom: var(--caption-space);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.control {
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2em;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.control:hover {
  border-color: var(--ink-soft);
}
.control.is-primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.control[hidden] {
  display: none;
}
.control[aria-pressed="false"] {
  color: var(--ink-soft);
  text-decoration: line-through;
}
.seek {
  min-width: 0;
  flex: 1 1 160px;
  accent-color: var(--ink);
}
.time {
  color: var(--ink-soft);
  font-family: var(--font-en);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.note {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7em;
}

@media (max-width: 600px) {
  .player {
    padding: 16px;
    gap: 10px;
  }
  .frame {
    border-radius: 10px;
  }
  .big-play {
    padding-left: 6px;
    width: 64px;
    height: 64px;
    font-size: 24px;
  }
}

@media (max-width: 500px) {
  .control {
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (max-width: 400px) {
  .player {
    padding: 8px;
  }
}
