/* Kontaktformular: Bewegung an der Rechenfrage und nach dem Absenden.
   Bei „Bewegung reduzieren“ schaltet basis.css alle Animationen ab; dann stehen Haken,
   Postfach und Bestätigung sofort da. */

/* Rechenfrage */
.frage,
.frage-schau {
  font-variant-numeric: tabular-nums;
}

.frage-schau {
  color: var(--akzent);
}

.antwort-zeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
}

/* Felder: treten nacheinander auf; im Fokus zieht eine Linie unter dem Feld entlang, die
   Beschriftung färbt sich; gültig ausgefüllt erscheint ein kleiner Haken */
.formular > p:not(.koeder) {
  position: relative;
  animation: feld-herein 350ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.formular > p:nth-child(2) {
  animation-delay: 50ms;
}

.formular > p:nth-child(3) {
  animation-delay: 100ms;
}

.formular > p:nth-child(4) {
  animation-delay: 150ms;
}

.formular > p:nth-child(5) {
  animation-delay: 200ms;
}

.formular > p:nth-child(6) {
  animation-delay: 250ms;
}

.formular > p:nth-child(7) {
  animation-delay: 300ms;
}

.formular label {
  transition: color 250ms ease;
}

.formular p:focus-within > label {
  color: var(--akzent);
}

.formular input,
.formular textarea {
  background:
    linear-gradient(var(--akzent) 0 0) center bottom / 0 2px no-repeat,
    var(--grund);
  transition:
    background-size 400ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 250ms ease,
    box-shadow 250ms ease;
}

.formular input:focus,
.formular textarea:focus {
  border-color: var(--akzent);
  background-size:
    calc(100% - 1.5rem) 2px,
    auto;
}

/* Haken aus zwei Rahmenkanten; nur Name und E-Mail (direkte Kinder der Zeile) */
.formular > p:has(> input:user-valid)::after {
  position: absolute;
  right: 1.125rem;
  bottom: 1.2rem;
  width: 0.4rem;
  height: 0.8rem;
  border: solid var(--akzent);
  border-width: 0 2px 2px 0;
  content: "";
  rotate: 45deg;
  animation: haken-klein-auf 300ms cubic-bezier(0.2, 0.8, 0.2, 1.6) both;
}

@keyframes feld-herein {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

@keyframes haken-klein-auf {
  from {
    opacity: 0;
    scale: 0.3;
  }
}

.schloss-zeile {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.25rem;
}

.schloss {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  fill: none;
  stroke: var(--schrift-neben);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.45;
  transition:
    stroke 300ms ease,
    opacity 300ms ease;
}

/* Bügel dreht um sein rechtes unteres Ende auf */
.schloss .buegel {
  transform-box: fill-box;
  transform-origin: right bottom;
  transition: transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1.4);
}

.chiffre {
  color: var(--akzent);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.geloest input {
  border-color: var(--akzent);
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--akzent) 28%, transparent);
}

.geloest .schloss {
  stroke: var(--akzent);
  opacity: 1;
  animation: aufleuchten 900ms ease-out both;
}

.geloest .schloss .buegel {
  transform: translateY(-0.125rem) rotate(32deg);
}

@keyframes aufleuchten {
  35% {
    filter: drop-shadow(0 0 0.5rem var(--akzent));
    transform: scale(1.18);
  }
}

.sendet .knopf {
  opacity: 0.7;
}

/* Übergang vom Formular zur Versandszene: Formular und Blatt tragen denselben Namen, der
   Browser lässt das eine in das andere übergehen (basis.css schaltet View Transitions zwischen
   Seiten ein; ohne Unterstützung steht das Blatt einfach da). */
.formular,
.blatt {
  view-transition-name: blatt;
}

::view-transition-group(blatt) {
  animation-duration: 700ms;
  animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1);
}

/* Nach dem Absenden: Ein Blatt wird abgetastet, löst sich in Ziffern auf, die ins Postfach
   strömen. Alles Schmuck (aria-hidden); die Bestätigung steht als Text darunter. */
.versand {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 4.5rem;
  align-items: center;
  gap: 0.75rem;
  max-width: 30rem;
  height: 7rem;
  margin: 0 0 1.5rem;
}

.blatt {
  position: relative;
  overflow: clip;
  width: 4rem;
  height: 5.25rem;
  border-radius: 0.375rem;
  /* Textzeilen des Blatts */
  background:
    repeating-linear-gradient(
        to bottom,
        transparent 0 0.5rem,
        light-dark(#c3ccd8, #5b6b85) 0.5rem 0.625rem
      )
      0.5rem 0.375rem / calc(100% - 1rem) calc(100% - 1.25rem) no-repeat,
    light-dark(#f3f6f9, #dfe6ee);
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 18%);
  animation: blatt-aufloesen 800ms ease-in 1450ms both;
}

/* Abtastlinie */
.blatt::after {
  position: absolute;
  inset: 0 0 auto;
  height: 0.25rem;
  background: var(--akzent);
  box-shadow: 0 0 0.75rem 0.25rem color-mix(in srgb, var(--akzent) 60%, transparent);
  content: "";
  opacity: 0;
  animation: abtasten 750ms ease-in-out 700ms both;
}

.strom {
  position: relative;
  container-type: inline-size;
  height: 5.25rem;
}

.strom i {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--akzent);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.8125rem;
  font-style: normal;
  line-height: 1.05;
  white-space: pre;
  opacity: 0;
  animation: stroemen 1000ms cubic-bezier(0.5, 0, 0.7, 1) both;
}

.strom i::before {
  content: "1\A 0\A 1\A 1\A 0";
}

.strom i:nth-child(3n)::before {
  content: "0\A 1\A 1\A 0\A 1";
}

.strom i:nth-child(3n + 1)::before {
  content: "1\A 1\A 0\A 0\A 1";
}

.strom i:nth-child(1) {
  animation-delay: 1450ms;
}

.strom i:nth-child(2) {
  animation-delay: 1530ms;
}

.strom i:nth-child(3) {
  animation-delay: 1610ms;
}

.strom i:nth-child(4) {
  animation-delay: 1690ms;
}

.strom i:nth-child(5) {
  animation-delay: 1770ms;
}

.strom i:nth-child(6) {
  animation-delay: 1850ms;
}

.strom i:nth-child(7) {
  animation-delay: 1930ms;
}

.strom i:nth-child(8) {
  animation-delay: 2010ms;
}

.strom i:nth-child(9) {
  animation-delay: 2090ms;
}

.strom i:nth-child(10) {
  animation-delay: 2170ms;
}

.postfach {
  width: 4.5rem;
  height: 4.5rem;
  fill: none;
  stroke: var(--akzent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: postfach-empfang 700ms cubic-bezier(0.2, 0.8, 0.2, 1.3) 2700ms both;
}

.postfach .haken-klein {
  stroke-width: 2;
  stroke-dasharray: 10;
  animation: zeichnen-klein 350ms ease-out 3150ms both;
}

.versand + .meldung {
  animation: meldung-herein 600ms ease-out 3000ms both;
}

@keyframes abtasten {
  0% {
    top: 0;
    opacity: 0;
  }

  15%,
  85% {
    opacity: 1;
  }

  100% {
    top: calc(100% - 0.25rem);
    opacity: 0;
  }
}

@keyframes blatt-aufloesen {
  to {
    clip-path: inset(0 0 0 100%);
    opacity: 0.2;
  }
}

@keyframes stroemen {
  0% {
    opacity: 0;
    translate: 0 0.5rem;
  }

  20%,
  75% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    translate: calc(100cqw - 1ch) 0.75rem;
    scale: 0.6;
  }
}

@keyframes postfach-empfang {
  from {
    opacity: 0.35;
    transform: scale(0.85);
  }
}

@keyframes zeichnen-klein {
  from {
    stroke-dashoffset: 10;
  }
}

@keyframes meldung-herein {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}
