/* The Simulation in the browser (practice_pages/show): scenarios, then the conversation. Laid
   out for a phone: the page itself scrolls, and the buttons of a conversation stay at the bottom
   edge. */

/* The button classes set `display`, which would show what the controller hides. */
.practice [hidden] {
  display: none;
}

/* Room for what floats over the end of the page: the way back, as in the Wissen area. */
.home-content.practice {
  padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

.practice__step,
.practice__lines {
  display: grid;
  gap: var(--space-3);
}

.practice__question {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}

.practice__hint,
.practice__hearing {
  margin: 0;
  color: var(--ink-muted);
}

.practice__hearing:empty {
  display: none;
}

.practice__button {
  width: 100%;
  min-height: 3rem;
}

/* --- Conversation ------------------------------------------------------------------------------ */

/* Its bottom padding is the height of the bar, so the last line can scroll out from under it. */
.practice__conversation {
  --practice-bar-height: calc(8.5rem + env(safe-area-inset-bottom));

  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--practice-bar-height);
}

/* Stays below the header while the lines scroll: what happens now is always in sight. */
.practice__status {
  position: sticky;
  top: var(--home-header-height, 0px);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding-block: var(--space-3);
  background: var(--bg);
  font-weight: 650;
}

.practice__status::before {
  width: 0.7rem;
  height: 0.7rem;
  flex: none;
  border-radius: 50%;
  background: var(--line);
  content: "";
}

.practice__status[data-phase="listening"] {
  color: var(--accent);
}

.practice__status[data-phase="listening"]::before,
.practice__status[data-phase="speaking"]::before {
  background: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .practice__status[data-phase="listening"]::before {
    animation: practice-pulse 1.4s ease-in-out infinite;
  }
}

@keyframes practice-pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

.practice__hint {
  font-size: 0.9rem;
}

/* A line the page scrolls to stops below header and status and above the bar. */
.practice__line,
.practice__hearing {
  scroll-margin-top: calc(var(--home-header-height, 0px) + 3.5rem);
  scroll-margin-bottom: var(--practice-bar-height);
}

.practice__line {
  max-width: 88%;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-l);
  background: var(--accent-soft);
  justify-self: start;
  overflow-wrap: anywhere;
}

.practice__line--person {
  border: 1px solid var(--line);
  background: var(--surface);
  justify-self: end;
}

.practice__speaker {
  display: block;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

/* A reply is a role-play: the scene the narrator tells, set apart from what the Gegenüber says. */
.practice__part {
  display: block;
}

.practice__part + .practice__part {
  margin-top: var(--space-2);
}

.practice__part--scene {
  color: var(--ink-muted);
  font-style: italic;
}

.practice__hearing {
  font-style: italic;
  text-align: right;
}

.practice__bar {
  position: fixed;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  padding-block: var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* As wide as the page above it (.home-shell). */
.practice__bar-buttons {
  display: grid;
  width: min(calc(100% - (2 * var(--space-4))), 48rem);
  margin-inline: auto;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.practice__button--wide {
  grid-column: 1 / -1;
}

/* A phone keeps `:hover` on the button tapped last, and the shared buttons change colour on it:
   in the bar that would read as a state of the conversation. */
@media (hover: none) {
  .practice .button--primary:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
    background: var(--accent);
  }

  .practice .button--secondary:hover {
    border-color: var(--line);
    color: var(--ink);
    background: var(--surface);
  }

  .practice .button--danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--surface);
  }
}
