/* learning_ui kit: mastery ring, course header bars, lesson sheet, unlock moment.
   Set --lp-accent on a parent to the subject colour (hub plum by default).
   Meaning never relies on colour alone: segment count, dot shape and labels carry it. */
:root {
  --lp-accent: #5B2E63; --lp-empty: #E3E0D6; --lp-amber: #C98A1B; --lp-gold: #B8923A;
  --lp-ink: #23271F; --lp-soft: #5F6557; --lp-line: #E4E5DD;
}

/* ── Ring ── */
.lp-ring { display: inline-grid; place-items: center; flex: none; line-height: 0; color: var(--lp-accent); }
.lp-ring--btn { padding: 4px; margin: -4px; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.lp-ring--btn:hover .lp-ring__svg { transform: scale(1.08); }
.lp-ring--btn:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 1px; }
.lp-ring__svg { overflow: visible; transition: transform .15s ease; }
.lp-ring__bg, .lp-ring__fg { fill: none; stroke-width: 3; }
.lp-ring__bg { stroke: var(--lp-empty); }
.lp-ring__fg { stroke: currentColor; stroke-linecap: butt; animation: lp-draw .5s ease both; }
.lp-ring__halo { fill: none; stroke: var(--lp-gold); stroke-width: .9; opacity: .9; }
@keyframes lp-draw { from { stroke-dashoffset: 8; opacity: .3; } to { stroke-dashoffset: 0; opacity: 1; } }

/* ── Course header: Progress (solid) vs Mastery (stages) ── */
.lp-head { display: grid; gap: 8px; margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--lp-line);
  border-radius: 14px; background: #fff; color: var(--lp-ink); }
.lp-head__title { margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--lp-soft); }
.lp-head__row { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.lp-head__k { font-size: 13px; font-weight: 600; color: var(--lp-soft); }
.lp-head__v { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lp-head__how { display: inline-block; margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--lp-accent); text-decoration: none; }
.lp-head__how:hover { text-decoration: underline; }
.lp-head__v--muted { color: var(--lp-soft); font-weight: 500; }
.lp-bar, .lp-stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--lp-empty); }
.lp-bar > i { display: block; background: var(--lp-accent); border-radius: 99px; transition: width .6s ease; }
.lp-bar > i:not([style*="width:0%"]) { min-width: 8px; }   /* 2 of 167 is still visibly started */
.lp-stack { gap: 2px; background: transparent; }
.lp-stack--empty { background: repeating-linear-gradient(90deg, var(--lp-empty) 0 6px, transparent 6px 9px); }
.lp-sw { display: block; height: 100%; min-width: 4px; }
.lp-sw--learning   { background: color-mix(in srgb, var(--lp-accent) 30%, #fff); }
.lp-sw--practicing { background: color-mix(in srgb, var(--lp-accent) 50%, #fff); }
.lp-sw--familiar   { background: color-mix(in srgb, var(--lp-accent) 70%, #fff); }
.lp-sw--strong     { background: repeating-linear-gradient(135deg, var(--lp-accent) 0 5px, color-mix(in srgb, var(--lp-accent) 82%, #fff) 5px 7px); }
.lp-sw--mastered   { background: var(--lp-accent); box-shadow: inset 0 -2px 0 var(--lp-gold); }
.lp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--lp-soft); }
.lp-legend li { display: inline-flex; align-items: center; gap: 6px; }
.lp-legend .lp-sw { width: 14px; height: 8px; border-radius: 2px; }
@media (max-width: 520px) {
  .lp-head__row { grid-template-columns: 64px minmax(0, 1fr); }
  .lp-head__v { grid-column: 2; white-space: normal; }
}

/* ── Unlock moment: the newly opened tile, once ── */
.lp-just-unlocked { position: relative; animation: lp-unlock 1.2s ease both; }
.lp-just-unlocked::after { content: 'Unlocked'; position: absolute; top: -10px; right: 14px; z-index: 2; padding: 3px 9px; border-radius: 99px;
  font: 700 11px/1.4 system-ui, sans-serif; letter-spacing: .04em; color: #fff; background: var(--lp-accent);
  animation: lp-tag 3.2s ease both; pointer-events: none; }
@keyframes lp-unlock { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lp-accent) 45%, transparent); }
  40% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--lp-accent) 18%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes lp-tag { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ── Lesson detail sheet ── */
.lp-sheet { position: fixed; inset: 0; margin: auto; height: fit-content; width: min(460px, calc(100vw - 32px)); max-height: min(80vh, 640px); padding: 0; border: 0; border-radius: 18px;
  color: var(--lp-ink); box-shadow: 0 30px 80px -20px rgba(20, 20, 30, .45); }
.lp-sheet::backdrop { background: rgba(20, 22, 28, .38); }
.lp-sheet__in { padding: 22px 22px 20px; }
.lp-sheet__top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.lp-sheet__title { margin: 0; font-size: 19px; line-height: 1.25; }
.lp-sheet__stage { margin: 2px 0 0; font-size: 14px; color: var(--lp-soft); }
.lp-sheet__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.lp-sheet__cell { padding: 10px; border-radius: 10px; background: #FAF8F3; text-align: center; }
.lp-sheet__cell b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.lp-sheet__cell span { font-size: 12px; color: var(--lp-soft); }
.lp-sheet__qs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; font-size: 13.5px; color: var(--lp-soft); }
.lp-sheet__qs span { display: inline-flex; align-items: center; gap: 6px; }
.lp-sheet__qs .lp-sw { width: 14px; height: 8px; border-radius: 2px; }
.lp-sheet__step { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.5;
                  background: color-mix(in srgb, var(--lp-accent) 7%, #fff); }
.lp-sheet__step b { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--lp-accent); }
.lp-sheet__how { margin: 10px 0 0; font-size: 13.5px; }
.lp-sheet__how a { color: var(--lp-accent); font-weight: 600; }
.lp-sheet__row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.lp-sheet__btn { min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--lp-line); background: #fff;
  font: inherit; font-weight: 600; color: var(--lp-ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.lp-sheet__btn--solid { background: var(--lp-accent); border-color: var(--lp-accent); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .lp-ring__fg, .lp-just-unlocked, .lp-just-unlocked::after, .lp-bar > i { animation: none; transition: none; }
}

/* A finished lesson (its check passed: lesson_states()[key]['completed']) on any app's lesson list looks the same:
   a soft green card (Japanese Vocabulary's look) and a "✓ Done" tag. !important on purpose: each app styles its own
   card (hover borders, stripes, tints) and this one rule has to win over all of them. */
.lp-done { background: #EDF7EF !important; border-color: #CFE6D4 !important; }
.lp-done-tag { display: inline-flex; align-items: center; gap: 3px; flex: none; padding: 2px 9px; border-radius: 99px;
  font: 700 11.5px/1.5 var(--font-body, system-ui, sans-serif); letter-spacing: 0; text-transform: none;
  color: #2E7D4F; background: #DCEFE1; white-space: nowrap; }
