/*
 * Scroll-driven tour of the player screen. A screenshot of the app sits in a sticky phone
 * frame; as each step scrolls past, a spotlight moves to that control and a small animation
 * plays over the screenshot. Everything drawn over the screenshot is in image pixels
 * (1080 x 1920) converted to cqw, so it scales with the phone. Colours drawn over the
 * screenshot are sampled from it at runtime (see feature-tour.js) and arrive as --s-*.
 */
.tour { padding: clamp(3rem, 7vw, 5.5rem) 0; }
.tour__head { max-width: 42rem; margin-bottom: 1rem; }
.tour__grid {
  --phone-w: min(460px, calc((100vh - 104px) * 0.5625));
  --bezel: calc(var(--phone-w) * 0.036);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
}

/* Steps */
.tour__steps { list-style: none; margin: 0; padding: 0; }
.tour__step {
  min-height: 56vh; display: flex; flex-direction: column; justify-content: center;
  max-width: 30rem; opacity: 0.35; transition: opacity 300ms ease;
}
.tour__step:first-child { min-height: 46vh; }
/* Tall enough that the phone is still pinned while the last step is centred. */
.tour__step:last-child { min-height: calc(var(--phone-w) * 1.7778 + 4rem); }
.tour__step.is-active { opacity: 1; }
.tour__step h3 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); }
.tour__step p { color: var(--xc-fg-muted); font-size: 1.08rem; }
.tour__num {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--xc-primary-container); color: var(--xc-on-primary-container);
  font-weight: 750; font-size: 0.95rem; margin-bottom: 0.9rem;
}
.tour__meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; }
.tour__meta .tour__num { margin-bottom: 0; }
.tour__badge {
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--xc-secondary-container); color: var(--xc-on-secondary-container);
}
.tour__hint { font-size: 0.92rem; color: var(--xc-fg-muted); }
.tour__hint::before { content: "Try it: "; font-weight: 650; color: var(--xc-primary); }

/* Stage */
.tour__stage {
  position: sticky; top: calc(64px + (100vh - 64px - var(--phone-w) * 1.7778) / 2);
  display: flex; align-items: center; justify-content: center; gap: calc(var(--bezel) + 1.75rem);
}
/* A vertical rail between the text and the phone, so it reads as scroll progress. */
.tour__dots {
  order: -1; position: relative; display: flex; flex-direction: column; gap: 0.75rem;
}
.tour__dots::before {
  content: ""; position: absolute; left: 50%; top: 0.5rem; bottom: 0.5rem; width: 2px;
  margin-left: -1px; background: var(--xc-outline-variant);
}
/* Numbered like the steps themselves, so each one is clearly a stop on the way down. */
.tour__dots button {
  position: relative; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; padding: 0;
  border-radius: 50%; border: 2px solid var(--xc-outline-variant); cursor: pointer;
  background: var(--xc-bg); color: var(--xc-fg-muted);
  font: 700 0.8rem/1 var(--xc-font-sans);
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease, transform 200ms ease;
}
.tour__dots button:hover { border-color: var(--xc-primary); color: var(--xc-primary); }
.tour__dots button.is-active {
  background: var(--xc-primary); border-color: var(--xc-primary); color: var(--xc-on-primary); transform: scale(1.15);
}

/* Phone */
.phone {
  position: relative; width: var(--phone-w); aspect-ratio: 1080 / 1920;
  /* Sized from --phone-w: cqw on the phone itself would resolve against the viewport. */
  container-type: inline-size; overflow: hidden; border-radius: 30px;
  box-shadow: 0 0 0 var(--bezel) black, 0 0 0 calc(var(--bezel) + 1px) var(--xc-outline-variant), 0 40px 80px -30px rgba(0, 0, 0, 0.55);
  font-family: Roboto, "Helvetica Neue", Arial, sans-serif; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.phone__img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.phone__img--dark { display: none; }
@media (prefers-color-scheme: dark) {
  .phone__img--light { display: none; }
  .phone__img--dark { display: block; }
}

.phone__svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.phone__fx { position: absolute; inset: 0; pointer-events: none; }
.phone__fx > * { position: absolute; }
.phone .spot { fill: rgba(0, 0, 0, 0.5); transition: opacity 400ms ease; }
.phone .spot-ring { fill: none; stroke: var(--xc-ad); stroke-width: 5; transition: opacity 400ms ease; }

/* Patches cover a piece of the screenshot with its own background and redraw it. */
.patch {
  display: flex; align-items: center; white-space: nowrap; line-height: 1;
  opacity: 0; transition: opacity 180ms ease;
}
.patch.is-on { opacity: 1; }
.patch--time { background: var(--s-bg-times); color: var(--s-ink-times); font-size: 3.05cqw; }
.patch--time-right { justify-content: flex-end; background: var(--s-bg-times-right); }
.patch--speed { background: var(--s-bg-speed); color: var(--s-accent); font-size: 3.4cqw; font-weight: 500; }
.patch--sleep {
  background: var(--s-bg-speed); color: var(--s-accent); font-size: 3.1cqw; font-weight: 600;
  justify-content: center;
}
.patch--chip {
  background: var(--s-chip); color: var(--s-chip-ink); font-size: 3.35cqw; font-weight: 500;
  justify-content: center;
}

/* Transcript */
.transcript {
  overflow: hidden; background: var(--s-bg-bottom); opacity: 0; transition: opacity 200ms ease;
  /* Keeps the edge fades below the spotlight; at opacity 1 they would otherwise escape it. */
  isolation: isolate;
}
/* Fade the lines at the edges by painting the background over them. A mask would also fade
   the panel, letting the screenshot's own text show through. */
.transcript::before, .transcript::after {
  content: ""; position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none;
}
.transcript::before { top: 0; height: 18%; background: linear-gradient(var(--s-bg-bottom), transparent); }
.transcript::after { bottom: 0; height: 12%; background: linear-gradient(transparent, var(--s-bg-bottom)); }
.transcript.is-on { opacity: 1; pointer-events: auto; }
.transcript__list { margin: 0; padding: 0 5.9cqw; transition: transform 600ms cubic-bezier(.2, .7, .2, 1); }
.transcript__line {
  margin: 0 0 3.05cqw; font-size: 3.15cqw; line-height: 1.53; color: var(--s-ink-dim); cursor: pointer;
  transition: color 300ms ease;
}
.transcript__line.is-active { font-size: 3.7cqw; line-height: 1.55; font-weight: 600; color: var(--s-ink-strong); }

/* Ripples, floating labels and tooltips */
.ripple {
  width: 14cqw; height: 14cqw; margin: -7cqw 0 0 -7cqw; border-radius: 50%;
  background: currentColor; color: var(--s-accent); animation: tour-ripple 650ms ease-out forwards;
}
@keyframes tour-ripple {
  from { transform: scale(0.2); opacity: 0.45; }
  to { transform: scale(1); opacity: 0; }
}
.float {
  transform: translate(-50%, -50%); padding: 1cqw 2.4cqw; border-radius: 99px; font-size: 3.2cqw;
  font-weight: 600; background: var(--s-chip); color: var(--s-chip-ink); white-space: nowrap;
  animation: tour-float 1100ms ease-out forwards;
}
@keyframes tour-float {
  0% { opacity: 0; transform: translate(-50%, -50%); }
  20% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -170%); }
}
.tip {
  transform: translate(-50%, -100%); padding: 0.9cqw 2.2cqw; border-radius: 1.6cqw;
  font-size: 2.8cqw; font-weight: 600; white-space: nowrap; line-height: 1.2;
  background: var(--s-chip); color: var(--s-chip-ink); opacity: 0;
  transition: opacity 250ms ease, transform 250ms ease;
}
.tip::after {
  content: ""; position: absolute; left: 50%; bottom: -1.2cqw; margin-left: -1.2cqw;
  border: 1.2cqw solid transparent; border-bottom: 0; border-top-color: var(--s-chip);
}
.tip.is-on { opacity: 1; transform: translate(-50%, calc(-100% - 1.5cqw)); }

/* The app's option dialog (OptionDialog.kt): a title, full-width text buttons, Cancel. */
.dialog {
  inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.42);
  opacity: 0; transition: opacity 200ms ease;
}
.dialog.is-on { opacity: 1; pointer-events: auto; }
.dialog__card {
  width: 74%; padding: 5.5cqw 5cqw 3cqw; border-radius: 6cqw;
  background: color-mix(in srgb, var(--s-bg-bottom) 90%, var(--s-accent));
  color: var(--s-ink-strong); transform: scale(0.94); transition: transform 200ms ease;
}
.dialog.is-on .dialog__card { transform: none; }
.dialog__title { font-size: 4.6cqw; margin-bottom: 3cqw; }
.dialog__opt, .dialog__cancel {
  display: block; width: 100%; border: 0; background: none; font-family: inherit; cursor: pointer;
}
.dialog__opt {
  font-size: 3.4cqw; font-weight: 500; color: var(--s-accent); text-align: center;
  padding: 2.1cqw 0; border-radius: 99px; transition: background 150ms ease;
}
.dialog__opt.is-hot { background: color-mix(in srgb, var(--s-accent) 18%, transparent); }
.dialog__cancel { text-align: right; padding-right: 2cqw; font-size: 3.4cqw; font-weight: 500; color: var(--s-accent); margin-top: 1.5cqw; }

/* Invisible buttons over the controls, so the tour can be played with directly. */
.hot { position: absolute; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 50%; }
.hot:focus-visible { outline: 3px solid var(--xc-ad); outline-offset: 0; }
.hot--wide { border-radius: 2.5cqw; }

/* Small screens: the phone sticks to the top and the steps scroll up beneath it. */
@media (max-width: 860px) {
  .tour__grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tour__grid { --phone-w: min(300px, calc((100vh - 64px) * 0.52 * 0.5625)); }
  .tour__stage {
    order: -1; top: 64px; z-index: 2; padding: 1rem 0 0.75rem; gap: 1.25rem;
    background: linear-gradient(var(--xc-bg) 88%, transparent);
  }
  .tour__step, .tour__step:first-child { min-height: 55vh; justify-content: flex-start; padding-top: 1rem; }
  .tour__step:last-child { min-height: 60vh; }
}

@media (prefers-reduced-motion: reduce) {
  .transcript__list, .tour__step, .patch, .dialog, .dialog__card, .tip { transition: none; }
}
