/* In-interface onboarding: a dimmed page, a transparent cut-out around the real
   control, and a small tooltip anchored to the cut-out. No modal dialog and no
   mock screenshots. All colours come from the panel tokens in styles.css. */
[data-onboarding] {
  display: contents;
}

body.tour-open {
  overflow: hidden;
}

/* The first-run resize hint is unrelated to the tour and would float above the
   dim layer, obscuring the coach mark. Suppress it while the tour is open; its
   own one-time timeout resumes after the tour closes. */
body.tour-open .panel-hint {
  display: none !important;
}

.tour-layer {
  --tour-dim: hsl(calc(var(--accent-h) + 6) calc(48% * var(--accent-s)) 10% / 0.62);
  --tour-ink: color-mix(in srgb, var(--text) 86%, var(--muted));
  --tour-muted: color-mix(in srgb, var(--muted) 72%, var(--text));
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.tour-layer[hidden],
.tour-tip[hidden],
.tour-spot[hidden] {
  display: none !important;
}

.tour-tip [hidden] {
  display: none !important;
}

.tour-shade {
  position: fixed;
  inset: 0;
  background: var(--tour-dim);
  pointer-events: auto;
  touch-action: none;
  animation: tour-fade 0.18s ease-out;
}

.tour-layer.has-spot .tour-shade {
  background: transparent;
}

.tour-spot {
  position: fixed;
  z-index: 1;
  border: 2px solid color-mix(in srgb, var(--brand) 64%, #fff);
  border-radius: 14px;
  background: transparent;
  pointer-events: none;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent),
    0 0 0 9999px var(--tour-dim);
  transition:
    left 0.26s cubic-bezier(0.2, 0.7, 0.2, 1),
    top 0.26s cubic-bezier(0.2, 0.7, 0.2, 1),
    width 0.26s cubic-bezier(0.2, 0.7, 0.2, 1),
    height 0.26s cubic-bezier(0.2, 0.7, 0.2, 1);
  animation: tour-spot-in 0.2s ease-out;
}

.tour-tip {
  position: fixed;
  z-index: 3;
  width: min(360px, calc(100vw - 24px));
  padding: 13px 15px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 4%, var(--surface)), var(--surface) 44%);
  color: var(--text);
  box-shadow:
    0 24px 64px hsl(calc(var(--accent-h) + 4) calc(58% * var(--accent-s)) 12% / 0.28),
    0 2px 7px hsl(calc(var(--accent-h) + 4) calc(58% * var(--accent-s)) 12% / 0.1);
  pointer-events: auto;
  outline: none;
  transition:
    left 0.24s cubic-bezier(0.2, 0.7, 0.2, 1),
    top 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tour-tip.is-centered {
  left: 50% !important;
  top: 50% !important;
  width: min(340px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  animation: tour-tip-in 0.18s ease-out;
}

.tour-tip.is-centered .tour-arrow {
  display: none;
}

.tour-arrow {
  position: absolute;
  display: none;
  width: 12px;
  height: 12px;
  background: var(--surface);
  transform: rotate(45deg);
  pointer-events: none;
}

.tour-tip[data-placement] .tour-arrow {
  display: block;
}

.tour-tip[data-placement="bottom"] .tour-arrow {
  top: -6px;
  left: calc(var(--tour-arrow-x, 26px) - 6px);
  box-shadow: -1px -1px 0 var(--line);
}

.tour-tip[data-placement="top"] .tour-arrow {
  bottom: -6px;
  left: calc(var(--tour-arrow-x, 26px) - 6px);
  box-shadow: 1px 1px 0 var(--line);
}

.tour-tip[data-placement="right"] .tour-arrow {
  left: -6px;
  top: calc(var(--tour-arrow-y, 26px) - 6px);
  box-shadow: -1px 1px 0 var(--line);
}

.tour-tip[data-placement="left"] .tour-arrow {
  right: -6px;
  top: calc(var(--tour-arrow-y, 26px) - 6px);
  box-shadow: 1px -1px 0 var(--line);
}

.tour-tip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
}

.tour-count {
  color: var(--tour-muted);
  font-size: calc(9px + var(--font-plus));
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tour-skip {
  min-height: 28px;
  margin: -4px -6px -4px 0;
  padding: 0 7px;
  border-radius: 8px;
  color: var(--tour-muted);
  font-size: calc(11px + var(--font-plus));
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.tour-skip:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.tour-tip-body {
  padding-top: 9px;
}

.tour-kicker {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: calc(8px + var(--font-plus));
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
}

.tour-title {
  margin: 0 0 6px;
  font-size: calc(18px + var(--font-plus));
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 800;
  color: var(--text);
}

.tour-title:focus,
.tour-title:focus-visible {
  outline: 0 !important;
  box-shadow: none;
}

.tour-text {
  margin: 0;
  color: var(--tour-ink);
  font-size: calc(12.5px + var(--font-plus));
  line-height: 1.55;
}

.tour-note {
  margin: 9px 0 0;
  padding: 7px 9px;
  border-left: 2px solid var(--brand);
  border-radius: 0 7px 7px 0;
  background: var(--surface-alt);
  color: var(--tour-muted);
  font-size: calc(10.5px + var(--font-plus));
  line-height: 1.45;
}

.tour-tip-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tour-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 5px;
  flex-wrap: wrap;
}

.tour-dot {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  transition: width 0.18s ease, background 0.18s ease;
}

.tour-dot.is-done {
  background: color-mix(in srgb, var(--brand) 38%, var(--line));
}

.tour-dot.is-current {
  width: 16px;
  background: var(--brand);
}

.tour-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.tour-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 34px;
  padding: 0 7px;
  border-radius: 8px;
  color: var(--tour-muted);
  font-size: calc(11px + var(--font-plus));
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.tour-back:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.tour-back-icon {
  transform: rotate(180deg);
}

.tour-next {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: calc(11px + var(--font-plus));
  font-weight: 700;
  gap: 5px;
  white-space: nowrap;
}

.tour-next svg {
  flex: 0 0 auto;
}

.tour-tip :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.tour-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@keyframes tour-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tour-spot-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tour-tip-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 6px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ---- phone: a compact card at the bottom, opposite the highlighted control --- */
@media (max-width: 640px) {
  .tour-tip {
    left: 10px !important;
    right: 10px !important;
    width: auto;
    max-height: 46dvh;
    padding: 12px 13px 10px;
    border-radius: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow:
      0 18px 46px hsl(calc(var(--accent-h) + 4) calc(58% * var(--accent-s)) 10% / 0.34),
      0 2px 6px hsl(calc(var(--accent-h) + 4) calc(58% * var(--accent-s)) 10% / 0.12);
    transition: none;
  }

  .tour-tip[data-mobile="bottom"] {
    top: auto !important;
    bottom: var(--tour-mobile-bottom, calc(10px + env(safe-area-inset-bottom)));
  }

  .tour-tip[data-mobile="top"] {
    top: calc(10px + env(safe-area-inset-top)) !important;
    bottom: auto;
  }

  .tour-tip .tour-arrow {
    display: none !important;
  }

  .tour-tip.is-centered {
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto;
    width: min(340px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: none;
    overflow: visible;
    transform: translate(-50%, -50%);
  }

  .tour-skip {
    min-height: 40px;
    padding-inline: 8px;
    font-size: calc(12px + var(--font-plus));
  }

  .tour-title {
    font-size: calc(17px + var(--font-plus));
    line-height: 1.22;
  }

  .tour-text {
    font-size: calc(12.5px + var(--font-plus));
    line-height: 1.52;
  }

  .tour-tip-foot {
    margin-top: 9px;
    padding-top: 9px;
  }

  .tour-back {
    min-height: 42px;
    padding-inline: 8px;
  }

  .tour-next {
    min-height: 42px;
    padding-inline: 14px;
  }
}

@media (max-width: 380px) {
  .tour-tip {
    left: 8px !important;
    right: 8px !important;
    padding-inline: 11px;
  }

  .tour-title {
    font-size: calc(16px + var(--font-plus));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-shade,
  .tour-spot,
  .tour-tip,
  .tour-tip.is-centered,
  .tour-dot,
  .tour-skip,
  .tour-back {
    animation: none !important;
    transition: none !important;
  }
}

[data-theme="dark"] .tour-layer {
  --tour-dim: #02080fd0;
}

[data-theme="dark"] .tour-tip {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, var(--surface)), var(--surface) 46%);
  box-shadow:
    0 24px 64px #0009,
    0 2px 7px #0006;
}

[data-theme="dark"] .tour-arrow {
  background: var(--surface);
}
