/* Guided tour overlay (src/core/coach.js). Tokens only, so light and dark
   both work. Sits above sheets (--z-modal) but under toasts, so a toast the
   tour triggers (e.g. "Register a visitor first") is still readable. */

.coach {
  --coach-dim: rgba(10, 10, 12, 0.56);
  --coach-ring: var(--surface-raised);
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 5);
  pointer-events: none;
}
:root[data-theme="dark"] .coach {
  --coach-dim: rgba(0, 0, 0, 0.66);
  --coach-ring: var(--text-primary);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .coach {
    --coach-dim: rgba(0, 0, 0, 0.66);
    --coach-ring: var(--text-primary);
  }
}

/* Four panels around the lit area. They catch taps (and do nothing with
   them); the lit area itself is left open on "tap" steps. They only paint
   the dim while nothing is lit (waiting, fallback). With a target, the ring's
   shadow does the dimming, so the hole follows the control's own rounded
   shape instead of a hard rectangle. */
.coach__dim {
  position: fixed;
  background: var(--coach-dim);
  pointer-events: auto;
}
.coach[data-hole="true"] .coach__dim {
  background: transparent;
}

/* The lit area: a thin ring hugging the control, and a shadow that dims
   everything else. border-radius is set from the control (coach.js). */
.coach__ring {
  position: fixed;
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 0 2px var(--coach-ring),
    0 0 0 6px rgba(255, 255, 255, 0.2),
    0 0 0 200vmax var(--coach-dim);
  pointer-events: none;
  transition:
    left var(--duration-base) var(--ease-out),
    top var(--duration-base) var(--ease-out),
    width var(--duration-base) var(--ease-out),
    height var(--duration-base) var(--ease-out),
    border-radius var(--duration-base) var(--ease-out);
}

/* "Explain" steps: look, don't touch. */
.coach__shield {
  position: fixed;
  border-radius: var(--radius-lg);
  pointer-events: auto;
  cursor: not-allowed;
}

.coach__tag {
  position: fixed;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  pointer-events: none;
}

/* "Tap here": two rings pulse out of the lit control, in the step label's
   green. Nothing sits on top of the control, so its icon stays readable. */
.coach__ripple {
  position: fixed;
  pointer-events: none;
}
.coach__ripple span {
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--color-success);
  border-radius: var(--coach-radius, var(--radius-lg));
  opacity: 0;
  animation: coach-ripple 1.8s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.coach__ripple span + span {
  animation-delay: 0.9s;
}
@keyframes coach-ripple {
  0% {
    transform: scale(0.85);
    opacity: 0.95;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.coach__bubble {
  position: fixed;
  width: min(
    360px,
    calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))
  );
  padding: 16px 16px 12px;
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  transition:
    top var(--duration-base) var(--ease-out),
    left var(--duration-base) var(--ease-out);
}
.coach__bubble::after {
  content: "";
  position: absolute;
  left: var(--coach-arrow-x, 50%);
  width: 14px;
  height: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  transform: translateX(-50%) rotate(45deg);
  display: none;
}
.coach__bubble[data-side="below"]::after {
  display: block;
  top: -8px;
  border-right: 0;
  border-bottom: 0;
}
.coach__bubble[data-side="above"]::after {
  display: block;
  bottom: -8px;
  border-left: 0;
  border-top: 0;
}

/* Cramped screens (a phone on its side): title and hint only, so the bubble
   never sits on top of the control the user has to tap. The full text is
   still announced to screen readers. */
.coach__bubble--mini {
  padding: 10px 14px 6px;
}
.coach__bubble--mini .coach__text,
.coach__bubble--mini .coach__dots {
  display: none;
}
.coach__bubble--mini .coach__foot {
  margin-top: 4px;
}

.coach__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.coach__count {
  white-space: nowrap;
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-success);
}
.coach__dots {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
  margin-right: auto;
}
.coach__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--surface-border-strong);
}
.coach__dot.is-done {
  background: var(--color-success);
}
.coach__dot.is-on {
  width: 16px;
  background: var(--text-primary);
}

.coach__title {
  margin: 0 0 4px;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  overflow-wrap: anywhere;
}
.coach__text {
  margin: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.coach__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 44px;
}
.coach__back {
  min-height: 44px;
  padding: 0 8px;
  margin-left: -8px;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}
.coach__back:disabled {
  opacity: 0.4;
  cursor: default;
}
/* Leaves the whole tour, so it sits in the header, apart from Back and
   Next. A full-size tap target that doesn't push the header taller. */
.coach__skip {
  min-height: 44px;
  margin: -12px -8px -12px 0;
  padding: 0 8px;
  border: 0;
  white-space: nowrap;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--text-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.coach__hint {
  flex: 1;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-success);
}
.coach__next {
  min-height: 44px;
  min-width: 88px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-accent-500);
  color: var(--accent-on);
  font: inherit;
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.coach__back:focus-visible,
.coach__skip:focus-visible,
.coach__next:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Screen-reader announcements only. */
.coach__live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* Probe the JS reads to keep the bubble clear of the notch and home bar. */
.coach__safe {
  position: absolute;
  visibility: hidden;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

@media (prefers-reduced-motion: reduce) {
  /* One still ring instead of the pulse. */
  .coach__ripple span {
    animation: none;
    opacity: 0.8;
    transform: scale(1.12);
  }
  .coach__ripple span + span {
    display: none;
  }
  .coach__ring,
  .coach__bubble {
    transition: none;
  }
}
