/* The lesson list of Motion for Product Design, a made-up course by Tempo School, and the open lesson. The lesson
   page sits on top of the list; script.js moves its pieces (sheet, player, title, length) from the row to their place
   and back. Sizes are in container units of the app, so the same layout fits a phone box and a wide window. GSAP
   moves the outer elements; hover and press live on the children (one element for GSAP, the child for the CSS). */
:root {
  --room: #ebe9e4;          /* the background around the app */
  --room-deep: #dcd9d1;     /* the background in the corners */
  --panel: #f6f5f1;         /* the list behind the rows */
  --sheet: #ffffff;         /* the lifted row and the lesson page */
  --ink: #15151a;           /* the words */
  --muted: #86868f;         /* the small words */
  --line: rgba(21, 21, 26, 0.08); /* hairlines */
  --accent: #5b4cf0;        /* the one accent: progress, the playing chapter */
  --done: #15151a;          /* the ticks of the finished lessons */
  --g1: #2a2560;            /* the colours of the open lesson (script.js sets them from LESSONS) */
  --g2: #0f0f18;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  color: var(--ink);
  background: var(--room);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
p, h1, h2 { margin: 0; }

.stage {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, var(--room) 45%, var(--room-deep) 100%);
  overflow: hidden;
}

/* a soft light behind the app, in the colour of the open lesson */
.glow {
  position: absolute;
  width: min(620px, 120vw, 115vh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--accent) 20%, transparent), transparent);
  filter: blur(24px);
  opacity: 0.5;
  pointer-events: none;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.3;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the phone app */
.app {
  --pad: min(5cqw, 3.4cqh);
  position: relative;
  width: min(392px, 94vw, 76vh);
  height: min(610px, 94vh);
  border-radius: min(34px, 7vh);
  background: var(--panel);
  overflow: hidden;
  container: app / size;
  box-shadow:
    0 0 0 1px rgba(21, 21, 26, 0.07),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 2px 4px rgba(21, 21, 26, 0.04),
    0 18px 40px -12px rgba(21, 21, 26, 0.2),
    0 50px 90px -40px rgba(21, 21, 26, 0.28);
  isolation: isolate;
}
/* the edge of the glass catches the light */
.app::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 9;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 30%);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  padding: 1px;
}

.status {
  position: absolute;
  inset: 0 0 auto;
  height: 7.4cqh;
  padding: 0 calc(var(--pad) + 1.4cqw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
  font-size: min(3.5cqw, 2.4cqh);
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.status__icons { display: flex; align-items: center; gap: 1.4cqw; }
.status__icons svg { height: min(2.8cqw, 1.9cqh); width: auto; fill: currentColor; color: var(--ink); }

/* ---- the list ---- */
.list {
  position: absolute;
  inset: 0;
  padding: 8.4cqh var(--pad) var(--pad);
  display: flex;
  flex-direction: column;
  gap: 2.4cqh;
}

.head { display: flex; flex-direction: column; gap: 0.9cqh; padding: 0 1cqw; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 1.4cqw;
  font-size: min(3.1cqw, 2.1cqh);
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.mark { width: min(3.4cqw, 2.3cqh); height: auto; fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; }

.head__title {
  font-size: min(6.6cqw, 4.6cqh);
  font-weight: 650;
  font-stretch: 92%;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.head__meta {
  display: flex;
  gap: 1.4cqw;
  font-size: min(3.2cqw, 2.2cqh);
  font-weight: 520;
  color: var(--muted);
}
.sep { opacity: 0.6; }

/* the progress of the course: one segment per lesson */
.course-bar { display: flex; gap: 3px; margin-top: 0.6cqh; height: 3px; }
.course-bar span { flex: 1; border-radius: 3px; background: rgba(21, 21, 26, 0.09); overflow: hidden; }
.course-bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); border-radius: inherit; }

.rows {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6cqh;
}

/* a row: GSAP moves .row, the hover and the press live on .row__hit */
.row { flex: 1 1 0; min-height: 0; max-height: 15cqh; position: relative; }
.row__hit {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 3.4cqw;
  padding: 0 2.6cqw 0 1.4cqw;
  border-radius: min(4.4cqw, 3cqh);
  text-align: left;
  isolation: isolate;
  transition: background-color 0.35s ease, box-shadow 0.35s ease, transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.row__hit::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  background: var(--sheet);
  opacity: 0;
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(21, 21, 26, 0.05), 0 10px 24px -12px rgba(21, 21, 26, 0.22);
  transition: opacity 0.3s ease;
}
.row.is-hover .row__hit::before, .row.is-lift .row__hit::before { opacity: 1; }
.row.is-press .row__hit { transform: scale(0.985); transition-duration: 0.12s; }
.row.is-lift .row__hit { transform: translateY(-1px); }
@media (hover: hover) {
  .row__hit:hover::before { opacity: 1; }
  .row__hit:hover .thumb { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 6px 14px -6px rgba(21, 21, 26, 0.45); }
  .row__hit:hover .thumb__play { opacity: 1; transform: scale(1); }
  .row__hit:active { transform: scale(0.985); transition-duration: 0.12s; }
}
.row.is-hover .thumb { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 6px 14px -6px rgba(21, 21, 26, 0.45); }
.row.is-hover .thumb__play { opacity: 1; transform: scale(1); }

/* the thumbnail and the player share the same pieces */
.thumb, .media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--g2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset, 0 2px 6px -3px rgba(21, 21, 26, 0.35);
}
.thumb {
  height: 72%;
  max-height: 10.6cqh;
  flex: none;
  border-radius: min(2.4cqw, 1.6cqh);
  transition: transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1), box-shadow 0.4s ease;
}
.paint, .media__paint {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(90% 120% at 18% 0%, color-mix(in oklab, var(--g1) 100%, #fff 10%) 0%, transparent 62%),
    radial-gradient(70% 90% at 100% 100%, color-mix(in oklab, var(--g1) 55%, transparent), transparent 70%),
    linear-gradient(160deg, var(--g1), var(--g2) 78%);
}
/* a hairline grid, like a motion graph paper */
.paint::after, .media__paint::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 12.5% 22.2%;
  background-position: -1px -1px;
  mask: radial-gradient(80% 90% at 50% 50%, #000 30%, transparent 100%);
}
.art, .media__art { position: absolute; inset: 0; display: block; }
.art svg, .media__art svg { width: 100%; height: 100%; display: block; overflow: visible; }

.thumb__play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.25s ease, transform 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.thumb__play svg { width: 46%; fill: #fff; margin-left: 8%; }

/* the watched bar: in the row it is a thin line, in the player it is the scrubber with its chapter gaps */
.track {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 9%;
  height: max(2px, 2.6%);
  display: flex;
  gap: 1.2%;
  z-index: 2;
}
.track span { position: relative; height: 100%; border-radius: 4px; background: rgba(255, 255, 255, 0.26); overflow: hidden; }
.track i { position: absolute; inset: 0; background: #fff; transform-origin: 0 50%; transform: scaleX(var(--f, 0)); border-radius: inherit; }
.thumb .track.is-empty { opacity: 0; }

.row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.5cqh; }
.row__title {
  display: block;
  width: max-content;
  max-width: 100%;
  white-space: nowrap;
  font-size: min(4.05cqw, 2.85cqh);
  font-weight: 590;
  font-stretch: 96%;
  letter-spacing: -0.012em;
  line-height: 1.2;
}
.row__sub {
  display: flex;
  align-items: center;
  gap: 1.2cqw;
  font-size: min(3.15cqw, 2.15cqh);
  font-weight: 520;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row__len { display: block; width: max-content; }
.row__state.is-going { color: var(--accent); }

/* the state at the end of a row: a tick, a ring of the time watched, or nothing yet */
.state { flex: none; width: min(6.4cqw, 4.4cqh); aspect-ratio: 1; display: grid; place-items: center; }
.state svg { width: 100%; height: 100%; fill: none; }
.state__track { stroke: rgba(21, 21, 26, 0.1); stroke-width: 1.6; }
.state__ring { stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.state__tick { stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.state__disc { fill: var(--done); transform-origin: 50% 50%; }
.state__lock { stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the lesson page ---- */
.detail {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 3;
}
.app.is-moving .detail, .app.is-open .detail { visibility: visible; }
.app.is-open .detail { pointer-events: auto; }
.app.is-open .list { visibility: hidden; }

.sheet {
  position: absolute;
  inset: 0;
  background: var(--sheet);
}

.detail__in {
  position: absolute;
  inset: 0;
  padding: 7.4cqh var(--pad) var(--pad);
  display: flex;
  flex-direction: column;
  gap: 1.9cqh;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 8cqh;
  flex: none;
}
.back {
  display: flex;
  align-items: center;
  gap: 1cqw;
  height: min(9cqw, 6cqh);
  padding: 0 3.4cqw 0 2.2cqw;
  border-radius: 99px;
  font-size: min(3.5cqw, 2.4cqh);
  font-weight: 600;
  background: rgba(21, 21, 26, 0.045);
  box-shadow: 0 0 0 1px var(--line) inset, 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.35s cubic-bezier(0.2, 1.5, 0.4, 1), background-color 0.25s ease;
}
.back svg { width: min(4.2cqw, 2.9cqh); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.35s cubic-bezier(0.2, 1.5, 0.4, 1); }
.back.is-press { transform: scale(0.95); transition-duration: 0.1s; }
@media (hover: hover) {
  .back:hover { background: rgba(21, 21, 26, 0.07); }
  .back:hover svg { transform: translateX(-2px); }
  .back:active { transform: scale(0.95); transition-duration: 0.1s; }
}
.bar__label { font-size: min(3.3cqw, 2.25cqh); font-weight: 560; color: var(--muted); }
.round {
  width: min(9cqw, 6cqh);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sheet);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(21, 21, 26, 0.05);
}
.round svg { width: 46%; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* the place of the player: the media flies in from the row and rests exactly here */
.slot {
  position: relative;
  flex: none;
  width: min(100%, 68cqh);
  margin-inline: auto;
  aspect-ratio: 16 / 9;
}
.media {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: min(4.6cqw, 3.2cqh);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07) inset, 0 2px 4px rgba(21, 21, 26, 0.1), 0 18px 30px -16px rgba(21, 21, 26, 0.5);
  cursor: pointer;
}
.media__scrim {
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(transparent, rgba(5, 5, 10, 0.55));
  z-index: 1;
}
.play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 19%;
  aspect-ratio: 1;
  margin: -9.5% 0 0 -9.5%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  z-index: 2;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3) inset, 0 10px 24px -10px rgba(0, 0, 0, 0.5);
  opacity: 0;
}
.play svg { grid-area: 1 / 1; width: 40%; fill: #fff; }
.play__p { margin-left: 8%; }
.play__s { opacity: 0; }
.play.is-playing .play__p { opacity: 0; }
.play.is-playing .play__s { opacity: 1; }
.tc {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 15%;
  display: flex;
  justify-content: space-between;
  z-index: 2;
  font-size: min(3cqw, 2.05cqh);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  font-variant-numeric: tabular-nums;
}
.media__sheen {
  position: absolute;
  inset: -10% -40%;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 255, 255, 0.16) 50%, transparent 62%);
  transform: translateX(-80%);
  opacity: 0;
}

.title {
  position: relative;
  z-index: 4;
  display: block;
  width: max-content;
  max-width: 100%;
  white-space: nowrap;
  font-size: min(6.6cqw, 4.6cqh);
  font-weight: 650;
  font-stretch: 92%;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 0.4cqh;
}
.meta {
  display: flex;
  align-items: center;
  gap: 1.3cqw;
  margin-top: -1.1cqh;
  font-size: min(3.3cqw, 2.25cqh);
  font-weight: 520;
  color: var(--muted);
  white-space: nowrap;
}
.meta svg { width: min(3.6cqw, 2.5cqh); fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.meta__len { position: relative; z-index: 4; display: block; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.chapters {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8cqh;
  border-top: 1px solid var(--line);
  padding-top: 1.6cqh;
}
.chapters__label { font-size: min(3cqw, 2.05cqh); font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.chapters__list { position: relative; display: flex; flex-direction: column; }
.chapters__hi {
  position: absolute;
  left: -2cqw;
  right: -2cqw;
  top: 0;
  height: 0;
  border-radius: min(2.8cqw, 1.9cqh);
  background: color-mix(in oklab, var(--accent) 8%, transparent);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 14%, transparent) inset;
}
.chapter {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: min(7cqh, 10cqw);
  font-size: min(3.6cqw, 2.5cqh);
  font-weight: 540;
  color: var(--muted);
  transition: color 0.4s ease;
}
.chapter b { font-weight: 560; font-variant-numeric: tabular-nums; font-size: 0.92em; }
.chapter.is-now { color: var(--ink); }
.chapter.is-now b { color: var(--accent); }

.done {
  flex: none;
  height: min(12cqw, 7.6cqh);
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2cqw;
  font-size: min(3.7cqw, 2.5cqh);
  font-weight: 620;
  color: #fff;
  background: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.15), 0 12px 22px -12px rgba(21, 21, 26, 0.6);
  transition: transform 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.done svg { width: min(4.6cqw, 3.1cqh); fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.done svg circle { stroke-opacity: 0.45; }
@media (hover: hover) { .done:hover { transform: translateY(-1px); } .done:active { transform: scale(0.97); } }
@container app (max-height: 480px) { .done { display: none; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
