/* The countdown cover (cover.html). Uses the tokens in styles.css. One screen, centred:
   the logo, Penny, the promise, the clock, the slogan. */

.cover-page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--s-5) var(--s-4);
  /* A soft light behind Penny, the only decoration on the page */
  background:
    radial-gradient(ellipse 60% 45% at 50% 38%, rgba(78, 158, 255, 0.10), rgba(78, 158, 255, 0) 70%),
    var(--pearl);
}

.cover__head { display: flex; justify-content: center; }
.cover__head .brand__mark { height: 36px; }
.cover__head .brand__word { font-size: 1.5rem; }

.cover {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--s-7) 0;
}

.cover__penny {
  width: clamp(96px, 70px + 6vw, 140px);
  height: auto;
  filter: drop-shadow(0 18px 24px rgba(11, 18, 32, 0.16)) drop-shadow(0 4px 6px rgba(42, 108, 178, 0.18));
}

.cover__title {
  margin-top: var(--s-5);
  font-family: var(--f-display);
  font-weight: 300;
  font-size: var(--t-h2);
  line-height: 1.06;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.cover__lede {
  margin-top: var(--s-4);
  max-width: 34rem;
  color: var(--slate);
  font-size: var(--t-lede);
  line-height: 1.6;
  text-wrap: pretty;
}
.cover__lede time { color: var(--ink); font-weight: 500; }

/* The clock: four numbers in the display face, each with a quiet label under it */
.cover__clock {
  display: flex;
  justify-content: center;
  gap: clamp(var(--s-4), 0.5rem + 3vw, var(--s-7));
  margin-top: var(--s-7);
}
.cover__unit { display: flex; flex-direction: column; align-items: center; }
.cover__num {
  display: flex;
  font-family: var(--f-display);
  font-weight: 300;
  font-size: clamp(3rem, 1.6rem + 5.2vw, 6.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
}
/* Each digit sits in a fixed-width cell so the clock never shifts as numbers change */
.cover__digit {
  position: relative;
  display: inline-block;
  width: 0.62em;
  text-align: center;
}
.cover__label {
  margin-top: var(--s-2);
  color: var(--mist);
  font-size: var(--t-small);
}

.cover__status {
  margin-top: var(--s-5);
  min-height: 1.65em;
  color: var(--signal);
  font-weight: 500;
}
.cover__status:empty { visibility: hidden; }

.cover__foot { text-align: center; }
.cover__slogan {
  font-family: var(--f-display);
  font-weight: 300;
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.cover__line { margin-top: var(--s-1); color: var(--slate); font-size: var(--t-small); }

@media (max-width: 599px) {
  .cover { padding: var(--s-6) 0; }
  .cover__clock { margin-top: var(--s-6); }
  .cover__num { font-size: clamp(2.5rem, 1rem + 8vw, 3.25rem); }
}

/* Motion: the digits are written in, left to right like ink. A soft-edged mask sweeps across
   the new digit (a mask, not a coloured veil, so it works over the glow behind Penny).
   Only the digit that changed is written again. */
@media (prefers-reduced-motion: no-preference) {
  .cover__digit {
    -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
            mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
    -webkit-mask-size: 250% 100%;
            mask-size: 250% 100%;
    -webkit-mask-position: 0 0;
            mask-position: 0 0;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
  }
  .cover__digit.is-writing { animation: cover-write 0.9s cubic-bezier(0.45, 0, 0.25, 1) both; }
  @keyframes cover-write {
    from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
    to { -webkit-mask-position: 0 0; mask-position: 0 0; }
  }

  /* Page load: Penny, then the words, then the clock, in one short sequence */
  .cover__penny,
  .cover__title,
  .cover__lede,
  .cover__clock {
    animation: cover-rise 1s var(--ease) both;
  }
  .cover__title { animation-delay: 0.12s; }
  .cover__lede { animation-delay: 0.22s; }
  .cover__clock { animation-delay: 0.34s; }
  @keyframes cover-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }
}

/* ---- Penny, alive ----
   Her idle life (head bob, blink) comes from the pm- classes in styles.css. On the cover her
   chest light beats once a second with the clock, and she nods when she answers in the chat
   below, and again at launch. */
.cover__penny svg { display: block; width: 100%; height: auto; overflow: visible; }
@media (prefers-reduced-motion: no-preference) {
  .cover__penny .pm-light { animation: none; opacity: 0.6; }
  .cover__penny.is-beat .pm-light { animation: cover-beat 0.9s var(--ease) both; }
  .cover__penny.is-nod .pm-head { animation: pm-nod 0.9s ease-in-out 1; }
}
@keyframes cover-beat {
  0% { opacity: 1; transform: scale(1.22); }
  100% { opacity: 0.6; transform: scale(1); }
}

/* ---- Penny at work: example chats, one at a time ---- */
.work {
  width: min(100%, 27rem);
  margin-top: var(--s-7);
}
.work__title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}
.work__card {
  position: relative;
  margin-top: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-6);
  background: var(--paper);
  border-radius: 22px;
  box-shadow: var(--shadow-raised);
  text-align: left;
}
/* Every scene sits in the same spot, so the card is as tall as the longest one and never jumps */
.work__stage { display: grid; }
.work__scene {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.work__when {
  margin-bottom: var(--s-1);
  color: var(--mist);
  font-size: var(--t-micro);
  text-align: center;
}
.work__msg {
  max-width: 85%;
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-small);
  line-height: 1.5;
}
.work__msg--them {
  align-self: flex-end;
  background: var(--dusk);
  color: var(--ink);
  border-radius: 16px 16px 4px 16px;
}
.work__msg--penny {
  align-self: flex-start;
  background: var(--signal);
  color: var(--paper);
  border-radius: 16px 16px 16px 4px;
}
.work__dots { display: none; gap: 4px; padding: 6px 2px; }
.work__dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.work__pause {
  position: absolute;
  right: var(--s-3);
  bottom: var(--s-3);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--mist);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.work__pause svg { width: 14px; height: 14px; fill: currentColor; }
.work__pause:hover { background: var(--pearl); color: var(--ink); }
.work__pause:active { transform: scale(0.94); }
.work__pause:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* Without the script, the first chat simply shows in full. With it (.is-live), scenes play in
   steps: the customer's message, Penny typing, her reply. */
.work__scene:not(.is-active) { visibility: hidden; opacity: 0; }
.work__card.is-live .work__when,
.work__card.is-live .work__msg { opacity: 0; transform: translateY(8px); }
.work__card.is-live .is-asked .work__when,
.work__card.is-live .is-asked .work__msg--them,
.work__card.is-live .is-typing .work__msg--penny,
.work__card.is-live .is-replied .work__msg--penny { opacity: 1; transform: none; }
.work__card.is-live .is-typing .work__dots { display: inline-flex; }
.work__card.is-live .is-typing .work__text { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .work__card.is-live .work__scene { transition: opacity 0.5s var(--ease), visibility 0s linear 0.5s; }
  .work__card.is-live .work__scene.is-active { transition: opacity 0.5s var(--ease), visibility 0s; }
  .work__card.is-live .work__when,
  .work__card.is-live .work__msg { transition: opacity 0.45s var(--ease), transform 0.6s var(--ease); }
  .work__dots i { animation: dot-bounce 1.1s ease-in-out infinite; }
  .work__dots i:nth-child(2) { animation-delay: 0.15s; }
  .work__dots i:nth-child(3) { animation-delay: 0.3s; }
}

@media (max-width: 599px) {
  .work { margin-top: var(--s-6); }
  .work__card { padding: var(--s-4) var(--s-4) var(--s-6); }
}
