/* ==========================================================================
 * Festival Studio - guided tour builder (js/map/tour.js)
 *
 * st-tour__*       the two panes: stop list and settings, phone stage
 * st-tour-stop     one stop card in the list
 * st-tour-stepper  the pause stepper in the stop editor
 * st-tour-play__*  the app's tour player, redrawn inside the phone. These
 *                  rules copy the sizes and colours of
 *                  festival_tour_overlay.dart on purpose - it is a preview of
 *                  what attendees see, not studio chrome - so they use the
 *                  app's pink and its dark cards instead of the studio tokens.
 *
 * The phone is laid out at 390 x 760 CSS px and scaled down with a transform
 * (set inline by tour.js), so every px value under .st-tour__device is in
 * phone pixels.
 * ========================================================================== */

/* ---------- frame ---------- */
.st-tour { container: st-tour / inline-size; position: relative; height: 100%; min-height: 0; overflow-y: auto; }
.st-tour__grid {
  display: grid; grid-template-columns: clamp(352px, 34%, 440px) minmax(0, 1fr);
  height: 100%; min-height: 0;
}
.st-tour--gate { display: grid; place-items: center; padding: 24px; }
.st-tour__loading { width: min(420px, 100%); }

/* ---------- left pane ---------- */
.st-tour__side { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--st-border); }
.st-tour__side[inert] { opacity: 0.55; }
.st-tour__head { padding: 16px 20px 14px; border-bottom: 1px solid var(--st-border); }
.st-tour__head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.st-tour__title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.st-tour__status { display: inline-flex; flex: 0 0 auto; }
.st-tour__summary { margin-top: 2px; font-size: 13px; color: var(--st-text-muted); font-variant-numeric: tabular-nums; }

.st-tour__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 22px; padding: 16px 20px 24px; }
.st-tour__notices { display: flex; flex-direction: column; gap: 10px; }
.st-tour__section { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.st-tour__section-head { display: flex; align-items: center; gap: 8px; }
.st-tour__section-title { font-size: 12.5px; font-weight: 600; color: var(--st-text-dim); }
.st-tour__count {
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; background: rgba(255, 255, 255, 0.08); color: var(--st-text-dim);
}
.st-tour__count:empty { display: none; }
.st-tour__limit { font-size: 12.5px; color: var(--st-text-muted); }

.st-tour__foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--st-border); background: var(--st-bg); }
.st-tour__remove { margin-left: -8px; color: var(--st-red-text); }
.st-tour__remove:hover:not(:disabled) { background: rgba(251, 113, 133, 0.12); color: #fecdd3; }

/* ---------- empty state ---------- */
.st-tour__empty { display: flex; flex-direction: column; gap: 8px; padding: 20px; border: 1px dashed var(--st-border-strong); border-radius: var(--st-r-14); }
.st-tour__empty-icon {
  width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 4px; border-radius: var(--st-r-12);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--st-border); color: var(--st-text-dim);
}
.st-tour__empty-title { font-size: 15px; font-weight: 600; }
.st-tour__empty-text { font-size: 13.5px; line-height: 1.55; color: var(--st-text-dim); }
.st-tour__empty-text strong { color: var(--st-text); }
.st-tour__steps { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--st-border); }
.st-tour__steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.5; color: var(--st-text-dim); }
.st-tour__steps strong { color: var(--st-text); }
.st-tour__step-num {
  flex: 0 0 auto; width: 20px; height: 20px; margin-top: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--st-text-dim); background: rgba(255, 255, 255, 0.07);
}
.st-tour__steps li:first-child .st-tour__step-num { color: #d7d1ff; background: rgba(109, 92, 255, 0.24); }

/* ---------- stop cards ---------- */
.st-tour__list-box { position: relative; }
.st-tour__list { display: flex; flex-direction: column; gap: 8px; }
.st-tour__drop { position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px; background: var(--st-violet-2); pointer-events: none; z-index: 3; }

.st-tour-stop {
  position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; min-width: 0;
  background: var(--st-bg-card); border: 1px solid var(--st-border); border-radius: var(--st-r-12);
  transition: border-color var(--st-ease), background var(--st-ease);
}
.st-tour-stop:hover { border-color: var(--st-border-strong); }
.st-tour-stop.is-selected { border-color: rgba(124, 92, 255, 0.65); background: #131931; }
.st-tour-stop.is-playing { border-color: var(--st-violet-2); box-shadow: inset 3px 0 0 var(--st-violet-2); }
.st-tour-stop.is-dragging { z-index: 2; border-color: var(--st-violet-2); background: var(--st-bg-pop); box-shadow: var(--st-shadow-pop); transition: none; }
.st-tour.is-sorting, .st-tour.is-sorting * { cursor: grabbing !important; user-select: none; }

.st-tour-stop__handle {
  display: grid; place-items: center; align-self: stretch; border-radius: 11px 0 0 11px;
  color: var(--st-text-muted); cursor: grab; touch-action: none;
}
.st-tour-stop__handle:hover { color: var(--st-text); background: rgba(255, 255, 255, 0.04); }
.st-tour-stop__handle:focus-visible { outline-offset: -2px; }

.st-tour-stop__main { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 12px 6px 12px 2px; text-align: left; border-radius: 8px; }
.st-tour-stop__main:focus-visible { outline-offset: -2px; }
.st-tour-stop__num {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: #d7d1ff; background: rgba(109, 92, 255, 0.24);
}
.st-tour-stop__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 1px; }
.st-tour-stop__title { font-size: 13.5px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.st-tour-stop__title.is-untitled { font-weight: 500; color: var(--st-text-muted); }
.st-tour-stop__desc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-size: 12.5px; line-height: 1.45; color: var(--st-text-dim); overflow-wrap: anywhere;
}
.st-tour-stop__meta { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 12px; color: var(--st-text-muted); font-variant-numeric: tabular-nums; }
.st-tour-stop__note { display: flex; align-items: flex-start; gap: 5px; font-size: 12px; line-height: 1.4; color: #fcd34d; }
.st-tour-stop__note .st-icon { margin-top: 2px; }
.st-tour-stop__dim { color: var(--st-text-muted); }

.st-tour-stop__order { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 6px 6px 0; }
.st-tour-stop__order .st-btn { width: 28px; height: 24px; border-radius: 6px; }

.st-tour-stop__actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--st-border); }
.st-tour-stop__actions .st-btn--sm:not(.st-btn--icon) { border-color: var(--st-border-strong); background: rgba(255, 255, 255, 0.02); }
.st-tour-stop__delete { color: var(--st-red-text); }
.st-tour-stop__delete:hover:not(:disabled) { background: rgba(251, 113, 133, 0.14); color: #fecdd3; }

/* ---------- pause stepper ---------- */
.st-tour-stepper {
  display: flex; align-items: center; gap: 8px; min-height: var(--st-control-h); padding: 3px 4px 3px 12px;
  border: 1px solid var(--st-border-strong); border-radius: var(--st-r-10); background: var(--st-bg-elev);
}
.st-tour-stepper > .st-icon { color: var(--st-text-muted); }
.st-tour-stepper__label { flex: 1 1 auto; min-width: 0; font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- right pane: the phone ---------- */
.st-tour__stage {
  display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; min-height: 0; overflow: auto;
  padding: 20px 24px 16px; background: var(--st-bg-elev);
}
.st-tour__device-area { flex: 1 1 auto; align-self: stretch; min-width: 0; min-height: 340px; display: grid; place-items: center; }
.st-tour__device-box { position: relative; width: 390px; height: 760px; flex: 0 0 auto; }
/* A plain bezel: a dark band with a hairline around it. */
.st-tour__device {
  position: absolute; top: 0; left: 0; width: 390px; height: 760px; transform-origin: 0 0; isolation: isolate;
  overflow: hidden; border-radius: 36px; background: #0d0f16;
  box-shadow: 0 0 0 7px #05060a, 0 0 0 8px rgba(255, 255, 255, 0.16);
  --st-tour-safe-top: 44px; --st-tour-safe-bottom: 20px;
}
/* mapbox-gl.css makes its container position: relative; the explicit size keeps it filling the phone either way. */
.st-tour__device > .st-tour__map { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.st-tour__map .st-map-fallback { border: 0; padding: 32px; }
.st-tour__map .st-map-fallback__title { font-size: 17px; }
.st-tour__map .st-map-fallback__text { font-size: 14.5px; }
.st-tour__veil { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: var(--st-bg-elev); }
.st-tour__veil .st-loading { font-size: 15px; }
/* Keep Mapbox's logo and credit clear of the rounded corners. */
.st-tour__map .mapboxgl-ctrl-bottom-left .mapboxgl-ctrl { margin: 0 0 12px 16px; }
.st-tour__map .mapboxgl-ctrl-bottom-right .mapboxgl-ctrl { margin: 0 14px 12px 0; }
.st-tour__overlay { position: absolute; inset: 0; z-index: 3; overflow: hidden; color: #fff; --st-tour-pink: #db2777; }
.st-tour__overlay:focus-visible { outline: none; }

.st-tour__rail { position: absolute; top: 4px; left: calc(100% + 20px); display: flex; flex-direction: column; gap: 6px; }

.st-tour__bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 10px; min-height: 36px; }
.st-tour__play-status { font-size: 13px; color: var(--st-text-dim); font-variant-numeric: tabular-nums; }
.st-tour__caption { max-width: 100%; font-size: 12.5px; line-height: 1.5; text-align: center; color: var(--st-text-muted); }

/* ---------- the player (phone pixels, the app's look) ---------- */
.st-tour-play__welcome {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 32px; text-align: center;
  background: rgba(13, 13, 18, 0.86); animation: st-tour-fade 420ms ease-out both;
}
.st-tour-play__welcome.is-leaving { opacity: 0; pointer-events: none; transition: opacity 350ms ease-in; }
.st-tour-play__disc {
  width: 84px; height: 84px; margin: 0 auto; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%;
  color: var(--st-tour-pink); background: rgba(219, 39, 119, 0.18); border: 1.5px solid rgba(219, 39, 119, 0.6);
  animation: st-tour-pop 532ms cubic-bezier(0.175, 0.885, 0.32, 1.275) 168ms both;
}
.st-tour-play__disc--logo { width: 120px; height: 120px; border: 2.5px solid #fff; }
.st-tour-play__disc--logo img { width: 100%; height: 100%; max-width: none; object-fit: cover; border-radius: 50%; }
.st-tour-play__welcome-title {
  margin-top: 26px; font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; overflow-wrap: anywhere;
  animation: st-tour-rise 476ms ease-out 392ms both;
}
.st-tour-play__welcome-text {
  margin-top: 14px; font-size: 15.5px; line-height: 1.5; color: rgba(255, 255, 255, 0.75); white-space: pre-line; overflow-wrap: anywhere;
  animation: st-tour-rise 490ms ease-out 630ms both;
}
.st-tour-play__welcome-actions { margin-top: 40px; display: flex; flex-direction: column; align-items: center; animation: st-tour-rise 532ms ease-out 868ms both; }
.st-tour-play__start {
  display: inline-flex; align-items: center; gap: 8px; height: 54px; padding: 0 22px; border-radius: 16px;
  background: var(--st-tour-pink); color: #fff; font-size: 16.5px; font-weight: 700;
  animation: st-tour-breathe 1600ms ease-in-out infinite alternate;
}
.st-tour-play__later { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 14px; color: rgba(255, 255, 255, 0.6); }
.st-tour-play__start:focus-visible, .st-tour-play__later:focus-visible, .st-tour-play__exit:focus-visible, .st-tour-play__next:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.st-tour-play__pill {
  position: absolute; top: calc(var(--st-tour-safe-top) + 12px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; padding: 8px 14px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.72); border: 0.5px solid rgba(255, 255, 255, 0.24); transition: opacity 300ms ease;
}
.st-tour-play__pill.is-hidden { opacity: 0; }
.st-tour-play__dots { display: flex; align-items: center; margin-right: 10px; }
.st-tour-play__dot { width: 7px; height: 7px; margin: 0 3px; border-radius: 4px; background: rgba(255, 255, 255, 0.35); transition: width 300ms ease-out, background-color 300ms ease-out; }
.st-tour-play__dot.is-reached { background: var(--st-tour-pink); }
.st-tour-play__dot.is-current { width: 18px; }
.st-tour-play__count { font-size: 12px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.st-tour-play__exit {
  position: absolute; top: calc(var(--st-tour-safe-top) + 8px); left: 12px; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; color: #fff; background: rgba(0, 0, 0, 0.72); border: 0.5px solid rgba(255, 255, 255, 0.24);
}

.st-tour-play__card {
  position: absolute; left: 18px; right: 18px; bottom: calc(var(--st-tour-safe-bottom) + 22px); overflow: hidden; border-radius: 22px;
  background: rgba(23, 23, 28, 0.97); border: 0.5px solid rgba(255, 255, 255, 0.12); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: st-tour-card-in 380ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.st-tour-play__card.is-leaving { animation: st-tour-card-out 240ms ease-in both; }
.st-tour-play__card-body { display: flex; flex-direction: column; padding: 18px 20px 16px; }
.st-tour-play__card-head { display: flex; align-items: center; gap: 10px; }
.st-tour-play__card-icon { flex: 0 0 auto; display: grid; padding: 7px; border-radius: 10px; color: var(--st-tour-pink); background: rgba(219, 39, 119, 0.16); }
.st-tour-play__card-title { min-width: 0; font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.st-tour-play__card-text { margin-top: 10px; font-size: 14.5px; line-height: 1.45; color: rgba(255, 255, 255, 0.78); white-space: pre-wrap; overflow-wrap: anywhere; }
.st-tour-play__card-body > .st-tour-play__card-text:first-child { margin-top: 0; }
.st-tour-play__next { align-self: flex-end; display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; padding: 2px 0 2px 6px; border-radius: 6px; color: var(--st-tour-pink); font-size: 14px; font-weight: 700; }
.st-tour-play__dwell { height: 3px; background: rgba(255, 255, 255, 0.08); }
.st-tour-play__dwell > span { display: block; width: 100%; height: 100%; background: var(--st-tour-pink); transform-origin: 0 50%; animation: st-tour-dwell 4000ms linear both; }

.st-tour-play__outro { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; pointer-events: none; }
.st-tour-play__outro-card {
  padding: 22px 28px; border-radius: 24px; text-align: center; background: rgba(23, 23, 28, 0.97); border: 0.5px solid rgba(255, 255, 255, 0.12);
  animation: st-tour-outro-in 380ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.st-tour-play__outro.is-leaving .st-tour-play__outro-card { animation: st-tour-outro-out 240ms ease-in both; }
.st-tour-play__outro-emoji { font-size: 40px; line-height: 1.2; }
.st-tour-play__outro-title { margin-top: 10px; font-size: 20px; font-weight: 700; }
.st-tour-play__outro-text { margin-top: 6px; font-size: 14.5px; color: rgba(255, 255, 255, 0.7); overflow-wrap: anywhere; }

@keyframes st-tour-fade { from { opacity: 0; } }
@keyframes st-tour-pop { from { opacity: 0; transform: scale(0); } }
@keyframes st-tour-rise { from { opacity: 0; transform: translateY(22px); } }
@keyframes st-tour-breathe { from { transform: scale(0.97); } to { transform: scale(1.03); } }
@keyframes st-tour-card-in { from { opacity: 0; transform: translateY(46px) scale(0.94); } }
@keyframes st-tour-card-out { to { opacity: 0; transform: translateY(46px) scale(0.94); } }
@keyframes st-tour-outro-in { from { opacity: 0; transform: scale(0.9); } }
@keyframes st-tour-outro-out { to { opacity: 0; transform: scale(0.9); } }
@keyframes st-tour-dwell { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- narrow: the panes stack and the page scrolls ---------- */
@container st-tour (max-width: 759px) {
  .st-tour__grid { grid-template-columns: minmax(0, 1fr); height: auto; }
  .st-tour__side { border-right: 0; border-top: 1px solid var(--st-border); order: 2; }
  .st-tour__body { overflow: visible; }
  .st-tour__foot { position: sticky; bottom: 0; z-index: 4; }
  .st-tour__stage { overflow: visible; }
  .st-tour__device-area { min-height: 560px; }
}

/* ---------- reduced motion: no entrances; the dwell bar still counts down ---------- */
@media (prefers-reduced-motion: reduce) {
  .st-tour-play__welcome, .st-tour-play__disc, .st-tour-play__welcome-title, .st-tour-play__welcome-text, .st-tour-play__welcome-actions,
  .st-tour-play__start, .st-tour-play__card, .st-tour-play__card.is-leaving, .st-tour-play__outro-card,
  .st-tour-play__outro.is-leaving .st-tour-play__outro-card { animation: none; }
  .st-tour-play__card.is-leaving, .st-tour-play__outro.is-leaving .st-tour-play__outro-card { opacity: 0; }
}
