/* ===========================================================================
   WELCOME MODAL — four-slide promo scroller
   ---------------------------------------------------------------------------
   Markup is built by static/js/welcome-modal.js; this file owns every visual.
   Four themes, each mirroring the gradient its source card already uses in
   partials/home_feature_cards.html (app.css), so the modal reads as the same
   product in light and dark.

   The card — not the slide — carries the theme: `data-ad` on .wm-card follows
   whichever slide is in view, so the close button, chevrons and dots recolour
   with it instead of needing a copy of every theme.

   Deliberately independent of Bootstrap's Modal and Carousel JS: index.html
   loads the bootstrap bundle with `defer`, so a bootstrap.* call at parse time
   is a race. CSS scroll-snap gives swipe, trackpad and keyboard for free.
   =========================================================================== */

.wm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 13, 22, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.wm-overlay.wm-open {
  opacity: 1;
  pointer-events: auto;
}

/* --- the card ------------------------------------------------------------ */

.wm-card {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100dvh - 2.5rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 28px;
  padding: 2.4rem 0 1.6rem;
  text-align: center;
  background: var(--wm-grad);
  color: var(--wm-ink);
  border: 1px solid var(--wm-edge);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  transform: translateY(26px) scale(0.96);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.wm-open .wm-card {
  transform: none;
  opacity: 1;
}

/* The card takes focus on open so Esc and screen readers work; it is not an
   interactive control, so it must not draw a focus ring. */
.wm-card:focus {
  outline: none;
}

/* Soft highlight so the flat gradient gains a little depth. */
.wm-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.28), transparent 60%);
  pointer-events: none;
}

.wm-card > * {
  position: relative;
}

/* --- close ---------------------------------------------------------------- */

.wm-close {
  position: absolute;
  top: 0.9rem;
  inset-inline-end: 0.9rem;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--wm-edge);
  border-radius: 50%;
  background: var(--wm-chip);
  color: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.wm-close:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* --- the scroller --------------------------------------------------------- */

.wm-track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  /* No visible scrollbar: the dots are the affordance, and a bar would sit
     across the gradient on every desktop that shows one. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.wm-track::-webkit-scrollbar {
  display: none;
}

.wm-slide {
  flex: 0 0 100%;
  min-width: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 1.85rem;
}

/* --- eyebrow row ---------------------------------------------------------- */

.wm-eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 1.15rem;
}

.wm-badge {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--wm-chip-strong);
  border: 1px solid var(--wm-edge);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* --- icon ----------------------------------------------------------------- */

.wm-icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  background: var(--wm-chip);
  border: 1px solid var(--wm-edge);
  font-size: 1.75rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

/* --- copy ----------------------------------------------------------------- */

.wm-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 0.6rem;
}

.wm-stars {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: #fbbf24;
  margin-bottom: 0.55rem;
}

.wm-text {
  font-size: 0.9rem;
  line-height: 1.55;
  opacity: 0.9;
  margin: 0 auto 1.5rem;
  max-width: 30ch;
}

/* --- CTA ------------------------------------------------------------------ */

.wm-cta {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  background: var(--wm-cta-bg);
  color: var(--wm-cta-ink);
  border: 1px solid var(--wm-cta-edge);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wm-cta:hover {
  transform: translateY(-2px);
  color: var(--wm-cta-ink);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.wm-dismiss {
  display: block;
  margin: 0.85rem auto 0;
  background: none;
  border: none;
  color: inherit;
  font-size: 0.78rem;
  opacity: 0.65;
  cursor: pointer;
  text-decoration: underline;
}

.wm-dismiss:hover {
  opacity: 0.95;
}

/* --- scroller navigation --------------------------------------------------- */

.wm-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 1.3rem;
  padding: 0 1.85rem;
}

.wm-arrow {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--wm-edge);
  border-radius: 50%;
  background: var(--wm-chip);
  color: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.wm-arrow:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.1);
}

.wm-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}

.wm-dots {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.wm-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  cursor: pointer;
  transition: width 0.25s ease, opacity 0.2s ease;
}

.wm-dot:hover {
  opacity: 0.6;
}

.wm-dot.is-active {
  opacity: 0.9;
  width: 20px;
  border-radius: 999px;
}

/* ===========================================================================
   Themes — light. Gradients match the matching card in app.css.
   =========================================================================== */

.wm-card {
  --wm-edge: rgba(255, 255, 255, 0.28);
  --wm-chip: rgba(255, 255, 255, 0.22);
  --wm-chip-strong: rgba(255, 255, 255, 0.32);
  --wm-cta-bg: #ffffff;
  --wm-cta-ink: #1f2937;
  --wm-cta-edge: transparent;
}

/* Travel guide — plum */
.wm-card[data-ad="guide"] {
  --wm-grad: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 60%, #f9a8d4 100%);
  --wm-ink: #831843;
  --wm-edge: rgba(131, 24, 67, 0.18);
  --wm-chip: rgba(131, 24, 67, 0.09);
  --wm-chip-strong: rgba(131, 24, 67, 0.14);
  --wm-cta-bg: rgba(131, 24, 67, 0.1);
  --wm-cta-ink: #831843;
  --wm-cta-edge: rgba(131, 24, 67, 0.25);
}

/* Chrome extension — indigo→magenta */
.wm-card[data-ad="chrome"] {
  --wm-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #db2777 100%);
  --wm-ink: #ffffff;
  --wm-cta-ink: #7c3aed;
}

/* Telegram bot — brand blue */
.wm-card[data-ad="telegram"] {
  --wm-grad: linear-gradient(135deg, #0088cc 0%, #00a2ed 60%, #32afed 100%);
  --wm-ink: #ffffff;
  --wm-cta-ink: #0088cc;
}

/* AI assistant — sky */
.wm-card[data-ad="ai"] {
  --wm-grad: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 60%, #7dd3fc 100%);
  --wm-ink: #0369a1;
  --wm-edge: rgba(3, 105, 161, 0.18);
  --wm-chip: rgba(3, 105, 161, 0.09);
  --wm-chip-strong: rgba(3, 105, 161, 0.14);
  --wm-cta-bg: rgba(3, 105, 161, 0.1);
  --wm-cta-ink: #0369a1;
  --wm-cta-edge: rgba(3, 105, 161, 0.25);
}

/* ===========================================================================
   Themes — dark
   =========================================================================== */

body.dark-mode .wm-overlay {
  background: rgba(0, 0, 0, 0.68);
}

body.dark-mode .wm-card {
  --wm-ink: #ffffff;
  --wm-edge: rgba(255, 255, 255, 0.12);
  --wm-chip: rgba(255, 255, 255, 0.1);
  --wm-chip-strong: rgba(255, 255, 255, 0.16);
  --wm-cta-bg: rgba(255, 255, 255, 0.12);
  --wm-cta-ink: #ffffff;
  --wm-cta-edge: rgba(255, 255, 255, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

body.dark-mode .wm-card::before {
  background: radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.1), transparent 60%);
}

body.dark-mode .wm-card[data-ad="guide"] {
  --wm-grad: linear-gradient(135deg, #831843 0%, #701a75 60%, #4c1d95 100%);
}

body.dark-mode .wm-card[data-ad="chrome"] {
  --wm-grad: linear-gradient(135deg, #1e1b4b 0%, #311042 60%, #4c0519 100%);
}

body.dark-mode .wm-card[data-ad="telegram"] {
  --wm-grad: linear-gradient(135deg, #00334d 0%, #004e73 60%, #006699 100%);
}

body.dark-mode .wm-card[data-ad="ai"] {
  --wm-grad: linear-gradient(135deg, #0c4a6e 0%, #075985 60%, #0369a1 100%);
}

/* ===========================================================================
   Responsive
   ---------------------------------------------------------------------------
   Every slide is as tall as the tallest (the Chrome one: stars plus three
   lines of copy), so the small-screen sizes below are set by that slide.
   =========================================================================== */

@media (max-width: 480px) {
  .wm-overlay {
    padding: 1rem;
  }

  /* Deliberately narrower than the screen: a phone-width card reads as a page
     takeover, an inset one reads as a card floating over the page. */
  .wm-card {
    width: min(316px, 100%);
    border-radius: 20px;
    padding: 1.7rem 0 1.15rem;
  }

  .wm-slide,
  .wm-nav {
    padding: 0 1.1rem;
  }

  .wm-close {
    top: 0.6rem;
    inset-inline-end: 0.6rem;
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .wm-eyebrow {
    font-size: 0.66rem;
    margin-bottom: 0.75rem;
  }

  .wm-badge {
    font-size: 0.58rem;
  }

  .wm-icon {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .wm-title {
    font-size: 1.05rem;
    margin-bottom: 0.45rem;
  }

  .wm-stars {
    font-size: 0.7rem;
    margin-bottom: 0.45rem;
  }

  .wm-text {
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 1.1rem;
    max-width: 26ch;
  }

  .wm-cta {
    padding: 0.58rem 1.35rem;
    font-size: 0.82rem;
  }

  .wm-nav {
    margin-top: 1rem;
    gap: 0.7rem;
  }

  .wm-arrow {
    width: 26px;
    height: 26px;
    font-size: 0.65rem;
  }

  .wm-dismiss {
    font-size: 0.72rem;
    margin-top: 0.7rem;
  }
}

/* Short viewports (a landscape phone, or a browser with the keyboard up) —
   trim the vertical rhythm rather than let the card overflow the screen. */
@media (max-height: 620px) {
  .wm-card {
    padding-top: 1.9rem;
  }

  .wm-icon {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    font-size: 1.25rem;
    margin-bottom: 0.7rem;
  }

  .wm-eyebrow {
    margin-bottom: 0.7rem;
  }

  .wm-title {
    font-size: 1.1rem;
  }

  .wm-text {
    margin-bottom: 1.1rem;
  }

  .wm-nav {
    margin-top: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {

  .wm-overlay,
  .wm-card,
  .wm-cta,
  .wm-close,
  .wm-arrow,
  .wm-dot {
    transition: none;
  }

  .wm-card {
    transform: none;
  }

  .wm-track {
    scroll-behavior: auto;
  }
}
