/* FinOps savings calculator on the Save Now Pay Later page (snpl-finops-calculator.php).
   A "Savings Calculator" and "FAQs" button in the top-right corner (a soft pulse and a shine sweep draw
   the eye) opens a panel just below it, which flips down over a dimmed page. Inside, a short
   chat: assistant messages on the left, the visitor's answers on the right, answer chips, a
   typing indicator, the answer box and the savings report card. Colours come from
   css/snpl-1.css (:root). */

.snpl-top-actions,
.finops-launcher,
.finops-drawer {
  --finops-edge: clamp(12px, 2vw, 28px);
  /* space from the top and right edges */
  --finops-launcher-h: 48px;
}

/* ---------- Top actions container: FAQs & Savings Calculator ---------- */
.snpl-top-actions {
  position: fixed;
  top: calc(var(--finops-edge) + env(safe-area-inset-top, 0px));
  right: calc(var(--finops-edge) + env(safe-area-inset-right, 0px));
  z-index: 991;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

/* ---------- "Savings Calculator" button (Green/Teal gradient) ---------- */
.finops-launcher {
  position: relative;
  top: auto;
  right: auto;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--finops-launcher-h);
  padding: 6px 20px 6px 6px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--snpl-teal), var(--blue));
  color: var(--snpl-white);
  font: 700 15px/1 "Manrope", Arial, sans-serif;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(11, 59, 156, 0.35);
  cursor: pointer;
  animation: finops-pulse 2.4s ease-out infinite;
  transition: transform 0.2s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- FAQs button: Deep Royal Navy / Indigo (pairs with the green calculator) ---------- */
.faq-launcher {
  background: linear-gradient(135deg, #051e52 0%, #0b3b9c 55%, #1d4b98 100%);
  box-shadow: 0 10px 24px rgba(5, 30, 82, 0.4);
  animation: faq-pulse 2.4s ease-out infinite 1.2s;
}

.faq-launcher:hover {
  background: linear-gradient(135deg, #03153b 0%, #082f7d 55%, #174288 100%);
}

@keyframes faq-pulse {
  0% {
    box-shadow: 0 10px 24px rgba(5, 30, 82, 0.4), 0 0 0 0 rgba(11, 59, 156, 0.6);
  }

  70% {
    box-shadow: 0 10px 24px rgba(5, 30, 82, 0.4), 0 0 0 14px rgba(11, 59, 156, 0);
  }

  100% {
    box-shadow: 0 10px 24px rgba(5, 30, 82, 0.4), 0 0 0 0 rgba(11, 59, 156, 0);
  }
}

/* A light sweep across the button every few seconds */
.finops-launcher::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg);
  animation: finops-shine 3.6s ease-in-out infinite;
  pointer-events: none;
}

.finops-launcher:hover {
  transform: translateY(-2px);
}

.finops-launcher:focus-visible {
  outline: 3px solid var(--snpl-focus);
  outline-offset: 3px;
}

/* While the panel is open, no pulse */
.finops-launcher[aria-expanded="true"] {
  animation: none;
  box-shadow: 0 10px 24px rgba(11, 59, 156, 0.35);
}

.finops-launcher__icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

@keyframes finops-pulse {
  0% {
    box-shadow: 0 10px 24px rgba(11, 59, 156, 0.35), 0 0 0 0 rgba(15, 159, 151, 0.55);
  }

  70% {
    box-shadow: 0 10px 24px rgba(11, 59, 156, 0.35), 0 0 0 14px rgba(15, 159, 151, 0);
  }

  100% {
    box-shadow: 0 10px 24px rgba(11, 59, 156, 0.35), 0 0 0 0 rgba(15, 159, 151, 0);
  }
}

@keyframes finops-shine {

  0%,
  55% {
    left: -60%;
  }

  100% {
    left: 130%;
  }
}

/* ---------- Panel, just below the button ---------- */
.finops-drawer {
  --finops-top: calc(var(--finops-edge) + var(--finops-launcher-h) + 10px + env(safe-area-inset-top, 0px));

  position: fixed;
  inset: var(--finops-top) calc(var(--finops-edge) + env(safe-area-inset-right, 0px)) auto auto;
  width: min(420px, calc(100vw - 24px));
  max-width: none;
  height: min(680px, calc(100vh - var(--finops-top) - 16px));
  height: min(680px, calc(100dvh - var(--finops-top) - 16px));
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--snpl-white);
  color: var(--navy);
  font-family: "Manrope", Arial, sans-serif;
  box-shadow: 0 24px 60px rgba(5, 30, 82, 0.35);
  transform-origin: top center;
}

.finops-drawer::backdrop {
  background: rgba(5, 30, 82, 0.45);
}

/* Older in-app browsers without showModal() (script-1.js adds .dialog-fallback) */
.finops-drawer.dialog-fallback {
  z-index: 1000;
}

/* Flips down from its top edge; window.snplCloseDialog() plays .is-closing (flips back up)
   before closing */
.finops-drawer[open] {
  animation: finops-flip-down 0.55s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.finops-drawer[open]::backdrop {
  animation: finops-fade-in 0.35s ease both;
}

.finops-drawer.is-closing {
  animation: finops-flip-up 0.3s ease-in both;
  pointer-events: none;
}

.finops-drawer.is-closing::backdrop {
  animation: finops-fade-out 0.3s ease both;
}

@keyframes finops-flip-down {
  from {
    opacity: 0;
    transform: perspective(1200px) rotateX(-90deg);
  }

  50% {
    opacity: 1;
  }

  to {
    opacity: 1;
    transform: perspective(1200px) rotateX(0);
  }
}

@keyframes finops-flip-up {
  from {
    opacity: 1;
    transform: perspective(1200px) rotateX(0);
  }

  to {
    opacity: 0;
    transform: perspective(1200px) rotateX(-90deg);
  }
}

@keyframes finops-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes finops-fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* The page behind does not scroll while the drawer is open (js/snpl-finops-calculator.js) */
html.finops-open {
  overflow: hidden;
}

.finops-drawer__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.finops-drawer__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #e3eaf6;
}

.finops-drawer__head>div {
  flex: 1 1 auto;
  min-width: 0;
}

.finops-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--snpl-teal), var(--blue));
  color: var(--snpl-white);
}

.finops-drawer__title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.2;
}

/* The title takes focus when the drawer opens (autofocus), like the consultation form; it is
   not a control, so no focus ring. */
.finops-drawer__title:focus {
  outline: none;
}

.finops-drawer__sub {
  margin: 2px 0 0;
  color: var(--snpl-slate);
  font-size: 13px;
}

.finops-drawer__close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--pale-blue);
  color: var(--blue);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.finops-drawer__close:hover {
  background: var(--snpl-blue-soft);
}

.finops-drawer__close:focus-visible,
.finops-chip:focus-visible,
.finops-send:focus-visible,
.finops-restart:focus-visible,
.finops-cta:focus-visible {
  outline: 3px solid var(--snpl-focus);
  outline-offset: 2px;
}

.finops-drawer__body {
  flex: 1 1 auto;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fbfcff;
}

/* ---------- Chat ---------- */
.finops-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.finops-msg {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  animation: finops-msg-in 0.3s ease both;
}

.finops-msg--bot {
  align-self: flex-start;
  border-radius: 4px 14px 14px 14px;
  background: #eef3fb;
  color: var(--navy);
}

.finops-msg--me {
  align-self: flex-end;
  border-radius: 14px 4px 14px 14px;
  background: var(--blue);
  color: var(--snpl-white);
  font-weight: 600;
}

/* Answer chips under a question */
.finops-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  animation: finops-msg-in 0.3s ease both;
}

.finops-chip {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--snpl-blue-muted);
  border-radius: 999px;
  background: var(--snpl-white);
  color: var(--blue);
  font: 600 14px/1.2 "Manrope", Arial, sans-serif;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.finops-chip:hover {
  border-color: var(--blue);
  background: var(--pale-blue);
}

/* "Assistant is typing" dots */
.finops-typing {
  display: inline-flex;
  gap: 4px;
  align-self: flex-start;
  padding: 14px 16px;
  border-radius: 4px 14px 14px 14px;
  background: #eef3fb;
}

.finops-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--snpl-blue-muted);
  animation: finops-typing 1s infinite ease-in-out;
}

.finops-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.finops-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes finops-typing {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes finops-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* The savings report, a wide card from the assistant */
.finops-report {
  align-self: stretch;
  padding: 16px;
  border: 1px solid #dbe5f5;
  border-radius: 14px;
  background: var(--snpl-white);
  box-shadow: 0 4px 14px rgba(5, 30, 82, 0.06);
  animation: finops-msg-in 0.3s ease both;
}

.finops-row__track {
  height: 10px;
  border-radius: 5px;
  background: #e3eaf6;
  overflow: hidden;
}

.finops-row__bar {
  width: 0;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--blue), var(--snpl-blue-bright));
  transition: width 0.6s cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* Opportunity score: the number out of 100, its rating and a bar */
.finops-score {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.finops-score__value {
  margin: 0;
  color: var(--snpl-slate);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.finops-score__value strong {
  color: var(--blue);
  font-size: 40px;
  font-weight: 800;
}

.finops-score__label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin: 0;
  color: var(--snpl-note);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.finops-score__rating {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--blue);
  color: var(--snpl-white);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}

.finops-score__track {
  margin-bottom: 14px;
}

/* Expected savings %, annual spend and the savings a year */
.finops-facts {
  margin: 0 0 16px;
  padding: 4px 12px;
  border-radius: 10px;
  background: var(--pale-blue);
}

.finops-facts__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
}

.finops-facts__row+.finops-facts__row {
  border-top: 1px solid #d3e0f5;
}

.finops-facts dt {
  color: var(--snpl-note);
  font-weight: 600;
}

.finops-facts dd {
  margin: 0;
  color: var(--navy);
  font-weight: 800;
  text-align: right;
}

/* The approximate savings a year, the headline of the card */
.finops-estimate {
  padding: 14px 16px;
  border: 1px solid #d3e0f5;
  border-radius: 12px;
  background: #f7faff;
}

.finops-estimate__label {
  margin: 0;
  color: var(--snpl-note);
  font-size: 14px;
  font-weight: 700;
}

.finops-estimate__value {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
}



/* The page's three promises, with a tick in front of each */
.finops-promise__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.finops-promise__list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.finops-promise__list li::before {
  content: "";
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: url("../images/save-now-pay-later/right-tick.png") center / contain no-repeat;
}

.finops-chat__action {
  align-self: center;
}

.finops-restart {
  min-height: 36px;
  margin-top: 4px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: 600 13px/1 "Manrope", Arial, sans-serif;
  text-decoration: underline;
  cursor: pointer;
}

.finops-restart:hover {
  text-decoration: none;
}

/* ---------- Answer box for the number questions ---------- */
.finops-composer {
  padding: 12px 16px 14px;
  border-top: 1px solid #e3eaf6;
  background: var(--snpl-white);
  animation: finops-msg-in 0.3s ease both;
}

.finops-composer[hidden],
.finops-composer__affix[hidden] {
  display: none;
}

.finops-composer__label {
  display: block;
  margin-bottom: 6px;
  color: var(--snpl-note);
  font-size: 12px;
  font-weight: 700;
}

.finops-composer__row {
  display: flex;
  gap: 8px;
}

.finops-composer__field {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--snpl-blue-muted);
  border-radius: 999px;
  background: var(--snpl-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.finops-composer__field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--pale-blue);
}

.finops-composer__field input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 4px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--navy);
  font: 700 16px/1.2 "Manrope", Arial, sans-serif;
  /* 16px: no zoom on iPhone */
  -moz-appearance: textfield;
  appearance: textfield;
}

.finops-composer__field input::-webkit-outer-spin-button,
.finops-composer__field input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.finops-composer__field input[aria-invalid="true"] {
  color: #b42318;
}

.finops-composer__affix {
  color: var(--snpl-slate);
  font-size: 15px;
  font-weight: 700;
}

.finops-send {
  display: grid;
  flex: 0 0 46px;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: var(--snpl-white);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.finops-send:hover {
  background: var(--snpl-blue-hover);
}

.finops-composer__error {
  margin: 6px 0 0;
  color: #b42318;
  font-size: 12px;
  font-weight: 600;
}

.finops-composer__error:empty {
  display: none;
}

/* ---------- Footer: the call to action ---------- */
.finops-drawer__foot {
  padding: 14px 20px 18px;
  border-top: 1px solid #e3eaf6;
  background: #f7faff;
  animation: finops-msg-in 0.3s ease both;
}

.finops-drawer__foot[hidden] {
  display: none;
}

.finops-cta {
  width: 100%;
  min-height: 48px;
  margin: 0;
  border: 0;
  border-radius: 10px;
  background: var(--snpl-teal);
  color: var(--snpl-white);
  font: 700 15px/1 "Manrope", Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 14px var(--snpl-teal-shadow);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.finops-cta:hover {
  background: var(--snpl-teal-hover);
  transform: translateY(-2px);
}

.finops-note {
  margin: 10px 0 0;
  color: var(--snpl-slate);
  font-size: 11px;
  line-height: 1.4;
}

/* Phones: smaller buttons; the panel fills the screen below it */
@media (max-width: 480px) {
  .snpl-top-actions {
    gap: 8px;
  }

  .finops-launcher,
  .finops-drawer {
    --finops-launcher-h: 40px;
  }

  .finops-launcher {
    gap: 6px;
    padding: 4px 12px 4px 4px;
    font-size: 13px;
  }

  .finops-launcher__icon {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }

  .finops-launcher__icon svg {
    width: 17px;
    height: 17px;
  }

  .finops-drawer {
    left: 8px;
    right: 8px;
    width: auto;
    height: calc(100vh - var(--finops-top) - 8px);
    height: calc(100dvh - var(--finops-top) - 8px);
  }
}

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

  .finops-launcher,
  .finops-launcher::after {
    animation: none;
  }

  .finops-launcher,
  .finops-row__bar,
  .finops-chip,
  .finops-cta {
    transition: none;
  }

  .finops-msg,
  .finops-chips,
  .finops-report,
  .finops-composer,
  .finops-drawer__foot,
  .finops-typing span {
    animation: none;
  }

  .finops-drawer[open],
  .finops-drawer[open]::backdrop {
    animation: finops-fade-in 0.15s ease both;
  }

  .finops-drawer.is-closing,
  .finops-drawer.is-closing::backdrop {
    animation: finops-fade-out 0.15s ease both;
  }
}
