/*
 * ブロックプログラミングエディタ 受講画面 — 画面のデザイン
 * Copyright (C) 2026 スタープログラミングスクール — AGPL-3.0-only (see LICENSE.txt)
 * 右側（映像・場面・テキスト）は、わくわくデジタルペイントの受講画面と同じ作り。エディタ本体の見た目は js/ の中にある。
 */
:root {
  --scratch-blue: #4c97ff;
  --scratch-blue-dark: #3373cc;
  --scratch-pane: #e9f1fc;
  --scratch-line: #d5e0f0;
  --ink: #575e75;
  --ink-strong: #2f3447;
  --paper: #ffffff;
  --learn-bg: #f4f6f9;
  --course-orange: #ff8a1f;
  --course-orange-soft: #fff0e2;
  --course-teal: #3fbf9f;
  --diff: #e0a800;
  --diff-soft: #fff8e1;
  --diff-ink: #6a5000;
  --video-bg: #1e2333;
  --video-ink: #c9d0e3;
  --warn: #c2410c;
  --font-ui: "Helvetica Neue", Helvetica, Arial, "BIZ UDPGothic", sans-serif;
  --font-body: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --font-display: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", sans-serif;
  color-scheme: light;
}
html, body { height: 100%; margin: 0; }
body { background: var(--scratch-pane); color: var(--ink); font-family: var(--font-ui); overflow: hidden; }
#blk-root { height: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--scratch-blue-dark); outline-offset: 2px; }
.wdp-learn *, .blk-modal *, .blk-view-page * { box-sizing: border-box; }

/* ---------- エディタつき：GUI の中の右 1/3 ---------- */
.blk-right { flex: 0 0 calc(100vw / 3); width: calc(100vw / 3); min-width: 330px; min-height: 0; display: flex; position: relative; }
.blk-right > .wdp-learn { flex: 1; }
/* GUI のメニューバー（右側に足した所） */
.blk-brand { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: .02em; white-space: nowrap; }
button.blk-save-now { border: 0; background: none; color: #fff; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
button.blk-mystuff { border: 0; background: none; cursor: pointer; }
a.blk-bar-link { color: #fff; font-size: .75rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.blk-loading { height: 100%; display: grid; place-items: center; font: 700 15px var(--font-body); color: var(--ink); }

/* ---------- 映像とテキストだけ（タブレットなど） ---------- */
.blk-view-page { height: 100%; display: grid; grid-template-rows: 48px minmax(0, 1fr); }
.blk-view-bar { display: flex; align-items: center; gap: 6px; background: var(--scratch-blue); color: #fff; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.blk-view-bar .blk-brand { padding-right: 12px; border-right: 1px solid rgba(255,255,255,.3); }
.blk-bar-note { font-size: 13px; font-weight: 700; opacity: .9; padding-left: 4px; }
.blk-bar-spacer { flex: 1; }
.blk-view-bar .blk-bar-link { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: #fff; font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.blk-view-bar .blk-bar-link:hover { background: var(--scratch-blue-dark); }
.wdp-learn.is-view { border-left: 0; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
.wdp-learn-main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.wdp-learn-media { flex: none; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* 横長の画面：左に映像、右にテキスト */
@media (min-aspect-ratio: 5/4) and (min-width: 700px) {
  .wdp-learn.is-view .wdp-learn-main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 14px; }
  .wdp-learn.is-view .wdp-learn-media { min-height: 0; overflow-y: auto; }
  .wdp-learn.is-view .wdp-text { min-height: 0; }
}
/* 縦長の画面（タブレットの縦など）：上に映像、下にテキスト */
@media not all and (min-aspect-ratio: 5/4), (max-width: 699px) {
  .wdp-learn.is-view .wdp-text { min-height: 280px; }
}
@media (max-width: 560px) {
  .blk-bar-note { display: none; }
  .blk-view-bar .blk-brand { font-size: 13px; }
}

/* ---------- 右側（映像・場面・テキスト）。わくわくデジタルペイントと同じ ---------- */
.wdp-learn { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; padding: 8px 12px 10px; background: var(--learn-bg); border-left: 1px solid var(--scratch-line); font-family: var(--font-body); color: var(--ink-strong); }
.wdp-lesson-head { display: flex; align-items: center; gap: 8px; flex: none; }
.wdp-lesson-title { margin: 0; flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; font: 800 16px/1.45 var(--font-display); color: var(--ink-strong); text-wrap: balance; }
.wdp-lesson-no { flex: none; background: var(--course-orange); color: #fff; font-size: 12px; padding: 1px 9px; border-radius: 999px; }

.wdp-menu-anchor { position: relative; flex: none; }
.wdp-round-btn { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--scratch-line); background: var(--paper); color: var(--ink-strong); display: grid; place-items: center; cursor: pointer; }
.wdp-round-btn:hover, .wdp-round-btn.is-on { border-color: var(--scratch-blue); color: var(--scratch-blue-dark); }
.wdp-settings { position: absolute; top: 42px; right: 0; z-index: 45; width: min(360px, calc(33vw - 16px)); min-width: 300px; max-height: calc(100vh - 110px); overflow: auto; background: var(--paper); border: 2px solid var(--scratch-blue); border-radius: 12px; box-shadow: 0 10px 28px rgba(30,35,51,.25); padding: 10px 12px 12px; font-size: 13px; line-height: 1.6; }
.wdp-set-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.wdp-set-row b { min-width: 6.5em; font-size: 13px; }
.wdp-opt { border: 2px solid var(--scratch-blue); background: var(--paper); color: var(--scratch-blue-dark); border-radius: 8px; padding: 3px 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.wdp-opt.is-on { background: var(--scratch-blue); color: #fff; }
.wdp-opt:disabled { opacity: .4; cursor: not-allowed; }
.wdp-opt.is-wide { text-align: left; }
.wdp-teach { margin-top: 10px; border-top: 1px dashed var(--scratch-line); padding-top: 8px; }
.wdp-teach summary { cursor: pointer; font-weight: 700; color: var(--ink-strong); display: flex; align-items: center; gap: 6px; }
.wdp-set-note { margin: 4px 0; font-size: 11px; color: var(--ink); }
.wdp-jump { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
.wdp-jump-btn { display: flex; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--scratch-line); background: var(--paper); border-radius: 6px; padding: 4px 8px; font-size: 12px; color: var(--ink-strong); cursor: pointer; }
.wdp-jump-btn:hover { border-color: var(--course-orange); }
.wdp-jump-btn.is-on { background: var(--course-orange-soft); border-color: var(--course-orange); color: #b85500; font-weight: 700; }
.wdp-jump-t { flex: none; width: 3.2em; font-variant-numeric: tabular-nums; }

.wdp-video { flex: none; display: flex; justify-content: center; }
.wdp-video-screen { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: var(--video-bg); border-radius: 8px; overflow: hidden; color: var(--video-ink); display: flex; flex-direction: column; transition: width .2s; }
.wdp-player-box { position: absolute; inset: 0; isolation: isolate; z-index: 0; }
.wdp-player-box video, .wdp-player-iframe { display: block; width: 100%; height: 100%; border: 0; }
.wdp-video-ph, .wdp-video-bar { position: relative; }
.wdp-video-ph { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; text-align: center; }
.wdp-video-play { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; color: #fff; padding-left: 4px; }
.wdp-video-title { font: 800 15px var(--font-display); color: #fff; text-wrap: balance; }
.wdp-video-note { font-size: 11px; opacity: .7; }
.wdp-video-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; background: rgba(0,0,0,.25); }
.wdp-video-time { font-size: 11px; font-variant-numeric: tabular-nums; color: #fff; }
.wdp-video-time.is-dim { color: var(--video-ink); opacity: .7; }
.wdp-timeline { position: relative; flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); }
.wdp-tick { position: absolute; top: -5px; width: 4px; height: 16px; margin-left: -2px; border: 0; padding: 0; border-radius: 2px; background: rgba(255,255,255,.55); cursor: pointer; z-index: 1; }
.wdp-tick:hover, .wdp-tick.is-on { background: var(--course-orange); }
/* 10びょう もどる / もういちど: over the video, shown on hover or while paused (the player's own bar stays usable) */
.wdp-vctl { position: absolute; top: 6px; right: 6px; z-index: 6; display: flex; gap: 4px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.wdp-video-screen:hover .wdp-vctl, .wdp-video-screen.is-paused .wdp-vctl, .wdp-vctl:focus-within { opacity: 1; pointer-events: auto; }
.wdp-vctl button { display: inline-flex; align-items: center; gap: 4px; border: 1px solid rgba(255,255,255,.6); background: rgba(20,24,36,.6); color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.wdp-vctl button:hover { background: rgba(20,24,36,.85); }

.wdp-scene-nav { flex: none; display: flex; align-items: center; gap: 6px; background: var(--paper); border: 2px solid var(--course-orange); border-radius: 10px; padding: 4px; }
.wdp-scene-nav.is-flash { animation: wdp-flash 1.4s; }
@keyframes wdp-flash { 0% { box-shadow: 0 0 0 0 rgba(255,138,31,.9); } 100% { box-shadow: 0 0 0 12px rgba(255,138,31,0); } }
.wdp-nav-btn { flex: none; display: inline-flex; align-items: center; gap: 2px; border: 0; background: var(--course-orange-soft); color: #b85500; border-radius: 7px; padding: 6px 10px; font-size: 13px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.wdp-nav-btn:hover:not(:disabled) { background: #ffe0c2; }
.wdp-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.wdp-nav-btn.is-hot { background: var(--course-orange); color: #fff; }
.wdp-scene-mid { flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 8px; font-weight: 800; color: var(--ink-strong); }
.wdp-scene-count { flex: none; font-size: 12px; color: #b85500; font-variant-numeric: tabular-nums; }
.wdp-scene-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wdp-peek { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; background: #fff3cd; border: 2px solid var(--course-orange); border-radius: 10px; padding: 4px 6px 4px 10px; font-size: 12px; }
.wdp-peek span { display: inline-flex; align-items: center; gap: 4px; }
.wdp-peek-btn { border: 0; background: var(--course-orange); color: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }

.wdp-text-tools { flex: none; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.wdp-chip { border: 0; border-radius: 999px; background: var(--course-teal); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 12px; cursor: pointer; }
.wdp-chip:hover { filter: brightness(.95); }

.wdp-text { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wdp-linkish { border: 0; background: none; padding: 2px 0; font-size: 11px; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.wdp-linkish:hover { color: var(--scratch-blue-dark); }
.wdp-about { padding: 14px 18px 18px; line-height: 1.75; font-size: 14px; }
.wdp-about p { margin: 0 0 10px; }
.wdp-about-links { margin: 0 0 12px; padding-left: 1.2em; }
.wdp-about-links a { color: var(--scratch-blue-dark); font-weight: 700; }
.wdp-about-note { font-size: 12px; color: var(--ink); }
/* テキスト（text/sNN.php）。テキストの見た目は text/css/textbook.css（.wdp-textbook の中だけに効く） */
.wdp-textbook { container: textbook / inline-size; overflow-x: hidden; background: var(--paper); border-radius: 6px; box-shadow: 0 1px 3px rgba(30,35,51,.15); padding: 0; display: block; }
.wdp-text.is-noruby .wdp-textbook rt { display: none; }
.wdp-textbook img.tb-img, .wdp-page img { cursor: zoom-in; }
.wdp-pages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 12px; }
.wdp-page { margin: 0; background: var(--paper); border-radius: 4px; box-shadow: 0 1px 3px rgba(30,35,51,.15); }
.wdp-page img { display: block; width: 100%; height: auto; border-radius: 4px; }

.wdp-zoom { position: fixed; inset: 0; z-index: 90; background: rgba(20,24,36,.88); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.wdp-zoom img { max-width: 100%; max-height: 100%; background: #fff; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.wdp-zoom-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: #fff; display: grid; place-items: center; cursor: pointer; }

.wdp-lesson-course { font: 700 11px var(--font-body); color: var(--ink); margin-left: auto; white-space: nowrap; }
.wdp-text { overflow-y: auto; overscroll-behavior: contain; background: var(--paper); border: 1px solid var(--scratch-line); border-radius: 10px; }
.wdp-text .wdp-pages { flex: none; overflow: visible; padding: 0; }
.wdp-text-empty { padding: 24px 18px; color: var(--ink); font: 700 14px/1.8 var(--font-body); }
.wdp-textbook img.zoomable { cursor: zoom-in; }

/* ---------- ちがう所（映像は本物の Scratch。エディタでは操作がちがう所） ---------- */
.blk-diff { flex: none; background: var(--diff-soft); border: 2px solid var(--diff); border-radius: 10px; padding: 6px 10px 8px; font: 13px/1.7 var(--font-body); color: var(--ink-strong); }
.blk-diff-head { display: flex; align-items: center; gap: 6px; }
.blk-diff-head em { flex: none; font-style: normal; background: var(--diff); color: #fff; border-radius: 999px; padding: 0 9px; font-size: 11px; font-weight: 700; }
.blk-diff-head b { flex: 1; min-width: 0; color: var(--diff-ink); }
.blk-diff-x { flex: none; width: 26px; height: 26px; border: 0; border-radius: 50%; background: none; color: var(--diff-ink); display: grid; place-items: center; cursor: pointer; }
.blk-diff-x:hover { background: rgba(224,168,0,.18); }
.blk-diff-body p { margin: 2px 0; }
.blk-diff-body b { color: var(--diff-ink); }
.blk-diff-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.blk-diff-btns button { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 800; cursor: pointer; }
.blk-diff-go { border: 0; background: var(--diff); color: #fff; }
.blk-diff-sub { border: 1px solid var(--diff); background: #fff; color: var(--diff-ink); }
.wdp-tl-diff { position: absolute; top: -1px; height: 8px; border-radius: 2px; background: repeating-linear-gradient(45deg, var(--diff) 0 4px, transparent 4px 8px); }

/* ---------- ダイアログ・お知らせ ---------- */
.blk-modal-back { position: fixed; inset: 0; z-index: 1000; background: rgba(76,151,255,.55); display: grid; place-items: center; padding: 16px; }
.blk-modal { width: min(440px, 100%); max-height: 86vh; overflow: auto; background: var(--paper); border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.25); font-family: var(--font-body); color: var(--ink-strong); outline: none; }
.blk-modal.is-wide { width: min(720px, 100%); }
.blk-modal-head { display: flex; align-items: center; justify-content: space-between; background: var(--scratch-blue); color: #fff; padding: 10px 12px 10px 18px; position: sticky; top: 0; z-index: 1; }
.blk-modal-head h2 { margin: 0; font: 800 16px var(--font-display); }
.blk-modal-x { border: 0; background: rgba(255,255,255,.2); color: #fff; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.blk-modal-body { padding: 14px 18px 18px; line-height: 1.75; font-size: 14px; }
.blk-about p { margin: 0 0 10px; }
.blk-about-links { margin: 0 0 12px; padding-left: 1.2em; }
.blk-about-links a { color: var(--scratch-blue-dark); font-weight: 700; }
.blk-about-note { font-size: 12px; color: var(--ink); }
.blk-btn { border: 0; border-radius: 6px; background: var(--scratch-blue); color: #fff; font-weight: 700; font-size: 13px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.blk-btn:hover { background: var(--scratch-blue-dark); }
.blk-btn.is-ghost { background: none; color: var(--ink); border: 1px solid #d3d8e2; }
.blk-btn.is-ghost:hover { background: var(--learn-bg); }
.blk-btn.is-danger { background: var(--warn); }
.blk-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.blk-resume-msg { margin: 0; }
.blk-works-note { margin: 0 0 10px; font-size: 12px; color: var(--ink); }
.blk-works-empty { margin: 0; }
.blk-works { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.blk-works li { display: flex; gap: 14px; align-items: center; padding: 10px; border: 1px solid #e3e6ec; border-radius: 8px; }
.blk-works li.is-current { border-color: var(--scratch-blue); background: #f3f8ff; }
.blk-work-thumb { width: 96px; height: 72px; flex: none; display: grid; place-items: center; background: var(--scratch-pane); border-radius: 6px; overflow: hidden; color: var(--ink); }
.blk-work-thumb img { width: 100%; height: 100%; object-fit: cover; }
.blk-work-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.blk-work-info b { color: var(--scratch-blue-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-work-info small { font-size: 12px; color: var(--ink); }
.blk-work-btns { flex: none; display: flex; gap: 6px; }
.blk-toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); max-width: min(560px, calc(100% - 32px)); background: var(--ink-strong); color: #fff; font: 700 13px/1.6 var(--font-body); padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1100; }
.blk-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.blk-toast.is-warn { background: var(--warn); }
.wdp-zoom { z-index: 1050; }
.wdp-settings { z-index: 500; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- 高さの低い画面（1366×768 など）：映像の下に出るものを小さく ---------- */
@media (max-height: 820px) {
  .wdp-learn { gap: 6px; padding-top: 6px; }
  .wdp-lesson-title { font-size: 14px; line-height: 1.35; }
  .wdp-lesson-no { font-size: 11px; }
  .wdp-learn-main, .wdp-learn-media { gap: 6px; }
  .wdp-scene-nav { padding: 2px 4px; }
  .wdp-nav-btn { padding: 4px 9px; }
  .blk-diff { font-size: 12px; line-height: 1.6; padding: 4px 8px 6px; }
  /* カードの本文は 3 行ほどにして、テキスト欄を残す（中でスクロール） */
  .blk-diff-body { max-height: 5em; overflow-y: auto; }
}
/* エディタ本体の全体の決まり（p { font-size: 1rem }）が右側に効かないように */
.blk-diff p, .blk-modal p { font-size: inherit; line-height: inherit; }

/* ---------- 映像とテキストだけ：チャプターの一覧（映像の下） ---------- */
.blk-chapters { flex: none; background: var(--paper); border: 1px solid var(--scratch-line); border-radius: 10px; padding: 8px 10px 10px; font-family: var(--font-body); }
.blk-chapters h2 { margin: 0 0 6px; font: 800 13px var(--font-display); color: var(--ink-strong); }
.blk-chapters ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.blk-chapter { display: flex; gap: 10px; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 6px; padding: 5px 8px; font-size: 13px; color: var(--ink-strong); cursor: pointer; }
.blk-chapter:hover:not(:disabled) { border-color: var(--course-orange); }
.blk-chapter:disabled { color: #a3a9b8; cursor: not-allowed; }
.blk-chapter.is-on { background: var(--course-orange-soft); border-color: var(--course-orange); color: #b85500; font-weight: 700; }
.blk-chapter-t { flex: none; width: 3.4em; font-variant-numeric: tabular-nums; }
/* 縦長の画面では、チャプターの一覧はたたむ（テキストを広く） */
@media not all and (min-aspect-ratio: 5/4), (max-width: 699px) {
  .blk-chapters { display: none; }
}
/* せまい画面（スマートフォン）でも横にはみ出さない */
.blk-view-page { grid-template-columns: minmax(0, 1fr); }
.wdp-learn, .wdp-learn-main, .wdp-learn-media, .wdp-text { min-width: 0; }
.wdp-learn.is-view { width: 100%; }
@media (max-width: 560px) {
  .wdp-lesson-course { display: none; }
  .wdp-vctl button { padding: 2px 8px; font-size: 11px; }
}
