/*
  LD2-B: the end of a lesson (Views/Courses/_LessonEnd.cshtml, js/lessonend.js; LD2-pinnacle.md §5.2). One card on the
  stage that builds itself: the world's picture completing as a band across the top with the title on it, then the
  beats side by side: what you learnt (the recap and the three counts) beside your deed and what you kept; the next
  lesson is the action bar's main link, the quieter ways on sit at the foot. Loaded by the lesson view only.
*/

.ln .ln-player--stage .ln-screen--end .ln-end { width: var(--ln-stage-w); max-width: none; padding: 0 0 26px; gap: 0; justify-items: stretch; text-align: start; overflow: hidden; border-radius: 26px; background: var(--ln-card); box-shadow: var(--ln-z2); }

/* ---------- The world's picture completes, the title on it ---------- */
.ln .ln-player--stage .ln-end-art { width: 100%; aspect-ratio: auto; height: clamp(190px, 30vh, 290px); margin: 0; border-radius: 0; box-shadow: none; }
/* The scene keeps its own shape, its middle (the place and its route) in the band. */
.ln .ln-player--stage .ln-end-art .ln-scene-wrap { position: absolute; inset: 0; height: auto; overflow: hidden; }
.ln .ln-player--stage .ln-end-art .ln-scene-wrap > svg { position: absolute; inset: auto 0 0; width: 100%; height: auto; }
.ln-end-head { position: absolute; inset: auto 0 0; padding: 40px 34px 18px; color: #fff; background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--w-deep) 82%, transparent)); }
.ln .ln-player--stage .ln-end-head .ln-kicker { margin: 0 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--w-glow); }
.ln .ln-player--stage .ln-end-title:focus { outline: none; }
.ln .ln-player--stage .ln-end-title { margin: 0; color: #fff; font-size: clamp(28px, 3.2vw, 40px); line-height: 1.08; text-wrap: balance; }
.ln .ln-player--stage .ln-end-head .ln-end-sub { margin: 4px 0 0; max-width: 70ch; font-size: 14px; color: rgba(255, 255, 255, .82); }

/* ---------- The beats ---------- */
.ln-end-beats { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-areas: "learnt deed" "learnt kept"; align-items: start; gap: 18px 26px; padding: 26px 34px 6px; }
.ln-end-beats:not(:has(.ln-end-deed)) { grid-template-areas: "learnt kept"; }
.ln-end-beat { display: grid; gap: 10px; min-width: 0; }
.ln-end-beat h3 { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--w-ink); }
.ln-end-beat h3::before { content: ""; flex: none; width: 22px; height: 2px; border-radius: 2px; background: var(--w-accent); }
.ln-end-learnt { grid-area: learnt; }
.ln-end-deed { grid-area: deed; }
.ln-end-kept { grid-area: kept; }
.ln-end-kept[hidden] { display: none; }

/* What you learnt: the recap's lines, then the counts of this run. */
.ln-end-recap { display: grid; gap: 8px; font-size: 16.5px; line-height: 1.5; color: var(--ln-ink-2); }
.ln-end-recap li { position: relative; padding-inline-start: 26px; }
.ln-end-recap li::before { content: "✓"; position: absolute; inset-inline-start: 0; top: .1em; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--ln-on-good, #fff); background: var(--ln-good); }
.ln-end-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.ln-end-counts[hidden] { display: none; }
.ln-end-counts div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 2px; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--w-accent) 11%, var(--ln-card)); }
.ln-end-counts dt { font-size: 13px; font-weight: 650; color: var(--ln-muted); line-height: 1.25; }
.ln-end-counts dd { margin: 0; font-family: var(--ln-display); font-weight: 600; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--w-ink); }

/* Your deed: the "Try it today" card, carried into the day. */
.ln-end-deed { padding: 16px 18px; border-radius: 18px; background: linear-gradient(135deg, color-mix(in srgb, var(--w-glow) 22%, var(--ln-card)), color-mix(in srgb, var(--w-glow) 36%, var(--ln-card))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--w-accent) 45%, transparent); }
.ln-end-deed .ln-prose { font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--ln-ink); }
.ln-end-deed .ln-today-icon { display: none; }
.ln-end-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.ln .ln-end-pill { min-height: 42px; padding: 0 15px; border-radius: 12px; font-size: 14px; font-weight: 750; color: var(--ln-ink); background: var(--ln-card); box-shadow: inset 0 0 0 1.5px var(--ln-line-2); transition: background var(--ip-motion-base), box-shadow var(--ip-motion-base); }
.ln .ln-end-pill:hover { box-shadow: inset 0 0 0 2px var(--w-accent); }
.ln .ln-end-pill--yes { color: var(--ln-paper); background: var(--ln-ink); box-shadow: none; }
.ln .ln-end-pill.is-on { color: var(--ln-on-good, #fff); background: var(--ln-good); box-shadow: none; }
.ln .ln-end-pill.is-on::before { content: "✓ "; }
.ln-end-said { font-size: 13.5px; font-weight: 650; color: var(--ln-good-ink, var(--ln-good)); }
.ln-end-said:empty { display: none; }

/* What you kept. */
.ln-end-kept ul { display: flex; flex-wrap: wrap; gap: 8px; }
.ln-end-kept li { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; font-size: 14px; font-weight: 650; color: var(--ln-ink); background: color-mix(in srgb, var(--w-accent) 10%, var(--ln-card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--w-accent) 25%, transparent); }
.ln-end-kept-mark { color: var(--w-ink); }

/* The ways on: the next lesson is the action bar's; without scripts it leads here. */
.ln-end-next { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px 18px; padding: 14px 34px 0; }
.ln-player--stage.is-live .ln-end-primary { display: none; }
.ln-end-next [hidden] { display: none; }
.ln-end-back { font-size: 14px; font-weight: 650; color: var(--ln-muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ln-line-2); }
.ln-end-back:hover { color: var(--ln-ink); }
.ln .ln-player--stage .ln-end > .ln-note { padding: 8px 34px 0; text-align: end; }

/* ---------- The look's celebration as the end arrives ---------- */
.ln-player--stage .is-celebrating .ln-end-beat { animation: ln-end-beat var(--ln-in) both; }
.ln-player--stage .is-celebrating .ln-end-deed { animation-delay: 120ms; }
.ln-player--stage .is-celebrating .ln-end-kept { animation-delay: 220ms; }
@keyframes ln-end-beat { from { opacity: 0; transform: translateY(calc(var(--ln-rise) * .6)); } }

/* Teens: the bold plane and a hard edge on the deed. */
.ln--teen .ln-player--stage .ln-screen--end .ln-end { border-radius: 14px; box-shadow: 8px 8px 0 var(--w-accent, #8b5cf6), 0 30px 60px -30px rgba(0, 0, 0, .8); }
.ln--teen .ln-end-title { font-weight: 800; letter-spacing: -.025em; }
.ln--teen .ln-end-deed { border-radius: 12px; box-shadow: inset 0 0 0 2px #22d3ee, 4px 4px 0 #8b5cf6; }
.ln--teen .ln-end-counts dd { font-family: var(--ln-sans); font-weight: 850; color: #22d3ee; }

/* Kids: round and bright; a star for each line learnt. */
.ln--kid .ln-player--stage .ln-screen--end .ln-end { border-radius: 36px; }
.ln--kid .ln-end-title { font-weight: 800; }
.ln--kid .ln-end-recap { font-size: 20px; }
.ln--kid .ln-end-recap li::before { content: "★"; color: #2b2100; background: #ffd84d; }
.ln--kid .ln-end-deed { border-radius: 26px; }
.ln--kid .ln-end-pill { min-height: 58px; border-radius: 20px; font-size: 18px; }
.ln--kid .ln-end-pill--yes { color: #2b2100; background: linear-gradient(180deg, #ffc23d, #ff9f1a); box-shadow: 0 5px 0 #d97a00; }

/* ---------- Phones: one column ---------- */
@media (max-width: 760px) {
  .ln .ln-player--stage .ln-screen--end .ln-end { width: calc(100vw - 16px); border-radius: 22px; padding-bottom: 18px; }
  .ln .ln-player--stage .ln-end-art { height: 150px; }
  .ln-end-head { padding: 30px 18px 14px; }
  .ln .ln-player--stage .ln-end-title { font-size: 26px; }
  .ln-end-beats, .ln-end-beats:not(:has(.ln-end-deed)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "learnt" "deed" "kept"; gap: 16px; padding: 18px 16px 4px; }
  .ln-end-counts { gap: 6px; }
  .ln-end-counts div { padding: 10px; }
  .ln-end-counts dd { font-size: 24px; }
  .ln-end-counts dt { font-size: 12px; }
  .ln-end-next { justify-content: center; padding: 12px 16px 0; }
  .ln .ln-player--stage .ln-end > .ln-note { padding: 8px 16px 0; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .ln-player--stage .is-celebrating .ln-end-beat { animation: none; }
}
