/* ==========================================================================
   Minetly · AI Master Class — the students page (/learn/)
   Loaded after style.css and built only from its tokens and components.
   1 Shell · 2 Shared pieces · 3 Starting and confirming · 4 Log in
   5 My course · 6 Motion · 7 Media queries
   Phone first (320 to 430px), enhanced at 480px, 768px and 1100px.

   Text and background pairs used here (WCAG contrast, 4.5:1 needed):
     --ink   on --bg 14.4 · --surface 15.2 · --peach 11.9 · --butter 12.9
             · --mint 12.3 · --lilac 11.4 · --sky 12.1 · --sun 9.9
     --ink-2 on --bg 6.9 · --surface 7.4 · --lilac 5.5 · --line 5.6
     --on-cta on --cta 6.2 · --surface on --ink 15.2
   ========================================================================== */

/* 1 ── SHELL ──────────────────────────────────────────────────────────── */

/* The page shows one screen at a time by setting the hidden attribute. Many
   components set their own display, so hidden has to win everywhere. This is
   the only !important rule in this file. */
.page-learn [hidden] { display: none !important; }

.page-learn .header { padding-top: env(safe-area-inset-top, 0px); }

/* The sticky header never covers an anchor target or the control that has
   focus, also when the phone adds a safe area above it. There is no buy bar
   on this page, so the sales page's large bottom margin is not needed. */
.page-learn [id],
.page-learn a,
.page-learn button,
.page-learn input {
  scroll-margin-top: calc(var(--header-h) + var(--s-3) + env(safe-area-inset-top, 0px));
}
.page-learn a,
.page-learn button,
.page-learn input { scroll-margin-bottom: var(--s-4); }

.page-learn main {
  padding-block: var(--s-6) calc(var(--s-12) + env(safe-area-inset-bottom, 0px));
}

/* Headings that receive focus from the script are not controls: no ring. */
.page-learn h1[tabindex="-1"]:focus,
.page-learn h2[tabindex="-1"]:focus { outline: 0; }

/* One narrow, centred column for every screen except "My course" */
.state__in {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--s-4);
  max-width: 32rem;
  margin-inline: auto;
}
.state__in > * { min-width: 0; }
.state__in > .card,
.state__in > .form,
.state__in > .notice,
.state__in > .boot__skel,
.state__in > .login__head,
.state__in > .login__more { justify-self: stretch; }

.state__title {
  font-size: clamp(2rem, 8.6vw, 2.75rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.015em;
}
.state__lead {
  max-width: 30rem;
  color: var(--ink-2);
  font-size: var(--fs-lead);
  line-height: 1.5;
}
.state__lead a { color: var(--ink); font-weight: 800; }

.wrap-any { overflow-wrap: anywhere; }

/* 2 ── SHARED PIECES ──────────────────────────────────────────────────── */

/* Clay card. A tone class (t-mint and friends) recolours it. No default
   --tone is set here on purpose: this file loads after the tone classes. */
.card {
  min-width: 0;
  padding: var(--s-5);
  border-radius: var(--r-card);
  background: var(--tone, var(--surface));
  box-shadow: var(--shadow-clay);
}

/* A short message with an icon: butter for notes, peach for problems,
   mint for good news. Always --ink text. */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--tone, var(--butter));
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: var(--shadow-clay-sm);
}
.notice > .ico { width: 22px; height: 22px; margin-top: 1px; }
.notice > p,
.notice > div { min-width: 0; overflow-wrap: anywhere; }

/* Buttons on this page may wrap on to two lines instead of spilling out of a
   320px screen, and fill the width of the form they sit in at every size. */
.page-learn .btn {
  padding-block: var(--s-2);
  white-space: normal;
  text-align: center;
}
.page-learn .form .btn {
  display: flex;
  justify-self: stretch;
  width: 100%;
  padding-inline: var(--s-5);
}

/* Not available right now (the "Send again" wait): flat and quiet, but the
   words stay easy to read. */
.page-learn .btn[aria-disabled="true"] {
  opacity: 1;
  cursor: default;
}
.page-learn .btn[aria-disabled="true"]:not([data-busy="true"]),
.page-learn .btn[aria-disabled="true"]:not([data-busy="true"]):active {
  --btn-bg: var(--line);
  --btn-fg: var(--ink-2);
  box-shadow: none;
  transform: none;
}

/* Working on it: the button stays pressed in and shows a small ring. */
.page-learn .btn[data-busy="true"],
.page-learn .btn[data-busy="true"]:active {
  box-shadow: 0 2px 0 var(--btn-edge), inset 0 2px 0 var(--gloss-soft);
  cursor: progress;
  transform: translateY(calc(var(--edge) - 2px));
}
.btn[data-busy="true"]::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}
.btn[data-busy="true"] > .ico,
.btn[data-busy="true"] > .markdone__box { display: none; }

/* A quiet text button or link with a full-size tap area */
.linkbtn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  justify-self: start;
  min-height: 48px;
  max-width: 100%;
  margin: 0 0 0 calc(var(--s-2) * -1);   /* the words line up with the text above; the padding is tap and focus room */
  padding: var(--s-1) var(--s-2);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.linkbtn .ico { width: 20px; height: 20px; }

/* Round number badge: the player and every step card */
.num-badge {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--badge, var(--butter));
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sticker);
}

/* Support line: the address is plain text that selects in one tap, because
   some in-app browsers cannot open an email app from a link. */
.support {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  min-width: 0;
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.5;
}
.support__addr {
  max-width: 100%;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 800;
  overflow-wrap: anywhere;
  -webkit-user-select: all;
  user-select: all;
}

/* 3 ── STARTING AND CONFIRMING ────────────────────────────────────────── */

/* Scripts are off: this message stands in for the waiting screen. It is one
   item of the column, so it spaces its own heading and paragraphs the way
   the column does. */
.boot__nojs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--s-4);
}

.boot__skel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
  margin-top: var(--s-2);
  padding: var(--s-5);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-clay);
}
.skel {
  display: block;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--line);
}
.skel--bar { width: 62%; height: 22px; }
.skel--media { height: auto; min-height: 120px; aspect-ratio: 16 / 9; border-radius: var(--r-md); }
.skel--short { width: 44%; }

.wait {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-5) var(--s-6);
  text-align: center;
}
.wait .linkbtn { justify-self: center; margin-left: 0; }
.wait__dots {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  height: 28px;
}
.wait__dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pop);
}
.wait__dots span:nth-child(2) { background: var(--sun); }
.wait__dots span:nth-child(3) { background: var(--cta); }
.wait__status { font-weight: 800; line-height: 1.45; }

/* 4 ── LOG IN ─────────────────────────────────────────────────────────── */

.login { gap: var(--s-5); }
.login__head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--s-3);
}
.login__spark { top: 0; right: 0; transform: rotate(12deg); }
.login__more {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--s-4);
  min-width: 0;
}

.page-learn .form { grid-template-columns: minmax(0, 1fr); }
.panel__title { font-size: var(--fs-h3); }

.field .form__hint { margin-top: 6px; }
.field__err {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.35;
}
.field__err .ico { width: 18px; height: 18px; margin-top: 1px; stroke-width: 2.25; }
.field__err span { min-width: 0; overflow-wrap: anywhere; }
.field input[aria-invalid="true"] {
  border-color: var(--ink);
  background: var(--peach);
  box-shadow: inset 0 0 0 1px var(--ink);
}

/* One big box for the six digits */
.field--code input {
  min-height: 64px;
  padding-inline: calc(var(--s-2) + .3em) var(--s-2);   /* the left side makes up for the gap after the last digit */
  font-family: var(--font-head);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: .3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* "Send again" keeps one height while its countdown line comes and goes */
.resend { min-height: 56px; }
.resend__text {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 2px;
  min-width: 0;
}
.resend__wait {
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 5 ── MY COURSE ──────────────────────────────────────────────────────── */

.course__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
}
.course__grid > * { min-width: 0; }
.course__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-1);
}
.course__who {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.course__h { margin-bottom: var(--s-4); font-size: var(--fs-h3); }

/* Progress: one line of words and a chunky bar */
.progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
}
.progress__label {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.progress__track {
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--bg);
  box-shadow: inset 0 0 0 2px var(--field-line);
  overflow: hidden;
}
.progress__fill {
  --done: 0;                   /* learn.js sets this to the share of steps done, 0 to 1 */
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--cta);
  box-shadow: inset 0 2px 0 var(--gloss-soft), inset 0 -5px 0 var(--cta-deep);
  /* the whole fill slides in from the left, so its end stays round */
  transform: translateX(calc(var(--done, 0) * 100% - 100%));
}

/* All steps done */
.cheer {
  display: flex;
  align-items: center;
  gap: var(--s-4);
}
.cheer__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sticker);
}
.cheer__icon .ico { width: 24px; height: 24px; }
.cheer__text {
  min-width: 0;
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
}

/* Player card. The video keeps its own shape (upright or wide) inside a dark
   frame and never grows taller than the screen. */
.player {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
  padding: var(--s-3) var(--s-3) var(--s-6);
}
.player__frame {
  border-radius: var(--r-md);
  background: var(--ink);
  overflow: hidden;
  isolation: isolate;          /* keeps the playing video clipped to the rounded corners in WebKit */
}
.player__frame video {
  width: 100%;
  max-height: 70vh;
  max-height: min(70vh, 620px);
  background: var(--ink);
}
/* The frame cuts off whatever is drawn outside the video, and that includes
   the video's focus ring. So the ring goes round the frame. A browser that
   cannot do that draws a light ring just inside the picture instead. */
.player__frame video:focus-visible {
  outline-color: var(--surface);
  outline-offset: -5px;
}
@supports selector(:has(*)) {
  .player__frame:has(video:focus-visible) {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
  }
  .player__frame video:focus-visible { outline: 0; }
}
.player__msg-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--s-3);
}
.player__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
  min-width: 0;
  padding-inline: var(--s-2);
}
.player__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
}
/* The number badge and the section name stay together: a long name wraps
   beside the badge, and the pills move to the next line when they must. */
.player__where {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}
.player__section {
  min-width: 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.3;
}
.player__title {
  font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2rem);
  overflow-wrap: anywhere;
}
.player__summary { max-width: 40rem; color: var(--ink-2); }
.player__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  margin-top: var(--s-2);
}
.player__actions .btn { flex: 1 1 200px; }   /* side by side only when both labels fit on one line */

/* "Mark as done": an empty ring that fills with a tick */
.markdone__box {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--field-line);
}
.markdone__box .ico { width: 16px; height: 16px; stroke-width: 2.5; opacity: 0; }
.markdone[aria-pressed="true"] {
  --btn-bg: var(--mint);
  --btn-edge: var(--shade-3);
}
.markdone[aria-pressed="true"] .markdone__box {
  background: var(--ink);
  color: var(--surface);
  box-shadow: none;
}
.markdone[aria-pressed="true"] .markdone__box .ico { opacity: 1; }

/* "Low data" switch */
.player__low {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 48px;
  margin: 0;
  padding: var(--s-1) var(--s-2) var(--s-1) 0;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.switch__track {
  position: relative;
  flex: none;
  width: 54px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--field-line);
}
.switch__knob {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink-2);
}
.switch[aria-pressed="true"] .switch__track { background: var(--cta); box-shadow: none; }
.switch[aria-pressed="true"] .switch__knob { background: var(--on-cta); transform: translateX(22px); }

/* Step list: six clay cards */
.steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
}
.steps__item { min-width: 0; }
.steps__item:nth-child(5n + 1) { --badge: var(--peach); }
.steps__item:nth-child(5n + 2) { --badge: var(--butter); }
.steps__item:nth-child(5n + 3) { --badge: var(--mint); }
.steps__item:nth-child(5n + 4) { --badge: var(--lilac); }
.steps__item:nth-child(5n + 5) { --badge: var(--sky); }
.step {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  text-align: left;
  box-shadow: var(--shadow-clay-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* the layout sits on a span inside the button: some older phone browsers
   cannot lay out a button itself as a grid */
.step__in {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "num text" "num mark";
  align-items: center;
  column-gap: var(--s-4);
  min-height: 76px;
  padding: var(--s-4);
}
.step__num { grid-area: num; }
.step__text {
  grid-area: text;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  min-width: 0;
}
.step__section {
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1.3;
}
.step__title {
  font-family: var(--font-head);
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.step__mark {
  grid-area: mark;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: 28px;
  margin-top: var(--s-2);
  padding: 2px var(--s-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.step__mark .ico { width: 16px; height: 16px; stroke-width: 2.5; }
.step__mark--done { background: var(--mint); }
.step__mark--next { background: var(--sun); }
/* the step that is in the player: lilac card with a solid ring */
.step[aria-current] {
  --badge: var(--surface);
  background: var(--lilac);
  box-shadow: var(--shadow-clay-sm), 0 0 0 3px var(--cta);
}

/* 6 ── MOTION ─────────────────────────────────────────────────────────── */
@keyframes learn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
@keyframes learn-hop {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
}
@keyframes learn-spin {
  to { transform: rotate(360deg); }
}

/* Everything that moves lives here, so nothing moves for a visitor who has
   asked their phone to reduce motion. */
@media (prefers-reduced-motion: no-preference) {
  .state > .wrap { animation: settle .45s var(--spring) backwards; }
  .skel { animation: learn-pulse 1.4s ease-in-out infinite; }
  .wait__dots span { animation: learn-hop 1.2s var(--ease) infinite; }
  .wait__dots span:nth-child(2) { animation-delay: .15s; }
  .wait__dots span:nth-child(3) { animation-delay: .3s; }
  .btn[data-busy="true"]::before { animation: learn-spin .8s linear infinite; }
  .progress__fill { transition: transform .5s var(--ease); }
  .switch__knob { transition: transform .2s var(--ease); }
  .markdone__box .ico { transition: opacity .15s var(--ease); }
  .step { transition: transform .14s var(--ease); }
  .step:active { transform: translateY(2px); }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .step:hover:not(:active) { transform: translateY(-2px); }
}

@media (hover: hover) {
  .linkbtn:hover { text-decoration-color: var(--cta); }
}

/* 7 ── MEDIA QUERIES ──────────────────────────────────────────────────── */

/* Wider phones: the "Done" / "Up next" marker moves beside the title */
@media (min-width: 480px) {
  .step__in {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "num text mark";
  }
  .step__mark { justify-self: end; margin-top: 0; }
}

/* Tablet and up */
@media (min-width: 768px) {
  .page-learn main {
    padding-block: var(--s-12) calc(var(--s-24) + env(safe-area-inset-bottom, 0px));
  }
  .state__in,
  .boot__nojs { gap: var(--s-5); }
  .card { padding: var(--s-6); }
  .wait { padding: var(--s-10) var(--s-8) var(--s-8); }

  .course__grid {
    max-width: 46rem;
    margin-inline: auto;
    gap: var(--s-6);
  }
  .player { padding: var(--s-4) var(--s-4) var(--s-8); }
  .player__body { padding-inline: var(--s-3); }
  .player__actions .btn { flex: 0 1 auto; padding-inline: var(--s-8); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
}

/* Desktop: the player on the left, the step list on the right */
@media (min-width: 1100px) {
  .course__grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
    align-items: start;
    gap: var(--s-8) var(--s-10);
    max-width: none;
  }
  .course__head { grid-column: 1; align-self: center; }
  .progress { grid-column: 2; }
  .course__wide { grid-column: 1 / -1; }
  .player { grid-column: 1; }
  .course__list { grid-column: 2; }
  .steps { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
}
