/* ==========================================================================
   U&I Cafe — Popup Manager (Front-End)
   Matched to the U&I Cafe design tokens (variables.css).
   Loaded conditionally only on pages with at least one active popup.
   ========================================================================== */

html.has-uc-popup,
html.has-uc-popup body {
  overflow: hidden;
}

.has-uc-popup .cursor-bubble {
  opacity: 0;
}

/* ---------- Root container ---------- */
.uc-popup {
  --uc-bg: var(--ink-2, #15100b);
  --uc-fg: var(--cream, #f4eee3);
  --uc-fg-dim: rgba(var(--cream-rgb, 244, 238, 227), 0.72);
  --uc-border: rgba(var(--cream-rgb, 244, 238, 227), 0.14);
  --uc-accent: var(--lime, #8ad22f);
  --uc-accent-ink: var(--ink, #0d0a07);
  --uc-overlay-rgb: var(--ink-rgb, 13, 10, 7);
  --uc-overlay-opacity: 0.78;
  --uc-overlay-blur: 6px;
  --uc-radius: 22px;
  --uc-max-w: 620px;

  position: fixed;
  inset: 0;
  z-index: var(--z-popup, 2050);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--admin-bar, 0px)) clamp(14px, 3vw, 28px) calc(20px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)), visibility 0s linear 0.35s;
}

.uc-popup.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)), visibility 0s;
}

/* Non-blocking popups (slide-in / bar without overlay) keep the page clickable */
.uc-popup--no-overlay {
  pointer-events: none !important;
}

.uc-popup--no-overlay .uc-popup__dialog {
  pointer-events: auto;
}

/* ---------- Backdrop ---------- */
.uc-popup__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(var(--uc-overlay-rgb), var(--uc-overlay-opacity));
  -webkit-backdrop-filter: blur(var(--uc-overlay-blur));
  backdrop-filter: blur(var(--uc-overlay-blur));
  opacity: 0;
  transition: opacity 0.35s ease;
}

.uc-popup.is-open .uc-popup__backdrop {
  opacity: 1;
}

/* ---------- Positions ---------- */
.uc-popup--pos-center        { align-items: center; justify-content: center; }
.uc-popup--pos-top-left      { align-items: flex-start; justify-content: flex-start; }
.uc-popup--pos-top-center    { align-items: flex-start; justify-content: center; }
.uc-popup--pos-top-right     { align-items: flex-start; justify-content: flex-end; }
.uc-popup--pos-bottom-left   { align-items: flex-end; justify-content: flex-start; }
.uc-popup--pos-bottom-center { align-items: flex-end; justify-content: center; }
.uc-popup--pos-bottom-right  { align-items: flex-end; justify-content: flex-end; }

.uc-popup--pos-top-bar,
.uc-popup--pos-bottom-bar {
  padding-inline: 0;
  padding-bottom: 0;
}

.uc-popup--pos-top-bar {
  align-items: flex-start;
  padding-top: var(--admin-bar, 0px);
}

.uc-popup--pos-bottom-bar {
  align-items: flex-end;
  padding-top: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Sizes ---------- */
.uc-popup--size-sm { --uc-max-w: 440px; }
.uc-popup--size-md { --uc-max-w: 620px; }
.uc-popup--size-lg { --uc-max-w: 800px; }
.uc-popup--size-xl { --uc-max-w: 960px; }

.uc-popup--type-slide-in { --uc-max-w: 420px; }
.uc-popup--type-slide-in.uc-popup--size-md { --uc-max-w: 460px; }
.uc-popup--type-slide-in.uc-popup--size-lg { --uc-max-w: 540px; }

/* ---------- Theme presets ---------- */
.uc-popup--theme-espresso {
  --uc-bg: linear-gradient(155deg, #1d1610 0%, #110c08 100%);
  --uc-fg: var(--cream, #f4eee3);
  --uc-fg-dim: rgba(var(--cream-rgb, 244, 238, 227), 0.72);
  --uc-border: rgba(var(--cream-rgb, 244, 238, 227), 0.14);
  --uc-accent: var(--lime, #8ad22f);
}

.uc-popup--theme-forest {
  --uc-bg: linear-gradient(160deg, var(--forest-2, #143a2f) 0%, var(--forest, #0f2b23) 100%);
  --uc-fg: var(--cream, #f4eee3);
  --uc-fg-dim: rgba(var(--cream-rgb, 244, 238, 227), 0.76);
  --uc-border: rgba(var(--cream-rgb, 244, 238, 227), 0.16);
  --uc-accent: var(--lime, #8ad22f);
}

.uc-popup--theme-cream {
  --uc-bg: var(--cream, #f4eee3);
  --uc-fg: var(--dark, #1a140e);
  --uc-fg-dim: var(--dark-dim, #5d5348);
  --uc-border: var(--dark-line, rgba(26, 20, 14, 0.14));
  --uc-accent: var(--lime-deep, #3f7d0d);
  --uc-accent-ink: #ffffff;
}

.uc-popup--theme-day-grad {
  --uc-bg: var(--grad-day, linear-gradient(160deg, #2b5e33 0%, #173a22 60%, #102a19 100%));
  --uc-fg: var(--cream, #f4eee3);
  --uc-fg-dim: rgba(var(--cream-rgb, 244, 238, 227), 0.8);
  --uc-border: rgba(var(--cream-rgb, 244, 238, 227), 0.18);
  --uc-accent: var(--lime, #8ad22f);
}

.uc-popup--theme-night-grad {
  --uc-bg: var(--grad-night, linear-gradient(160deg, #b7782f 0%, #8a5321 55%, #5e3815 100%));
  --uc-fg: var(--cream, #f4eee3);
  --uc-fg-dim: rgba(var(--cream-rgb, 244, 238, 227), 0.84);
  --uc-border: rgba(var(--cream-rgb, 244, 238, 227), 0.2);
  --uc-accent: var(--gold, #f5b942);
}

/* ---------- Dialog card ---------- */
.uc-popup__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, var(--uc-max-w));
  max-height: calc(100svh - 48px - var(--admin-bar, 0px));
  background: var(--uc-bg);
  color: var(--uc-fg);
  border: 1px solid var(--uc-border);
  border-radius: var(--uc-radius);
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  overflow: visible;
  outline: none;
  will-change: transform, opacity;
  transition: transform 0.45s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)), opacity 0.35s ease;
}

.uc-popup__shell {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  max-height: calc(100svh - 48px - var(--admin-bar, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: inherit;
  overscroll-behavior: contain;
}

/* Split image layouts */
.uc-popup--img-left .uc-popup__shell {
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
}

.uc-popup--img-right .uc-popup__shell {
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
}

.uc-popup--img-right .uc-popup__media {
  order: 2;
}

.uc-popup__media {
  position: relative;
  min-height: 220px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.uc-popup__media a,
.uc-popup__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.uc-popup--img-top .uc-popup__media {
  max-height: 250px;
}

/* Background image mode */
.uc-popup__bg-media {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  z-index: 0;
}

.uc-popup__bg-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.45);
}

.uc-popup__bg-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13, 10, 7, 0.45) 0%, rgba(13, 10, 7, 0.82) 100%);
}

.uc-popup--img-background .uc-popup__shell {
  position: relative;
  z-index: 1;
}

/* Poster / image-only mode */
.uc-popup--img-image-only .uc-popup__dialog {
  background: transparent;
  border: none;
  box-shadow: 0 32px 90px -18px rgba(0, 0, 0, 0.72);
  width: auto;
  max-width: min(92vw, var(--uc-max-w));
}

.uc-popup__poster {
  border-radius: var(--uc-radius);
  overflow: hidden;
  line-height: 0;
}

.uc-popup__poster-img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(90svh - 60px);
  height: auto;
  object-fit: contain;
}

/* ---------- Fullscreen takeover ---------- */
.uc-popup--type-fullscreen {
  padding: 0;
}

.uc-popup--type-fullscreen .uc-popup__dialog {
  width: 100%;
  max-width: none;
  height: 100svh;
  max-height: 100svh;
  border-radius: 0;
  border: none;
  display: grid;
  place-items: center;
}

.uc-popup--type-fullscreen .uc-popup__shell {
  width: min(100%, 880px);
  max-height: 92svh;
}

.uc-popup--type-fullscreen .uc-popup__close {
  top: calc(20px + var(--admin-bar, 0px));
  right: 20px;
}

/* ---------- Announcement bar ---------- */
.uc-popup--type-bar .uc-popup__dialog {
  width: 100%;
  max-width: none;
  border-radius: 0;
  border-left: none;
  border-right: none;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.45);
}

.uc-popup--type-bar .uc-popup__content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  padding: 14px 56px 14px 20px;
  text-align: left;
}

.uc-popup--type-bar .uc-popup__eyebrow {
  margin: 0;
}

.uc-popup--type-bar .uc-popup__script {
  display: none;
}

.uc-popup--type-bar .uc-popup__headline {
  margin: 0;
  font-size: clamp(0.95rem, 1.5vw, 1.08rem);
}

.uc-popup--type-bar .uc-popup__body,
.uc-popup--type-bar .uc-popup__body p {
  margin: 0;
  font-size: 0.9rem;
}

.uc-popup--type-bar .uc-popup__actions {
  margin-top: 0;
}

.uc-popup--type-bar .uc-popup__cta {
  padding: 0.55em 1.2em;
  font-size: 0.85rem;
}

.uc-popup--type-bar .uc-popup__close {
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
}

.uc-popup--type-bar .uc-popup__fine,
.uc-popup--type-bar .uc-popup__dont-show {
  width: 100%;
  text-align: center;
  margin-top: 2px;
}

/* ---------- Content typography ---------- */
.uc-popup__content {
  padding: clamp(24px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.uc-popup--align-center .uc-popup__content {
  text-align: center;
  align-items: center;
}

.uc-popup__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(var(--lime-rgb, 138, 210, 47), 0.14);
  border: 1px solid rgba(var(--lime-rgb, 138, 210, 47), 0.34);
  color: var(--uc-accent);
  font-family: var(--font-display, sans-serif);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.uc-popup--theme-cream .uc-popup__eyebrow {
  background: rgba(var(--lime-deep-rgb, 63, 125, 13), 0.1);
  border-color: rgba(var(--lime-deep-rgb, 63, 125, 13), 0.25);
}

.uc-popup__script {
  margin: 0;
  font-family: var(--font-script, cursive);
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  line-height: 1.1;
  color: var(--uc-accent);
}

.uc-popup__headline {
  margin: 0;
  font-family: var(--font-display, sans-serif);
  font-size: clamp(1.45rem, 3vw, 2.05rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--uc-fg);
}

.uc-popup__body,
.uc-popup__editor {
  color: var(--uc-fg-dim);
  font-family: var(--font-body, sans-serif);
  font-size: 0.98rem;
  line-height: 1.6;
}

.uc-popup__body p,
.uc-popup__editor p {
  margin: 0 0 0.75em;
}

.uc-popup__body p:last-child,
.uc-popup__editor p:last-child {
  margin-bottom: 0;
}

/* ---------- Countdown timer ---------- */
.uc-popup__countdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.uc-popup--align-center .uc-popup__countdown {
  align-items: center;
}

.uc-popup__countdown-label {
  font-family: var(--font-display, sans-serif);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--uc-fg-dim);
}

.uc-popup__countdown-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.uc-cd-unit {
  min-width: 58px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--uc-border);
  text-align: center;
}

.uc-popup--theme-cream .uc-cd-unit {
  background: rgba(26, 20, 14, 0.05);
}

.uc-cd-unit strong {
  display: block;
  font-family: var(--font-display, sans-serif);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--uc-accent);
  font-variant-numeric: tabular-nums;
}

.uc-cd-unit span {
  display: block;
  margin-top: 2px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--uc-fg-dim);
}

/* ---------- Coupon pill ---------- */
.uc-popup__coupon {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px dashed var(--uc-accent);
  background: rgba(var(--lime-rgb, 138, 210, 47), 0.08);
  color: var(--uc-fg);
  cursor: pointer;
  transition: background-color 0.25s ease, transform 0.2s ease;
}

.uc-popup__coupon:hover {
  background: rgba(var(--lime-rgb, 138, 210, 47), 0.16);
}

.uc-popup__coupon:active {
  transform: scale(0.98);
}

.uc-popup__coupon-code {
  font-family: var(--font-display, sans-serif);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--uc-accent);
}

.uc-popup__coupon-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--uc-fg-dim);
}

.uc-popup__coupon-meta .ico {
  width: 15px;
  height: 15px;
}

/* ---------- Actions ---------- */
.uc-popup__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-top: 6px;
}

.uc-popup--align-center .uc-popup__actions {
  justify-content: center;
}

.uc-popup__secondary {
  background: none;
  border: none;
  padding: 6px 2px;
  font-family: var(--font-display, sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--uc-fg-dim);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 0.25s ease;
}

.uc-popup__secondary:hover {
  color: var(--uc-fg);
}

/* ---------- Embedded forms (CF7 / WPForms) ---------- */
.uc-popup__shortcode {
  width: 100%;
  margin-top: 4px;
}

.uc-popup__shortcode input[type="text"],
.uc-popup__shortcode input[type="email"],
.uc-popup__shortcode input[type="tel"],
.uc-popup__shortcode textarea,
.uc-popup__shortcode select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--uc-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--uc-fg);
  font-family: var(--font-body, sans-serif);
  font-size: 0.94rem;
}

.uc-popup--theme-cream .uc-popup__shortcode input[type="text"],
.uc-popup--theme-cream .uc-popup__shortcode input[type="email"],
.uc-popup--theme-cream .uc-popup__shortcode input[type="tel"],
.uc-popup--theme-cream .uc-popup__shortcode textarea,
.uc-popup--theme-cream .uc-popup__shortcode select {
  background: #ffffff;
}

/* ---------- Don't show again & fine print ---------- */
.uc-popup__dont-show {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--uc-fg-dim);
  cursor: pointer;
}

.uc-popup__dont-show input {
  width: 15px;
  height: 15px;
  accent-color: var(--uc-accent);
  cursor: pointer;
}

.uc-popup__fine {
  margin: 2px 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--uc-fg-dim);
  opacity: 0.82;
}

/* ---------- Close button ---------- */
.uc-popup__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--uc-border);
  background: rgba(13, 10, 7, 0.55);
  color: var(--cream, #f4eee3);
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.uc-popup__close .ico {
  width: 18px;
  height: 18px;
}

.uc-popup__close:hover,
.uc-popup__close:focus-visible {
  background: var(--uc-accent);
  border-color: var(--uc-accent);
  color: var(--uc-accent-ink);
  transform: rotate(90deg);
}

.uc-popup--theme-cream .uc-popup__close {
  background: rgba(26, 20, 14, 0.08);
  color: var(--dark, #1a140e);
}

.uc-popup--close-minimal .uc-popup__close {
  background: transparent;
  border-color: transparent;
}

.uc-popup--close-outside .uc-popup__close {
  top: -16px;
  right: -16px;
  background: var(--ink, #0d0a07);
  border-color: rgba(var(--cream-rgb, 244, 238, 227), 0.28);
  color: var(--cream, #f4eee3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* ---------- Entrance animations ---------- */
.uc-popup--anim-fade .uc-popup__dialog       { opacity: 0; }
.uc-popup--anim-zoom .uc-popup__dialog       { opacity: 0; transform: scale(0.9); }
.uc-popup--anim-slide-up .uc-popup__dialog   { opacity: 0; transform: translateY(36px); }
.uc-popup--anim-slide-down .uc-popup__dialog { opacity: 0; transform: translateY(-36px); }
.uc-popup--anim-slide-left .uc-popup__dialog { opacity: 0; transform: translateX(48px); }
.uc-popup--anim-slide-right .uc-popup__dialog { opacity: 0; transform: translateX(-48px); }
.uc-popup--anim-flip .uc-popup__dialog       { opacity: 0; transform: perspective(900px) rotateX(-14deg) scale(0.95); }
.uc-popup--anim-none .uc-popup__dialog       { transition: none; }

.uc-popup.is-open .uc-popup__dialog {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .uc-popup--img-left .uc-popup__shell,
  .uc-popup--img-right .uc-popup__shell {
    grid-template-columns: 1fr;
  }

  .uc-popup--img-right .uc-popup__media {
    order: 0;
  }

  .uc-popup--img-left .uc-popup__media,
  .uc-popup--img-right .uc-popup__media {
    max-height: 210px;
  }

  .uc-popup--close-outside .uc-popup__close {
    top: 10px;
    right: 10px;
  }

  .uc-popup--type-slide-in {
    padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .uc-popup,
  .uc-popup__backdrop,
  .uc-popup__dialog,
  .uc-popup__close {
    transition: none !important;
    transform: none !important;
  }
}

