/* MARK: Site pop-up (shown once per visit; text and dates are set in wp-admin under Settings > Site pop-up) */
/* The fallback colours let the same box preview on the wp-admin settings page, where the theme variables are not loaded. */
/* No "display" is set on .cm-popup on purpose: a closed <dialog> must stay hidden. */

.cm-popup {
  box-sizing: border-box;
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: visible; /* the X sits on the corner, partly outside; the box inside does the clipping */
  border: 0;
  border-radius: 16px;
  background: var(--calabash-white, #ffffff);
  box-shadow: 0 24px 64px rgb(6 44 79 / 40%);
  color: #3b4b5c;
  font-family: inherit;
}

.cm-popup *,
.cm-popup *::before,
.cm-popup *::after {
  box-sizing: border-box;
}

.cm-popup::backdrop {
  background: rgb(6 44 79 / 60%);
}

/* The heading stays put; only a long message scrolls. The X is outside this box, so it never moves. */
.cm-popup__box {
  position: relative;
  display: flex;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  flex-direction: column;
  overflow: hidden;
  border-radius: inherit;
  outline: none;
}

/* MARK: The coloured top with the heading */
.cm-popup__band {
  position: relative;
  flex: none;
  overflow: hidden;
  padding: 2.25rem 4rem;
  background: var(--calabash-navy, #062c4f);
  color: #ffffff;
  text-align: center;
}

.cm-popup--orange .cm-popup__band {
  background: var(--calabash-company-orange-a11y-dark, #9d460b);
}

.cm-popup .cm-popup__title {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.25;
}

/* MARK: The message */
.cm-popup__body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.6rem 1.75rem 1.9rem;
  font-size: 1.125rem;
  line-height: 1.6;
  text-align: center;
  overflow-wrap: break-word;
}

.cm-popup__body p {
  margin: 0 0 0.85rem;
}

.cm-popup__body p:last-child {
  margin-bottom: 0;
}

/* MARK: The X: a small round button sitting on the top right corner, mostly outside the box */
.cm-popup .cm-popup__close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 2;
  display: grid;
  width: 30px;
  min-width: 0;
  height: 30px;
  min-height: 0;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
  color: var(--calabash-navy, #062c4f);
  line-height: 0;
  cursor: pointer;
}

/* A little more room to click than the circle itself. */
.cm-popup .cm-popup__close::before {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  content: "";
}

.cm-popup .cm-popup__close:hover {
  background: #e8eef4;
  color: var(--calabash-navy, #062c4f);
}

.cm-popup .cm-popup__close:focus-visible {
  outline: 3px solid var(--calabash-company-turquoise, #45bee1);
  outline-offset: 2px;
}

@media (max-width: 36rem) {
  .cm-popup__band {
    padding: 2rem 3.25rem 1.6rem;
  }

  .cm-popup .cm-popup__title {
    font-size: 1.35rem;
  }

  .cm-popup__body {
    padding: 1.25rem 1.25rem 1.5rem;
    font-size: 1.0625rem;
  }
}

/* MARK: With an image: a small central box, with the picture as the main thing */
/* The box takes the picture's shape, tall or wide. SIZE: the picture fits within 30rem wide by 28rem tall; */
/* change those two numbers to make the box bigger or smaller. It is never narrower than 20rem (for the words). */
.cm-popup.cm-popup--image {
  --cm-popup-rest: 8rem; /* the height of the heading and message; the script puts the measured figure here */
  /* Less than 28rem only in a short window. A very long message does not shrink the picture: it scrolls. */
  --cm-popup-image-room: max(12rem, min(28rem, 85vh - min(13rem, var(--cm-popup-rest))));
  width: min(30rem, 100vw - 2rem, max(20rem, min(var(--cm-popup-image-width), var(--cm-popup-image-room) * var(--cm-popup-image-ratio))));
}

/* Whole, never cropped: when the box is wider than the picture (a very tall one), it sits in the middle. */
.cm-popup--image .cm-popup__image {
  display: block;
  flex: none;
  width: 100%;
  height: auto;
  max-height: var(--cm-popup-image-room);
  margin: 0;
  background: #f3f5f7;
  object-fit: contain;
}

/* The heading and message are kept slim, to leave the room to the picture. */
.cm-popup--image .cm-popup__band {
  padding: 0.95rem 3.25rem;
}

.cm-popup.cm-popup--image .cm-popup__title {
  font-size: 1.25rem;
}

.cm-popup--image .cm-popup__body {
  min-height: 3.5rem;
  max-height: 13rem;
  padding: 0.7rem 1rem 0.85rem;
  font-size: 0.95rem;
  line-height: 1.5;
  text-wrap: balance; /* even lines, so no single word is left on its own */
}

/* MARK: A gentle arrival */
@media (prefers-reduced-motion: no-preference) {
  .cm-popup[open] {
    animation: cm-popup-in 240ms ease-out;
  }
}

@keyframes cm-popup-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* MARK: Preview on the wp-admin settings page */
.cm-popup.cm-popup--preview {
  max-width: 100%;
  max-height: none;
  margin: 0 0 1rem;
  border: 1px solid #c3c4c7;
  box-shadow: 0 4px 16px rgb(0 0 0 / 12%);
}

.cm-popup--preview .cm-popup__box {
  max-height: none;
}

/* MARK: Christmas: the festive extras (only with the "Christmas" colour) */
/* A gold frame and glow, holly, a string of twinkling lights, white snow among the strip's green, a warm card for the words and snow falling
   behind the box. The drawings are small SVG pictures written into this file, so nothing else is downloaded. People whose device asks for
   reduced motion get the same scene held still. */
.cm-popup.cm-popup--christmas {
  box-shadow: 0 0 0 3px #e3bf6a, 0 0 38px 6px rgb(255 198 92 / 34%), 0 24px 64px rgb(0 0 0 / 45%);
}

.cm-popup--christmas::backdrop {
  background-color: rgb(7 28 48 / 72%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='470' height='470' viewBox='0 0 470 470'%3E%3Cg fill='%23ffffff' fill-opacity='0.9'%3E%3Ccircle cx='38' cy='62' r='3.2'/%3E%3Ccircle cx='173' cy='21' r='2.2'/%3E%3Ccircle cx='322' cy='108' r='3.6'/%3E%3Ccircle cx='431' cy='47' r='2.4'/%3E%3Ccircle cx='92' cy='187' r='2.6'/%3E%3Ccircle cx='257' cy='236' r='3'/%3E%3Ccircle cx='405' cy='289' r='2.1'/%3E%3Ccircle cx='31' cy='318' r='2.3'/%3E%3Ccircle cx='196' cy='371' r='3.4'/%3E%3Ccircle cx='352' cy='424' r='2.7'/%3E%3Ccircle cx='112' cy='447' r='2'/%3E%3Ccircle cx='452' cy='196' r='2.9'/%3E%3C/g%3E%3Cdefs%3E%3Cg id='a'%3E%3Cpath d='M0 0H6M3.5 0L5.3-1.6M3.5 0L5.3 1.6'/%3E%3C/g%3E%3Cg id='f' fill='none' stroke='%23ffffff' stroke-width='1.4' stroke-linecap='round'%3E%3Cuse href='%23a' transform='rotate(0)'/%3E%3Cuse href='%23a' transform='rotate(60)'/%3E%3Cuse href='%23a' transform='rotate(120)'/%3E%3Cuse href='%23a' transform='rotate(180)'/%3E%3Cuse href='%23a' transform='rotate(240)'/%3E%3Cuse href='%23a' transform='rotate(300)'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23f' transform='translate(228 128) scale(1.4) rotate(12)'/%3E%3Cuse href='%23f' transform='translate(76 262) scale(1.1) rotate(35)'/%3E%3Cuse href='%23f' transform='translate(338 342) scale(1.25) rotate(5)'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='310' height='310' viewBox='0 0 310 310'%3E%3Cg fill='%23ffffff' fill-opacity='0.7'%3E%3Ccircle cx='22' cy='31' r='1.4'/%3E%3Ccircle cx='127' cy='12' r='1.1'/%3E%3Ccircle cx='219' cy='58' r='1.5'/%3E%3Ccircle cx='288' cy='131' r='1.1'/%3E%3Ccircle cx='64' cy='96' r='1.2'/%3E%3Ccircle cx='171' cy='139' r='1.5'/%3E%3Ccircle cx='14' cy='188' r='1.1'/%3E%3Ccircle cx='236' cy='214' r='1.4'/%3E%3Ccircle cx='103' cy='232' r='1.2'/%3E%3Ccircle cx='281' cy='281' r='1.3'/%3E%3Ccircle cx='158' cy='289' r='1'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 470px 470px, 310px 310px;
}

.cm-popup--christmas .cm-popup__band {
  background: radial-gradient(130% 150% at 50% 0%, #d22f3d 0%, #b01526 48%, #850b1b 100%);
  box-shadow: inset 0 -3px 0 #e3bf6a;
}

.cm-popup--christmas .cm-popup__band.site-notice--christmas::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='190' height='110' viewBox='0 0 190 110'%3E%3Cdefs%3E%3Cg id='a'%3E%3Cpath d='M0 0H6M3.5 0L5.3-1.6M3.5 0L5.3 1.6'/%3E%3C/g%3E%3Cg id='f' fill='none' stroke='%23ffffff' stroke-opacity='0.9' stroke-width='1.5' stroke-linecap='round'%3E%3Cuse href='%23a' transform='rotate(0)'/%3E%3Cuse href='%23a' transform='rotate(60)'/%3E%3Cuse href='%23a' transform='rotate(120)'/%3E%3Cuse href='%23a' transform='rotate(180)'/%3E%3Cuse href='%23a' transform='rotate(240)'/%3E%3Cuse href='%23a' transform='rotate(300)'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23f' transform='translate(26 18) scale(0.7)'/%3E%3Cuse href='%23f' transform='translate(98 60) scale(0.55) rotate(30)'/%3E%3Cuse href='%23f' transform='translate(150 22) scale(0.65) rotate(15)'/%3E%3Cuse href='%23f' transform='translate(60 92) scale(0.6) rotate(45)'/%3E%3Cuse href='%23f' transform='translate(168 88) scale(0.5)'/%3E%3C/svg%3E");
}

.cm-popup.cm-popup--christmas .cm-popup__title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 0 14px rgb(255 214 122 / 60%);
}

.cm-popup__holly {
  position: absolute;
  top: 0.2rem;
  left: 0.15rem;
  z-index: 1;
  width: 52px;
  height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='40' viewBox='0 0 52 40'%3E%3Cg fill='%232e9c57' stroke='%230f4f2b' stroke-width='1'%3E%3Cpath transform='translate(27 21) rotate(-34)' d='M0 0C4-3 5-8 8-9C9-5 12-4 15-8C16-4 19-3 22-5C22-2 24 0 26 0C24 0 22 2 22 5C19 3 16 4 15 8C12 4 9 5 8 9C5 8 4 3 0 0Z'/%3E%3Cpath transform='translate(25 21) rotate(168)' d='M0 0C4-3 5-8 8-9C9-5 12-4 15-8C16-4 19-3 22-5C22-2 24 0 26 0C24 0 22 2 22 5C19 3 16 4 15 8C12 4 9 5 8 9C5 8 4 3 0 0Z'/%3E%3C/g%3E%3Cg fill='none' stroke='%2314663a' stroke-width='0.9'%3E%3Cpath transform='translate(27 21) rotate(-34)' d='M3 0H21'/%3E%3Cpath transform='translate(25 21) rotate(168)' d='M3 0H20'/%3E%3C/g%3E%3Cg fill='%23ff3341' stroke='%236e0710' stroke-width='0.9'%3E%3Ccircle cx='23' cy='21' r='4.2'/%3E%3Ccircle cx='30' cy='23' r='4.2'/%3E%3Ccircle cx='25' cy='27.5' r='4.2'/%3E%3C/g%3E%3Cg fill='%23ffffff'%3E%3Ccircle cx='21.7' cy='19.6' r='1.1'/%3E%3Ccircle cx='28.7' cy='21.6' r='1.1'/%3E%3Ccircle cx='23.7' cy='26.1' r='1.1'/%3E%3C/g%3E%3C/svg%3E") no-repeat;
  pointer-events: none;
}

/* The wire is the element itself; every other bulb is on one of its two layers, so they can twinkle in turn. */
.cm-popup__lights,
.cm-popup__lights::before,
.cm-popup__lights::after {
  position: absolute;
  height: 18px;
  background-position: 50% 0;
  background-repeat: repeat-x;
  pointer-events: none;
}

.cm-popup__lights {
  right: 0;
  bottom: 3px;
  left: 0;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='18' viewBox='0 0 96 18'%3E%3Cpath d='M0 2Q12 9 24 2Q36 9 48 2Q60 9 72 2Q84 9 96 2' fill='none' stroke='%230d3b26' stroke-width='1.6'/%3E%3C/svg%3E");
}

.cm-popup__lights::before,
.cm-popup__lights::after {
  content: "";
  inset: 0;
}

.cm-popup__lights::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='18' viewBox='0 0 96 18'%3E%3Ccircle cx='12' cy='11.4' r='6.4' fill='%23ffd34d' fill-opacity='0.35'/%3E%3Crect x='10.4' y='4.6' width='3.2' height='3.2' rx='0.6' fill='%230d3b26'/%3E%3Cellipse cx='12' cy='11.6' rx='3.3' ry='4.4' fill='%23ffd34d'/%3E%3Cellipse cx='10.9' cy='10.2' rx='0.8' ry='1.4' fill='%23ffffff' fill-opacity='0.75'/%3E%3Ccircle cx='60' cy='11.4' r='6.4' fill='%236fd0ff' fill-opacity='0.35'/%3E%3Crect x='58.4' y='4.6' width='3.2' height='3.2' rx='0.6' fill='%230d3b26'/%3E%3Cellipse cx='60' cy='11.6' rx='3.3' ry='4.4' fill='%236fd0ff'/%3E%3Cellipse cx='58.9' cy='10.2' rx='0.8' ry='1.4' fill='%23ffffff' fill-opacity='0.75'/%3E%3C/svg%3E");
}

.cm-popup__lights::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='18' viewBox='0 0 96 18'%3E%3Ccircle cx='36' cy='11.4' r='6.4' fill='%2352e887' fill-opacity='0.35'/%3E%3Crect x='34.4' y='4.6' width='3.2' height='3.2' rx='0.6' fill='%230d3b26'/%3E%3Cellipse cx='36' cy='11.6' rx='3.3' ry='4.4' fill='%2352e887'/%3E%3Cellipse cx='34.9' cy='10.2' rx='0.8' ry='1.4' fill='%23ffffff' fill-opacity='0.75'/%3E%3Ccircle cx='84' cy='11.4' r='6.4' fill='%23fff4cf' fill-opacity='0.35'/%3E%3Crect x='82.4' y='4.6' width='3.2' height='3.2' rx='0.6' fill='%230d3b26'/%3E%3Cellipse cx='84' cy='11.6' rx='3.3' ry='4.4' fill='%23fff4cf'/%3E%3Cellipse cx='82.9' cy='10.2' rx='0.8' ry='1.4' fill='%23ffffff' fill-opacity='0.75'/%3E%3C/svg%3E");
}

.cm-popup--christmas.cm-popup--image .cm-popup__band {
  padding-top: 0.7rem;
  padding-bottom: 1.5rem;
}

.cm-popup--christmas .cm-popup__body {
  background: #fff8ec;
  box-shadow: inset 0 3px 0 #e3bf6a;
  color: #123f2c;
  font-weight: 500;
}

.cm-popup--christmas .cm-popup__body::before {
  display: block;
  height: 12px;
  margin-bottom: 0.4rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='132' height='12' viewBox='0 0 132 12'%3E%3Cg stroke='%23c99a2e' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M8 6H52M80 6H124'/%3E%3C/g%3E%3Cpath fill='%23d9a933' d='M66 0L67.6 4.1L72 4.3L68.5 7L69.7 11.3L66 8.8L62.3 11.3L63.5 7L60 4.3L64.4 4.1Z'/%3E%3C/svg%3E") 50% 0 no-repeat;
  content: "";
}

.cm-popup--christmas.cm-popup--image .cm-popup__body {
  padding-top: 0.6rem;
}

.cm-popup--christmas .cm-popup__image {
  background: #fff8ec;
}

.cm-popup.cm-popup--christmas .cm-popup__close {
  box-shadow: 0 0 0 2px #e3bf6a, 0 2px 8px rgb(0 0 0 / 30%);
  color: #8c1021;
}

@media (prefers-reduced-motion: no-preference) {
  .cm-popup--christmas::backdrop {
    animation: cm-popup-snow 28s linear infinite;
  }

  .cm-popup__lights::before {
    animation: cm-popup-twinkle 1.8s ease-in-out infinite;
  }

  .cm-popup__lights::after {
    animation: cm-popup-twinkle 1.8s ease-in-out -0.9s infinite;
  }
}

/* Each layer moves a whole number of its own tiles, so the fall never jumps. */
@keyframes cm-popup-snow {
  from {
    background-position: 0 0, 0 0;
  }

  to {
    background-position: 470px 940px, -310px 620px;
  }
}

@keyframes cm-popup-twinkle {
  50% {
    opacity: 0.3;
  }
}
