/* WRIST demo sandbox — tour + first-impression styling (demo mode only).
   Ramsey Systems brand palette: crimson #B31F2F → plum #5C2845 → navy #0B335E
   (taken from the Ramsey logo gradient). The welcome hero reuses the app's
   animated Ramsey logo as its centrepiece. */

:root {
  --rs-red: #b31f2f;
  --rs-plum: #5c2845;
  --rs-navy: #0b335e;
  --wt-grad: linear-gradient(120deg, #b31f2f 0%, #5c2845 50%, #0b335e 100%);
  --wt-ink: #0b1f38;
  --wt-slate: #51607a;
}

/* ─────────────────────────  Welcome hero  ───────────────────────── */

#wrist-tour-hero {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#wrist-tour-hero.wt-hidden { display: none; }

#wrist-tour-hero .wt-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 55% at 50% 42%, rgba(11, 51, 94, 0.34), transparent 70%),
    rgba(9, 17, 33, 0.72);
  backdrop-filter: blur(10px) saturate(115%);
  -webkit-backdrop-filter: blur(10px) saturate(115%);
  animation: wt-fade 0.45s ease both;
}

/* drifting brand-coloured aurora behind the card */
#wrist-tour-hero .wt-aurora { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#wrist-tour-hero .wt-blob {
  position: absolute;
  width: 460px; height: 460px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  mix-blend-mode: screen;
}
#wrist-tour-hero .wt-blob--red  { background: radial-gradient(circle, #d1233a, transparent 62%); left: 16%; top: 16%;  animation: wt-drift 17s ease-in-out infinite; }
#wrist-tour-hero .wt-blob--plum { background: radial-gradient(circle, #7d2f57, transparent 62%); right: 14%; top: 24%; animation: wt-drift 21s ease-in-out infinite reverse; }
#wrist-tour-hero .wt-blob--navy { background: radial-gradient(circle, #12508f, transparent 62%); left: 40%; bottom: 2%;  animation: wt-drift 25s ease-in-out infinite; }

#wrist-tour-hero .wt-card {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  padding: 36px 40px 32px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 40px 90px rgba(9, 17, 33, 0.5), 0 0 0 1px rgba(11, 51, 94, 0.08);
  text-align: center;
  overflow: hidden;
  animation: wt-rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* shimmering brand gradient bar across the top edge */
#wrist-tour-hero .wt-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--wt-grad);
  background-size: 200% 100%;
  animation: wt-shimmer 6s linear infinite;
}

#wrist-tour-hero .wt-logo { margin: 4px 0 18px; }
#wrist-tour-hero .wt-logo .rs-logo { width: 190px; height: auto; }

#wrist-tour-hero .wt-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  margin-bottom: 16px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a1f33;
  background: rgba(179, 31, 47, 0.08);
  border: 1px solid rgba(179, 31, 47, 0.22);
  border-radius: 999px;
}
#wrist-tour-hero .wt-badge .wt-spark { animation: wt-twinkle 2.4s ease-in-out infinite; }

#wrist-tour-hero .wt-title {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--wt-ink);
}
#wrist-tour-hero .wt-title .grad {
  background: var(--wt-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

#wrist-tour-hero .wt-sub {
  margin: 0 auto 26px;
  max-width: 44ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--wt-slate);
}

#wrist-tour-hero .wt-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ─────────────────────────  Buttons  ───────────────────────── */

.wt-btn { font: inherit; cursor: pointer; border-radius: 12px; transition: transform 0.15s ease, box-shadow 0.2s ease; }
.wt-btn--primary {
  padding: 14px 26px;
  min-width: 260px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border: none;
  background: var(--wt-grad);
  background-size: 170% 170%;
  box-shadow: 0 12px 28px rgba(11, 51, 94, 0.35), 0 4px 12px rgba(179, 31, 47, 0.3);
  animation: wt-pan 7s ease infinite;
}
.wt-btn--primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(11, 51, 94, 0.45); }
.wt-btn--primary:active { transform: translateY(0); }
.wt-btn--ghost { padding: 9px 18px; font-size: 13.5px; font-weight: 600; color: #64748b; background: transparent; border: none; }
.wt-btn--ghost:hover { color: var(--rs-navy); }

/* Floating replay launcher (hidden while the tour is running) */
#demo-tour-btn {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 100000;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--wt-grad);
  background-size: 170% 170%;
  box-shadow: 0 10px 26px rgba(11, 51, 94, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: wt-pan 7s ease infinite;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
#demo-tour-btn::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(179, 31, 47, 0.5);
  opacity: 0;
  animation: wt-ping 3.2s ease-out infinite;
  pointer-events: none;
}
#demo-tour-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(11, 51, 94, 0.5); }
body.wrist-tour-running #demo-tour-btn { display: none; }

/* ─────────────────────────  driver.js layering + fixed placement  ─────────────
   Overlay must sit BELOW the popover. The popover is PINNED bottom-centre and
   floats on top of the dim — never anchored below an element (which could push
   it off-screen on small viewports). */
.driver-overlay { z-index: 100000 !important; }
.driver-popover.wrist-tour-popover {
  z-index: 100010 !important;
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: 30px !important;
  transform: translateX(-50%) !important;
  margin: 0 !important;
  max-width: min(440px, calc(100vw - 32px)) !important;
}
.driver-popover.wrist-tour-popover .driver-popover-arrow { display: none !important; }

/* ─────────────────────────  driver.js popover restyle  ───────────────────────── */

.driver-popover.wrist-tour-popover {
  --wt-progress: 0%;
  border-radius: 18px;
  padding: 12px 2px 12px;
  background: #ffffff;
  box-shadow: 0 26px 60px rgba(9, 17, 33, 0.32), 0 0 0 1px rgba(11, 51, 94, 0.08);
  border: none;
  animation: wt-fade 0.28s ease both;
}
.driver-popover.wrist-tour-popover::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: rgba(148, 163, 184, 0.22);
  border-radius: 18px 18px 0 0;
}
.driver-popover.wrist-tour-popover::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  height: 4px;
  width: var(--wt-progress);
  background: var(--wt-grad);
  border-radius: 18px 0 0 0;
  box-shadow: 0 0 10px rgba(179, 31, 47, 0.45);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.driver-popover.wrist-tour-popover .driver-popover-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--wt-ink);
  padding: 4px 18px 0;
}
.driver-popover.wrist-tour-popover .driver-popover-description {
  font-size: 14px;
  line-height: 1.6;
  color: var(--wt-slate);
  padding: 0 18px;
}
.driver-popover.wrist-tour-popover .driver-popover-footer { padding: 10px 18px 6px; gap: 8px; }
.driver-popover.wrist-tour-popover .driver-popover-progress-text {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #94a3b8;
}
.driver-popover.wrist-tour-popover button { text-shadow: none; border: none; border-radius: 9px; font-weight: 600; font-size: 13.5px; }
.driver-popover.wrist-tour-popover .driver-popover-next-btn {
  padding: 8px 16px;
  color: #fff;
  background: var(--wt-grad);
  background-size: 150% 150%;
  box-shadow: 0 5px 14px rgba(11, 51, 94, 0.4);
}
.driver-popover.wrist-tour-popover .driver-popover-next-btn:hover { filter: brightness(1.06); }
.driver-popover.wrist-tour-popover .driver-popover-prev-btn { padding: 8px 12px; color: #64748b; background: #f1f5f9; }
.driver-popover.wrist-tour-popover .driver-popover-close-btn { color: #cbd5e1; font-size: 22px; }
.driver-popover.wrist-tour-popover .driver-popover-close-btn:hover { color: #64748b; }

/* soft brand-coloured glow ring on the highlighted element */
.driver-active-element {
  border-radius: 10px !important;
  box-shadow: 0 0 0 3px rgba(179, 31, 47, 0.5), 0 0 26px 6px rgba(11, 51, 94, 0.4) !important;
  transition: box-shadow 0.3s ease;
}

/* ─────────────────────────  Value-set creation walkthrough  ─────────────────
   Custom interactive flow (advances as the user acts). Its card floats ABOVE
   the value-set modal (z 2147483646) so it stays visible throughout. */
#wrist-vs-guide {
  position: fixed;
  top: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 2147483647;
  width: min(430px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 26px 60px rgba(9, 17, 33, 0.42), 0 0 0 1px rgba(11, 51, 94, 0.1);
  overflow: hidden;
  /* keeps translateX(-50%) centring intact (a plain transform keyframe would
     clobber it and shove the card off-centre) */
  animation: wvg-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes wvg-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* Card drops to the bottom when the highlighted control is up top, so it never
   covers what it's pointing at. */
#wrist-vs-guide.wvg-bottom { top: auto; bottom: 22px; }

/* Beside a centred dialog (the "Name this ValueSet" save-details panel), the
   card docks into the side gutter, vertically centred, so it clears BOTH the
   name field at the dialog's top and the Save/Back footer at its bottom — a
   centre-docked card cannot avoid a centre-docked full-height dialog. The width
   is kept narrow (matches CARD_W in demoTour.js placeVsCard) so it fits the
   gutter on typical desktops. */
#wrist-vs-guide.wvg-side {
  top: 50%;
  bottom: auto;
  left: auto;
  right: auto;
  width: min(320px, calc(100vw - 32px));
  transform: translateY(-50%);
  animation: wvg-side-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#wrist-vs-guide.wvg-side.wvg-left { left: 20px; }
#wrist-vs-guide.wvg-side.wvg-right { right: 20px; }
@keyframes wvg-side-in {
  from { opacity: 0; transform: translateY(-50%) translateX(10px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

#wrist-vs-guide.wt-hidden { display: none; }
#wrist-vs-guide .wvg-bar { position: relative; height: 4px; background: rgba(148, 163, 184, 0.22); }
#wrist-vs-guide .wvg-bar::after {
  content: "";
  position: absolute; top: 0; left: 0; height: 4px;
  width: var(--wvg-progress, 0%);
  background: var(--wt-grad);
  box-shadow: 0 0 10px rgba(179, 31, 47, 0.45);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#wrist-vs-guide .wvg-body { padding: 15px 18px 2px; }
#wrist-vs-guide .wvg-title { margin: 0 0 6px; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; color: var(--wt-ink); }
#wrist-vs-guide .wvg-text { margin: 0; font-size: 14px; line-height: 1.55; color: var(--wt-slate); }
#wrist-vs-guide .wvg-text b { color: var(--rs-red); font-weight: 700; }
#wrist-vs-guide .wvg-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 12px; }
#wrist-vs-guide .wvg-step { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: #94a3b8; }
#wrist-vs-guide .wvg-actions { display: flex; align-items: center; gap: 12px; }
#wrist-vs-guide .wvg-skipstep,
#wrist-vs-guide .wvg-skip { background: none; border: none; color: #94a3b8; font: inherit; font-size: 12.5px; cursor: pointer; padding: 0; }
#wrist-vs-guide .wvg-skipstep:hover,
#wrist-vs-guide .wvg-skip:hover { color: #64748b; }
#wrist-vs-guide .wvg-next {
  background: var(--wt-grad);
  background-size: 150% 150%;
  color: #fff; border: none; border-radius: 9px;
  padding: 8px 16px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  box-shadow: 0 5px 14px rgba(11, 51, 94, 0.4);
}
#wrist-vs-guide .wvg-next:hover { filter: brightness(1.06); }
#wrist-vs-guide .wvg-wait {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-style: italic; color: #94a3b8;
}
#wrist-vs-guide .wvg-wait::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--rs-red); box-shadow: 0 0 0 0 rgba(179, 31, 47, 0.5);
  animation: wvg-pulse 1.4s ease-out infinite;
}
@keyframes wvg-pulse { 0% { box-shadow: 0 0 0 0 rgba(179,31,47,.5); } 70%,100% { box-shadow: 0 0 0 8px rgba(179,31,47,0); } }

/* brand glow on the control the user must act on (works above the modal) */
.wrist-vs-highlight {
  box-shadow: 0 0 0 3px rgba(179, 31, 47, 0.65), 0 0 26px 7px rgba(11, 51, 94, 0.45) !important;
  border-radius: 8px !important;
  transition: box-shadow 0.25s ease;
}

/* ─────────────────────────  Overview: persistent card + spotlight  ───────────
   A single card that updates IN PLACE step to step (no disappear/reappear), and
   a box-shadow "spotlight" that glides smoothly to each highlighted element. */
#wrist-tour-spot {
  position: fixed;
  top: 0; left: 0; width: 0; height: 0;
  z-index: 100000;
  border-radius: 10px;
  box-shadow:
    0 0 0 9999px rgba(11, 16, 32, 0.62),
    0 0 0 3px rgba(179, 31, 47, 0.55),
    0 0 26px 6px rgba(11, 51, 94, 0.4);
  pointer-events: none;
  transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1), left 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.4s cubic-bezier(0.22, 1, 0.36, 1), height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#wrist-tour-spot.wt-hidden { display: none; }

#wrist-tour-card {
  --wt-progress: 0%;
  position: fixed;
  left: 50%; bottom: 30px; top: auto;
  transform: translateX(-50%);
  z-index: 100010;
  width: min(440px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 26px 60px rgba(9, 17, 33, 0.32), 0 0 0 1px rgba(11, 51, 94, 0.08);
  overflow: hidden;
  animation: wt-fade 0.3s ease both;
  /* smooth glide when the card swaps top<->bottom between steps */
  transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1), bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#wrist-tour-card.wt-top { top: 24px; bottom: auto; }
#wrist-tour-card.wt-hidden { display: none; }
#wrist-tour-card .wtc-bar { position: relative; height: 4px; background: rgba(148, 163, 184, 0.22); }
#wrist-tour-card .wtc-bar::after {
  content: "";
  position: absolute; top: 0; left: 0; height: 4px;
  width: var(--wt-progress, 0%);
  background: var(--wt-grad);
  box-shadow: 0 0 10px rgba(179, 31, 47, 0.45);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
#wrist-tour-card .wtc-body { padding: 16px 18px 2px; }
#wrist-tour-card .wtc-title { margin: 0 0 6px; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; color: var(--wt-ink); }
#wrist-tour-card .wtc-text { margin: 0; font-size: 14px; line-height: 1.58; color: var(--wt-slate); }
#wrist-tour-card .wtc-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 12px; }
#wrist-tour-card .wtc-step { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: #94a3b8; }
#wrist-tour-card .wtc-actions { display: flex; align-items: center; gap: 10px; }
#wrist-tour-card .wtc-back { background: none; border: none; color: #94a3b8; font: inherit; font-size: 13px; cursor: pointer; padding: 0; }
#wrist-tour-card .wtc-back:hover { color: #64748b; }
#wrist-tour-card .wtc-next {
  background: var(--wt-grad); background-size: 150% 150%;
  color: #fff; border: none; border-radius: 9px;
  padding: 8px 16px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  box-shadow: 0 5px 14px rgba(11, 51, 94, 0.4);
}
#wrist-tour-card .wtc-next:hover { filter: brightness(1.06); }
#wrist-tour-card .wtc-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: #cbd5e1; font-size: 18px; line-height: 1; cursor: pointer; padding: 4px;
}
#wrist-tour-card .wtc-close:hover { color: #64748b; }

@media (prefers-reduced-motion: reduce) {
  #wrist-tour-spot, #wrist-tour-card { transition: none !important; }
}

/* ─────────────────────────  keyframes  ───────────────────────── */

@keyframes wt-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wt-rise { from { opacity: 0; transform: translateY(22px) scale(0.965); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes wt-shimmer { to { background-position: 200% 0; } }
@keyframes wt-pan { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes wt-twinkle { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes wt-ping { 0% { opacity: 0.6; transform: scale(1); } 80%,100% { opacity: 0; transform: scale(1.35); } }
@keyframes wt-drift {
  0%,100% { transform: translate(0, 0) scale(1); }
  33%     { transform: translate(34px, -22px) scale(1.08); }
  66%     { transform: translate(-22px, 16px) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  #wrist-tour-hero .wt-card,
  #wrist-tour-hero .wt-backdrop,
  #wrist-tour-hero .wt-blob,
  #wrist-tour-hero .wt-card::before,
  #wrist-tour-hero .wt-badge .wt-spark,
  .wt-btn--primary,
  #demo-tour-btn,
  #demo-tour-btn::after { animation: none !important; }
}

@media (max-width: 560px) {
  #wrist-tour-hero .wt-card { padding: 30px 24px 26px; }
  #wrist-tour-hero .wt-title { font-size: 25px; }
  #wrist-tour-hero .wt-logo .rs-logo { width: 160px; }
  .wt-btn--primary { min-width: 0; width: 100%; }
}
