/* ==================================================================================================
   Product tour — spotlight veil, glowing ring, spring card                     owner: hub
   Markup is built by static/js/tour.js (.tour popover layer → .tour__veil, .tour__ring, .tour__card).
   ================================================================================================== */

.tour {
  position: fixed;
  inset: 0;
  z-index: var(--z-progress);
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  color: var(--text);
  background: transparent;
  border: 0;
  /* the layer itself blocks clicks on the page while the tour runs */
  pointer-events: auto;
}
.tour::backdrop {
  background: transparent;
}

/* Veil: dim + blur everything except the spotlight hole (clip-path set from JS) */
.tour__veil {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(3px) saturate(120%);
  backdrop-filter: blur(3px) saturate(120%);
  opacity: 0;
}
.tour.is-open .tour__veil {
  opacity: 1;
}

/* Ring around the spotlight */
.tour__ring {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--ring-w, 0);
  height: var(--ring-h, 0);
  border-radius: var(--ring-r, 12px);
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 0 7px color-mix(in srgb, var(--accent) 22%, transparent),
    0 0 32px 4px color-mix(in srgb, var(--accent) 35%, transparent);
  transform: translate(var(--ring-x, 50vw), var(--ring-y, 50vh));
  pointer-events: none;
}
.tour__ring.is-hidden {
  opacity: 0;
}

/* Card */
.tour__card {
  position: absolute;
  top: 0;
  left: 0;
  width: min(360px, calc(100vw - 24px));
  padding: var(--space-5);
  color: var(--text);
  background: var(--surface-elevated);
  border-radius: var(--radius-xl);
  box-shadow:
    0 0 0 1px var(--line),
    var(--shadow-xl);
  transform: translate(var(--tour-x, 50vw), var(--tour-y, 50vh));
  outline: none;
  touch-action: pan-y; /* horizontal swipes reach tour.js (next / back) */
}
.tour__card.has-art {
  width: min(400px, calc(100vw - 24px));
  text-align: center;
}
.tour__art:empty {
  display: none;
}
.tour__art {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: var(--space-1) auto var(--space-4);
  color: var(--text-on-accent);
  background:
    radial-gradient(120% 120% at 20% 0%, color-mix(in srgb, var(--c-pink) 70%, transparent), transparent 60%),
    linear-gradient(135deg, var(--accent), var(--c-purple));
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--text-on-accent) 35%, transparent),
    0 10px 24px -8px color-mix(in srgb, var(--accent) 60%, transparent);
}
.tour__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.tour__card.has-art .tour__head {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  left: var(--space-5);
}
.tour__count {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--accent-ink);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tour__close {
  margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0 auto;
}
.tour__title {
  margin: 0 0 var(--space-1-5, 6px);
  font-family: var(--font-display);
  font-size: var(--fs-title-3);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight, 1.2);
  letter-spacing: var(--tracking-tight);
}
.tour__text {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text-2);
}
.tour__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.tour__card.has-art .tour__foot {
  flex-direction: column-reverse;
}
.tour__dots {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0;
}
.tour__dot {
  position: relative;
  flex: none;
  width: 11px;
  height: 20px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.tour__dot::after {
  position: absolute;
  top: 7px;
  left: 2px;
  width: 6px;
  height: 6px;
  content: "";
  background: var(--fill-3);
  border-radius: var(--radius-full);
}
.tour__dot[aria-current="step"] {
  width: 20px;
}
.tour__dot[aria-current="step"]::after {
  width: 15px;
  background: var(--accent);
}
.tour__dot:focus-visible {
  outline: 2px solid var(--focus-ring);
}
.tour__actions {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}
.tour__card.has-art .tour__actions {
  justify-content: center;
  width: 100%;
  margin-left: 0;
}
.tour__card.has-art .tour__next {
  min-width: 160px;
}

/* Phones: bottom (or top) sheet */
.tour__card[data-side="sheet"],
.tour__card[data-side="sheet-top"] {
  width: calc(100vw - 24px);
}

/* Fallback when the Popover API is missing */
.tour--fallback {
  z-index: 2147483000;
}

/* Motion: spring card, gliding spotlight */
@media (prefers-reduced-motion: no-preference) {
  .tour__veil {
    transition:
      opacity var(--dur-3) var(--ease-out),
      clip-path var(--dur-4) var(--ease-spring);
  }
  .tour__ring {
    transition:
      transform var(--dur-4) var(--ease-spring),
      width var(--dur-4) var(--ease-spring),
      height var(--dur-4) var(--ease-spring),
      opacity var(--dur-2) var(--ease-out);
  }
  .tour__ring:not(.is-hidden) {
    animation: tour-pulse 2.4s var(--ease-in-out) infinite;
  }
  .tour__card {
    opacity: 0;
    transition:
      transform var(--dur-4) var(--ease-spring),
      opacity var(--dur-2) var(--ease-out);
  }
  .tour__card.is-in {
    opacity: 1;
    animation: tour-card-in var(--dur-4) var(--ease-spring);
  }
  .tour.is-leaving .tour__veil,
  .tour.is-leaving .tour__ring,
  .tour.is-leaving .tour__card {
    opacity: 0;
    transition: opacity var(--dur-2) var(--ease-out);
  }
  .tour__dot::after {
    transition:
      width var(--dur-3) var(--ease-spring),
      background-color var(--dur-2) var(--ease-out);
  }
}
@keyframes tour-card-in {
  from {
    opacity: 0;
    scale: 0.92;
    translate: calc(var(--tour-dir, 1) * 18px) 6px;
  }
  to {
    opacity: 1;
    scale: 1;
    translate: 0 0;
  }
}
@keyframes tour-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 0 7px color-mix(in srgb, var(--accent) 22%, transparent),
      0 0 32px 4px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 0 11px color-mix(in srgb, var(--accent) 12%, transparent),
      0 0 40px 8px color-mix(in srgb, var(--accent) 28%, transparent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tour__card.is-in {
    opacity: 1;
  }
}

/* ==================================================================================================
   r4 · 12.22 «Birge OS» — glass coach marks with an arrow, accent halo, «What's New» welcome sheet.
   ================================================================================================== */
.tour__card {
  border-radius: var(--radius-panel);
  background: var(--glass-sheen), var(--mat-thick);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-xl);
  -webkit-backdrop-filter: var(--mat-filter-strong);
  backdrop-filter: var(--mat-filter-strong);
}
.tour__count {
  color: var(--text-3);
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  text-transform: none;
}
.tour__title {
  font-size: var(--fs-title-3);
}
.tour__text {
  font-size: var(--fs-md);
}

/* Arrow: a 12 px rotated square on the edge that faces the spotlight (tour.js sets --tour-arrow) */
.tour__arrow {
  position: absolute;
  display: none;
  width: 12px;
  height: 12px;
  border: 0 solid var(--glass-border);
  background: var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter-strong);
  backdrop-filter: var(--mat-filter-strong);
  rotate: 45deg;
  pointer-events: none;
}
.tour__card:not(.has-art)[data-side="bottom"] .tour__arrow,
.tour__card:not(.has-art)[data-side="top"] .tour__arrow,
.tour__card:not(.has-art)[data-side="left"] .tour__arrow,
.tour__card:not(.has-art)[data-side="right"] .tour__arrow {
  display: block;
}
.tour__card[data-side="bottom"] .tour__arrow {
  top: -6.5px;
  left: calc(var(--tour-arrow, 50%) - 6px);
  border-top-width: 0.5px;
  border-left-width: 0.5px;
}
.tour__card[data-side="top"] .tour__arrow {
  bottom: -6.5px;
  left: calc(var(--tour-arrow, 50%) - 6px);
  border-right-width: 0.5px;
  border-bottom-width: 0.5px;
}
.tour__card[data-side="right"] .tour__arrow {
  top: calc(var(--tour-arrow, 40px) - 6px);
  left: -6.5px;
  border-bottom-width: 0.5px;
  border-left-width: 0.5px;
}
.tour__card[data-side="left"] .tour__arrow {
  top: calc(var(--tour-arrow, 40px) - 6px);
  right: -6.5px;
  border-top-width: 0.5px;
  border-right-width: 0.5px;
}

/* Halo: 4 px accent focus ring around the target, a slow pulse */
.tour__ring {
  box-shadow:
    0 0 0 1.5px var(--accent),
    0 0 0 5.5px var(--focus-ring);
}
@media (prefers-reduced-motion: no-preference) {
  .tour__ring:not(.is-hidden) {
    animation: tour-halo 2.4s var(--ease-in-out) infinite;
  }
}
@keyframes tour-halo {
  0%,
  100% {
    box-shadow:
      0 0 0 1.5px var(--accent),
      0 0 0 5.5px var(--focus-ring);
  }
  50% {
    box-shadow:
      0 0 0 1.5px var(--accent),
      0 0 0 9px color-mix(in srgb, var(--accent) 18%, transparent);
  }
}

/* Centred cards (no target): app icon instead of the gradient art */
.tour__card.has-art .tour__art {
  width: 64px;
  height: 64px;
  border-radius: 16px;
}

/* «What's New» welcome sheet: 520 px, 72 px Birge icon, 28 px title, feature rows, full Continue */
.tour__card.is-welcome {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: var(--space-10) var(--space-8) var(--space-6);
  border-radius: var(--radius-sheet);
  background: var(--surface-elevated);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.tour__card.is-welcome .tour__art {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-5);
  background: none;
  border-radius: 0;
  box-shadow: none;
}
.tour__logo {
  display: block;
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 10px 20px color-mix(in srgb, var(--accent) 35%, transparent));
}
.tour__card.is-welcome .tour__head {
  top: var(--space-3);
  right: var(--space-3);
}
.tour__card.is-welcome .tour__count,
.tour__card.is-welcome .tour__dots,
.tour__card.is-welcome .tour__back {
  display: none;
}
.tour__card.is-welcome .tour__title {
  font-size: var(--fs-title-1);
  line-height: 1.15;
  text-wrap: balance;
}
.tour__card.is-welcome .tour__text {
  max-width: 40ch;
  margin-inline: auto;
  text-wrap: pretty;
}
.tour__features {
  display: grid;
  gap: var(--space-5);
  margin: var(--space-8) 0 var(--space-2);
  padding: 0 var(--space-2);
  list-style: none;
  text-align: start;
}
.tour__features[hidden] {
  display: none;
}
.tour__feature {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}
.tour__feature-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tour__feature-text strong {
  font-size: calc(0.9375rem * var(--text-scale, 1));
  font-weight: var(--fw-semibold);
  line-height: 1.3;
}
.tour__feature-text span {
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.tour__card.is-welcome .tour__foot {
  margin-top: var(--space-6);
}
.tour__card.is-welcome .tour__actions {
  width: 100%;
}
.tour__card.is-welcome .tour__next {
  width: 100%;
  min-width: 0;
  height: var(--control-h-lg);
  font-size: var(--fs-lg);
}
@media (max-width: 639px) {
  .tour__card.is-welcome {
    padding: var(--space-8) var(--space-5) var(--space-5);
  }
  .tour__features {
    gap: var(--space-4);
    margin-top: var(--space-6);
    padding: 0;
  }
}
@media (max-height: 720px) {
  .tour__card.is-welcome {
    padding-top: var(--space-6);
  }
  .tour__card.is-welcome .tour__art,
  .tour__logo {
    width: 56px;
    height: 56px;
    margin-bottom: var(--space-3);
  }
  .tour__feature-text span {
    display: none;
  }
  .tour__feature {
    align-items: center;
  }
}
