/* The course list of Halyard, a made-up online design school, and the page of one course. The detail sits on top of
   the list; script.js moves its pieces (sheet, header, title, numbers, price, button) from the card to their place
   and back. GSAP moves the outer elements; hover and press live on the children (one element for GSAP, the child for
   the CSS). */
:root {
  --room: #e9e7e2;          /* the background around the app */
  --room-deep: #dcd9d2;     /* the background in the corners */
  --panel: #f6f5f2;         /* the app behind the cards */
  --card: #ffffff;          /* the cards and the course page */
  --ink: #16161b;           /* the words */
  --muted: #84848d;         /* the small words */
  --line: rgba(22, 22, 27, 0.08); /* hairlines */
  --star: #e0a43a;          /* the rating star */
  --c: #3a49c9;             /* the colour of the open course (script.js sets it from COURSES) */
}

* { box-sizing: border-box; }

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

body {
  font-family: 'Instrument 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; }

.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 course */
.glow {
  position: absolute;
  width: min(560px, 120vw, 110vh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--c) 22%, transparent), transparent);
  filter: blur(20px);
  opacity: 0.55;
  transition: background 0.8s ease;
  pointer-events: none;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  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 app window */
.app {
  position: relative;
  width: min(392px, 94vw);
  height: min(580px, 94vh);
  border-radius: min(30px, 6vh);
  background: var(--panel);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(22, 22, 27, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 2px 4px rgba(22, 22, 27, 0.04),
    0 18px 40px -12px rgba(22, 22, 27, 0.18),
    0 50px 90px -40px rgba(22, 22, 27, 0.25);
  isolation: isolate;
}

/* ---- the list ---- */
.list {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: min(20px, 3.6vh) min(18px, 4.6vw);
  gap: min(14px, 2.4vh);
}

.list__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.mark { width: 12px; height: 12px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }

.list__title {
  margin: 0;
  font-size: min(23px, 5.4vh);
  font-weight: 620;
  font-stretch: 96%;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.round {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(22, 22, 27, 0.05);
}
.round svg { width: 17px; height: 17px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: min(10px, 1.8vh);
}

.card {
  flex: 1 1 0;
  max-height: 148px;
  min-height: 0;
  position: relative;
}

.card__hit {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  gap: 12px;
  padding: min(12px, 2vh);
  text-align: left;
  border-radius: 20px;
  background: var(--card);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px rgba(22, 22, 27, 0.04),
    0 8px 18px -12px rgba(22, 22, 27, 0.18);
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), box-shadow 0.45s ease;
  overflow: hidden;
}
.card__hit:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.card.is-hover .card__hit {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(22, 22, 27, 0.1),
    0 2px 4px rgba(22, 22, 27, 0.05),
    0 16px 30px -14px rgba(22, 22, 27, 0.28);
}
.card.is-press .card__hit { transform: translateY(0) scale(0.985); transition-duration: 0.12s; }
@media (hover: hover) {
  .card__hit:hover {
    transform: translateY(-2px);
    box-shadow:
      0 0 0 1px rgba(22, 22, 27, 0.1),
      0 2px 4px rgba(22, 22, 27, 0.05),
      0 16px 30px -14px rgba(22, 22, 27, 0.28);
  }
  .card__hit:hover .glyph { transform: rotate(-8deg) scale(1.04); }
  .card__hit:active { transform: translateY(0) scale(0.985); transition-duration: 0.12s; }
}
.card.is-hover .glyph { transform: rotate(-8deg) scale(1.04); }

/* the light that runs over a card when it lands back */
.card__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.85) 50%, transparent 65%);
  mix-blend-mode: soft-light;
  opacity: 0;
}

.cover {
  position: relative;
  height: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.paint {
  background:
    radial-gradient(110% 90% at 18% 8%, color-mix(in oklab, var(--cc) 55%, white) 0%, transparent 62%),
    radial-gradient(80% 70% at 100% 100%, color-mix(in oklab, var(--cc) 70%, black) 0%, transparent 70%),
    var(--cc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.glyph {
  width: 62%;
  aspect-ratio: 1;
  display: block;
  transition: transform 0.6s cubic-bezier(0.34, 1.4, 0.5, 1);
}
.glyph svg, .hero__glyph svg { width: 100%; height: 100%; display: block; overflow: visible; }

.card__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: min(5px, 0.9vh);
}

.kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 540;
  color: var(--muted);
  white-space: nowrap;
}
.rate { display: inline-flex; align-items: center; gap: 3px; color: var(--ink); }
.rate b { font-weight: 600; font-variant-numeric: tabular-nums; }
.star { width: 11px; height: 11px; fill: var(--star); flex: none; }

.card__title {
  margin: 0;
  font-size: min(15.5px, 4.3vw);
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  line-height: 1.15;
  transform-origin: 0 0;
}

.meta {
  display: flex;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.meta b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.card__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
}
.price { font-size: 15px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.pill {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--cc);
  background: color-mix(in oklab, var(--cc) 11%, white);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--cc) 16%, transparent);
}

/* ---- the course page ---- */
.detail {
  position: absolute;
  inset: 0;
  visibility: hidden;
  z-index: 2;
}
.app.is-moving .detail,
.app.is-open .detail { visibility: visible; }

.sheet {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--card);
}

.hero {
  --cc: var(--c);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: clamp(104px, 31%, 220px);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.hero__glyph {
  position: absolute;
  right: 12%;
  top: calc(clamp(104px, 31%, 220px) / 2);
  width: min(112px, 21vh);
  aspect-ratio: 1;
  margin-top: max(-56px, -10.5vh);
  transform-origin: 0 0;
}
.hero__sheen {
  position: absolute;
  inset: -20% -40%;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.38) 50%, transparent 60%);
  transform: translateX(-80%);
  pointer-events: none;
}

.back {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 4px 12px -4px rgba(0, 0, 0, 0.25);
  z-index: 3;
  transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.5, 1), background 0.3s ease;
}
.back svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back:active { transform: scale(0.92); }
@media (hover: hover) { .back:hover { background: rgba(255, 255, 255, 0.32); transform: translateX(-1px); } }

.chip {
  position: absolute;
  left: 20px;
  top: calc(clamp(104px, 31%, 220px) - 38px);
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.body {
  position: absolute;
  left: 0;
  right: 0;
  top: clamp(104px, 31%, 220px);
  bottom: min(76px, 17vh);
  padding: min(18px, 3vh) 20px 0;
  display: flex;
  flex-direction: column;
}

.d-title {
  margin: 0;
  align-self: flex-start;
  font-size: min(27px, 7.2vw, 6.2vh);
  font-weight: 640;
  font-stretch: 96%;
  letter-spacing: -0.025em;
  line-height: 1.12;
  white-space: nowrap;
  transform-origin: 0 0;
}

.by { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.by span { color: var(--ink); font-weight: 560; }

.stats {
  margin-top: min(16px, 2.6vh);
  padding: min(12px, 2vh) 0;
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat { flex: 1; display: flex; flex-direction: column; gap: 2px; padding-left: 14px; }
.stat:first-child { padding-left: 0; }
.stat__rule { width: 1px; background: var(--line); }
.stat__n {
  align-self: flex-start;
  font-size: min(20px, 4.8vh);
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform-origin: 0 0;
}
.stat__n--rate { display: inline-flex; align-items: center; gap: 0.18em; }
.stat__n--rate .star { width: 0.72em; height: 0.72em; }
.stat__n--rate b { font-weight: inherit; }
.stat__l { font-size: 11px; color: var(--muted); }

.cur-head {
  display: flex;
  justify-content: space-between;
  margin: min(14px, 2.4vh) 0 min(6px, 1vh);
  font-size: 12px;
  font-weight: 600;
}
.cur-head__n { color: var(--muted); font-weight: 500; }

.lessons-box {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 70%, transparent);
  mask-image: linear-gradient(#000 70%, transparent);
}
.lessons { list-style: none; margin: 0; padding: 0; }
.lesson {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: min(42px, 8.4vh);
  font-size: 13px;
  transform-origin: 0 0;
}
.lesson::after {
  content: '';
  position: absolute;
  left: 30px;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--line);
  transform-origin: 0 0;
  transform: scaleX(var(--rule, 1));
}
.lesson__icon {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--c) 30%, transparent);
}
.lesson__icon svg { width: 8px; height: 8px; fill: var(--c); }
.lesson.is-first .lesson__icon { background: var(--c); box-shadow: 0 3px 8px -2px color-mix(in oklab, var(--c) 60%, transparent); }
.lesson.is-first .lesson__icon svg { fill: #fff; margin-left: 1px; }
.lesson__name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 520; }
.lesson__time { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(76px, 17vh);
  padding: 0 16px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bar__bg {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bar__price { position: relative; display: flex; flex-direction: column; min-width: 0; }
.bar__price b {
  align-self: flex-start;
  font-size: min(22px, 5vh);
  font-weight: 660;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  transform-origin: 0 0;
}
.bar__price span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.cta {
  position: relative;
  flex: none;
  width: min(190px, 52%);
  height: min(48px, 11vh);
  border-radius: 999px;
  color: #fff;
  background: var(--c);
  font-size: 14px;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 10px 22px -10px color-mix(in oklab, var(--c) 80%, transparent);
  transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.5, 1), filter 0.3s ease;
}
.cta > span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.cta__a { opacity: 0; }
.cta svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.5, 1); }
.cta:active { transform: scale(0.97); }
@media (hover: hover) {
  .cta:hover { filter: brightness(1.06); }
  .cta:hover svg { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
  .card__hit, .glyph, .cta, .back { transition: none; }
}
