/* The two demos on TabbyGato's own music engine (js/demo-live.mjs): the loop demo and the key demo.
   The controls borrow the app's own look (app/src/app.css): the desk-colored bottom bar, trays of
   icon-over-label cells, the filled green Play, plus and minus around a bar number, and chips with a tick.
   The colors are the app's tokens (app/src/tokens.css), written out here because the site does not load that file. */

[data-live-chapter] {
  --live-desk: #e2e7e2;       /* --tg-desk */
  --live-card: #fbfbf8;       /* --tg-card */
  --live-off: rgba(32, 38, 37, .045);
  --live-hover: rgba(32, 38, 37, .07);
  --live-soft: #b8dccb;       /* --tg-accent-soft */
  --live-play: #2f62b8;       /* --tg-play */
}

.live-shell { position: relative; isolation: isolate; } /* keeps alphaTab's marks under the site header */

/* The start row under the screenshot: the line that says what happened and, for a visitor with a data saver
   only, the "Try" button. On a wide screen the demos start by themselves (js/demo-live.mjs). */
.live-start { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-height: 44px; margin-top: 16px; }
.live-start[hidden] { display: none; }
.live-try {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 20px 0 15px;
  border: 1px solid rgba(36, 92, 83, .28); border-radius: 999px;
  background: #E3ECE6; color: var(--accent);
  font-size: 15px; font-weight: 600;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.live-try:hover { background: #D6E4DB; box-shadow: 0 6px 16px -10px rgba(36, 92, 83, .55); }
.live-try svg { width: 17px; height: 17px; fill: currentColor; }
.live-try[hidden] { display: none; }
.live-note { font-size: 15px; color: var(--muted); }
.live-note[hidden] { display: none; }
[data-live-chapter].is-loading .live-note::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 10px; vertical-align: -1px;
  border: 2px solid rgba(36, 92, 83, .25); border-top-color: var(--accent); border-radius: 50%;
  animation: live-spin .8s linear infinite;
}
@keyframes live-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [data-live-chapter].is-loading .live-note::before { animation-duration: 2.4s; } }

/* Two lines of the credit fit inside the row's 44 pixels, so the row keeps its height when the credit appears. */
.live-credit { display: none; font-size: 14px; line-height: 1.5; color: var(--muted); max-width: 44em; }
[data-live-chapter].is-live .live-credit { display: block; }
/* The screenshot's link keeps its place under a live demo, unseen, so nothing below the demo moves. */
[data-live-chapter].is-live figcaption { visibility: hidden; }

/* On a wide screen with a mouse, a live demo takes the place of the picture switch (Whole song / Focus, or
   Off / All), so the switch leaves before the demo starts and nothing moves when the demo arrives. A demo that
   fails brings the switch back. The media rule sets the same layout before the script runs, so the first paint
   already has the start row's height and no switch. */
[data-live-chapter].live-ready .view-switch,
[data-live-chapter].is-live .view-switch { display: none; }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .js [data-live-chapter]:not(.is-failed) .view-switch { display: none; }
  .js [data-live-chapter] .live-start { display: flex; }
}

/* The stage covers the screenshot exactly, so nothing on the page moves when the demo arrives. */
.live-stage {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--score);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-frame);
  overflow: hidden;
  /* Drawn but unseen while the engine draws the bars: alphaTab needs the stage's real width. */
  visibility: hidden; opacity: 0;
  transition: opacity .5s var(--ease-out), visibility 0s .5s;
}
.live-stage.is-in { visibility: visible; opacity: 1; transition: opacity .5s var(--ease-out); }
.live-still .live-stage { transition: none; }

.live-hint { padding: 14px 22px 0; font-size: 14px; font-weight: 550; color: var(--muted); }
.live-music {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  overflow: auto; overscroll-behavior: contain;
  padding: 0 10px;
  scrollbar-color: #B7C2B9 transparent; scrollbar-width: thin;
}
.live-score { position: relative; margin-block: auto; }
.live-score .at-surface { cursor: text; }

/* alphaTab's marks, in the app's colors: the green wash of a loop, and the blue playing marks. */
.live-score .at-selection div { background: rgba(36, 92, 83, .14); }
.live-score .at-cursors { mix-blend-mode: darken; }
.live-score .at-cursor-bar { background: rgba(47, 98, 184, .10); }
.live-score .at-cursor-beat { background: #6e90d1; width: 3px; }
.live-score .at-highlight * { fill: var(--live-play); stroke: var(--live-play); }

/* ---------- The bar of controls, after the app's bottom bar ---------- */
.live-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--live-desk);
  border-top: 1px solid #D3DAD3;
}
.live-tray {
  display: flex; align-items: stretch; gap: 2px; height: 56px; padding: 4px 6px;
  border-radius: 14px; background: color-mix(in srgb, var(--live-card) 55%, transparent);
}
.live-cell {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 44px; min-height: 44px; margin: 0; padding: 2px 8px;
  font-size: 12px; font-weight: 600; line-height: 1.15; white-space: nowrap; color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  transition: background-color .15s var(--ease);
}
.live-cell:hover { background: var(--live-hover); }
.live-cell[aria-disabled="true"] { opacity: .38; cursor: default; }
.live-cell[aria-disabled="true"]:hover { background: transparent; }
.live-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.live-play { width: 84px; background: var(--accent); color: var(--on-accent); }
.live-play:hover { background: var(--accent); filter: brightness(1.08); }
.live-play .live-icon { width: 22px; height: 22px; }
.live-play .i-pause, .is-playing .live-play .i-play { display: none; }
.is-playing .live-play .i-pause { display: block; }

.live-step { width: 44px; padding: 0; }
.live-stack { display: grid; grid-template-rows: 22px 16px; align-content: center; min-width: 52px; text-align: center; }
.live-value { font-size: 15px; font-weight: 700; line-height: 22px; font-variant-numeric: tabular-nums; }
.live-cap { font-size: 12px; font-weight: 500; line-height: 16px; color: var(--muted); }

.live-loop { align-items: center; gap: 4px; padding: 4px 8px; }
.live-say { padding: 0 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
.live-num { display: inline-flex; align-items: center; gap: 0; border-radius: 10px; background: var(--live-off); }
.live-num .live-cell { min-width: 36px; padding: 0 4px; }
.live-num .live-icon { width: 16px; height: 16px; }
.live-num b { min-width: 26px; text-align: center; font-size: 15px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.live-focus { flex-direction: row; gap: 6px; padding: 0 14px; font-size: 13px; }
.live-focus .live-icon { width: 17px; height: 17px; }
.live-focus .i-back, .is-focus .live-focus .i-focus { display: none; }
.is-focus .live-focus .i-back { display: block; }
.live-focus[aria-pressed="true"] { background: var(--live-soft); color: var(--accent); }

.live-status {
  flex: 1 1 0; min-width: 0; margin-left: 6px;
  font-size: 13px; line-height: 1.35; color: var(--muted); text-align: right; text-wrap: balance;
}

/* ---------- The key demo: its choices sit above the music ---------- */
.live-bar-top { flex-wrap: wrap; gap: 8px 22px; padding: 10px 16px; border-top: 0; border-bottom: 1px solid #D3DAD3; }
.live-choice { display: flex; align-items: center; gap: 10px; }
.live-cap-l { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.live-seg { display: flex; flex-wrap: wrap; gap: 4px; }
.live-seg button {
  display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 12px;
  font-size: 13px; font-weight: 550; color: var(--muted); white-space: nowrap;
  background: var(--live-card); border: 1px solid transparent; border-radius: 8px;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.live-seg button:hover { background: #fff; color: var(--ink); }
.live-seg button[aria-pressed="true"], .live-seg button[aria-pressed="true"]:hover { background: var(--live-soft); color: var(--accent); font-weight: 700; }
.live-seg button[aria-pressed="true"]::before {
  content: ""; width: 9px; height: 5px; margin: 0 1px 3px 0;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
}
.live-stage-key .live-music { padding-top: 6px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

[data-live-chapter] .live-cell:focus-visible,
[data-live-chapter] .live-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

/* ---------- The practice player in "When you get stuck" (November 18, 2026) ----------
   The stage stands in the page flow once it is live, so the bar of controls can wrap onto a second row on a narrow
   window. The screenshot leaves when the stage arrives. */
.stuck-player.is-live .live-shell > .frame { display: none; }
.stuck-player .live-stage { min-height: 300px; }
.stuck-player.is-live .live-stage { position: relative; inset: auto; min-height: 520px; }
.stuck-player .live-bar { flex-wrap: wrap; }
.stuck-player .live-status { flex: 1 1 220px; text-align: left; margin-left: 4px; }
.live-toggle { padding: 2px 10px; }
.live-toggle[aria-pressed="true"] { background: var(--live-soft); color: var(--accent); }
.live-toggle .live-icon { width: 18px; height: 18px; }
@media (max-width: 700px) {
  .stuck-player.is-live .live-stage { min-height: 0; border-radius: 14px; }
  .stuck-player .live-music { padding-block: 10px; }
  .stuck-player .live-hint { padding: 12px 14px 0; }
  .stuck-player .live-bar { padding: 8px; gap: 6px; }
  .stuck-player .live-tray { height: auto; min-height: 52px; }
  .stuck-player .live-play { width: auto; padding: 2px 14px; }
}

/* ---------- Tab and Recording sides, home note discs, the recording side (November 18, 2026) ---------- */
.player-sides { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: 12px; background: rgba(32, 38, 37, .06); }
.player-sides button { min-height: 40px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; }
.player-sides button[aria-pressed="true"] { background: var(--score); color: var(--ink); box-shadow: 0 1px 3px rgba(32, 38, 37, .12); }
.player-sides button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stuck-player.on-recording .live-shell, .stuck-player.on-recording .live-start { display: none; }
.stuck-player .home-disc { fill: #a2560a; fill-opacity: .14; stroke: none; pointer-events: none; }

/* The Recording and YouTube sides hold the app's own recording screen in a frame (js/demo-recording.mjs). The screen
   needs the room the app has, so while one of them shows, the player takes the section's whole width, above the list. */
.stuck-grid:has(.stuck-player.on-recording) { grid-template-columns: minmax(0, 1fr); }
.stuck-player.on-recording { order: -1; position: static; }
.rec-frame-box { overflow: hidden; border-radius: 18px; box-shadow: 0 0 0 1px var(--line), 0 18px 40px -24px rgba(32, 38, 37, .35); background: #e2e7e2; }
.rec-frame { display: block; width: 100%; height: clamp(600px, calc(100svh - var(--header, 64px) - 120px), 780px); border: 0; }
.rec-frame-box.is-waiting { opacity: .55; }
.rec-frame-box.is-video .rec-frame { height: clamp(700px, calc(100svh - var(--header, 64px) - 60px), 900px); } /* the video sits above the strip, so the frame needs the room */
@media (max-width: 700px) {
  .rec-frame-box { border-radius: 14px; margin-inline: -8px; }
  .rec-frame { height: clamp(640px, calc(100svh - 72px), 820px); }
}

/* ---------- The YouTube side: the visitor's own link, then YouTube's player above the same tools ---------- */
.yt-ask { position: relative; inset: auto; visibility: visible; opacity: 1; display: grid; gap: 10px; padding: 22px; }
.yt-label { font-size: 15px; font-weight: 650; color: var(--ink); }
.yt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.yt-row input { flex: 1 1 260px; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; font-size: 15px; }
.yt-error { color: #b3261e; font-size: 14px; }
.yt-error[hidden] { display: none; }
.yt-note { font-size: 13px; color: var(--muted); max-width: 40em; }
.rec-other { display: block; margin: 0 0 8px auto; font-size: 14px; background: none; border: 0; cursor: pointer; }
.rec-other[hidden] { display: none; }
.yt-ask[hidden] { display: none; }
.yt-ask { align-content: start; min-height: 0; }
.yt-row { align-items: center; }
.yt-row input { height: 44px; flex-grow: 1; }
.stuck-player .yt-ask, .stuck-player.is-live .yt-ask { min-height: 0; }
