:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --testo: #17171a;
  --testo-2: #6b6b73;
  --testo-3: #a6a6ae;
  --bordo: rgba(17, 17, 19, 0.12);
  --accento: #2f54eb;
  --accento-tenue: rgba(47, 84, 235, 0.12);
  --barra-spenta: #d4d4da;
  --focus: #2f54eb;
}

* { 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;
}

/* ---- the essay ---- */
.post {
  width: min(420px, 100%);
  display: grid;
  gap: clamp(8px, 1.8vh, 12px);
}

.post__kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--testo-3);
  font-weight: 500;
}

.post__title {
  font-family: "Newsreader Variable", Georgia, serif;
  font-weight: 450;
  font-size: clamp(24px, min(6.4vw, 6.4vh), 32px);
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.post__text {
  position: relative;
  font-family: "Newsreader Variable", Georgia, serif;
  font-size: clamp(15px, min(4.2vw, 4.4vh), 17px);
  line-height: 1.5;
  color: #3a3a40;
}

/* the soft marker that follows the word being read: GSAP owns its x, y, width, height */
.mark {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 5px;
  background: var(--accento-tenue);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
}

.post__text .w {
  position: relative;
  z-index: 1;
  transition: color 0.25s ease;
}

.post__text .w.is-read { color: var(--testo); }

.post__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(4px, 1vh, 8px);
  min-height: 46px;
}

.post__meta {
  font-size: 12.5px;
  color: var(--testo-2);
  white-space: nowrap;
}

/* ---- the pill that becomes the player: GSAP owns its width and transform ---- */
.listen {
  position: relative;
  height: 44px;
  flex: none;
}

.listen__bg {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--carta);
  border: 1px solid var(--bordo);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.05), 0 6px 18px -10px rgba(17, 17, 19, 0.22);
}

.listen__open {
  position: relative;
  height: 44px;
  padding: 0 16px 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--testo);
  font: inherit;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 999px;
}

.listen__open:focus-visible,
.player button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.listen__dur {
  color: var(--testo-3);
  font-weight: 450;
  font-variant-numeric: tabular-nums;
}

.ico {
  width: 18px;
  height: 18px;
  flex: none;
}

.ico--phones {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico--phones rect { fill: var(--testo); stroke: none; }

/* the player row, laid over the same pill */
.player {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 5px;
}

.player[hidden] { display: none; }

.player button {
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  color: var(--testo);
  -webkit-tap-highlight-color: transparent;
}

.player__toggle {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accento) !important;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 4px 10px -4px rgba(47, 84, 235, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.player__toggle .ico {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

.player__bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  flex: none;
}

.bar {
  display: block;
  width: 2.5px;
  height: 22px;
  border-radius: 2px;
  background: var(--barra-spenta);
  transform-origin: 50% 50%;
  transition: background-color 0.25s ease;
}

.bar.is-past { background: var(--accento); }

.player__time {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--testo-2);
  font-variant-numeric: tabular-nums;
  width: 34px;
  text-align: right;
  flex: none;
}

.player__speed {
  height: 26px;
  min-width: 34px;
  padding: 0 7px;
  border-radius: 7px;
  background: rgba(17, 17, 19, 0.05) !important;
  font-size: 12px !important;
  font-weight: 620;
  flex: none;
}

.speed__win {
  display: block;
  height: 16px;
  overflow: hidden;
  line-height: 16px;
}

.speed__lab {
  display: block;
  font-variant-numeric: tabular-nums;
}

.player__close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--testo-3) !important;
  flex: none;
}

.ico--close {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

@media (hover: hover) {
  .listen__open .ico--phones { transition: transform 0.35s cubic-bezier(.34, 1.56, .64, 1); }
  .listen__open:hover .ico--phones { transform: rotate(-9deg) translateY(-1px); }
  .listen__open:hover .listen__dur { color: var(--testo-2); }
  .player__close:hover { color: var(--testo) !important; }
  .player__speed:hover { background: rgba(17, 17, 19, 0.09) !important; }
}

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

@media (max-width: 380px) {
  .post__foot { flex-direction: column; align-items: flex-start; gap: 10px; }
}
