/* =========================================================================
   VARN LAUNCH — first-load modal + follow-up bottom bar
   -------------------------------------------------------------------------
   Markup:  template-parts/varn-launch.php
   Script:  assets/js/varn-launch.js
   Enqueue: inc/enqueue.php (global)

   Every value is a design token. Everything is namespaced `varn-` so it
   cannot reach any existing rule, and both regions are position:fixed
   overlays that never touch the normal flow — so no current layout moves.

   Visibility is driven from JS, not from here: each region ships with the
   `hidden` attribute (utilities/[hidden] wins), the script removes it and
   adds `.is-open` to run the entrance. `.varn-lock` on <html> holds the page
   still while the modal is up.
   ========================================================================= */

/* The `hidden` attribute must win. Both regions set `display` below (flex on
   the modal), which would otherwise override the browser's [hidden] rule and
   leave an invisible backdrop catching clicks over the whole page at rest.
   This attribute selector out-specifies those display rules. */
.varn-modal[hidden],
.varn-bar[hidden] {
  display: none !important;
}

/* =========================================================================
   1. CORNER POPUP CARD
   A compact promo card anchored to the bottom-right — NOT a centered
   takeover. The page stays scrollable behind a light dim; the card floats
   in the corner the way the supplied reference does.
   ========================================================================= */

.varn-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;    /* bottom … */
  justify-content: flex-end; /* … right corner */
  padding: var(--space-5);
  pointer-events: none;      /* only the card and its dim catch clicks */
}

.varn-modal__backdrop {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: rgba(22, 20, 16, 0.38);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.varn-modal.is-open .varn-modal__backdrop {
  opacity: 1;
}

.varn-modal__dialog {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - (2 * var(--space-5)));
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  /* Entrance: rise into the corner. Overridden to a plain state by the
     reduced-motion block at the foot of this file. */
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-spring);
}

.varn-modal.is-open .varn-modal__dialog {
  opacity: 1;
  transform: none;
}

/* ── Close button ─────────────────────────────────────────────────────── */
.varn-modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text-heading);
  background: color-mix(in srgb, var(--bg-surface) 70%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.varn-modal__close:hover,
.varn-modal__close:focus-visible {
  background: var(--bg-sunken);
  transform: rotate(90deg);
}

.varn-modal__close-icon {
  display: block;
}

/* ── Visual half ──────────────────────────────────────────────────────── */
.varn-modal__visual {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  overflow: hidden;
  padding: var(--space-6) var(--space-5);
  /* A light panel with a soft brand-toned aurora — three blurred colour
     washes over an off-white base. Reads premium and airy rather than flat
     white; a hairline separates it from the white content half. */
  background:
    radial-gradient(120% 80% at 12% 10%, rgba(127, 119, 221, 0.20) 0%, transparent 55%),
    radial-gradient(110% 80% at 90% 20%, rgba(237, 147, 177, 0.18) 0%, transparent 55%),
    radial-gradient(130% 90% at 78% 108%, rgba(216, 90, 48, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #f7f6fd 100%);
  border-right: 1px solid var(--border-subtle);
}

/* A faint spotlight directly behind the logo, so it sits in light rather than
   on a wash. Decorative, under everything. */
.varn-modal__visual::before {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, transparent 70%);
}

.varn-modal__logo {
  position: relative;
  width: 100%;
  max-width: 196px;
  height: auto;
  /* A soft lift so the lockup floats off the panel. */
  filter: drop-shadow(0 14px 28px rgba(38, 36, 46, 0.16));
}

/* The four bar colours as a single row of swatch dots above the logo. Each
   carries a soft halo in its OWN colour plus a hairline, so they read as
   little jewels rather than flat circles — and the cream dot stays defined. */
.varn-modal__swatches {
  position: relative;
  display: flex;
  gap: var(--space-4);
}

.varn-modal__swatches i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--varn-dot);
  border: 1px solid rgba(38, 36, 46, 0.08);
  box-shadow:
    0 6px 14px color-mix(in srgb, var(--varn-dot) 45%, transparent),
    0 0 0 5px color-mix(in srgb, var(--varn-dot) 12%, transparent);
  animation: varn-float 6s var(--ease-inout) infinite;
}

.varn-modal__swatches i:nth-child(1) { animation-delay: 0s; }
.varn-modal__swatches i:nth-child(2) { animation-delay: 0.6s; }
.varn-modal__swatches i:nth-child(3) { animation-delay: 1.2s; }
.varn-modal__swatches i:nth-child(4) { animation-delay: 1.8s; }

@keyframes varn-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* ── Content half ─────────────────────────────────────────────────────── */
.varn-modal__body {
  padding: var(--space-7) var(--space-6) var(--space-6);
  overflow-y: auto;
}

.varn-modal__title {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(28px, 4vw, 36px);
  font-weight: var(--font-bold);
  line-height: 1.1;
  color: var(--text-heading);
}

.varn-modal__title span {
  color: var(--violet-600);
}

.varn-modal__kind {
  margin: var(--space-2) 0 0;
  font-size: 16px;
  font-weight: var(--font-semibold);
  color: var(--text-muted);
}

.varn-modal__desc {
  margin: var(--space-4) 0 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-body);
}

.varn-modal__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

/* Not a pill: a text link on a bottom border, with the arrow riding right on
   hover. Reuses Varn's violet so it reads as the product's own control. */
.varn-modal__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: var(--font-semibold);
  color: var(--violet-600);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--duration-normal) var(--ease-out);
}

.varn-modal__cta-label {
  padding-bottom: 3px;
  border-bottom: 2px solid var(--violet-200);
  transition: border-color var(--duration-normal) var(--ease-out);
}

.varn-modal__cta-icon {
  color: currentColor;
  transition: transform var(--duration-normal) var(--ease-out);
}

.varn-modal__cta:hover,
.varn-modal__cta:focus-visible {
  color: #4a3fbf; /* one step darker than --violet-600 */
}

.varn-modal__cta:hover .varn-modal__cta-label,
.varn-modal__cta:focus-visible .varn-modal__cta-label {
  border-bottom-color: currentColor;
}

.varn-modal__cta:hover .varn-modal__cta-icon,
.varn-modal__cta:focus-visible .varn-modal__cta-icon {
  transform: translateX(4px);
}

/* =========================================================================
   2. BOTTOM BAR
   ========================================================================= */

/* Slides up from below the fold when the script (varn-launch.js) adds
   .is-open — armed after the card is closed, triggered on scroll-down. */
.varn-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-toast);
  background: var(--violet-50);
  border-top: 1px solid var(--violet-100);
  box-shadow: 0 -8px 30px rgba(38, 36, 46, 0.10);
  /* Entrance: slide up from below the fold. */
  transform: translateY(110%);
  transition: transform var(--duration-slow) var(--ease-spring);
}

.varn-bar.is-open {
  transform: none;
}

.varn-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.varn-bar__lede {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.varn-bar__mark {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
}

.varn-bar__text {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-body);
}

.varn-bar__text strong {
  color: var(--text-heading);
  font-weight: var(--font-bold);
}

.varn-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.varn-bar__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: var(--font-semibold);
  white-space: nowrap;
  color: var(--text-inverse);
  background: var(--violet-600);
  border-radius: var(--radius-full);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.varn-bar__cta:hover,
.varn-bar__cta:focus-visible {
  background: #4a3fbf; /* one step darker than --violet-600 for hover */
  color: var(--text-inverse);
  transform: translateY(-2px);
}

.varn-bar__cta-icon {
  color: currentColor;
}

.varn-bar__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-out),
              color var(--duration-normal) var(--ease-out);
}

.varn-bar__close:hover,
.varn-bar__close:focus-visible {
  color: var(--text-heading);
  background: var(--violet-100);
}

/* =========================================================================
   3. RESPONSIVE
   ========================================================================= */

@media (max-width: 640px) {
  .varn-modal {
    padding: var(--space-3);
  }

  /* The visual half is decoration; stack it on top as a short banner rather
     than a column, and let the card span the width at the foot of the
     screen — a bottom sheet rather than a corner card on a phone. */
  .varn-modal__dialog {
    grid-template-columns: 1fr;
    max-width: none;
    width: 100%;
  }

  .varn-modal__visual {
    min-height: 140px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .varn-modal__logo {
    max-width: 160px;
  }

  .varn-modal__body {
    padding: var(--space-6) var(--space-5) var(--space-5);
  }

  /* Bar: mark + text + CTA read as one stack, close pinned top-right. */
  .varn-bar__inner {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding-right: 44px; /* room for the close button */
    position: relative;
  }

  .varn-bar__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .varn-bar__cta {
    flex: 1;
    justify-content: center;
  }

  .varn-bar__close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 32px;
    height: 32px;
  }
}

/* =========================================================================
   4. REDUCED MOTION
   Honour the OS setting: reveal both regions with no travel and no float,
   so the promos still appear but nothing animates.
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  .varn-modal__dialog,
  .varn-modal__backdrop,
  .varn-bar {
    transition: opacity var(--duration-normal) var(--ease-out);
  }

  .varn-modal__dialog {
    transform: none;
  }

  .varn-bar {
    transform: none;
    opacity: 0;
  }

  .varn-bar.is-open {
    opacity: 1;
  }

  .varn-modal__close:hover,
  .varn-modal__close:focus-visible {
    transform: none;
  }

  .varn-modal__swatches i {
    animation: none;
  }
}
