/* The lessons screen: a white reading room around a dark player.
   Three token layers: raw values, what they mean here, then the parts that use them. */
:root {
  /* Primitive */
  --navy-900: #0b1220;
  --navy-800: #111b2e;
  --slate-600: #4b5563;
  --slate-500: #6b7280;
  --slate-200: #e4e7ec;
  --slate-100: #f1f3f6;
  --slate-50: #f8f9fb;
  --white: #ffffff;
  --amber-400: #ffc857;
  --amber-300: #ffd47a;
  --amber-50: #fff7e0;
  --amber-800: #8a5a00;
  --green-600: #1c8f4e;
  --paper: #f4efe6;

  /* Semantic */
  --bg: var(--white);
  --surface: var(--slate-50);
  --surface-2: var(--slate-100);
  --text: var(--navy-900);
  --text-2: var(--slate-600);
  --text-3: var(--slate-500);
  --border: var(--slate-200);
  --accent: var(--amber-400);
  --accent-hover: var(--amber-300);
  --accent-soft: var(--amber-50);
  --on-accent: #1a1405;
  --accent-text: var(--amber-800);
  --success: var(--green-600);
  --media: var(--navy-900);
  --on-media: var(--paper);

  /* Component */
  --row-active-bg: var(--accent-soft);
  --row-hover-bg: var(--surface);
  --thumb-radius: 8px;
  --card-radius: 16px;
  --font: "IBM Plex Sans Arabic", "Dubai", "Segoe UI", Tahoma, sans-serif;
  --pad: clamp(16px, 4vw, 28px);
  --stage-radius: 20px;
  /* One curve for things that arrive, one for things pressed. */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-press: cubic-bezier(.34, 1.4, .64, 1);
}
* { box-sizing: border-box; }
/* Pages cross-fade into each other instead of flashing. */
@view-transition { navigation: auto; }
/* A phone first: no grey flash on a tap, no double-tap zoom, no tap delay. */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* Installed on an iPhone the page runs under the clock, whose digits are white:
   a dark strip sits behind them, and the page starts below it. */
body::before { content: ""; position: fixed; z-index: 9; top: 0; inset-inline: 0; height: env(safe-area-inset-top); background: var(--media); }
body { margin: 0; padding-top: env(safe-area-inset-top); background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
svg { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; border-radius: 6px; }
.eyebrow { font-size: .82rem; font-weight: 600; color: var(--accent-text); }
.muted { color: var(--text-2); }
.note { font-size: .9rem; color: var(--accent-text); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 52px; padding: 10px 26px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 1rem;
  line-height: 1.3; text-decoration: none; cursor: pointer; -webkit-user-select: none; user-select: none;
  transition: background-color .25s var(--ease-out), transform .35s var(--ease-press); }
.btn:active { transform: scale(.96); transition-duration: .09s; }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--border); font-weight: 600; }
/* Hover is for a mouse only: on a phone it would stick after the tap. */
@media (hover: hover) {
  .btn:hover { background: var(--accent-hover); }
  .btn.ghost:hover { background: var(--surface); }
  .stage-btn:hover { opacity: 1; }
  .row:hover { background: var(--row-hover-bg); }
  .row.soon:hover { background: none; }
  .row.active:hover { background: var(--row-active-bg); }
  .end .btn.ghost:hover { background: rgba(244, 239, 230, .06); }
}
.btn.small { min-height: 44px; padding: 6px 18px; font-size: .9rem; white-space: nowrap; }

/* Top bar */
.bar { display: flex; align-items: center; gap: 14px; height: 60px; padding-inline: var(--pad); border-bottom: 1px solid var(--border); }
.mark { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.mark i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.meter { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; font-size: .82rem; color: var(--text-2); white-space: nowrap; }
.meter .track { width: clamp(48px, 16vw, 140px); height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter .track i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--success); transition: width .9s var(--ease-out); }

/* Layout: player and lesson notes, then the course contents beside or below. */
.learn { display: grid; }
@media (min-width: 1000px) {
  .learn { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .side { border-inline-start: 1px solid var(--border); position: sticky; top: 0; max-height: 100vh; overflow: auto; }
}

/* Player: a rounded card, with the page showing around it. */
.stage-slot { padding: 10px var(--pad); background: var(--bg); }
.stage { position: relative; aspect-ratio: 16 / 9; background: var(--media); overflow: hidden; border-radius: var(--stage-radius);
  box-shadow: 0 14px 34px -18px rgba(11, 18, 32, .55), 0 0 0 1px rgba(11, 18, 32, .06); }
/* On a phone the player stays in view while she scrolls the contents. */
@media (max-width: 999px) { .main { display: contents; } .stage-slot { position: sticky; top: env(safe-area-inset-top); z-index: 10; } }
@media (min-width: 1000px) { .stage-slot { padding: 28px 40px 0; } }
/* The layers carry the curve too: Safari does not always clip a frame to its parent's corners. */
.stage iframe, .poster, .end { border-radius: inherit; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.poster { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; width: 100%; padding: 0; border: 0;
  background: var(--media); color: var(--on-media); pointer-events: none; }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; opacity: .62;
  transition: opacity .5s var(--ease-out); }
/* The play button asks to be pressed: it breathes, and two rings leave it one after the other. */
.poster .play { position: relative; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 10px rgba(255, 200, 87, .22), 0 10px 30px rgba(0, 0, 0, .45);
  animation: play-breathe 2.4s ease-in-out infinite; }
.poster .play::before, .poster .play::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--accent); opacity: 0; animation: play-ring 2.4s cubic-bezier(.2, .6, .35, 1) infinite; }
.poster .play::after { animation-delay: 1.2s; }
.poster .play svg { position: relative; width: 30px; height: 30px; margin-inline-start: 3px; }
@keyframes play-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes play-ring { 0% { transform: scale(1); opacity: .75; } 100% { transform: scale(2.3); opacity: 0; } }
/* A new lesson's poster fades in over the last one. */
.poster.swap img { animation: fade-in .6s var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } }
.poster .hint { position: absolute; inset-inline: 0; bottom: 12px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .82rem; font-weight: 500; text-shadow: 0 1px 6px #000; }
.poster .hint svg { width: 18px; height: 18px; }
.stage-btn { position: absolute; z-index: 4; top: 10px; inset-inline-end: 10px; display: none; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(11, 18, 32, .6); color: var(--on-media); cursor: pointer; opacity: .75;
  transition: opacity .25s ease, transform .35s var(--ease-press); }
.stage-btn:active { opacity: 1; transform: scale(.9); transition-duration: .09s; }
.stage-btn svg { width: 20px; height: 20px; }
/* Inline play on a wide screen: no poster, the lesson's own start card shows, with a button to fill the screen. */
.stage.inline .poster { display: none; }
.stage.inline #grow { display: grid; }

/* Watching: the player takes the whole screen, turned sideways on a phone held upright. */
body.watching { overflow: hidden; }
.stage.live { position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100dvh; aspect-ratio: auto; border-radius: 0; box-shadow: none;
  animation: stage-in .55s var(--ease-out); }
/* scale is its own property here, so it does not undo the sideways turn below. */
@keyframes stage-in { from { opacity: 0; scale: .9; } }
.stage.live .poster, .stage.live #grow { display: none; }
/* The close button keeps clear of the notch when the phone itself is held sideways. */
.stage.live #shut { display: grid; inset-inline-end: max(10px, env(safe-area-inset-left)); }
@media (orientation: portrait) and (pointer: coarse) {
  .stage.live { inset: auto; top: 50%; left: 50%; width: 100dvh; height: 100vw; transform: translate(-50%, -50%) rotate(90deg); }
  /* Turned by the stylesheet, the player's left edge lies along the top of the phone, under the clock. */
  .stage.live #shut { inset-inline-end: calc(10px + env(safe-area-inset-top)); }
}

/* End of a lesson, shown over the player. */
.end { position: absolute; inset: 0; z-index: 6; display: none; place-items: center; padding: 16px; overflow: auto;
  background: rgba(4, 7, 13, .82); color: var(--on-media); }
.end.on { display: grid; animation: fade-in .45s ease-out; }
.end.on .box { animation: box-in .6s var(--ease-out); }
@keyframes box-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.end .box { display: grid; gap: 16px; width: min(100%, 720px); padding: 20px 24px; border-radius: 20px; background: var(--navy-800);
  box-shadow: 0 0 0 1px rgba(255, 200, 87, .25); }
/* Measured against the player, not the page: the player may be turned sideways. */
.end { container-type: inline-size; }
@container (min-width: 560px) { .end .box { grid-template-columns: 1fr 1fr; gap: 24px; } }
.end .col { display: grid; gap: 8px; align-content: center; }
.end .ok { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: #7be495; box-shadow: inset 0 0 0 1.5px #7be495; }
.end .ok svg { width: 22px; height: 22px; }
.end .eyebrow, .end .note { color: var(--accent); }
.end .muted { color: #aab3c2; }
.end .btn { width: 100%; min-height: 48px; }
.end .btn.ghost { color: var(--on-media); box-shadow: inset 0 0 0 1.5px rgba(244, 239, 230, .2); }
.end .plain { border: 0; background: none; color: #aab3c2; font-size: .9rem; min-height: 44px; cursor: pointer; }

/* The lesson on show */
.now { display: grid; gap: 10px; padding: 10px var(--pad) 26px; border-bottom: 1px solid var(--border); }
.now.swap > * { animation: now-in .55s var(--ease-out) backwards; }
.now.swap > :nth-child(2) { animation-delay: .05s; }
.now.swap > :nth-child(3) { animation-delay: .1s; }
.now.swap > :nth-child(4) { animation-delay: .15s; }
@keyframes now-in { from { opacity: 0; transform: translateY(10px); } }
.now h1 { font-size: clamp(1.35rem, 5vw, 1.9rem); line-height: 1.4; font-weight: 700; }
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: .88rem; color: var(--text-2); }
.facts span { display: inline-flex; align-items: center; gap: 6px; }
.facts svg { width: 17px; height: 17px; }
.ticks li { position: relative; padding-block: 4px; padding-inline-start: 28px; }
.ticks li::before { content: ""; position: absolute; inset-inline-start: 3px; top: .95em; width: 11px; height: 6px;
  border: solid var(--success); border-width: 0 0 2px 2px; transform: rotate(-45deg); }
@media (min-width: 1000px) { .now { padding: 28px 40px 40px; border-bottom: 0; } }

/* Course contents */
.side-head { padding: 20px var(--pad) 14px; }
.side-head h2 { font-size: 1.15rem; font-weight: 700; }
.side-head p { font-size: .85rem; color: var(--text-2); }
.unit > summary { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px var(--pad); cursor: pointer; list-style: none;
  background: var(--surface); border-block: 1px solid var(--border); }
.unit + .unit > summary { border-top: 0; }
.unit > summary::-webkit-details-marker { display: none; }
.unit > summary b { display: block; font-weight: 600; line-height: 1.4; }
.unit > summary small { font-size: .8rem; color: var(--text-2); }
.unit > summary .chev { margin-inline-start: auto; width: 20px; height: 20px; color: var(--text-2); transition: transform .45s var(--ease-out); }
.unit > summary { -webkit-user-select: none; user-select: none; }
/* Rows of a unit she opens by hand come down one after the other. */
.unit.fresh > .row { animation: now-in .45s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
.unit[open] > summary .chev { transform: rotate(180deg); }

.row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 24px; gap: 12px; align-items: center; width: 100%; min-height: 76px;
  padding: 10px var(--pad); border: 0; border-bottom: 1px solid var(--border); background: none; text-align: start;
  text-decoration: none; cursor: pointer; transition: background-color .35s var(--ease-out); position: relative; }
.row:active { background: var(--surface-2); transition-duration: .05s; }
.row .thumb { transition: transform .35s var(--ease-press); }
.row:active .thumb { transform: scale(.95); transition-duration: .09s; }
.row.soon { cursor: default; }
.row.soon:active { background: none; }
.row.soon:active .thumb { transform: none; }
.row.active { background: var(--row-active-bg); }
.row.active::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--accent); }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--thumb-radius); overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .time { position: absolute; bottom: 4px; inset-inline-end: 4px; padding: 0 6px; border-radius: 4px; background: rgba(11, 18, 32, .82);
  color: #fff; font-size: .7rem; font-weight: 600; line-height: 1.6; }
.row.locked .thumb img { filter: saturate(.35) brightness(.72); }
.thumb .seal { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.thumb .seal svg { width: 22px; height: 22px; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .6)); }
.thumb.blank { display: grid; place-items: center; color: var(--text-3); border: 1px dashed var(--border); }
.thumb.blank svg { width: 22px; height: 22px; }
.row-title { display: block; font-weight: 600; line-height: 1.45; color: var(--text); }
.row.soon .row-title { color: var(--text-3); font-weight: 500; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; font-size: .8rem; color: var(--text-2); }
.row-meta .kind { display: inline-flex; align-items: center; gap: 5px; }
.row-meta svg { width: 15px; height: 15px; }
.tag { padding: 0 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; line-height: 1.7; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent-text); }
.tag.dim { background: var(--surface-2); color: var(--text-2); }
.row-state { display: grid; place-items: center; width: 24px; height: 24px; color: var(--text-3); }
.row-state svg { width: 20px; height: 20px; }
.row.done .row-state { color: var(--success); }
.row.active .row-state { color: var(--text); }
.eq { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 14px; }
.eq i { width: 3px; border-radius: 1.5px; background: currentColor; }
.eq i:nth-child(1) { height: 55%; } .eq i:nth-child(2) { height: 100%; } .eq i:nth-child(3) { height: 35%; }

/* Three ticks for the three times through a lesson */
.views { display: inline-flex; align-items: center; gap: 3px; }
.views i { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--surface-2); color: var(--slate-200);
  transition: background-color .3s ease, color .3s ease; }
.views i svg { width: 13px; height: 13px; }
.views i.on { background: var(--success); color: var(--white); }
.facts .views { margin-inline-end: 2px; }
.facts .views i { width: 20px; height: 20px; }
.end .views i { width: 30px; height: 30px; background: rgba(244, 239, 230, .1); color: rgba(244, 239, 230, .25); }
.end .views i svg { width: 20px; height: 20px; }
.end .views i.on { background: #7be495; color: var(--navy-900); }
.end h3 { font-size: 1.25rem; line-height: 1.4; }
.tag.next { background: var(--text); color: var(--white); }
.row.up { box-shadow: inset 0 0 0 2px var(--accent); }
/* The end of the list clears the home bar. */
.side { padding-bottom: env(safe-area-inset-bottom); }

/* The offer, under the list */
.offer { display: grid; gap: 12px; margin: 20px var(--pad) 32px; padding: 22px; border-radius: var(--card-radius); background: var(--media);
  color: var(--on-media); }
.offer .eyebrow, .offer .note { color: var(--accent); }
.offer h3 { font-size: 1.1rem; line-height: 1.5; font-weight: 600; }
.offer .price { display: flex; align-items: baseline; gap: 10px; }
.offer .price b { font-size: 2rem; line-height: 1.2; }
.offer .price span { font-size: .85rem; color: #aab3c2; }
.owned .only-locked { display: none; }

/* Lock card */
.sheet { width: min(100%, 460px); max-width: 100%; max-height: 92dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0;
  background: var(--bg); color: var(--text); box-shadow: 0 -10px 50px rgba(11, 18, 32, .25); overflow: auto; }
.sheet::backdrop { background: rgba(11, 18, 32, .55); }
.sheet[open] { animation: rise .5s var(--ease-out); }
.sheet[open]::backdrop { animation: fade-in .4s ease-out; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 22px; } }
.sheet-body { position: relative; display: grid; gap: 10px; padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); }
.sheet-body h3 { font-size: 1.3rem; line-height: 1.4; }
.sheet-x { position: absolute; top: 26px; inset-inline-end: 28px; z-index: 2; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(11, 18, 32, .65); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.sheet-shot { position: relative; border-radius: 14px; overflow: hidden; background: var(--media); }
.sheet-shot img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; filter: brightness(.6) saturate(.7); }
.sheet-shot span { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.sheet-shot svg { width: 42px; height: 42px; }
.sheet-line { color: var(--text-2); font-size: .92rem; }
.sheet .btn { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .sheet[open], .sheet[open]::backdrop, .stage.live, .end.on, .end.on .box, .now.swap > *, .unit.fresh > .row, .poster.swap img,
  .poster .play, .poster .play::before, .poster .play::after { animation: none; }
  .btn, .row, .row .thumb, .stage-btn, .poster img, .meter .track i { transition: none; }
}
