/* The raised pop-up every work screen opens in (STORY-04.48, work-pop.js; SN, DECIDED, 2026-11-22): a lesson, a Basics unit,
   For every part, Words, a quiz, Try it, a practice set, a model test, a result, Review your mistakes and Today's five, over
   the page that opened it, which stays drawn behind a blurred, dimmed backdrop. Centred, at most 1680 px wide and 92% of the
   height, with at least 24 px of the page showing at each side and 32 px above and below (owner, 2026-11-22; work-pop.js
   popRect gives the same numbers); the whole viewport
   up to 860 px wide or 520 px tall (a phone, upright or on its side), with no backdrop showing. The screen inside fills it and scrolls inside it; the page behind keeps
   its place (html.wp-lock: the root does not scroll while it is open). */

.wp {
  box-sizing: border-box; width: min(1680px, calc(100vw - 48px)); height: min(92vh, calc(100vh - 64px)); max-width: none; max-height: none;
  margin: auto; padding: 0; border: 0; border-radius: var(--r-l);
  overflow: hidden; overflow: clip; /* clip: no script can scroll the box (STORY-04.59, OF eb96f9bb); hidden where clip is unknown */
  background: var(--exam-bg); color: var(--ink); box-shadow: var(--float), 0 0 0 1px var(--line-2);
}
.wp[open] { display: flex; flex-direction: column; }
.wp:focus { outline: none; }
.wp::backdrop { background: var(--scrim-pop); -webkit-backdrop-filter: blur(var(--scrim-blur)); backdrop-filter: blur(var(--scrim-blur)); }
.wp__in { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.wp__in > * { min-height: 0; min-width: 0; }
html.wp-lock { overflow: hidden; }

/* The frames fill the pop-up instead of the window (exam.css sizes them to the window). */
.wp .exam { height: auto; min-height: 0; }
.wp .exam-bar { min-height: 56px; padding-top: 0; }
.wp .exam.rf { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding-top: 72px; scroll-padding-bottom: 96px; }
.wp .try-frame .tr-try > .tr-prompt { max-height: calc(min(92vh, 100vh - 64px) - 120px); }
.wp > .save-notice { flex: none; padding: var(--s2) var(--s4); }
.wp__in > .wrap { overflow-y: auto; padding: var(--s5); }

/* A reader (views/journey-lesson.js): its bar, then the lesson scrolling under it, Back and Next at its foot. */
.wp .jl { display: flex; flex-direction: column; min-height: 0; height: 100%; gap: 0; background: var(--surface); }
.wp .jl-bar { flex: none; grid-template-columns: minmax(0, 1fr); }
.wp .jl__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s5) var(--s6) 0; }
.wp .jl__scroll > .jl__body { max-width: 1100px; margin-inline: auto; }
.wp .lp--embedded .lp-nav { bottom: 0; background: var(--surface); }

/* Opening: a short rise and fade, only for people who have not asked for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .wp[open] { animation: wp-rise 200ms var(--ease-out); }
  .wp[open]::backdrop { animation: wp-fade 200ms ease-out; }
}
@keyframes wp-rise { from { opacity: 0; transform: translateY(12px) scale(0.99); } }
@keyframes wp-fade { from { opacity: 0; } }

@media (max-width: 860px), (max-height: 520px) {
  .wp { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
  .wp::backdrop { background: var(--exam-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .wp .exam-bar { min-height: calc(48px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .wp .exam.rf { scroll-padding-bottom: 160px; }
  .wp .jl__scroll { padding: var(--s4) var(--s4) 0; }
  .wp .lp { min-height: 0; }
  .wp__in > .wrap { padding: var(--s4); }
}

/* ---- The purchase pop-up (STORY-04.50, views/purchase.js; the approved mock-up) and the catalog it shares with #/plans ---- */
/* As tall as its content (mock ruling 1), up to the work screens' height, at most 1400 px wide; a phone keeps the whole screen. */
@media (min-width: 861px) and (min-height: 521px) {
  .wp.wp--fit { width: min(1400px, calc(100vw - 48px)); height: fit-content; max-height: min(92vh, calc(100vh - 64px)); }
  .wp--fit .po { max-height: min(92vh, calc(100vh - 64px)); }
}
.po { display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--surface); color: var(--ink); }
.wp--fit .po { height: auto; }
.po-bar { flex: none; display: flex; align-items: center; gap: var(--s1); min-height: 60px; padding-inline: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.po-bar .po-x { margin-inline-start: 0; }
.po-bar__t { display: flex; align-items: center; gap: 8px; min-width: 0; font: 700 var(--fs-m)/1.2 var(--display); }
.po-bar__t > .i { color: var(--teal); }
.po-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 32px 40px 28px; }
.po-in { display: grid; gap: 28px; max-width: 1120px; margin-inline: auto; container-type: inline-size; }
.po-head { display: grid; gap: 18px; }
.po-ttl { display: flex; align-items: flex-start; gap: 16px; }
.po-ttl__gem { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border: 1px solid var(--teal-line); border-radius: var(--r-m); background: var(--teal-tint); color: var(--teal); }
.po-h { margin: 0; font: 700 1.875rem/1.12 var(--display); letter-spacing: -0.02em; text-wrap: balance; outline: none; }
.po-gives { display: grid; margin: 0; padding: 0; list-style: none; }
.po-gives li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: var(--fs-base); line-height: 1.45; }
.po-gives li:first-child { border-top: 0; padding-top: 0; }
.po-gives .i { color: var(--teal); margin-top: 1px; }
.po-stack { display: grid; gap: 14px; }
.po-load { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink-2); }
.po-callout { margin: 0; }
.po-callout__b { display: grid; gap: 12px; flex: 1; min-width: 0; }
.po-callout__b > p { margin: 0; font-weight: 600; }
.po-callout__a { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.po-error { margin: var(--s2) 0 0; color: var(--coral-deep); font-weight: 600; }
.po-foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 24px; padding: 10px 40px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.po-foot__t { margin: 0; max-width: 74ch; color: var(--ink-2); font-size: var(--fs-s); line-height: 1.45; }
.po-foot__t:empty { display: none; }
.po-foot__r { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.po-link, .po-quiet { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-weight: 700; font-size: var(--fs-s); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; cursor: pointer; }
.po-link { color: var(--teal); }
.po-quiet { color: var(--ink-2); font-weight: 600; font-size: var(--fs-base); }
.po-backto .i { margin-inline-end: 4px; }
.po-backrow { margin-bottom: var(--s3); }

/* The catalog: Free, Every month, Every 3 months; one column (Free as one line under the paid cards) until there is room. */
.po-catw { container-type: inline-size; min-width: 0; }
.po-cat { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.po-card { position: relative; display: grid; align-content: start; gap: 12px; min-width: 0; padding: 20px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--surface); }
.po-card--free { background: var(--paper-2); border-color: var(--line); }
.po-card--paid { grid-template-rows: auto 1fr auto; }
.po-card__top { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.po-card--free .po-card__top { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.po-card__h { margin: 0; font: 700 1.125rem/1.2 var(--display); }
.po-card__sub { margin: 0; color: var(--ink-2); font-size: var(--fs-s); line-height: 1.45; }
.po-card .plan__price { display: grid; gap: 4px; min-width: 0; max-width: 100%; font: 700 2rem/1.05 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.po-card .plan__tax { font: 700 var(--fs-xs)/1.4 var(--text); letter-spacing: 0; color: var(--ink-2); }
.po-card .plan__skel { display: inline-block; width: 150px; max-width: 100%; height: 34px; border-radius: 8px; background: var(--paper-2); }
.po-pay { min-height: 48px; }
.po-pay-wait { display: block; height: 48px; border-radius: 8px; background: var(--paper-2); }
.po-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--teal); font-size: var(--fs-s); font-weight: 700; }
.po-fl { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.po-fl li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; color: var(--ink-2); font-size: var(--fs-base); line-height: 1.45; }
.po-fl .i { color: var(--teal); margin-top: 2px; }
.po-free-n { display: none; }
.po-free-n summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--paper-2); cursor: pointer; list-style: none; }
.po-free-n summary::-webkit-details-marker { display: none; }
.po-free-n summary > .i { color: var(--ink-2); transition: transform 0.2s; }
.po-free-n[open] summary > .i { transform: rotate(180deg); }
.po-free-n[open] summary { border-end-start-radius: 0; border-end-end-radius: 0; }
.po-free-n .po-fl { padding: 14px 16px 16px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-m) var(--r-m); background: var(--paper-2); }
.po-free-n__g { display: inline-flex; align-items: center; gap: 12px; }
@container (min-width: 900px) {
  .po-head { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px 56px; align-items: start; }
  .po-cat { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (max-width: 899px) {
  .po-free-w { display: none; }
  .po-free-n { display: block; }
  .po-card--paid { grid-template-rows: none; gap: 4px 12px; padding: 14px 16px; }
  .po-card--paid .po-card__top { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
  .po-card--paid .plan__price { font-size: 1.5rem; justify-items: end; text-align: end; }
  .po-card--paid .po-pay { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { .po-free-n summary > .i { transition: none; } }
/* A phone: the pop-up is the whole screen; the bar stays at the top while the rest scrolls. */
@media (max-width: 860px), (max-height: 520px) {
  .po { overflow-y: auto; }
  .po-bar { position: sticky; top: 0; z-index: 2; min-height: 56px; padding-inline: 6px 12px; }
  .po-body { flex: none; overflow: visible; padding: 16px 16px 8px; }
  .po-in { gap: 14px; }
  .po-cat { gap: 10px; }
  .po-foot { display: block; padding: 4px 16px 12px; border-top: 0; }
  .po-foot__r { justify-content: space-between; margin: 2px 0 0; }
  .po-ttl { gap: 12px; }
  .po-ttl__gem { width: 44px; height: 44px; border-radius: 14px; }
  .po-h { font-size: 1.5rem; }
  .po-gives li { padding: 7px 0; }
}
