/* play.css — the Play page: free play, guided solve and watch it solve.
   Builds on rubiks.css (and coach.css for the coach panel); colours are tokens only.
   body[data-play-mode="free|guided|watch"] says which mode is showing. */

.play-hero { margin-bottom: 14px; }

/* ── the mode switch ───────────────────────────────────────────────────────── */
.play-modes {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin: 0 0 18px; max-width: 860px;
}
.play-modes button {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  min-block-size: 60px; padding: 10px 14px; text-align: left;
  font: inherit; color: var(--ink-dim); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.play-modes button:hover { color: var(--ink); border-color: var(--line-strong); }
.play-modes button svg {
  flex: none; width: 36px; height: 36px; padding: 8px; border-radius: 50%;
  background: var(--surface-sunken); border: 1px solid var(--line); color: var(--ink-dim);
}
.play-modes .pm-text { display: flex; flex-direction: column; min-width: 0; }
.play-modes .pm-label { font-weight: 700; color: var(--ink); line-height: 1.25; }
.play-modes .pm-sub { font-size: 0.8rem; line-height: 1.3; }
.play-modes button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.play-modes button[aria-pressed="true"] svg { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* what each mode shows */
body:not([data-play-mode="free"]) .free-only { display: none !important; }
body[data-play-mode="watch"] .no-watch { display: none !important; }
body[data-play-mode="free"] .play-coach { display: none; }

/* ── the setup card (guided and watch) ─────────────────────────────────────── */
.play-setup { padding: 14px 16px; }
.play-setup .setup-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.play-setup .panel-title { margin: 0 0 10px; }
.play-setup.is-running .panel-title { margin: 0; color: var(--accent-text); }
.setup-summary { margin: 0; font-size: 0.9rem; color: var(--ink); font-weight: 600; min-width: 0; }
.setup-fields { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.setup-fields .field { min-width: min(100%, 190px); flex: 1 1 190px; }
.setup-fields .setup-method { flex: 1.3 1 220px; }
.setup-options { display: contents; }
.setup-fields select { width: 100%; }
.setup-blurb { margin: 8px 0 0; font-size: 0.86rem; color: var(--ink-dim); }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.play-setup.is-running .setup-actions { margin-top: 10px; }
.play-setup.is-running .setup-actions .btn { min-block-size: 38px; padding: 0 12px; font-size: 0.88rem; }
.setup-msg { margin: 8px 0 0; font-size: 0.84rem; color: var(--ink-faint); }
.setup-msg:empty { display: none; }
/* while the coach runs it is one line: what it is doing, and three buttons */
.play-setup.is-running {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; padding: 10px 14px;
}
.play-setup.is-running .setup-head { flex: 1 1 260px; min-width: 0; }
.play-setup.is-running .setup-actions { margin-top: 0; }

/* Phones and small tablets: the coach docks at the bottom (coach.css), so the cube
   fits in the space between the app bar and the sheet's usual height. play.js keeps
   --play-bar-h up to date; coach-panel.js sets --coach-peek-h. */
@media (max-width: 979px) {
  body.has-coach-sheet .play-stage {
    max-height: max(170px, calc(100svh - var(--play-bar-h, 100px) - var(--coach-peek-h, 300px) - 20px));
    min-height: 0;
  }
}

/* the coach in the side column: sticky, never taller than the window */
@media (min-width: 980px) {
  body:not([data-play-mode="free"]) .play-coach .coach {
    max-height: calc(100vh - var(--bar-h) - 24px); overflow: auto; overscroll-behavior: contain;
  }
}
.play-coach:empty { display: none; }

/* before Start: what the coach will do (play.js hides it once the coach is running) */
body[data-play-mode="free"] .play-intro { display: none; }
.play-intro .panel-title { margin: 0 0 14px; }
.intro-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.intro-list[hidden] { display: none; }
.intro-list li {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; align-items: start;
  font-size: 0.92rem; line-height: 1.5; color: var(--ink-dim);
}
.intro-list strong { color: var(--ink); }
.intro-list .kbd { font-size: 0.78rem; }
.intro-icon {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.intro-icon svg { width: 18px; height: 18px; }
.intro-move { font-family: var(--font-mono); font-weight: 800; font-size: 0.92rem; letter-spacing: -0.02em; }

/* turn buttons: the coach's next move */
.play-pad .pad-btn.is-next {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); border-style: solid;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Cube column + tools column; one column on phones and small tablets. */
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (min-width: 980px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
  .play-side { position: sticky; top: calc(var(--bar-h) + 12px); }
}
.play-main, .play-side { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.play-side > .panel + .panel { margin-top: 0; }

/* size picker */
.play-sizes { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.play-sizes .seg button { min-inline-size: 44px; padding: 0 9px; font-variant-numeric: tabular-nums; }
.play-size-other { display: flex; align-items: center; gap: 6px; }
.play-size-other label { font-size: var(--fs-small); color: var(--ink-dim); font-weight: 600; }
.play-size-other input { width: 4.6em; min-block-size: 40px; padding: 6px 8px; }

/* the cube */
.play-stage { max-height: min(72vh, 760px); min-height: 280px; }

.play-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.play-toolbar .play-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.play-scramble { font-size: var(--fs-small); color: var(--ink-dim); }
.play-scramble summary { cursor: pointer; min-block-size: 32px; display: flex; align-items: center; }
.play-scramble .alg { display: block; margin-top: 4px; overflow-wrap: anywhere; color: var(--ink); }

/* on-screen turn buttons: 6 across on every width */
.play-pad {
  display: grid; gap: 6px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.play-pad .pad-btn {
  min-inline-size: 0; padding: 0 4px; min-block-size: 44px;
  font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.play-pad .pad-btn.is-rot { color: var(--ink-dim); border-style: dashed; }
.play-pad-panel .panel-title { margin: 0; }
.play-pad-panel .row.spread { margin-bottom: 12px; }

/* The whole label is the 44px touch target, so the box itself can be normal size. */
.play-check {
  display: inline-flex; align-items: center; gap: 10px;
  min-block-size: 44px; font-size: 0.92rem; color: var(--ink); cursor: pointer;
}
.play-check input {
  width: 20px; height: 20px; min-block-size: 0; min-inline-size: 0;
  accent-color: var(--accent); margin: 0; flex: none;
}

/* timer */
.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.6rem, 2rem + 2.4vw, 3.6rem); font-weight: 800; line-height: 1.1;
  letter-spacing: -0.02em; color: var(--ink);
}
.timer-display[data-phase="inspecting"] { color: var(--warn); }
.timer-display[data-phase="running"] { color: var(--accent-text); }
.timer-display[data-phase="done"] { color: var(--safe-text); }
.timer-status { color: var(--ink-dim); font-size: 0.92rem; margin: 6px 0 8px; min-height: 2.8em; }
.timer-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin: 10px 0; padding: 10px; border-radius: var(--radius);
  background: var(--surface-sunken); border: 1px solid var(--line);
}
.timer-stats div { min-width: 0; }
.timer-stats dt { font-size: 0.75rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.timer-stats dd { margin: 2px 0 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.timer-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 240px; overflow: auto; }
.timer-list li {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 5px 2px; border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.timer-list li:last-child { border-bottom: 0; }
.timer-list li .mono { font-family: inherit; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-list li.is-best .mono { color: var(--safe-text); }
.timer-list li .faint { font-size: 0.8rem; text-align: right; }

/* algorithm box */
.play-alg textarea { width: 100%; font-family: var(--font-mono); font-size: 1rem; }
.alg-msg { min-height: 1.5em; margin: 6px 0 10px; font-size: var(--fs-small); color: var(--ink-dim); }
.alg-msg.is-bad { color: var(--danger); }
.alg-msg.is-ok { color: var(--safe-text); }

.play-more .field { margin-bottom: 8px; }
.play-more input[type="range"] { width: 100%; }
.play-more output { font-family: var(--font-mono); color: var(--ink); margin-left: 4px; }
.play-more hr { margin: 14px 0; }

/* keyboard help */
.keys { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.keys td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys td:first-child { white-space: nowrap; width: 1%; padding-right: 14px; }
.keys tr:last-child td { border-bottom: 0; }

@media (max-width: 700px) {
  .play-modes { gap: 6px; margin-bottom: 14px; }
  .play-modes button { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 4px; text-align: center; min-block-size: 64px; }
  .play-modes button svg { width: 30px; height: 30px; padding: 6px; }
  .play-modes .pm-text { align-items: center; }
  .play-modes .pm-label { font-size: 0.82rem; }
  .play-modes .pm-sub { display: none; }
  /* with the coach on, keep the heading short so the cube fits above the sheet */
  body:not([data-play-mode="free"]) .play-hero .lede { display: none; }
  body:not([data-play-mode="free"]) .play-hero { margin-bottom: 10px; }
}
@media (max-width: 560px) {
  /* 2×2…9×9 as two tidy rows of four */
  .play-sizes .seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .play-sizes .seg button { padding: 0 4px; }
}
@media (max-width: 480px) {
  .play-toolbar .btn { padding: 0 12px; }
  .play-toolbar .play-count { margin-left: 0; }
  .keys td:first-child { white-space: normal; }
}

/* ── quick menus, the pattern bar and Quick learn's practice bar ───────────── */
.play-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.play-quick[hidden], .play-pattern[hidden], .play-practice[hidden] { display: none; }

.play-pattern, .play-practice {
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
.play-practice { border-color: var(--accent-line); background: var(--accent-soft); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.play-practice .row { gap: 6px; }
.pb-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.pb-line { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pb-label {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-text); margin-right: 4px;
}
.pb-moves {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px;
  font-family: var(--font-mono); font-size: 0.92rem;
}
.pb-moves li {
  min-inline-size: 2.4em; padding: 2px 6px; text-align: center; border-radius: var(--radius-sm);
  background: var(--surface-sunken); border: 1px solid var(--line); color: var(--ink);
}
.pb-moves li.is-done { color: var(--ink-faint); }
.pb-moves li.is-now { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pb-status { margin: 6px 0 0; font-size: var(--fs-small); color: var(--ink-dim); }
.pb-status:empty { display: none; }

/* practising: the coach has the side column, and the free-play tools step aside */
body[data-practice] .free-only { display: none !important; }
body[data-play-mode="free"][data-practice] .play-coach { display: block; }

/* ── the two menus: a drawer at the side, a bottom sheet on phones ─────────── */
dialog.play-sheet {
  width: min(560px, calc(100vw - 24px));
  display: none; flex-direction: column; overflow: hidden;
}
dialog.play-sheet[open] { display: flex; }
dialog.play-sheet .rk-dialog-body { flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
@media (max-width: 640px) {
  dialog.play-sheet {
    width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 86svh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-bottom: 0;
  }
  dialog.play-sheet .rk-dialog-body { max-height: none; padding: 12px; }
}

/* Apply a pattern */
.pm-lead { margin: 0 0 12px; }
.pm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pm-item {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-hi);
}
.pm-item.is-current { border-color: var(--accent-line); background: var(--accent-soft); }
.pm-pic { display: block; width: 72px; height: 72px; }
.pm-pic svg { display: block; width: 100%; height: 100%; }
.pm-text { min-width: 0; }
.pm-name { margin: 0; font-weight: 700; color: var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.pm-on { font-size: 0.72rem; }
.pm-meta { margin: 0; font-size: 0.8rem; color: var(--ink-dim); }
.pm-desc {
  margin: 4px 0 0; font-size: 0.86rem; color: var(--ink-dim); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pm-more { margin: 14px 0 0; }
@media (max-width: 400px) {
  .pm-item { grid-template-columns: 56px minmax(0, 1fr); gap: 10px; }
  .pm-pic { width: 56px; height: 56px; }
}

/* Quick learn */
.ql-lead { margin: 0 0 12px; }
.ql-other {
  margin: 0 0 14px; padding: 12px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.ql-other[hidden] { display: none; }
.ql-other p { margin: 0 0 10px; color: var(--ink); }
.ql-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ql-step { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-hi); }
.ql-title { margin: 0; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.ql-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.8rem; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line);
}
.ql-goal { margin: 4px 0 0; font-size: 0.88rem; color: var(--ink-dim); }
.ql-keys { margin: 6px 0 0; font-size: 0.86rem; color: var(--ink-dim); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ql-keys .alg { overflow-wrap: anywhere; }
.ql-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); }
.ql-key { min-width: 0; }
.ql-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ql-links { margin: 14px 0 0; }
