/* The practice page: a virtual cube to play with, and the coach on request.
   Builds on /assets/style.css. */

.play { padding-top: 18px; padding-bottom: 40px; }
.play-head h1 { font-size: clamp(24px, 3.4vw, 34px); letter-spacing: -0.01em; margin: 0 0 2px; }
.play-head p { color: var(--muted); margin: 0 0 14px; font-size: 15px; }

.play-area { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }

/* The stage: the cube is the page */
.stage {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(110% 80% at 50% 42%, #1d2029 0%, #13141a 58%, #0b0c10 100%);
  border: 1px solid var(--hairline); border-radius: var(--radius);
  height: clamp(460px, calc(100vh - 200px), 900px);
  height: clamp(460px, calc(100svh - 200px), 900px);
}
#cube { display: block; flex: 1 1 auto; min-height: 0; width: 100%; touch-action: none; cursor: grab; outline: none; }
#cube.turning { cursor: grabbing; }
#cube.orbiting { cursor: move; }
.no-gl {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted);
  background: inherit;
}
/* Focused only by the page (after the celebration), never by Tab. */
.stage:focus { outline: none; }
.stage:focus-visible { outline: 2px solid rgba(52, 199, 89, 0.5); outline-offset: 2px; }
.no-gl[hidden] { display: none; }

.stage-top {
  position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; gap: 10px;
  pointer-events: none;
}
.stage-top > * { pointer-events: auto; }
.stage-top .chip { margin-left: auto; flex: none; }
.hint-card {
  margin: 0; display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 14px 6px 6px;
  background: rgba(14, 15, 19, 0.84); border: 1px solid rgba(52, 199, 89, 0.55); border-radius: 14px;
  font-weight: 600; font-size: 16px; line-height: 1.25; animation: pop 0.25s ease;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.hint-notation {
  flex: none; align-self: flex-start;
  font: 700 17px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--accent);
  background: rgba(52, 199, 89, 0.16); border-radius: 9px; padding: 7px 10px; min-width: 40px; text-align: center;
}
.hint-words { display: flex; flex-direction: column; gap: 2px; padding: 3px 0; max-width: 30em; }
.hint-detail { font-size: 14px; font-weight: 500; line-height: 1.35; color: rgba(255, 255, 255, 0.72); }
.hint-detail:empty { display: none; }

/* The controls under the cube */
.toolbar {
  flex: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 22px;
  padding: 12px 14px 16px;
}
.tb-row { display: flex; align-items: center; gap: 8px; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--hairline);
}
.seg button {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); background: transparent; border: 0;
  border-radius: 999px; min-height: 38px; padding: 0 14px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { color: var(--text); background: var(--card-raised); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.tb-btn {
  font: inherit; font-size: 15px; font-weight: 700; color: var(--text);
  background: rgba(37, 38, 46, 0.92); border: 1px solid var(--hairline); border-radius: 999px;
  min-height: 44px; padding: 0 20px; cursor: pointer;
}
.tb-btn:hover:not(:disabled) { background: #30313b; }
.tb-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tb-btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.06); }
.tb-btn.coach-me { color: var(--accent); border-color: rgba(52, 199, 89, 0.5); }
.tb-btn:disabled { opacity: 0.4; cursor: default; }

/* Buttons */
.chip {
  font: inherit; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.86);
  background: rgba(26, 27, 33, 0.9); border: 1px solid var(--hairline); border-radius: 999px;
  min-height: 36px; padding: 0 14px; cursor: pointer;
}
.chip:hover { background: var(--card-raised); }
.chip[aria-pressed="true"] { color: var(--accent); background: rgba(52, 199, 89, 0.14); border-color: rgba(52, 199, 89, 0.5); }
.btn {
  font: inherit; font-weight: 700; font-size: 18px; color: var(--text);
  background: var(--card); border: 1px solid var(--hairline); border-radius: 16px;
  min-height: 54px; padding: 0 18px; cursor: pointer; flex: 1;
}
.btn:hover:not(:disabled) { background: var(--card-raised); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.06); }
.btn:disabled { opacity: 0.4; cursor: default; }
.link-btn { font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 10px; cursor: pointer; }
.link-btn:hover { color: var(--text); }
/* No double-tap zoom on quick repeated taps ("Do it", "Undo"). */
button, summary, .cue { touch-action: manipulation; }
button:focus-visible { outline: 3px solid rgba(52, 199, 89, 0.7); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Coaching: the panel beside the cube (below it on narrow screens) */
.play-area[data-mode="coach"] { grid-template-columns: minmax(0, 1fr) 380px; }
.coach-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coach-badge {
  font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent);
  background: rgba(52, 199, 89, 0.14); border-radius: 999px; padding: 5px 10px;
}
.chip.stop { border-color: rgba(255, 255, 255, 0.22); }
@media (min-width: 901px) {
  .play-area[data-mode="coach"] .coach { max-height: clamp(460px, calc(100svh - 200px), 900px); overflow-y: auto; padding-right: 2px; }
}

.coach { display: flex; flex-direction: column; gap: 14px; }
.coach-head { padding: 2px 2px 0; }
.stage-row { display: flex; align-items: center; justify-content: space-between; }
.stage-label { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.info {
  font: inherit; font-weight: 700; font-style: italic; font-family: Georgia, serif; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--card); color: var(--muted); cursor: pointer;
}
.coach-head h2 { font-size: 26px; margin: 2px 0 10px; letter-spacing: -0.01em; }
.progress { display: flex; gap: 4px; height: 5px; }
.progress > span { flex: 1; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
.progress > span > span { display: block; height: 100%; background: var(--accent); transition: width 0.3s ease; }
.progress > span > span.past { background: rgba(255, 255, 255, 0.55); }

.card { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 18px 20px; }
.step .chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.notation {
  font: 700 20px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--accent);
  background: rgba(52, 199, 89, 0.14); border-radius: 9px; padding: 7px 12px; min-width: 48px; text-align: center;
}
.info-chip { font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, 0.8); background: var(--card-raised); border-radius: 999px; padding: 6px 11px; }
.step h3 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; }
.step .detail { margin: 0; color: #d6d8de; }
.step .note { margin: 12px 0 0; padding: 10px 12px; background: var(--card-raised); border-radius: 12px; font-size: 15px; color: rgba(255, 255, 255, 0.86); }
.step .note::before { content: "💡 "; }

.intro .goal { font-size: 19px; font-weight: 600; margin: 0 0 8px; }
.intro .explain { color: var(--muted); margin: 0 0 12px; }
.intro .tips { list-style: none; margin: 0 0 16px; padding: 12px 14px; background: var(--card-raised); border-radius: 12px; font-size: 15px; }
.intro .tips:empty { display: none; }
/* The explanation folds away on a phone (see main.ts); beside the cube it is always open. */
.intro-more { background: none; border: 0; border-radius: 0; padding: 0; margin: 0; }
.intro-more > summary { display: none; }
.intro .tips li { padding-left: 24px; position: relative; color: rgba(255, 255, 255, 0.85); }
.intro .tips li + li { margin-top: 8px; }
.intro .tips li::before { content: "💡"; position: absolute; left: 0; }
.intro .btn { width: 100%; }

.status { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 15px; }
.status[data-tone="good"] { color: var(--accent); font-weight: 600; animation: pop 0.35s ease; }
@keyframes pop { from { transform: scale(0.96); opacity: 0.4; } to { transform: none; opacity: 1; } }

.wrong { background: rgba(255, 159, 10, 0.1); border: 1px solid rgba(255, 159, 10, 0.45); border-radius: var(--radius); padding: 14px 16px; }
.wrong p { margin: 0 0 12px; color: #ffd8a8; }
.wrong strong { color: #ffb340; }
.row, .actions { display: flex; gap: 10px; }
.actions .btn:last-child { flex: 0 0 34%; }

.meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.meta-buttons { display: flex; gap: 8px; }

/* Solved */
.solved {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(70% 70% at 50% 50%, rgba(14, 15, 19, 0.25), rgba(0, 0, 0, 0.55));
}
.solved-card {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 24px; padding: 26px 24px 14px;
  width: min(360px, 100%); text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.solved .tick {
  width: 88px; height: 88px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center;
  font-size: 44px; font-weight: 800; color: var(--accent); background: rgba(52, 199, 89, 0.16);
  box-shadow: 0 0 0 10px rgba(52, 199, 89, 0.07), 0 0 40px rgba(52, 199, 89, 0.35);
}
.solved h2 { font-size: 42px; margin: 4px 0 0; letter-spacing: -0.01em; }
.solved-turns { color: var(--muted); margin: 0 0 18px; font-size: 18px; font-variant-numeric: tabular-nums; }
.solved .btn { width: 100%; }
.solved .link-btn { margin-top: 6px; }
@keyframes rise { from { transform: translateY(14px) scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* "Coach me" far from solved: learn the method, or the shortest way */
.choice {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 16px;
  background: rgba(6, 7, 10, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.choice-card {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 24px; padding: 22px 20px 10px;
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: rise 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.choice h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.01em; }
.choice-opt {
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; min-height: 64px;
  background: var(--card-raised); border: 1px solid var(--hairline); border-radius: 16px;
}
.choice-opt:hover:not(:disabled) { border-color: rgba(52, 199, 89, 0.6); background: #2c2d36; }
.choice-opt:disabled { opacity: 0.45; cursor: default; }
.choice-opt[aria-busy="true"] { opacity: 1; border-color: rgba(52, 199, 89, 0.6); }
.choice-name { font-size: 18px; font-weight: 700; }
.choice-line { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.choice-working { margin: 2px 0 0; min-height: 1.4em; font-size: 15px; color: var(--accent); font-weight: 600; }
.choice-working:empty { min-height: 0; margin: 0; }

.app-line { color: var(--muted); font-size: 15px; text-align: center; margin: 16px auto 0; }

/* Below the cube: the way on down the page (the canvas itself does not scroll on touch). */
.cues { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 12px auto 0; }
.cue {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  font-size: 15px; font-weight: 600; color: var(--text);
  background: var(--card); border: 1px solid var(--hairline); border-radius: 999px;
}
.cue:hover { text-decoration: none; background: var(--card-raised); }
.cue span { color: var(--accent); }

/* How it works and questions: the page's text below the cube. */
.how { padding-top: 48px; scroll-margin-top: 16px; }
.how h2 { font-size: 28px; letter-spacing: -0.01em; margin: 0 0 18px; }
.how-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.how .faq-title { margin-top: 48px; }
.faq { max-width: 760px; }
.faq h3 { font-size: 19px; margin: 22px 0 6px; }
.faq h3:first-child { margin-top: 0; }
.faq p { margin: 0; color: #d6d8de; }
.noscript { color: var(--text); background: var(--card); border: 1px solid var(--hairline); border-radius: 14px; padding: 14px 16px; }

@media (max-width: 900px) {
  .play-area[data-mode="coach"] { grid-template-columns: minmax(0, 1fr); }
  .play-area[data-mode="coach"] .stage { height: clamp(280px, 44vh, 520px); height: clamp(280px, 44svh, 520px); }
  .play-area[data-mode="coach"] { gap: 14px; }
}
@media (max-width: 760px) {
  .play { padding-top: 12px; padding-bottom: 28px; }
  .wrap.play-head, .wrap.play-area, .wrap.app-line, .wrap.cues, .wrap.how { padding-left: 16px; padding-right: 16px; }
  .play-head h1 { font-size: 23px; }
  .play-head p { font-size: 14px; margin-bottom: 10px; }
  .play-head .keys { display: none; }
  /* Short enough that the cues below and the next section peek in: the canvas does not scroll the page. */
  .stage { height: clamp(380px, calc(100vh - 300px), 640px); height: clamp(380px, calc(100svh - 300px), 640px); }
  .app-line { margin-top: 12px; font-size: 14px; }
  .how { padding-top: 36px; }
  .how h2 { font-size: 24px; }
  .how-grid { grid-template-columns: 1fr; gap: 12px; }
  .toolbar { gap: 8px; padding: 10px 10px 12px; }
  .tb-row { flex: 1 1 100%; }
  .tb-row > * { flex: 1 1 0; }
  .tb-row > .seg { flex: 2.3 1 0; }
  .seg button { flex: 1 1 0; padding: 0 6px; }
  .tb-btn { padding: 0 12px; }
  .step h3 { font-size: 22px; }
  .hint-card { font-size: 15px; }
}
/* Coaching on a phone: the header steps aside, the cube gets smaller, and the
   step and its button come straight under it, all on one screen. */
@media (max-width: 760px) {
  body.coaching .site-header, body.coaching .play-head { display: none; }
  body.coaching .play { padding-top: 8px; }
  .play-area[data-mode="coach"] { gap: 10px; }
  .play-area[data-mode="coach"] .stage { height: clamp(220px, 38vh, 400px); height: clamp(220px, 38svh, 400px); }
  .coach { gap: 10px; }
  .coach-bar { order: 1; }
  .coach .intro, .coach .step { order: 2; }
  .coach .wrong { order: 3; }
  .coach .actions { order: 4; }
  .coach .status { order: 5; }
  .coach-head { order: 6; }
  .coach .meta { order: 7; }
  .coach .card { padding: 12px 14px; }
  .step .chips { margin-bottom: 6px; }
  .notation { font-size: 18px; padding: 6px 10px; }
  .step h3 { font-size: 20px; margin-bottom: 4px; }
  .step .detail { font-size: 15px; line-height: 1.45; }
  .step .note { margin-top: 8px; padding: 8px 10px; font-size: 14px; }
  .coach .btn { min-height: 50px; }
  .coach-head h2 { font-size: 20px; margin: 0 0 8px; }
  .intro .goal { font-size: 17px; margin-bottom: 6px; }
  .intro-more > summary {
    display: list-item; cursor: pointer; font-size: 15px; font-weight: 600; color: var(--muted); margin: 0 0 10px;
  }
  .intro-more[open] > summary { margin-bottom: 8px; }
}
@media (hover: none) { .play-head .keys { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .status[data-tone="good"], .hint-card, .solved-card, .choice-card { animation: none; }
  .progress > span > span { transition: none; }
}
