/* TTPush 使用教學 — in-app tutorial player and first-run welcome card, in the 澄 Lucid language.
   Uses the foundation tokens (public/ui/foundation.css), so both themes work without extra rules.
   Every selector is scoped to .tutorial-dialog / .tutorial-welcome (test enforced) and the rules are
   unlayered, so they sit above the foundation's own button and dialog defaults. */
.tutorial-dialog, .tutorial-welcome { font-family: var(--font-ui); color: var(--ink); }

/* ---------- Dialog shell ---------- */
dialog.tutorial-dialog {
  box-sizing: border-box; width: min(1240px, calc(100vw - 48px)); min-width: 0; max-width: none; height: fit-content; max-height: calc(100dvh - 48px);
  margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-2xl);
  color: var(--ink); background: var(--card-sheen), var(--surface); box-shadow: var(--sh-3);
  opacity: 1; transform: none; transition: opacity .28s var(--ease), transform .28s var(--ease), overlay .28s allow-discrete, display .28s allow-discrete;
}
dialog.tutorial-dialog:not([open]) { opacity: 0; transform: translateY(14px) scale(.985); }
@starting-style { dialog.tutorial-dialog[open] { opacity: 0; transform: translateY(14px) scale(.985); } }
dialog.tutorial-dialog::backdrop { background: var(--scrim); transition: opacity .28s; }
@starting-style { dialog.tutorial-dialog[open]::backdrop { opacity: 0; } }
.tutorial-dialog *, .tutorial-welcome * { box-sizing: border-box; }
.tutorial-dialog button, .tutorial-welcome button {
  appearance: none; -webkit-appearance: none; margin: 0; padding: 0; min-width: 0; min-height: 0; width: auto; border: 0; border-radius: 0;
  background: none; box-shadow: none; transform: none; color: inherit; font: inherit; letter-spacing: inherit; text-align: inherit; cursor: pointer;
}
.tutorial-dialog button:focus-visible, .tutorial-welcome button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tutorial-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100dvh - 48px); }

.tutorial-head { display: flex; align-items: center; gap: var(--sp-4); padding: 16px 18px 14px 24px; border-bottom: 1px solid var(--line-2); }
.tutorial-head-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; color: var(--on-hero); background: linear-gradient(160deg, var(--hero-a), var(--hero-b)); box-shadow: var(--sh-2); }
.tutorial-head-icon svg { width: 22px; height: 22px; }
.tutorial-head h2 { margin: 0; color: var(--ink); font-size: var(--fs-20); font-weight: 800; line-height: 1.3; }
.tutorial-sub { margin: 2px 0 0; color: var(--ink-3); font-size: var(--fs-14); line-height: 1.5; }
.tutorial-head > div:nth-child(2) { flex: 1; min-width: 0; }
.tutorial-dialog .tutorial-close { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2); font-size: 24px; line-height: 1; transition: background-color var(--t-fast), border-color var(--t-fast); }
.tutorial-dialog .tutorial-close:hover { border-color: var(--line-strong); background: var(--surface-2); }

.tutorial-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.tutorial-player { display: grid; align-content: start; gap: 14px; min-width: 0; padding: 20px 20px 18px 24px; }
.tutorial-video-wrap { position: relative; overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100dvh - 290px); border-radius: var(--r-lg); background: var(--media-bg); box-shadow: 0 0 0 1px var(--line), var(--sh-2); }
.tutorial-video-wrap video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--media-bg); }
.tutorial-dialog .tutorial-resume { position: absolute; left: 50%; bottom: 22%; display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 22px; border-radius: 12px; color: var(--on-brand); background: var(--brand); font-size: var(--fs-16); font-weight: 700; box-shadow: var(--sh-btn), var(--sh-2); transform: translateX(-50%); }
.tutorial-dialog .tutorial-resume:hover { background: var(--brand-hover); }
.tutorial-dialog .tutorial-resume[hidden] { display: none; }
.tutorial-dialog .tutorial-resume svg { width: 18px; height: 18px; }
.tutorial-error { display: grid; place-content: center; justify-items: center; gap: 10px; height: 100%; padding: 24px; color: var(--ink-2); text-align: center; background: var(--surface-2); }
.tutorial-error strong { color: var(--ink); font-size: var(--fs-18); }
.tutorial-error span { max-width: 36ch; color: var(--ink-3); font-size: var(--fs-15); line-height: var(--lh-long); }

.tutorial-now { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface-2); }
.tutorial-now-chip { display: grid; place-items: center; flex: none; min-width: 34px; height: 28px; padding: 0 8px; border-radius: var(--r-sm); color: var(--on-brand); background: var(--brand); font-family: var(--font-num); font-size: var(--fs-13); font-weight: 800; }
.tutorial-now-chip:empty { display: none; }
.tutorial-now strong { color: var(--ink); font-size: var(--fs-16); }
.tutorial-now small { min-width: 0; overflow: hidden; color: var(--ink-3); font-size: var(--fs-14); text-overflow: ellipsis; white-space: nowrap; }
.tutorial-now time { flex: none; margin-left: auto; color: var(--ink-3); font-family: var(--font-num); font-size: var(--fs-14); font-weight: 600; font-variant-numeric: tabular-nums; }

/* The side column never sets the dialog height: it fills the row the video column defines and scrolls inside. */
.tutorial-side { position: relative; min-height: 0; border-left: 1px solid var(--line-2); background: var(--surface-2); }
.tutorial-side-inner { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.tutorial-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; margin: 16px 16px 10px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-3); }
.tutorial-dialog .tutorial-tabs button { min-height: 36px; padding: 0 10px; border-radius: var(--r-md); color: var(--ink-2); font-size: var(--fs-14); font-weight: 650; text-align: center; transition: background-color var(--t-fast), color var(--t-fast); }
.tutorial-dialog .tutorial-tabs button[aria-selected="true"] { color: var(--ink); background: var(--raise); box-shadow: var(--sh-1), 0 0 0 1px var(--line); }
.tutorial-dialog .tutorial-tabs button:not([aria-selected="true"]):hover { color: var(--ink); }
.tutorial-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.tutorial-panel[hidden] { display: none; }
.tutorial-chapters { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.tutorial-dialog .tutorial-chapter { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 10px; border-radius: 10px; transition: background-color var(--t-fast); }
.tutorial-dialog .tutorial-chapter:hover { background: var(--hover-veil); }
.tutorial-chapter .num { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-2); background: var(--surface); font-family: var(--font-num); font-size: var(--fs-13); font-weight: 750; font-variant-numeric: tabular-nums; }
.tutorial-chapter .title { display: grid; gap: 2px; min-width: 0; color: var(--ink); font-size: var(--fs-15); font-weight: 650; line-height: 1.4; }
.tutorial-chapter .title small { overflow: hidden; color: var(--ink-3); font-size: var(--fs-13); font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.tutorial-chapter .time { display: grid; justify-items: end; gap: 3px; color: var(--ink-3); font-family: var(--font-num); font-size: var(--fs-13); font-weight: 500; font-variant-numeric: tabular-nums; }
.tutorial-chapter .check { width: 16px; height: 16px; border: 1px solid var(--line-strong); border-radius: 50%; }
.tutorial-chapter.watched .check { border-color: var(--ok-solid); background: var(--ok-solid) var(--check-glyph) center / 12px no-repeat; }
.tutorial-dialog .tutorial-chapter[aria-current="true"] { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-line); }
.tutorial-chapter[aria-current="true"] .num { border-color: var(--brand); color: var(--on-brand); background: var(--brand); }
.tutorial-chapter[aria-current="true"] .title { color: var(--brand-ink); }

.tutorial-transcript { display: grid; gap: 2px; }
.tutorial-dialog .tutorial-cue { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); font-size: var(--fs-15); line-height: var(--lh-long); transition: background-color var(--t-fast), color var(--t-fast); }
.tutorial-dialog .tutorial-cue:hover { color: var(--ink); background: var(--hover-veil); }
.tutorial-cue time { padding-top: 2px; color: var(--ink-3); font-family: var(--font-num); font-size: var(--fs-13); font-weight: 600; line-height: var(--lh-long); font-variant-numeric: tabular-nums; }
.tutorial-dialog .tutorial-cue.active { color: var(--ink); background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.tutorial-cue.active time { color: var(--brand-ink); }
.tutorial-cue-chapter { margin: 12px 10px 4px; color: var(--brand-ink); font-size: var(--fs-13); font-weight: 700; }
.tutorial-cue-chapter:first-child { margin-top: 2px; }

.tutorial-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px 24px; border-top: 1px solid var(--line-2); color: var(--ink-3); font-size: var(--fs-13); background: var(--surface-2); }
.tutorial-foot kbd { display: inline-grid; place-items: center; min-width: 26px; height: 24px; margin-right: 6px; padding: 0 7px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-sm); color: var(--ink-2); background: var(--kbd-bg); font-family: var(--font-ui); font-size: var(--fs-12); font-weight: 700; }
.tutorial-foot .tutorial-foot-note { margin-left: auto; }

/* ---------- Phones / small tablets: full-height bottom sheet ---------- */
@media (max-width: 900px) {
  dialog.tutorial-dialog { width: 100vw; max-width: 100vw; height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); margin: auto 0 0; border-width: 1px 0 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; }
  dialog.tutorial-dialog:not([open]) { transform: translateY(40px); }
  @starting-style { dialog.tutorial-dialog[open] { opacity: 0; transform: translateY(40px); } }
  .tutorial-shell { height: 100%; max-height: none; grid-template-rows: auto minmax(0, 1fr); }
  .tutorial-head { position: relative; padding: 18px 12px 12px 16px; }
  .tutorial-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; border-radius: var(--r-round); background: var(--line-strong); transform: translateX(-50%); }
  .tutorial-head-icon { width: 38px; height: 38px; border-radius: 11px; }
  .tutorial-head h2 { font-size: var(--fs-18); }
  .tutorial-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  .tutorial-player { gap: 10px; padding: 12px 12px 0; }
  .tutorial-video-wrap { border-radius: var(--r-md); }
  .tutorial-side { min-height: 0; border-left: 0; background: none; }
  .tutorial-side-inner { position: static; height: 100%; }
  .tutorial-tabs { display: none; }
  .tutorial-panel.tutorial-chapters-panel { display: block !important; overflow-x: auto; overflow-y: hidden; padding: 10px 12px 6px; }
  .tutorial-chapters { display: flex; gap: 8px; width: max-content; }
  .tutorial-dialog .tutorial-chapter { grid-template-columns: auto auto; gap: 8px; width: auto; min-height: 44px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .tutorial-chapter .num { width: 30px; height: 30px; border-radius: 8px; font-size: var(--fs-12); }
  .tutorial-chapter .title { font-size: var(--fs-14); white-space: nowrap; }
  .tutorial-chapter .title small, .tutorial-chapter .time { display: none; }
  .tutorial-panel.tutorial-transcript-panel { display: block !important; padding: 4px 12px calc(16px + env(safe-area-inset-bottom)); }
  .tutorial-foot { display: none; }
}

/* ---------- First-run welcome card ---------- */
.tutorial-welcome {
  position: fixed; right: 24px; bottom: 24px; z-index: 900; display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 16px; width: min(400px, calc(100vw - 32px));
  padding: 20px 22px 18px 20px; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--card-sheen), var(--surface); box-shadow: var(--sh-3);
  animation: tt-welcome-in .5s var(--ease) both;
}
.tutorial-welcome.leaving { animation: tt-welcome-out .3s var(--ease) forwards; }
@keyframes tt-welcome-in { from { opacity: 0; transform: translateY(20px); } }
@keyframes tt-welcome-out { to { opacity: 0; transform: translateY(14px); } }
.tutorial-welcome-coin { width: 48px; height: 48px; }
.tutorial-welcome-coin svg { width: 48px; height: 48px; border-radius: 13px; box-shadow: var(--sh-2); }
.tutorial-welcome strong { display: block; padding-right: 28px; color: var(--ink); font-size: var(--fs-16); font-weight: 800; line-height: 1.4; }
.tutorial-welcome p { margin: 6px 0 14px; color: var(--ink-2); font-size: var(--fs-15); line-height: var(--lh-long); }
.tutorial-welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tutorial-welcome .tt-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--r-md); font-size: var(--fs-15); font-weight: 650; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.tutorial-welcome .tt-btn svg { width: 18px; height: 18px; }
.tutorial-welcome .tt-btn-primary { color: var(--on-brand); background: var(--brand); box-shadow: var(--sh-btn); }
.tutorial-welcome .tt-btn-primary:hover { background: var(--brand-hover); }
.tutorial-welcome .tt-btn-ghost { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.tutorial-welcome .tt-btn-ghost:hover { background: var(--surface-2); }
.tutorial-welcome .tutorial-welcome-x { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); color: var(--ink-3); font-size: 20px; line-height: 1; }
.tutorial-welcome .tutorial-welcome-x:hover { color: var(--ink); background: var(--hover-veil); }
@media (max-width: 900px) {
  .tutorial-welcome { right: 16px; left: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); width: auto; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 16px 16px 14px; }
  .tutorial-welcome-coin, .tutorial-welcome-coin svg { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.tutorial-dialog, dialog.tutorial-dialog::backdrop { transition: none; }
  .tutorial-welcome, .tutorial-welcome.leaving { animation: none; }
}
