/* =========================================================
   Potvrdenie odoslania – modálne okno s animáciou (success-modal.js)
   Okno má pevnú výšku, nič v ňom neposkakuje:
   1. v strede animácia (podpis newslettera / zalepenie obálky)
   2. pribudne odznak „verified“
   3. celá scéna vybledne
   4. scéna sa presunie hore
   5. formulár zmizne, ostane iba odznak – znova naplno viditeľný
   6. pod odznakom sa vypíše ďakovný text a zobrazia sa tlačidlá
   Potrebuje premenné z tokens.css a tlačidlá z web.css.
   ========================================================= */

body:has(.success-modal[open]) {
  overflow: hidden;
}

.success-modal {
  width: min(520px, 100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

.success-modal[open] {
  animation: sm-in var(--dur-slow) var(--ease-out);
}

.success-modal::backdrop {
  background: rgba(21, 24, 29, 0.55);
  backdrop-filter: blur(4px);
}

.success-modal[open]::backdrop {
  animation: sm-fade var(--dur) ease;
}

.success-modal.is-closing {
  animation: sm-out var(--dur) var(--ease-out) forwards;
}

@keyframes sm-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

@keyframes sm-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes sm-fade {
  from {
    opacity: 0;
  }
}

.sm-body {
  --h: 470px; /* pevná výška okna */
  --badge-top: 92px; /* kde skončí stred odznaku po presune hore */
  position: relative;
  height: var(--h);
  overflow: hidden;
  border-radius: inherit;
}

.sm-body:focus {
  outline: none;
}

.sm-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.sm-close:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.sm-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* ---------- Scéna s animáciou ---------- */
.sm-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: transform 0.8s var(--ease-in-out), opacity 0.6s ease;
}

.sm-stage svg.sm-scene {
  width: 300px;
  max-width: 80%;
  height: auto;
  overflow: visible;
  transition: opacity 0.4s ease, transform 0.5s var(--ease-out);
}

/* po dokončení akcie scéna ustúpi a v strede sa objaví odznak */
.sm-stage.is-done svg.sm-scene {
  opacity: 0.3;
  transform: scale(0.95);
}

.sm-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  fill: none;
  stroke: var(--red);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.5) rotate(-20deg);
  transition: opacity 0.35s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sm-badge .sm-badge-check {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.45s var(--ease-out) 0.35s;
}

.sm-stage.is-done .sm-badge {
  opacity: 1;
  transform: none;
}

.sm-stage.is-done .sm-badge .sm-badge-check {
  stroke-dashoffset: 0;
}

/* 3. celá scéna vybledne */
.sm-stage.is-dim {
  opacity: 0.4;
}

/* 4.–5. presun hore, formulár zmizne a odznak je znova naplno viditeľný */
.sm-stage.is-up {
  opacity: 1;
  transform: translateY(calc(var(--badge-top) - var(--h) / 2));
  transition: transform 0.7s var(--ease-in-out), opacity 0.4s ease 0.7s;
}

.sm-stage.is-up svg.sm-scene {
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}

/* ---------- Newsletter: pero a podpis ---------- */
.sm-signature {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* čiarkovanie a jeho animácia sú priamo v SVG (SMIL), CSS by ich prebilo */
}

.sm-pen {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sm-stage.is-signing .sm-pen {
  opacity: 1;
}

/* po podpise pero odíde hore doprava */
.sm-pen-lift {
  transition: transform 0.5s var(--ease-out), opacity 0.4s ease;
}

.sm-stage.is-signed .sm-pen-lift {
  transform: translate(26px, -30px) rotate(12deg);
  opacity: 0;
}

/* ---------- Kontakt: list do obálky ---------- */
.sm-letter,
.sm-flap-open,
.sm-flap-closed,
.sm-envelope {
  transform-box: fill-box;
}

.sm-letter {
  transition: transform 0.9s var(--ease-in-out);
}

.sm-stage.is-sending .sm-letter {
  transform: translateY(46px);
}

.sm-flap-open {
  transform-origin: center bottom;
  transition: transform 0.35s ease-in 0.8s, opacity 0s linear 1.15s;
}

.sm-stage.is-sending .sm-flap-open {
  transform: scaleY(0);
  opacity: 0;
}

.sm-flap-closed {
  transform-origin: center top;
  transform: scaleY(0);
  transition: transform 0.35s var(--ease-out) 1.15s;
}

.sm-stage.is-sending .sm-flap-closed {
  transform: scaleY(1);
}

.sm-envelope {
  transition: transform 0.6s var(--ease-out);
}

.sm-stage.is-sent .sm-envelope {
  transform: translate(8px, -6px) rotate(-4deg);
}

/* ---------- Kalkulačka: odomknutie a odhalenie výsledkov ---------- */
.sm-shackle,
.sm-lock,
.sm-cover,
.sm-val {
  transform-box: fill-box;
}

/* zámok sa otvorí */
.sm-shackle {
  transition: transform 0.35s var(--ease-out);
}

.sm-stage.is-unlocking .sm-shackle {
  transform: translateY(-6px);
}

.sm-lock {
  transform-origin: center;
  transition: transform 0.35s ease-in 0.45s, opacity 0.3s ease 0.5s;
}

.sm-stage.is-unlocking .sm-lock {
  transform: scale(0.6);
  opacity: 0;
}

/* sivá vrstva sa stiahne nadol a odhalí výsledky */
.sm-cover {
  transform-origin: center bottom;
  transition: transform 0.6s var(--ease-in-out) 0.7s;
}

.sm-stage.is-unlocking .sm-cover {
  transform: scaleY(0);
}

/* hodnoty sa postupne dokreslia sprava */
.sm-val {
  transform-origin: right center;
  transform: scaleX(0);
  transition: transform 0.4s var(--ease-out);
}

.sm-val-result {
  transform-origin: left center;
}

.sm-stage.is-unlocking .sm-val {
  transform: none;
}

/* oneskorenie každej hodnoty je v SVG ako --d */
.sm-stage.is-unlocking .sm-val {
  transition-delay: var(--d, 1.1s);
}

/* ---------- 6. Text pod odznakom – vypisuje sa postupne ---------- */
.sm-content {
  position: absolute;
  top: calc(var(--badge-top) + 80px);
  right: 2em;
  left: 2em;
  text-align: center;
}

.sm-content:not([hidden]) {
  animation: sm-fade 0.4s ease;
}

/* miesto je vyhradené dopredu, aby sa pri písaní nič neposúvalo */
.sm-content h2 {
  min-height: 2.3em;
  margin: 0 0 var(--space-sm);
  font-size: var(--fs-2xl);
  line-height: 1.15;
}

.sm-content p {
  min-height: 4.8em;
  max-width: 36ch;
  margin: 0 auto;
  color: var(--muted);
}

/* blikajúci kurzor za práve písaným textom */
.sm-typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--red);
  animation: sm-caret 0.8s steps(1) infinite;
}

@keyframes sm-caret {
  50% {
    opacity: 0;
  }
}

.sm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur) ease, transform var(--dur) var(--ease-out);
}

.sm-actions.is-visible {
  opacity: 1;
  transform: none;
}

/* Mobil – vyššie okno, lebo text sa zalomí do viac riadkov */
@media (max-width: 560px) {
  .sm-body {
    --h: min(540px, 100dvh - 32px);
    --badge-top: 84px;
  }

  .sm-content {
    right: 1.25em;
    left: 1.25em;
  }

  .sm-actions .btn {
    width: 100%;
  }
}
