/* ============================================================================
 * PlainLogic mobile-game components — assets/css/games-mobile.css
 *
 * Styles for window.PlainLogicGamesMobile (assets/js/games-mobile.js):
 * the game topbar (back link + title + motion toggle), HUD chips/badges,
 * HUD buttons (restart / undo / redo), and the collapsible "What you
 * learned" panel. Companion to assets/css/games.css — never overrides it.
 *
 * Uses the site tokens from lab.css (light + dark via [data-theme]).
 * Mobile-first: 375px clean, no horizontal overflow. Touch targets >= 44px,
 * no hover dependency. Correct/incorrect is never color-only.
 * ========================================================================== */

/* ---------- game topbar: back link + title + motion toggle ---------- */
.plgm-topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; max-width: 100%;
}
.plgm-back {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 14px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: .85rem;
  font-family: "DM Mono", monospace; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; flex: 0 0 auto;
  touch-action: manipulation;
}
.plgm-back:active { transform: translateY(1px); }
.plgm-title {
  flex: 1 1 auto; min-width: 0;
  font-family: "DM Mono", monospace; font-size: .78rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plgm-motion {
  flex: 0 0 auto; min-height: 44px; padding: 10px 14px;
  background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 999px;
  color: var(--muted); font-family: "DM Mono", monospace; font-size: .72rem;
  letter-spacing: .06em; text-transform: uppercase; cursor: pointer; white-space: nowrap;
  touch-action: manipulation;
}
.plgm-motion[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.plgm-motion:active { transform: translateY(1px); }

/* ---------- HUD row ---------- */
.plgm-hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 18px; max-width: 100%;
}

/* ---------- score chip ---------- */
.plgm-chip {
  display: inline-flex; align-items: baseline; gap: 8px;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px;
  padding: 8px 16px; font-family: "DM Mono", monospace; font-size: .8rem;
  color: var(--ink); white-space: nowrap;
}
.plgm-chip-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; color: var(--muted); }
.plgm-chip-num { font-size: 1.05rem; font-weight: 700; }

/* ---------- level / round badge ---------- */
.plgm-level {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 999px;
  padding: 8px 16px; font-family: "DM Mono", monospace; font-size: .8rem;
  color: var(--muted); white-space: nowrap;
}
.plgm-level b { color: var(--ink); font-size: 1.05rem; }
.plgm-level-of { font-size: .72rem; }

/* ---------- HUD buttons (restart / undo / redo) ---------- */
.plgm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 10px 18px;
  background: var(--paper); border: 1.5px solid var(--line-strong); border-radius: 14px;
  color: var(--ink); font: inherit; font-weight: 700; font-size: .92rem;
  cursor: pointer; touch-action: manipulation;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.plgm-btn:active { transform: translateY(1px); }
.plgm-btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.plgm-btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- collapsible "What you learned" panel ---------- */
details.plgm-learned {
  background: var(--card); border: 1.5px solid var(--ink);
  border-radius: var(--radius); margin-top: 26px; box-shadow: 0 3px 0 var(--ink);
  overflow: hidden;
}
summary.plgm-learned-summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 18px 20px;
  touch-action: manipulation;
}
summary.plgm-learned-summary::-webkit-details-marker { display: none; }
summary.plgm-learned-summary::marker { content: ""; }
.plgm-learned-head { flex: 1 1 auto; min-width: 0; }
.plgm-learned-head .eyebrow { display: block; margin: 0 0 4px; }
.plgm-learned-title {
  display: block; font-size: clamp(1.15rem, 4.2vw, 1.5rem); font-weight: 800;
  letter-spacing: -.02em; color: var(--ink); line-height: 1.3;
}
.plgm-learned-caret {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); display: grid; place-items: center;
  transition: transform .2s ease;
}
.plgm-learned-caret::before {
  content: ""; width: 10px; height: 10px;
  border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink);
  transform: rotate(45deg) translate(-2px, -2px);
}
details.plgm-learned[open] .plgm-learned-caret { transform: rotate(180deg); }
details.plgm-learned .plg-learned-list { padding: 0 20px 22px 20px; }

/* ---------- build CTA (mobile variant shares .plg-build card styles) ---------- */
.plgm-build { max-width: 100%; }

/* ---------- focus ---------- */
.plgm-topbar a:focus-visible, .plgm-topbar button:focus-visible,
.plgm-hud button:focus-visible, summary.plgm-learned-summary:focus-visible {
  outline: 3px solid var(--teal); outline-offset: 2px;
}

/* ---------- reduced motion: complete, playable, static ----------
 * Both the OS setting and the in-game toggle (html[data-motion="reduced"])
 * kill motion. The shell's own rules live in games.css. */
@media (prefers-reduced-motion: reduce) {
  .plgm-btn, .plgm-back, .plgm-motion, .plgm-learned-caret { transition: none; }
  .plgm-btn:active, .plgm-back:active, .plgm-motion:active { transform: none; }
  details.plgm-learned[open] .plgm-learned-caret { transform: none; }
}
html[data-motion="reduced"] .plgm-btn,
html[data-motion="reduced"] .plgm-back,
html[data-motion="reduced"] .plgm-motion,
html[data-motion="reduced"] .plgm-learned-caret { transition: none; }
html[data-motion="reduced"] .plgm-btn:active,
html[data-motion="reduced"] .plgm-back:active,
html[data-motion="reduced"] .plgm-motion:active { transform: none; }
html[data-motion="reduced"] details.plgm-learned[open] .plgm-learned-caret { transform: none; }
