/* Tutorial player (ui.tutorial, ADR-0031): non-modal coach card docked bottom right (bottom sheet on
   phones) and the outline of the current target element. No inline styles (CSP). */

/* Docked above the assistant button (bottom 4.75rem + its height) and the review toolbar. */
.ui-tutorial {
  position: fixed;
  right: 1.25rem;
  bottom: 8.5rem;
  z-index: 1085;
  width: min(24rem, calc(100vw - 2rem));
}

.ui-tutorial[hidden] {
  display: none;
}

.ui-tutorial--preview {
  position: static;
  width: min(24rem, 100%);
}

.ui-tutorial__card {
  display: grid;
  padding: 1.1rem 1.2rem 1rem;
  gap: 0.55rem;
  color: var(--color-ink);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-brand-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 18px 50px var(--color-shadow);
}

.ui-tutorial__card:focus-visible {
  outline: 0;
  box-shadow:
    var(--focus-ring),
    0 18px 50px var(--color-shadow);
}

.ui-tutorial__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ui-tutorial__eyebrow {
  min-width: 0;
  overflow: hidden;
  color: var(--color-brand-text);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ui-tutorial__count {
  margin-left: auto;
  color: var(--color-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.ui-tutorial__close {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  color: var(--color-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font-size: 1.15rem;
  line-height: 1;
}

.ui-tutorial__close:hover {
  color: var(--color-ink);
  background: var(--color-surface-soft);
}

.ui-tutorial__title {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

.ui-tutorial__body,
.ui-tutorial__hint {
  margin: 0;
  color: var(--color-ink-soft);
  font-size: 0.85rem;
  line-height: 1.6;
}

.ui-tutorial__hint {
  padding: 0.5rem 0.65rem;
  color: var(--color-info-line-fg);
  background: var(--color-info-line-bg);
  border-left: 3px solid var(--color-info-line-border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.ui-tutorial__progress {
  width: 100%;
  height: 0.3rem;
}

.ui-tutorial__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.ui-tutorial__spacer {
  flex: 1 1 auto;
}

.ui-tutorial__quit {
  padding-left: 0;
  color: var(--color-muted);
}

/* Current target of a highlight step: yellow marker (stands out from the teal brand UI in both
   themes) with a thin dark edge so it also reads on white, plus a pulsing yellow halo. */
:root {
  --ui-tutorial-mark: #ffd21f;
  --ui-tutorial-mark-edge: #3d3100;
}

.ui-tutorial-target {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--ui-tutorial-mark);
  outline-offset: 3px;
  border-radius: var(--radius-md);
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--ui-tutorial-mark) 35%, transparent),
    0 0 0 7px color-mix(in srgb, var(--ui-tutorial-mark-edge) 35%, transparent);
  animation: ui-tutorial-pulse 1.8s ease-out infinite;
}

@keyframes ui-tutorial-pulse {
  0% {
    box-shadow:
      0 0 0 6px color-mix(in srgb, var(--ui-tutorial-mark) 45%, transparent),
      0 0 0 6px color-mix(in srgb, var(--ui-tutorial-mark) 55%, transparent);
  }
  100% {
    box-shadow:
      0 0 0 6px color-mix(in srgb, var(--ui-tutorial-mark) 35%, transparent),
      0 0 0 1.1rem transparent;
  }
}

/* Animated arrow pointing at the target (positioned by ui-tutorial.js, follows scrolling). */
.ui-tutorial-arrow {
  position: fixed;
  z-index: 1084;
  width: 2.5rem;
  height: 3rem;
  margin-left: -1.25rem;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgb(0 0 0 / 0.35));
  animation: ui-tutorial-bob 0.9s ease-in-out infinite alternate;
}

.ui-tutorial-arrow[hidden] {
  display: none;
}

.ui-tutorial-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ui-tutorial-arrow__shape {
  fill: var(--ui-tutorial-mark);
  stroke: var(--ui-tutorial-mark-edge);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

/* Below the target, pointing up (no room above it). */
.ui-tutorial-arrow--up svg {
  rotate: 180deg;
}

.ui-tutorial-arrow--up {
  animation-name: ui-tutorial-bob-up;
}

@keyframes ui-tutorial-bob {
  from {
    translate: 0 -0.55rem;
  }
  to {
    translate: 0 0;
  }
}

@keyframes ui-tutorial-bob-up {
  from {
    translate: 0 0.55rem;
  }
  to {
    translate: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-tutorial-target,
  .ui-tutorial-arrow {
    animation: none;
  }
}

@media (max-width: 36rem) {
  /* Above the floating review toolbar and the assistant button. */
  .ui-tutorial {
    right: 0.5rem;
    bottom: 8.5rem;
    left: 0.5rem;
    width: auto;
  }

  .ui-tutorial--preview {
    width: 100%;
  }
}

/* Open surfaces: offcanvas panels sit on the right, modals in the centre. Dock the card bottom left
   and narrow it so it covers neither the offcanvas footer nor the edge of a centred modal. */
@media (min-width: 36.01rem) {
  body.ui-surface-open .ui-tutorial:not(.ui-tutorial--preview) {
    right: auto;
    left: 1.25rem;
    width: min(20rem, calc(100vw - 2rem));
  }
}
