/* 第 6~9 堂(Python 課)的介面:接在 web.css 後面,工作台沿用網頁課的版型(.tmi-wb)。明亮兒童風;只有程式碼和輸出區是深色(同正式站)。 */

/* 這幾塊有自己設 display,[hidden] 要壓得過 */
.tmi-pywb [hidden], .tmi-pyscreen [hidden], .tmi-ws [hidden], .tmi-pyload[hidden], .xq-pyrun [hidden] { display: none !important; }

/* ---------- 換一堂課:九堂 ---------- */
/* 電腦畫面不夠寬時只留「第 N 堂」(堂名在滑鼠移上去的提示、讀屏的 aria-label 裡都有) */
@media (max-width: 1280px) { .tmi-lessons a small { display: none; } }
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  /* 九顆圓鈕排兩排(五 + 四),小標在上面:整塊留在搖桿右邊,不壓到搖桿 */
  .tmi-lessons { display: grid; grid-template-columns: repeat(5, 34px); gap: 3px; padding: 4px; border-radius: 20px; }
  .tmi-lessons-k { grid-column: 1 / -1; margin: 0 0 0 6px; line-height: 1.2; }
}
@media (max-width: 370px) {
  .tmi-lessons { grid-template-columns: repeat(5, 31px); }
  .tmi-lessons a { width: 31px; height: 31px; font-size: 14px; }
}

/* ---------- Python 工作台 ---------- */
.tmi-pywb .tmi-wb-panes { position: relative; }
.tmi-pywb.text .tmi-wb-panes { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "code con"; }
.tmi-pywb .tmi-pane-con .tmi-term { flex: 1; min-height: 0; }
.tmi-pywb.text .tmi-pane-con .tmi-con { flex: 1; max-height: none; }
.tmi-pywb.game .tmi-pane-con .tmi-con { max-height: 150px; }
.tmi-pywb .tmi-run { min-width: 120px; }
.xq .tmi-stop { background: #ffe1d6; color: #b4380c; box-shadow: inset 0 -3px 0 #f0a58a; }
.tmi-pyready { font-size: 13px; font-weight: 800; color: var(--soft); white-space: nowrap; }
.tmi-pyready.on { color: #23805a; }

/* 輸出(終端機) */
.tmi-term { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.tmi-pycon { font-size: 15px; }
.tmi-pycon .ask { color: #ffd24a; }
.tmi-caret { animation: tmi-blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes tmi-blink { 50% { opacity: 0; } }
/* 程式問問題:亮黃色的一塊,孩子一眼看得到要回答 */
.tmi-ask { flex: none; display: grid; gap: 6px; padding: 10px 12px; border-radius: 16px; background: #fff3c4; box-shadow: inset 0 0 0 2px #ffd24a, 0 4px 12px rgba(232, 165, 34, .25); }
.tmi-ask-k { margin: 0; font-size: 14px; font-weight: 900; color: #6b5212; }
.tmi-ask-q { margin-left: 4px; color: var(--ink); }
.tmi-ask-row { display: flex; flex-wrap: wrap; gap: 6px; }
.xq .tmi-ask-in { flex: 1 1 160px; min-width: 0; height: 40px; padding: 0 12px; border: 0; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 2px #e8b21f; font: 800 16px/1.2 var(--font); color: var(--ink); }
.xq .tmi-ask-in:focus { outline: 3px solid #ffd24a; }
.xq .tmi-repl-in { flex: none; width: 100%; height: 36px; padding: 0 12px; border: 0; border-radius: 12px; background: #1f2328; color: #e8e8e8; box-shadow: none; font: 14px/1 Consolas, "Cascadia Mono", monospace; }
.xq .tmi-repl-in::placeholder { color: #8b949e; }

/* 遊戲畫面(480×360,引擎照實際大小放大底層畫布) */
.tmi-gview { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.tmi-gbox { position: relative; flex: 1; min-height: 180px; padding: 4px; border-radius: 16px; background: #2b3242; box-shadow: inset 0 0 0 3px #3a4256; }
.tmi-canvas { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); object-fit: contain; background: transparent; }
.tmi-gpad { flex-wrap: wrap; }

/* 素材清單(同正式站 GameRunner 的 Assets) */
.tmi-pane-assets { grid-area: code; display: none; flex-direction: column; gap: 6px; min-height: 0; padding: 10px 12px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); overflow: auto; }
.tmi-wb[data-left="assets"] .tmi-pane-assets { display: flex; }
.tmi-wb[data-left="assets"] .tmi-pane-code { display: none; }
.tmi-assets { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.tmi-assets li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid #f0ece2; }
.tmi-assets img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #f7f5ef; }
.tmi-assets code { flex: 1; min-width: 0; font: 800 14px/1.3 Consolas, "Cascadia Mono", monospace; color: #2d3b4a; overflow-wrap: anywhere; }
.tmi-asset-k { padding: 2px 10px; border-radius: 999px; background: #e3f1fb; color: #2f78bd; font-size: 12.5px; font-weight: 900; }
.tmi-asset-k.snd { background: #e3f6e9; color: #23805a; }
.tmi-asset-play { width: 44px; height: 44px; border: 0; border-radius: 10px; background: #f7f5ef; font-size: 20px; cursor: pointer; }

/* 第一次載入的等待畫面 */
.tmi-pyload { position: absolute; inset: 0; z-index: 6; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 18px; border-radius: 16px; text-align: center;
  background: rgba(255, 253, 246, .97); box-shadow: inset 0 0 0 3px #ffe08a; }
.tmi-pyload p { margin: 0; max-width: 420px; }
.tmi-pyload-snake { font-size: 54px; line-height: 1; animation: tmi-hop 1.1s ease-in-out infinite; }
@keyframes tmi-hop { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }
.tmi-pyload-t { font-size: 19px; font-weight: 900; color: var(--ink); }
.tmi-pyload-n { font-size: 14.5px; font-weight: 700; color: #5d4a12; line-height: 1.6; }
.tmi-pyload-bar { width: min(280px, 80%); height: 10px; border-radius: 999px; background: #fff0b8; overflow: hidden; }
.tmi-pyload-bar i { display: block; width: 40%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffd24a, #3fae7a); animation: tmi-slide 1.4s ease-in-out infinite; }
@keyframes tmi-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.tmi-pyload-s { font-size: 13px; font-weight: 800; color: var(--soft); }
.tmi-pyload-tip { font-size: 14px; font-weight: 800; color: #2d4a78; }
.tmi-pyload-slow { font-size: 13.5px; font-weight: 900; color: #b4380c; }
.tmi-pyload.fail { box-shadow: inset 0 0 0 3px #f0a58a; }
.tmi-pyload.fail .tmi-pyload-snake, .tmi-pyload.fail .tmi-pyload-bar i { animation: none; }
.tmi-pyload.fail .tmi-pyload-bar, .tmi-pyload.fail .tmi-pyload-s, .tmi-pyload.fail .tmi-pyload-n { display: none; }

/* 指揮官(奇奇的程式)、偵探(嫌疑程式)的執行區 */
.tmi-pyscreen { position: relative; flex: none; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.tmi-pyscreen .tmi-con { min-height: 110px; max-height: 240px; }
.tmi-pyscreen .tmi-gview { flex: none; height: 260px; }
.tmi-sus-py .xq-suspect-code { max-height: 220px; }
.xq-ai .tmi-pyscreen, .xq-suspect .tmi-pyscreen { margin-top: 2px; }

/* ---------- 實戰島(Python):在自己的電腦上跑、看程式碼、放執行畫面 ---------- */
.xq-pyrun, .xq-pycode { --k: #f07848; }
body.xv .xq-props > .xq-pyrun { width: min(600px, 100%); }
body.xv .xq-props > .xq-pycode { width: min(680px, 100%); height: 100%; }
.xq-pycode .xq-card-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: hidden; }
.xq-pycode .tmi-ed { min-height: 200px; }
.tmi-pyrun-steps { margin: 4px 0 8px; padding-left: 1.4em; display: grid; gap: 10px; font-size: 15.5px; line-height: 1.65; font-weight: 700; color: var(--ink); }
.tmi-pyrun-steps b { color: #b4520c; margin-right: 2px; }
.tmi-pyrun-cmd { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.tmi-pyrun-cmd code { padding: 6px 12px; border-radius: 10px; background: #1f2328; color: #c3e88d; font: 15px/1.4 Consolas, "Cascadia Mono", monospace; }
.tmi-pyrun-phone { margin: 0 0 8px; padding: 10px 14px; border-radius: 14px; background: #ffe9df; color: #9a3412; font-weight: 800; line-height: 1.6; }
.tmi-pyprobs { margin: 6px 0 0; }
.tmi-shot { display: grid; gap: 6px; margin-top: 10px; padding: 12px 14px; border-radius: 16px; background: #eef6ff; box-shadow: inset 0 0 0 2px #cfe3f7; }
.tmi-shot p, .tmi-shot ol { margin: 0; }
.tmi-shot ol { padding-left: 1.3em; display: grid; gap: 4px; font-size: 14.5px; line-height: 1.6; font-weight: 700; }
.tmi-ws-bigcode { flex: 1; min-height: 0; max-height: none; margin: 0; }

/* ---------- 手機、直立平板 ---------- */
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
  .tmi-pywb .tmi-wb-panes { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "only"; }
  .tmi-pane-assets { grid-area: only; }
  .tmi-wb[data-pane="code"][data-left="assets"] .tmi-pane-assets { display: flex; }
  .tmi-pywb .tmi-pane-con .tmi-con, .tmi-pywb.game .tmi-pane-con .tmi-con { flex: 1; max-height: none; }
  .tmi-pyready { display: none; }
  .tmi-stop-l { display: none; }
  .xq .tmi-stop { min-width: 0; padding: 0 12px; }
  /* 看遊戲:探長的對話框收起來、視窗撐到底(同打字時的 xq-editing) */
  /* vision.css 是執行時才載入、排在後面的:選擇器要和它的 body.xv.xp-quest.xq-editing 一樣具體才壓得過 */
  body.tmi-playing .xq-talk, body.tmi-playing .xv-orn { display: none; }
  /* 底下留給右下角的 🔍 探長按鈕,不蓋到「空白」鍵 */
  body.xv.xp-quest.tmi-playing .xq-props, body.xp-quest.tmi-playing .xq-props { bottom: calc(84px + var(--safe-b, 0px)); }
  .tmi-pywb .tmi-run { min-width: 0; }
  .tmi-gbox { min-height: 0; }
  .xq .tmi-ask-in { font-size: 16px; }   /* iPhone 點進小於 16px 的輸入框會自動放大畫面 */
  .xq .tmi-repl-in { font-size: 16px; }
  .tmi-pyscreen .tmi-gview { height: 220px; }
  .xq-pycode .tmi-ed { min-height: 0; flex: 1; }
  .tmi-pyrun-steps { font-size: 15px; }
}
