:root {
  --fondo: #000000;
  --carta: #0d0d0f;
  --testo: #f4f4f6;
  --testo-2: #9a9aa3;
  --testo-3: #5f5f68;
  --bordo: rgba(255, 255, 255, 0.08);
  --spento: rgba(255, 255, 255, 0.16);
  --spento-su: rgba(255, 255, 255, 0.3);
  --pieno: #f4f4f6;
  --focus: #8fb4ff;
  /* the chapter tint: the script writes it on .card when the chapter changes */
  --tinta: 18;
}

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

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.card {
  position: relative;
  width: min(420px, 100%);
  padding: clamp(16px, min(5vw, 4.6vh), 22px);
  border-radius: 20px;
  background: var(--carta);
  border: 1px solid var(--bordo);
  box-shadow: 0 30px 60px -30px hsla(var(--tinta), 70%, 45%, 0.35), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  display: grid;
  gap: clamp(10px, 2.6vh, 16px);
}

/* ---- cover and titles ---- */
.head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
}

.cover {
  position: relative;
  width: clamp(54px, min(16vw, 15vh), 68px);
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 100%, hsl(var(--tinta), 85%, 58%) 0%, transparent 60%),
    linear-gradient(160deg, hsl(calc(var(--tinta) + 25), 55%, 30%), hsl(calc(var(--tinta) - 15), 60%, 12%));
  box-shadow: 0 8px 22px -10px hsla(var(--tinta), 80%, 55%, 0.7);
}

.cover svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cover__dot { fill: #fff; }

.cover__arc {
  fill: none;
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linecap: round;
}

/* a thin light across the top edge of the cover */
.cover__shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 38%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  pointer-events: none;
}

.meta { min-width: 0; display: grid; gap: 3px; }

.meta__show {
  font-size: 11.5px;
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--testo-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta__show span { font-weight: 420; color: var(--testo-3); }

.meta__title {
  font-size: clamp(15px, min(4.4vw, 4.4vh), 18px);
  font-weight: 620;
  font-stretch: 92%;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.meta__chapter {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: var(--testo-2);
  min-width: 0;
}

.meta__lab { color: var(--testo-3); }

/* one line that rolls when its text changes: the old text leaves before the new one arrives */
.roll {
  position: relative;
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  white-space: nowrap;
  min-width: 0;
}

.roll > span { display: inline-block; }

.meta__chapter .roll { color: hsl(var(--tinta), 80%, 72%); text-overflow: ellipsis; }

/* ---- the chapter track ---- */
.track {
  position: relative;
  height: 22px;
  margin-top: clamp(34px, 7vh, 40px);
  touch-action: none;
  cursor: pointer;
}

.bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  outline: none;
}

.bar:focus-visible { box-shadow: 0 0 0 2px var(--focus); border-radius: 6px; }

/* every chapter is a segment: GSAP-free, the script writes left, width and height on every frame */
.seg {
  position: absolute;
  top: 50%;
  height: 4px;
  border-radius: 99px;
  background: var(--spento);
  overflow: hidden;
  transform: translateY(-50%);
}

.seg__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--pieno);
  border-radius: inherit;
}

.seg__hint {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: inherit;
  transition: width 0.12s linear;
}

/* the tint under the head: only the chapter that is playing glows faintly in its colour */
.seg__glow {
  position: absolute;
  inset: 0;
  background: hsl(var(--tinta), 85%, 62%);
  opacity: 0;
}

.knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ---- the chapter title above the bar ---- */
.tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

.tip__in {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px 7px;
  border-radius: 9px;
  background: #1c1c20;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.8);
  font-size: 12px;
}

.tip__in b { font-weight: 600; }
.tip__in i { font-style: normal; color: var(--testo-2); }

/* ---- times ---- */
.times {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--testo-3);
}

.times span { min-width: 4.2ch; }
.times span:last-child { text-align: right; }

/* ---- controls ---- */
.controls {
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: center;
  gap: clamp(12px, 5vw, 22px);
}

.controls > :first-child { grid-column: 2; }

.btn {
  position: relative;
  border: 0;
  padding: 0;
  background: none;
  color: var(--testo);
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 50%; }

.btn svg { display: block; }

.btn--skip { width: 38px; height: 38px; }

.btn--skip svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn--skip small {
  position: absolute;
  font-size: 8.5px;
  font-weight: 650;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -38%);
}

.btn--play {
  width: clamp(46px, min(13vw, 12vh), 54px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f4f4f6;
  color: #000;
  box-shadow: 0 10px 24px -10px hsla(var(--tinta), 80%, 60%, 0.65);
}

.btn--play svg { width: 46%; height: 46%; fill: currentColor; }

.btn--speed {
  grid-column: 5;
  justify-self: end;
  min-width: 34px;
  height: 24px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--testo-2);
}

@media (hover: hover) {
  .btn--skip:hover { color: #fff; }
  .btn--speed:hover { color: var(--testo); border-color: rgba(255, 255, 255, 0.28); }
}

/* ---- the drawn pointer of the autopilot ---- */
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #ffffff;
  stroke: #000000;
  stroke-width: 1.3;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
