/*
  popup.css
  Announcement popup for TheShiningCleanse. A cream card with a photo panel on desktop,
  a bottom sheet on phones. Classes are prefixed .promo- and are shared with the admin
  live preview (js/popup.js builds the same card for both).

  Motion only exists inside .promo-root (the real overlay). A card built on its own,
  for example in the admin preview, is always drawn in its final state.
*/

/* ========== PAGE LOCK ========== */
/* Keeps the page from scrolling behind the popup. popup.js sets --promo-sbw to the
   width of the scrollbar it hides, so the page content does not shift sideways. */
html.promo-lock,
html.promo-lock body {
  overflow: hidden;
}

html.promo-lock body {
  padding-right: var(--promo-sbw, 0px);
}

/* ========== OVERLAY ========== */
.promo-root {
  --promo-ease: cubic-bezier(0.16, 1, 0.3, 1);
  align-items: center;
  box-sizing: border-box;
  display: flex;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", sans-serif);
  inset: 0;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 24px;
  position: fixed;
  z-index: 2000;
  -webkit-font-smoothing: antialiased;
}

.promo-backdrop {
  -webkit-backdrop-filter: blur(7px) saturate(0.9);
  backdrop-filter: blur(7px) saturate(0.9);
  background: radial-gradient(120% 90% at 50% 40%, rgba(21, 40, 33, 0.6), rgba(8, 15, 11, 0.84));
  inset: 0;
  position: absolute;
  touch-action: none;
}

/* ========== CARD ========== */
.promo-card {
  --promo-ease: cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--color-cream, #F5F0E8);
  border-radius: 18px;
  box-shadow:
    0 60px 110px -34px rgba(0, 0, 0, 0.65),
    0 22px 44px -22px rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
  color: var(--color-text-dark, #1A1A1A);
  container: promo / inline-size;
  margin-inline: auto;
  max-width: 880px;
  overflow: hidden;
  position: relative;
  text-align: left;
  width: 100%;
}

.promo-card:focus {
  outline: none;
}

.promo-root .promo-card {
  margin: 0;
  position: relative;
  z-index: 1;
}

.promo-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  min-height: 500px;
}

.promo-root .promo-grid {
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ========== PHOTO PANEL ========== */
.promo-media {
  background: linear-gradient(155deg, var(--color-mid, #1E4435) 0%, var(--color-forest, #152821) 55%, var(--color-deep, #0E1C15) 100%);
  isolation: isolate;
  min-height: 100%;
  overflow: hidden;
  position: relative;
}

/* Soft shade so the small caption and the close button stay readable on any photo. */
.promo-media::before {
  background:
    linear-gradient(180deg, rgba(14, 28, 21, 0.14) 0%, rgba(14, 28, 21, 0) 34%, rgba(14, 28, 21, 0.58) 100%);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.promo-media__img {
  display: block;
  height: 100%;
  inset: 0;
  object-fit: cover;
  object-position: var(--promo-pos, 50% 50%);
  position: absolute;
  width: 100%;
}

/* Each photo is framed around its subject, not its centre. */
.promo-card[data-image="residential"] { --promo-pos: 60% 50%; }
.promo-card[data-image="deep"] { --promo-pos: 100% 50%; }
.promo-card[data-image="move"] { --promo-pos: 55% 50%; }
.promo-card[data-image="patio"] { --promo-pos: 78% 50%; }
.promo-card[data-image="commercial"] { --promo-pos: 55% 50%; }

/* The before-and-after photo carries its own text labels. Anchoring it to the bottom edge
   and enlarging it slightly crops those labels out, so only the clean result shows. */
.promo-card[data-image="deep"] .promo-media__img {
  bottom: 0;
  height: 122%;
  top: auto;
}

/* With no photo: a deep green panel with a faint diamond lattice, echoing the logo mark. */
.promo-media__pattern {
  background:
    radial-gradient(70% 55% at 76% 28%, rgba(201, 168, 76, 0.3), transparent 70%),
    radial-gradient(60% 50% at 8% 96%, rgba(201, 168, 76, 0.12), transparent 70%);
  inset: 0;
  overflow: hidden;
  position: absolute;
}

.promo-media__pattern::before {
  background-image:
    linear-gradient(45deg, rgba(201, 168, 76, 0.13) 1px, transparent 1px),
    linear-gradient(-45deg, rgba(201, 168, 76, 0.13) 1px, transparent 1px);
  background-size: 46px 46px;
  content: "";
  inset: -20%;
  -webkit-mask-image: radial-gradient(80% 70% at 50% 45%, #000 15%, transparent 75%);
  mask-image: radial-gradient(80% 70% at 50% 45%, #000 15%, transparent 75%);
  position: absolute;
}

.promo-media__pattern::after {
  aspect-ratio: 1;
  border: 1.5px solid rgba(201, 168, 76, 0.55);
  box-shadow:
    0 0 0 26px rgba(201, 168, 76, 0.05),
    inset 0 0 0 14px rgba(201, 168, 76, 0.07);
  content: "";
  left: 50%;
  position: absolute;
  top: 46%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 52%;
}

/* A photo covers the pattern; the pattern comes back if the photo cannot load. */
.promo-card:not([data-image="none"]) .promo-media__pattern {
  display: none;
}

.promo-media__tag {
  align-items: center;
  bottom: 22px;
  color: rgba(245, 240, 232, 0.92);
  display: flex;
  font-size: 10px;
  font-weight: 500;
  gap: 12px;
  left: 24px;
  letter-spacing: 0.28em;
  line-height: 1;
  position: absolute;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
  text-transform: uppercase;
  z-index: 3;
}

.promo-media__mark {
  border: 1.5px solid var(--color-gold, #C9A84C);
  flex: none;
  height: 11px;
  position: relative;
  transform: rotate(45deg);
  width: 11px;
}

.promo-media__mark::after {
  background: var(--color-gold, #C9A84C);
  content: "";
  height: 3px;
  left: 50%;
  margin: -1.5px 0 0 -1.5px;
  position: absolute;
  top: 50%;
  width: 3px;
}

/* One light sweep across the photo when the popup opens. Invisible until animated. */
.promo-media__glint {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.promo-media__glint::before {
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.36) 50%, rgba(255, 255, 255, 0) 100%);
  bottom: -10%;
  content: "";
  left: 0;
  opacity: 0;
  position: absolute;
  top: -10%;
  transform: translateX(-140%) skewX(-16deg);
  width: 46%;
}

/* ========== TEXT PANEL ========== */
.promo-body {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  justify-content: center;
  min-width: 0;
  padding: 64px clamp(28px, 6cqi, 52px) clamp(34px, 6cqi, 54px);
  position: relative;
}

/* The logo's diamond, drawn very large and very faint in the corner. */
.promo-body::before {
  border: 1.5px solid var(--color-gold, #C9A84C);
  bottom: -110px;
  content: "";
  height: 240px;
  opacity: 0.14;
  pointer-events: none;
  position: absolute;
  right: -90px;
  transform: rotate(45deg);
  width: 240px;
  z-index: -1;
}

.promo-badge {
  align-items: center;
  background: rgba(201, 168, 76, 0.16);
  border: 1px solid rgba(125, 102, 38, 0.28);
  border-radius: 999px;
  color: var(--color-gold-ink, #7D6626);
  display: inline-flex;
  font-size: 10.5px;
  font-weight: 600;
  gap: 9px;
  letter-spacing: 0.18em;
  line-height: 1.35;
  margin: 0 0 22px;
  max-width: 100%;
  padding: 8px 14px 8px 12px;
  text-transform: uppercase;
}

.promo-badge::before {
  background: var(--color-gold, #C9A84C);
  content: "";
  flex: none;
  height: 6px;
  transform: rotate(45deg);
  width: 6px;
}

.promo-title {
  color: var(--color-deep, #0E1C15);
  font-family: var(--font-display, var(--font-serif, Georgia, "Times New Roman", serif));
  font-size: 44px;
  font-size: clamp(32px, 5.2cqi, 52px);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.04;
  margin: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.promo-title em {
  color: var(--color-gold-ink, #7D6626);
  font-style: italic;
  font-weight: inherit;
}

.promo-message {
  color: var(--color-text-dark-secondary, #555555);
  font-size: 15.5px;
  font-weight: 400;
  line-height: 1.7;
  margin: 18px 0 0;
  max-width: 34ch;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.promo-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 30px;
}

/* ========== BUTTONS ========== */
.promo-btn {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  border: 0;
  box-sizing: border-box;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  justify-content: center;
  text-decoration: none;
}

.promo-btn--primary {
  background: var(--color-deep, #0E1C15);
  border-radius: 999px;
  box-shadow: 0 12px 26px -12px rgba(14, 28, 21, 0.75);
  color: var(--color-cream, #F5F0E8);
  font-size: 12px;
  font-weight: 600;
  isolation: isolate;
  letter-spacing: 0.16em;
  min-height: 52px;
  overflow: hidden;
  padding: 0 38px;
  position: relative;
  text-transform: uppercase;
  transition: box-shadow 0.4s var(--promo-ease), transform 0.4s var(--promo-ease), color 0.35s ease;
}

/* The gold finish floods in behind the label on hover. */
.promo-btn--primary::before {
  background: linear-gradient(135deg, #DAC383 0%, var(--color-gold, #C9A84C) 45%, #A28431 100%);
  content: "";
  inset: 0;
  opacity: 0;
  position: absolute;
  transform: scale(0.8);
  transition: opacity 0.4s ease, transform 0.5s var(--promo-ease);
  z-index: -1;
}

.promo-btn--primary:hover,
.promo-btn--primary:focus-visible {
  box-shadow: 0 16px 30px -12px rgba(125, 102, 38, 0.8);
  color: var(--color-deep, #0E1C15);
  transform: translateY(-1px);
}

.promo-btn--primary:hover::before,
.promo-btn--primary:focus-visible::before {
  opacity: 1;
  transform: scale(1);
}

.promo-btn--primary:active {
  transform: translateY(0) scale(0.98);
}

.promo-btn--quiet {
  background: none;
  border-radius: 6px;
  color: var(--color-text-dark-secondary, #555555);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  min-height: 44px;
  padding: 0 6px;
  position: relative;
  transition: color 0.3s ease;
}

.promo-btn--quiet::after {
  background: currentColor;
  bottom: 9px;
  content: "";
  height: 1px;
  left: 6px;
  position: absolute;
  right: 6px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s var(--promo-ease);
}

.promo-btn--quiet:hover,
.promo-btn--quiet:focus-visible {
  color: var(--color-deep, #0E1C15);
}

.promo-btn--quiet:hover::after,
.promo-btn--quiet:focus-visible::after {
  transform: scaleX(1);
}

/* ========== CLOSE BUTTON ========== */
.promo-close {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(14, 28, 21, 0.18);
  border-radius: 50%;
  color: var(--color-deep, #0E1C15);
  cursor: pointer;
  display: grid;
  height: 44px;
  padding: 0;
  place-items: center;
  position: absolute;
  right: 16px;
  top: 16px;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.5s var(--promo-ease);
  width: 44px;
  z-index: 5;
}

.promo-close svg {
  fill: none;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
  width: 16px;
}

.promo-close:hover {
  background: var(--color-deep, #0E1C15);
  border-color: var(--color-deep, #0E1C15);
  color: var(--color-cream, #F5F0E8);
  transform: rotate(90deg);
}

.promo-btn:focus-visible,
.promo-close:focus-visible {
  box-shadow: 0 0 0 5px rgba(201, 168, 76, 0.6);
  outline: 2px solid var(--color-deep, #0E1C15);
  outline-offset: 3px;
}

/* ========== NARROW CARD (phone sheet and narrow previews) ========== */
@container promo (max-width: 640px) {
  .promo-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .promo-media {
    aspect-ratio: 16 / 9;
    min-height: 150px;
  }

  .promo-body {
    padding: 28px 24px 28px;
  }

  .promo-message {
    max-width: none;
  }

  .promo-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
    margin-top: 24px;
    width: 100%;
  }

  .promo-btn--primary {
    width: 100%;
  }

  .promo-btn--quiet {
    align-self: center;
  }

  .promo-close {
    background: rgba(14, 28, 21, 0.5);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-color: rgba(245, 240, 232, 0.4);
    color: var(--color-cream, #F5F0E8);
    right: 14px;
    top: 14px;
  }

  .promo-close:hover {
    background: var(--color-cream, #F5F0E8);
    border-color: var(--color-cream, #F5F0E8);
    color: var(--color-deep, #0E1C15);
  }

  .promo-media__tag {
    bottom: 18px;
    left: 20px;
  }

  /* Wide, short photo strip: show the before-and-after split instead of one side. */
  .promo-card[data-image="deep"] .promo-media__img {
    object-position: 50% 50%;
  }

  .promo-body::before {
    bottom: -100px;
    height: 170px;
    right: -60px;
    width: 170px;
  }
}

/* Browsers without container queries: same layout, keyed to the screen width. */
@supports not (container-type: inline-size) {
  @media (max-width: 640px) {
    .promo-grid {
      grid-template-columns: minmax(0, 1fr);
      min-height: 0;
    }

    .promo-media {
      aspect-ratio: 16 / 9;
      min-height: 150px;
    }

    .promo-body {
      padding: 28px 24px 28px;
    }

    .promo-actions {
      align-items: stretch;
      flex-direction: column;
      margin-top: 24px;
      width: 100%;
    }

    .promo-btn--quiet {
      align-self: center;
    }

    .promo-close {
      background: rgba(14, 28, 21, 0.55);
      border-color: rgba(245, 240, 232, 0.4);
      color: var(--color-cream, #F5F0E8);
    }

    .promo-title {
      font-size: 32px;
    }
  }
}

/* ========== PHONE: BOTTOM SHEET ========== */
@media (max-width: 640px) {
  .promo-root {
    align-items: flex-end;
    padding: 0;
  }

  .promo-root .promo-card {
    border-radius: 22px 22px 0 0;
    max-width: none;
    width: 100%;
  }

  .promo-root .promo-grid {
    max-height: calc(100vh - 12px);
    max-height: calc(100dvh - 12px);
  }

  /* Image strip on top, roughly a third of the screen. */
  .promo-root .promo-media {
    aspect-ratio: auto;
    height: 38vh;
    height: 38dvh;
    max-height: 340px;
    min-height: 150px;
    touch-action: none;
  }

  .promo-root .promo-body {
    padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  }

  /* Drag-handle look. The photo strip can be pulled down to dismiss. */
  .promo-root .promo-card::before {
    background: rgba(255, 255, 255, 0.82);
    border-radius: 3px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
    content: "";
    height: 5px;
    left: 50%;
    margin-left: -22px;
    pointer-events: none;
    position: absolute;
    top: 10px;
    width: 44px;
    z-index: 4;
  }
}

@media (max-width: 640px) and (max-height: 600px) {
  .promo-root .promo-media {
    height: 26dvh;
    min-height: 110px;
  }
}

/* Short landscape screens: keep the card compact so everything fits without scrolling. */
@media (min-width: 641px) and (max-height: 560px) {
  .promo-grid {
    min-height: 0;
  }

  .promo-body {
    padding: 40px 40px 24px;
  }

  .promo-badge {
    margin-bottom: 14px;
  }

  .promo-title {
    font-size: 32px;
  }

  .promo-message {
    font-size: 14px;
    line-height: 1.55;
    margin-top: 12px;
  }

  .promo-actions {
    margin-top: 20px;
  }
}

/* ========== MOTION ========== */
/* Everything below only applies inside the real overlay (.promo-root). */
@keyframes promoBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes promoBackdropOut {
  to { opacity: 0; }
}

@keyframes promoCardIn {
  from { opacity: 0; transform: translateY(34px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes promoCardOut {
  to { opacity: 0; transform: translateY(14px) scale(0.985); }
}

@keyframes promoSheetIn {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@keyframes promoSheetOut {
  to { transform: translateY(100%); }
}

@keyframes promoImageIn {
  from { filter: blur(16px); opacity: 0.55; transform: scale(1.12); }
  to { filter: blur(0); opacity: 1; transform: scale(1); }
}

@keyframes promoRiseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes promoGlint {
  0% { opacity: 0; transform: translateX(-140%) skewX(-16deg); }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(300%) skewX(-16deg); }
}

@keyframes promoDiamond {
  0%, 100% { transform: translate(-50%, -50%) rotate(45deg) scale(1); }
  50% { transform: translate(-50%, -50%) rotate(52deg) scale(1.04); }
}

@keyframes promoFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes promoFadeOut {
  to { opacity: 0; }
}

.promo-root .promo-backdrop {
  animation: promoBackdropIn 0.55s ease both;
}

.promo-root .promo-card {
  animation: promoCardIn 0.85s var(--promo-ease) 0.05s both;
}

.promo-root .promo-media__img {
  animation: promoImageIn 1.3s var(--promo-ease) 0.1s both;
}

.promo-root .promo-media__glint::before {
  animation: promoGlint 1.6s cubic-bezier(0.4, 0, 0.2, 1) 0.8s both;
}

.promo-root .promo-media__pattern::after {
  animation: promoDiamond 16s ease-in-out infinite;
}

.promo-root .promo-body > * {
  animation: promoRiseIn 0.8s var(--promo-ease) both;
}

.promo-root .promo-body > :nth-child(1) { animation-delay: 0.34s; }
.promo-root .promo-body > :nth-child(2) { animation-delay: 0.42s; }
.promo-root .promo-body > :nth-child(3) { animation-delay: 0.5s; }
.promo-root .promo-body > :nth-child(4) { animation-delay: 0.58s; }

@media (max-width: 640px) {
  .promo-root .promo-card {
    animation: promoSheetIn 0.8s var(--promo-ease) 0.05s both;
  }
}

/* Once settled, the card hands its transform back so it can be dragged. */
.promo-root .promo-card.promo-settled {
  animation: none;
}

/* Leaving is quicker than arriving. */
.promo-root.promo-closing .promo-backdrop {
  animation: promoBackdropOut 0.24s ease-in both;
}

.promo-root.promo-closing .promo-card {
  animation: promoCardOut 0.24s ease-in both;
}

@media (max-width: 640px) {
  .promo-root.promo-closing .promo-card {
    animation: promoSheetOut 0.28s cubic-bezier(0.5, 0, 0.75, 0) both;
  }
}

/* Closing after a downward drag continues from where the finger left it. */
.promo-root.promo-closing .promo-card.promo-dragged {
  animation: none;
  opacity: 0.6;
  transition: opacity 0.26s ease-in, transform 0.26s cubic-bezier(0.5, 0, 0.75, 0);
}

.promo-root .promo-card.promo-returning {
  transition: transform 0.35s var(--promo-ease);
}

/* ========== REDUCED MOTION ========== */
/* No movement: a plain, quick fade. */
@media (prefers-reduced-motion: reduce) {
  .promo-root .promo-backdrop,
  .promo-root .promo-card {
    animation: promoFadeIn 0.2s ease both;
  }

  .promo-root .promo-media__img,
  .promo-root .promo-media__glint::before,
  .promo-root .promo-media__pattern::after,
  .promo-root .promo-body > * {
    animation: none;
  }

  .promo-root .promo-card.promo-settled {
    animation: none;
  }

  .promo-root.promo-closing .promo-backdrop,
  .promo-root.promo-closing .promo-card {
    animation: promoFadeOut 0.14s ease both;
  }

  .promo-btn--primary,
  .promo-btn--primary::before,
  .promo-btn--quiet::after,
  .promo-close {
    transition: none;
  }

  .promo-btn--primary:hover,
  .promo-btn--primary:focus-visible,
  .promo-btn--primary:active,
  .promo-close:hover {
    transform: none;
  }
}

/* Design cleanup: the old diamond logo motif is retired site-wide. */
.promo-media__mark,
.promo-body::before,
.promo-badge::before,
.promo-media__pattern::before {
  display: none !important;
}

.promo-media__pattern::after {
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.promo-btn--primary {
  box-shadow: none;
}
