:root {
  --fondo: #f4f4f5;
  --card: #ffffff;
  --inchiostro: #17171b;
  --grigio: #71717a;
  --grigio-chiaro: #a1a1aa;
  --linea: rgba(23, 23, 27, 0.08);
  --campo: #f4f4f6;
  --accento: #4f46e5;
  --accento-tenue: #eef0ff;
  --fatto: #16a34a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.4vmin, 20px);
  overflow: hidden;
}

/* the card: measured on the height too, so it sits whole in the phone's box */
.course {
  width: min(380px, 100%);
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--linea);
  box-shadow: 0 1px 2px rgba(23, 23, 27, 0.05), 0 24px 54px -26px rgba(40, 40, 80, 0.3);
  overflow: hidden;
}

.course__head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: clamp(10px, 2.6vh, 18px) 18px clamp(8px, 1.8vh, 14px);
}
.course__brand {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--grigio);
}
.course__brand svg { width: 14px; height: 14px; fill: none; stroke: var(--accento); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.course__title {
  margin-top: 3px;
  font-size: clamp(15px, 4.4vh, 19px); font-weight: 680; letter-spacing: -0.015em; line-height: 1.15;
}
.course__meta { display: flex; margin-top: 4px; font-size: 12px; color: var(--grigio); font-weight: 540; }

/* the course ring with the percentage in the middle */
.ring { position: relative; flex: none; width: clamp(42px, 11vh, 52px); height: clamp(42px, 11vh, 52px); }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring__track { stroke: var(--campo); }
.ring__fill { stroke: var(--accento); stroke-linecap: butt; }
.ring__num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; letter-spacing: -0.01em;
}
.ring__pc { font-size: 9px; font-weight: 640; margin-left: 1px; color: var(--grigio); }

/* the rolling number: the old value slides out, the new one in, inside a mask that fades the edges */
.roll {
  position: relative; display: inline-flex; justify-content: flex-end;
  height: 1.25em; line-height: 1.25em; overflow: hidden; vertical-align: bottom;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
          mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
.roll__in { display: block; white-space: nowrap; }
.roll__out { position: absolute; right: 0; top: 0; white-space: nowrap; }

/* the lessons */
.lessons {
  list-style: none;
  margin: 0 10px;
  border-top: 1px solid var(--linea);
  padding: 6px 0;
}
.lesson {
  position: relative;
  border-radius: 12px;
  padding: 0 8px;
  cursor: default;
}
.lesson__row {
  position: relative;
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px;
  height: clamp(28px, 7vh, 38px);
  font-size: 13px;
}
.lesson__title { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.3s; }
.lesson__time { font-size: 11.5px; color: var(--grigio); font-weight: 520; }

/* the status mark: an empty ring, a play mark for the lesson in progress, a filled disc with the check */
.mark { position: relative; width: 20px; height: 20px; }
.mark svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.mark__ring { fill: none; stroke: #d4d4d8; stroke-width: 1.5; }
.mark__disc { fill: var(--fatto); }
.mark__check { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mark__play { fill: var(--accento); }

.lesson.is-done .lesson__title { color: var(--grigio-chiaro); }
.lesson.is-done .lesson__time { color: var(--grigio-chiaro); }

/* the lesson in progress: a soft tint and the part that opens under the row */
.lesson__bg {
  position: absolute; inset: 0; border-radius: 12px;
  background: var(--accento-tenue);
  opacity: 0; pointer-events: none;
}
.lesson__more { position: relative; height: 0; overflow: hidden; }
.lesson__more-in {
  display: flex; align-items: center; gap: 10px;
  padding: 0 0 clamp(8px, 1.6vh, 11px) 30px;
}
.bar { position: relative; flex: 1; height: 4px; border-radius: 99px; background: rgba(79, 70, 229, 0.14); overflow: hidden; }
.bar__fill { position: absolute; inset: 0; border-radius: 99px; background: var(--accento); transform-origin: left center; transform: scaleX(0); }
.lesson__watch { font-size: 10.5px; color: var(--accento); font-weight: 600; white-space: nowrap; min-width: 50px; }
.done-btn {
  position: relative;
  border: 0; border-radius: 999px;
  height: 26px; padding: 0 11px;
  background: var(--inchiostro); color: #fff;
  font: inherit; font-size: 11.5px; font-weight: 620; white-space: nowrap;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  box-shadow: 0 1px 2px rgba(23, 23, 27, 0.2);
}
.done-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.done-btn:focus-visible, .foot__btn:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
@media (hover: hover) {
  .done-btn:hover { background: #2b2b33; }
  .foot__btn:hover { background: #3f37d6; }
}

/* the footer: Next up, then the completed state with the certificate */
.course__foot {
  position: relative;
  height: clamp(44px, 11vh, 58px);
  margin: 0 10px 10px;
  border-radius: 14px;
  background: var(--campo);
  overflow: hidden;
}
.foot__a, .foot__b {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
}
.foot__label { font-size: 11px; color: var(--grigio); font-weight: 560; }
.foot__next { font-size: 12.5px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot__b { opacity: 0; }
.cert { flex: none; width: 46px; height: 32px; display: block; filter: drop-shadow(0 4px 8px rgba(40, 40, 80, 0.18)); }
.cert svg { width: 100%; height: 100%; display: block; }
.cert__paper { fill: #fffdf7; stroke: #e7e2d4; }
.cert__frame { fill: none; stroke: #d9cfb3; stroke-width: 0.8; }
.cert__lines { stroke: #c9c3b4; stroke-width: 1.6; stroke-linecap: round; }
.cert__ribbon { fill: var(--accento); }
.cert__seal { fill: #f0b429; stroke: #d9971a; stroke-width: 0.6; }
.foot__done { display: flex; flex-direction: column; min-width: 0; }
.foot__title { font-size: 13px; font-weight: 680; color: var(--fatto); }
.foot__sub { font-size: 11px; color: var(--grigio); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot__btn {
  margin-left: auto;
  border: 0; border-radius: 999px; height: 28px; padding: 0 13px;
  background: var(--accento); color: #fff;
  font: inherit; font-size: 12px; font-weight: 620; cursor: pointer;
}

.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  pointer-events: none; z-index: 5; opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}
.ghost path { fill: #17171b; stroke: #ffffff; stroke-width: 1.4; stroke-linejoin: round; }

@media (max-width: 360px) {
  .course__head { padding-left: 14px; padding-right: 14px; }
  .lessons { margin: 0 6px; }
  .course__foot { margin: 0 6px 6px; }
  .lesson__watch { display: none; }
  .lesson__row { font-size: 12.5px; }
}
@media (max-height: 420px) {
  .lessons { padding: 3px 0; }
  .course__meta { margin-top: 2px; }
}
