/* PianoKite web lessons (static/lesson.js). Theme follows the site's --pt-accent and the
 * system light/dark setting; every class is prefixed pk-. */
.pk-lesson {
  --pk-accent: var(--pt-accent, #4f46e5);
  --pk-accent-2: var(--pt-accent-2, #4338ca);
  --pk-soft: var(--pt-accent-soft, #eef2ff);
  --pk-bg: #ffffff;
  --pk-bg-2: #f6f5fb;
  --pk-fg: #1f1d2b;
  --pk-muted: #5d5a6c;
  --pk-line: #e5e2ec;
  --pk-right: #3b82f6;
  --pk-left: #f59e0b;
  --pk-ok: #16a34a;
  --pk-bad: #dc2626;
  --pk-miss: #a1a1aa;
  --pk-band: rgba(100, 116, 139, .28);
  --pk-star: #f5b301;
  --pk-white: #ffffff;
  --pk-white-edge: #cfcbd8;
  --pk-black: #1d1b26;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-height: 480px; /* reserved before the script runs: no layout shift */
  margin: 1.5rem 0;
  padding: 16px;
  border: 1px solid var(--pk-line);
  border-radius: 18px;
  background: var(--pk-bg);
  color: var(--pk-fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pk-lesson {
    --pk-bg: #1b1a24;
    --pk-bg-2: #24232f;
    --pk-fg: #ecebf3;
    --pk-muted: #a9a6b9;
    --pk-line: #34323f;
    --pk-right: #60a5fa;
    --pk-left: #fbbf24;
    --pk-ok: #22c55e;
    --pk-bad: #f87171;
    --pk-miss: #6b6878;
    --pk-band: rgba(148, 163, 184, .25);
    --pk-white: #ecebf3;
    --pk-white-edge: #8f8c9d;
    --pk-black: #0b0a10;
  }
}
:root[data-theme="dark"] .pk-lesson {
  --pk-bg: #1b1a24; --pk-bg-2: #24232f; --pk-fg: #ecebf3; --pk-muted: #a9a6b9; --pk-line: #34323f;
  --pk-right: #60a5fa; --pk-left: #fbbf24; --pk-ok: #22c55e; --pk-bad: #f87171; --pk-miss: #6b6878;
  --pk-band: rgba(148, 163, 184, .25); --pk-white: #ecebf3; --pk-white-edge: #8f8c9d; --pk-black: #0b0a10;
}
.pk-lesson *, .pk-lesson *::before, .pk-lesson *::after { box-sizing: border-box; }
.pk-lesson [hidden] { display: none !important; }
.pk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header */
.pk-top { display: flex; flex-direction: column; gap: 8px; }
.pk-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; flex-wrap: wrap; }
.pk-stepno { font-size: .85rem; color: var(--pk-muted); font-weight: 600; }
.pk-tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.pk-progress { height: 6px; border-radius: 99px; background: var(--pk-bg-2); overflow: hidden; }
.pk-progress > span { display: block; height: 100%; background: var(--pk-accent); border-radius: inherit; transition: width .3s; }

/* ---- buttons */
.pk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: .55rem 1.15rem; border-radius: 999px;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 2px solid transparent; background: var(--pk-bg-2); color: var(--pk-fg);
}
.pk-btn:focus-visible, .pk-key:focus-visible { outline: 3px solid var(--pk-accent); outline-offset: 2px; }
.pk-btn:disabled { opacity: .55; cursor: default; }
.pk-primary { background: var(--pk-accent); color: #fff; }
.pk-primary:hover:not(:disabled) { background: var(--pk-accent-2); color: #fff; }
.pk-ghost { background: transparent; color: var(--pk-accent); border-color: var(--pk-accent); }
.pk-ghost:hover:not(:disabled) { background: var(--pk-soft); }
.pk-small { min-height: 34px; padding: .3rem .8rem; font-size: .85rem; }
.pk-link { background: none; border: 0; color: var(--pk-muted); text-decoration: underline; padding-left: .5rem; padding-right: .5rem; }
.pk-big-btn { min-height: 52px; padding: .8rem 1.8rem; font-size: 1.05rem; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pk-primary, :root:not([data-theme="light"]) .pk-primary:hover:not(:disabled) { color: #13121a; }
}
:root[data-theme="dark"] .pk-primary { color: #13121a; }

/* ---- step content */
.pk-stage { min-height: 170px; display: flex; flex-direction: column; }
.pk-step { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; width: 100%; }
.pk-h { margin: 0; font-size: 1.25rem; line-height: 1.25; }
.pk-title { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.pk-eyebrow { margin: 0; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--pk-accent); }
.pk-goal { margin: 0; color: var(--pk-muted); max-width: 34em; }
.pk-text { max-width: 36em; }
.pk-text p, .pk-prompt { margin: 0 0 .5em; max-width: 36em; }
.pk-prompt-big { font-size: 1.1rem; font-weight: 600; }
.pk-mode, .pk-score, .pk-how, .pk-caption, .pk-hint { margin: 0; color: var(--pk-muted); font-size: .9rem; }
.pk-how { max-width: 36em; font-size: .82rem; }
.pk-score { font-weight: 600; color: var(--pk-fg); }
.pk-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.pk-cue { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pk-big { margin: 0; font-size: 2.4rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pk-letter { font-size: 3.2rem; color: var(--pk-accent); }
.pk-phase { font-size: 1.7rem; }
.pk-loading, .pk-error { margin: auto; color: var(--pk-muted); }
.pk-kinds { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; list-style: none; padding: 0; margin: 4px 0; }
.pk-kinds li { font-size: .8rem; padding: .2rem .6rem; border-radius: 99px; background: var(--pk-soft); color: var(--pk-accent); font-weight: 600; }
.pk-bar { width: min(280px, 100%); height: 12px; border-radius: 99px; background: var(--pk-bg-2); overflow: hidden; }
.pk-bar > span { display: block; width: 0; height: 100%; background: var(--pk-ok); transition: width .15s; }
.pk-count { margin: 4px 0 0; font-weight: 600; }
.pk-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; list-style: none; padding: 0; margin: 4px 0; }
.pk-dots li { width: 12px; height: 12px; border-radius: 50%; background: var(--pk-line); }
.pk-dots li.pk-ok { background: var(--pk-ok); }
.pk-dots li.pk-meh { background: var(--pk-star); }

/* tip visuals */
.pk-visual { width: 100%; margin: 4px 0; }
.pk-visual-keys { max-width: 560px; }
.pk-symbols { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; }
.pk-symbol { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; }
.pk-symbol figcaption { font-size: .85rem; color: var(--pk-muted); font-weight: 600; }
.pk-glyph { color: var(--pk-fg); }
.pk-symbols-one .pk-glyph { transform: scale(1.3); margin: 8px 0; }
.pk-emoji { font-size: 2.4rem; }
.pk-listen { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }

/* quiz */
.pk-qbody { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.pk-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: min(440px, 100%); }
.pk-option { border-radius: 12px; border-color: var(--pk-line); background: var(--pk-bg); font-size: 1rem; }
.pk-option:hover:not(:disabled) { border-color: var(--pk-accent); }
.pk-option.pk-right { border-color: var(--pk-ok); background: color-mix(in srgb, var(--pk-ok) 15%, transparent); opacity: 1; }
.pk-option.pk-wrong { border-color: var(--pk-bad); color: var(--pk-bad); }

/* play */
.pk-rollslot:empty { display: none; }
.pk-rollbox { position: relative; height: 220px; border-radius: 12px 12px 0 0; background: var(--pk-bg-2); overflow: hidden; margin-bottom: -12px; }
.pk-roll { display: block; width: 100%; height: 100%; }
.pk-retry { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pk-retry p { margin: 0; }

/* ---- keyboard */
.pk-kbdwrap { width: 100%; }
.pk-kbd {
  position: relative; width: 100%; height: 132px; user-select: none; -webkit-user-select: none;
  touch-action: none; border-radius: 0 0 10px 10px; overflow: hidden;
  background: var(--pk-white); border-left: 1px solid var(--pk-white-edge);
}
.pk-kbd-pic { height: 96px; touch-action: auto; border-radius: 8px; pointer-events: none; }
.pk-key {
  position: absolute; top: 0; margin: 0; padding: 0 0 6px; border: 0; font: inherit; cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px;
  color: var(--pk-muted);
}
.pk-white { height: 100%; z-index: 1; background: var(--pk-white); border-right: 1px solid var(--pk-white-edge); border-bottom: 1px solid var(--pk-white-edge); border-radius: 0 0 6px 6px; }
.pk-black { height: 62%; z-index: 2; background: var(--pk-black); border-radius: 0 0 5px 5px; color: #cbd5e1; box-shadow: inset 0 -4px 0 rgba(255,255,255,.08); }
.pk-klabel { font-size: .85rem; font-weight: 700; color: var(--pk-fg); line-height: 1; }
.pk-black .pk-klabel { color: #fff; }
.pk-kletter { font-size: .62rem; font-weight: 600; opacity: .7; line-height: 1; min-height: .62rem; }
@media (hover: none) { .pk-kletter { display: none; } }
.pk-kbd-pic .pk-kletter { display: none; }
/* marks */
.pk-m-lit-r { background: var(--pk-right); }
.pk-m-lit-l { background: var(--pk-left); }
.pk-m-lit-r .pk-klabel, .pk-m-lit-l .pk-klabel, .pk-m-lit-r .pk-kletter, .pk-m-lit-l .pk-kletter { color: #fff; opacity: 1; }
.pk-white.pk-m-allowed { background: color-mix(in srgb, var(--pk-accent) 14%, var(--pk-white)); }
.pk-black.pk-m-allowed { background: color-mix(in srgb, var(--pk-accent) 70%, var(--pk-black)); }
.pk-white.pk-m-hint { background: color-mix(in srgb, var(--pk-accent) 28%, var(--pk-white)); }
.pk-black.pk-m-hint { background: color-mix(in srgb, var(--pk-accent) 55%, var(--pk-black)); }
.pk-m-found, .pk-m-now { background: var(--pk-ok); }
.pk-m-found .pk-kletter, .pk-m-now .pk-kletter { color: #fff; }
.pk-down.pk-white { background: color-mix(in srgb, var(--pk-fg) 14%, var(--pk-white)); }
.pk-down.pk-black { background: #3f3b52; }
.pk-down.pk-m-lit-r, .pk-down.pk-m-lit-l, .pk-down.pk-m-found { filter: brightness(.9); }
.pk-f-ok { background: var(--pk-ok) !important; transition: none; }
.pk-f-bad { background: var(--pk-bad) !important; transition: none; }
.pk-f-other { background: var(--pk-miss) !important; }
.pk-key { transition: background-color .25s; }

/* ---- feedback and end */
.pk-feedback {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 16px; border-radius: 16px; background: var(--pk-bg); border: 1px solid var(--pk-line);
  box-shadow: 0 8px 30px rgba(15, 12, 40, .18);
  animation: pk-up .25s ease-out;
}
@keyframes pk-up { from { transform: translateY(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pk-feedback { animation: none; } .pk-key, .pk-progress > span { transition: none; } }
.pk-praise { margin: 0; font-size: 1.35rem; font-weight: 800; color: var(--pk-ok); }
.pk-stars { display: inline-flex; gap: 4px; line-height: 1; }
.pk-star { font-size: 1.6rem; color: var(--pk-line); }
.pk-star.pk-on { color: var(--pk-star); }
.pk-stars-md .pk-star { font-size: 2rem; }
.pk-stars-lg .pk-star { font-size: 3rem; }
.pk-end { gap: 12px; padding: 8px 0; }
.pk-cta { margin-top: 8px; padding: 14px; border-radius: 14px; background: var(--pk-soft); display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 34em; }
.pk-cta p { margin: 0; font-size: .92rem; }
.pk-foot:empty { display: none; }

/* ---- small screens */
@media (max-width: 520px) {
  .pk-lesson { padding: 12px; margin: 1rem 0; border-radius: 14px; }
  .pk-kbd { height: 116px; }
  .pk-rollbox { height: 180px; }
  .pk-title { font-size: 1.35rem; }
  .pk-big { font-size: 2rem; }
  .pk-letter { font-size: 2.8rem; }
  .pk-options { grid-template-columns: 1fr; }
  .pk-klabel { font-size: .72rem; }
  .pk-feedback { left: 8px; right: 8px; bottom: 8px; padding: 12px; }
}
