/* Learn Suite — shared "house style".
 * Kid-friendly, warm, high-contrast, accessible. Used by every learn app's chrome
 * (top bar, panels, buttons, sliders, toast, modal). The canvas/WebGL surface draws
 * its own colours; this styles the surrounding UI. Tokens only — retheme in one place. */

@font-face {
  font-family: 'Nunito';
  src: url('/learn/_vendor/fonts/nunito.woff2') format('woff2');
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --lx-font: 'Nunito', ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --lx-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, monospace;

  --lx-bg: #fbf7ef;          /* warm paper */
  --lx-bg-2: #f1ece1;
  --lx-surface: #ffffff;
  --lx-surface-2: #f7f3ea;
  --lx-ink: #1f2a33;         /* near-black, ~13:1 on paper */
  --lx-ink-soft: #4a5560;    /* AA on surface */
  --lx-muted: #6b7680;       /* AA on surface for ≥16px */
  --lx-line: #e2dccd;
  --lx-line-strong: #cdc6b4;

  --lx-accent: #2f6f7a;      /* deep teal */
  --lx-accent-ink: #ffffff;
  --lx-accent-soft: #e2f0f1;
  --lx-amber: #c77f33;
  --lx-good: #2e7d4f;
  --lx-good-soft: #e4f3e9;
  --lx-warn: #b4592b;
  --lx-danger: #b23a3a;
  --lx-focus: #1d6fd6;       /* high-contrast focus ring */

  --lx-r: 14px;              /* radius */
  --lx-r-sm: 9px;
  --lx-r-lg: 20px;
  --lx-shadow: 0 1px 2px rgba(31,42,51,.06), 0 8px 24px rgba(31,42,51,.10);
  --lx-shadow-sm: 0 1px 2px rgba(31,42,51,.08);
  --lx-tap: 44px;           /* min touch target */
  --lx-ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; width: 100%;
  background: var(--lx-bg); color: var(--lx-ink);
  font-family: var(--lx-font); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
body { overflow: hidden; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--lx-focus); outline-offset: 2px; border-radius: 6px; }

.lx-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lx-skip {
  position: fixed; left: 12px; top: -60px; z-index: 1000;
  background: var(--lx-accent); color: #fff; padding: 10px 16px; border-radius: var(--lx-r-sm);
  transition: top .15s var(--lx-ease); font-weight: 700;
}
.lx-skip:focus { top: 12px; }

/* ── Top bar ── */
.lx-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--lx-surface); border-bottom: 1px solid var(--lx-line);
  box-shadow: var(--lx-shadow-sm); position: relative; z-index: 5;
}
.lx-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; color: var(--lx-ink); }
.lx-brand .lx-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--lx-accent-soft); color: var(--lx-accent); font-size: 18px; flex: none;
}
.lx-tag { color: var(--lx-muted); font-size: 13.5px; font-weight: 600; }
.lx-spacer { flex: 1 1 auto; }

/* ── Buttons ── */
.lx-btn {
  font: inherit; font-weight: 700; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--lx-tap); padding: 0 16px; border-radius: var(--lx-r-sm);
  background: var(--lx-surface); color: var(--lx-ink); border: 1.5px solid var(--lx-line-strong);
  transition: transform .08s var(--lx-ease), background .15s, border-color .15s, box-shadow .15s;
}
.lx-btn:hover { border-color: var(--lx-accent); }
.lx-btn:active { transform: translateY(1px); }
.lx-btn[disabled] { opacity: .45; cursor: not-allowed; }
.lx-btn--primary { background: var(--lx-accent); color: var(--lx-accent-ink); border-color: var(--lx-accent); }
.lx-btn--primary:hover { filter: brightness(1.06); }
.lx-btn--ghost { background: transparent; border-color: transparent; }
.lx-btn--ghost:hover { background: var(--lx-surface-2); border-color: transparent; }
.lx-btn--round { width: var(--lx-tap); min-width: var(--lx-tap); padding: 0; border-radius: 999px; }
.lx-btn--lg { min-height: 56px; font-size: 18px; padding: 0 22px; border-radius: var(--lx-r); }
.lx-iconbtn {
  width: var(--lx-tap); height: var(--lx-tap); min-width: var(--lx-tap);
  display: grid; place-items: center; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1.5px solid transparent; color: var(--lx-ink-soft); font-size: 19px;
}
.lx-iconbtn:hover { background: var(--lx-surface-2); color: var(--lx-ink); }

/* Narrow screens (phones): trim the bar to essentials so every action icon stays reachable.
   Covers both the engine template (.lge-dots, #brand-title) and standalone games (.dots). */
@media (max-width: 560px) {
  .lx-topbar { gap: 7px; padding: 8px 10px; }
  .lx-brand { font-size: 0; gap: 0; }                /* hide the wordmark text, keep the colour chip */
  .lx-tag { display: none; }                          /* "Puzzle N of M" label */
  .lx-topbar .lge-dots, .lx-topbar .dots { display: none; }  /* progress dots — descendant selector beats engine.css; returns ≥561px */
  .lx-iconbtn { width: 40px; height: 40px; min-width: 40px; font-size: 18px; }
}

/* ── Panels / cards ── */
.lx-panel { background: var(--lx-surface); border: 1px solid var(--lx-line); border-radius: var(--lx-r); box-shadow: var(--lx-shadow-sm); }
.lx-card { background: var(--lx-surface); border: 1px solid var(--lx-line); border-radius: var(--lx-r); padding: 14px 16px; }
.lx-card h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--lx-accent); }
.lx-cite { font-size: 13px; color: var(--lx-ink-soft); }
.lx-cite b { color: var(--lx-ink); }
.lx-note { display: none; margin-top: 10px; padding: 10px 12px; border-radius: var(--lx-r-sm); font-size: 13.5px;
  background: #fbeee6; border: 1px solid #eccdb9; color: #8a3d20; }
.lx-note.show { display: block; }
.lx-note b { color: var(--lx-warn); }

/* ── Segmented control (radiogroup) ── */
.lx-seg { display: inline-flex; background: var(--lx-surface-2); border: 1px solid var(--lx-line); border-radius: 999px; padding: 3px; gap: 2px; }
.lx-seg button { font: inherit; font-weight: 700; font-size: 14px; border: 0; background: transparent; color: var(--lx-ink-soft);
  min-height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer; }
.lx-seg button[aria-pressed="true"], .lx-seg button.on { background: var(--lx-surface); color: var(--lx-accent); box-shadow: var(--lx-shadow-sm); }

/* ── Sliders ── */
.lx-row { display: grid; gap: 6px; margin: 12px 0; }
.lx-row .lx-lab { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.lx-row .lx-lab b { font-variant-numeric: tabular-nums; color: var(--lx-accent); font-family: var(--lx-mono); }
input[type=range].lx-range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; }
.lx-range::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: var(--lx-line-strong); }
.lx-range::-moz-range-track { height: 8px; border-radius: 999px; background: var(--lx-line-strong); }
.lx-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; margin-top: -8px; width: 24px; height: 24px; border-radius: 999px;
  background: var(--lx-accent); border: 3px solid #fff; box-shadow: var(--lx-shadow-sm); }
.lx-range::-moz-range-thumb { width: 24px; height: 24px; border: 3px solid #fff; border-radius: 999px; background: var(--lx-accent); box-shadow: var(--lx-shadow-sm); }

.lx-check { display: inline-flex; align-items: center; gap: 9px; min-height: var(--lx-tap); cursor: pointer; font-weight: 600; font-size: 14.5px; }
.lx-check input { width: 22px; height: 22px; accent-color: var(--lx-accent); }

/* ── Toast (aria-live) ── */
.lx-toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(10px);
  background: var(--lx-ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 700; font-size: 15px;
  box-shadow: var(--lx-shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--lx-ease); z-index: 60; max-width: 90vw; text-align: center;
}
.lx-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Modal ── */
.lx-modal-bg { position: fixed; inset: 0; background: rgba(31,42,51,.5); backdrop-filter: blur(3px); display: none; place-items: center; z-index: 80; padding: 18px; }
.lx-modal-bg.show { display: grid; }
.lx-modal { background: var(--lx-surface); border-radius: var(--lx-r-lg); box-shadow: var(--lx-shadow); max-width: 540px; width: 100%; max-height: 86vh; overflow: auto; padding: 24px 26px; }
.lx-modal h2 { margin: 0 0 12px; font-size: 22px; }
.lx-modal p { color: var(--lx-ink-soft); }

/* ── Hint / kbd / chip ── */
.lx-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(31,42,51,.82); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; pointer-events: none; transition: opacity .4s; z-index: 8; }
.lx-kbd { font-family: var(--lx-mono); font-size: 12px; background: var(--lx-surface-2); border: 1px solid var(--lx-line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--lx-ink-soft); }
.lx-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--lx-accent-soft); color: var(--lx-accent); font-weight: 700; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; }

/* ── Loading splash ── */
.lx-load { position: fixed; inset: 0; display: grid; place-items: center; background: var(--lx-bg); z-index: 200; transition: opacity .4s; }
.lx-load.hide { opacity: 0; pointer-events: none; }
.lx-load .in { text-align: center; color: var(--lx-ink-soft); font-weight: 700; }
.lx-spin { width: 42px; height: 42px; margin: 0 auto 14px; border-radius: 999px; border: 4px solid var(--lx-line); border-top-color: var(--lx-accent); animation: lx-spin 1s linear infinite; }
@keyframes lx-spin { to { transform: rotate(360deg); } }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .lx-spin { animation: none; }
}
