/* Countdown digit roll and RSVP feedback for orbit.html.
   Motion is transform/opacity only; every default state is fully visible. */

/* ---------- Countdown ---------- */

.orbit .orbit-clock {
  /* Read by orbit-guest.js: 1 = roll and count-up allowed, 0 = change digits instantly. */
  --orbit-counter-motion: 1;
  --orbit-counter-ease: cubic-bezier(.16, 1, .3, 1);
}

.orbit .orbit-clock dd {
  position: relative;
  /* Two digits always occupy the same box, so changing values never nudge the cell. */
  min-inline-size: 2ch;
  font-variant-numeric: lining-nums tabular-nums;
  text-align: center;
}

.orbit .orbit-count-value {
  display: inline-block;
}

.orbit .orbit-count-leaving {
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation: orbit-count-out .35s var(--orbit-counter-ease) both;
}

.orbit .orbit-count-entering {
  animation: orbit-count-in .35s var(--orbit-counter-ease) both;
}

@keyframes orbit-count-out {
  to { opacity: 0; transform: translateY(-.5em); }
}

@keyframes orbit-count-in {
  from { opacity: 0; transform: translateY(.5em); }
}

/* ---------- Reply marks ---------- */

.orbit .orbit-rsvp-panel input:checked + .orbit-reply-mark {
  animation: orbit-mark-press .2s var(--orbit-counter-ease, ease-out);
}

/* orbit-paper.css already scales the tick (scale 0 -> 1); give it a confident arrival
   and let it fade in with the scale so it reads as drawn rather than popped. */
.orbit .orbit-reply-mark::after {
  transition: scale .2s cubic-bezier(.16, 1, .3, 1);
}

.orbit .orbit-rsvp-panel input:checked + .orbit-reply-mark::after {
  animation: orbit-reduced-fade .2s ease-out both;
}

@keyframes orbit-mark-press {
  from { transform: scale(.86); }
}

/* ---------- Primary buttons ---------- */

.orbit .orbit-primary {
  transition: background-color .2s ease, transform .2s cubic-bezier(.16, 1, .3, 1), opacity .2s ease;
}

.orbit .orbit-primary:not([aria-disabled="true"]):active {
  transform: scale(.97);
  transition-duration: .2s, .12s, .2s;
}

.orbit .orbit-primary svg {
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}

@media (hover: hover) {
  /* The only arrowed primary points down to the reply card; nudge it that way. */
  .orbit .orbit-primary:not([aria-disabled="true"]):hover svg {
    transform: translateY(4px);
  }
}

/* Quiet pending state while orbit-guest.js waits on /api/rsvp (it sets aria-disabled). */
.orbit .orbit-rsvp .orbit-primary[aria-disabled="true"] {
  cursor: progress;
  opacity: .82;
}

.orbit .orbit-rsvp-panel[data-pending="true"] #rsvp-submit[aria-disabled="true"] {
  animation: orbit-pending 1.4s ease-in-out .3s infinite alternate;
}

@keyframes orbit-pending {
  to { opacity: .7; }
}

/* ---------- Summary, form and errors ---------- */

.orbit #rsvp-summary:not([hidden]),
.orbit #rsvp-form:not([hidden]) {
  animation: orbit-reply-rise .3s cubic-bezier(.16, 1, .3, 1) both;
}

.orbit .orbit-rsvp .rsvp-field-error:not([hidden]),
.orbit #rsvp-status[data-kind="error"] {
  animation: orbit-reply-fade .2s ease-out both;
}

@keyframes orbit-reply-rise {
  from { opacity: 0; transform: translateY(6px); }
}

@keyframes orbit-reply-fade {
  from { opacity: 0; transform: translateY(-3px); }
}

/* ---------- Reduced motion: no travel, only short fades ---------- */

@media (prefers-reduced-motion: reduce) {
  .orbit .orbit-clock {
    --orbit-counter-motion: 0;
  }

  .orbit .orbit-count-leaving,
  .orbit .orbit-count-entering,
  .orbit .orbit-rsvp-panel input:checked + .orbit-reply-mark,
  .orbit .orbit-rsvp-panel[data-pending="true"] #rsvp-submit[aria-disabled="true"] {
    animation: none;
  }

  .orbit .orbit-reply-mark::after {
    transition: none;
  }

  .orbit .orbit-rsvp-panel input:checked + .orbit-reply-mark::after {
    animation: orbit-reduced-fade .15s linear both;
  }

  .orbit .orbit-primary,
  .orbit .orbit-primary:not([aria-disabled="true"]):active {
    transition: background-color .15s linear, opacity .15s linear;
  }

  .orbit .orbit-primary:active,
  .orbit .orbit-primary:not([aria-disabled="true"]):hover,
  .orbit .orbit-primary:not([aria-disabled="true"]):hover svg {
    transform: none;
  }

  .orbit .orbit-primary svg {
    transition: none;
  }

  .orbit #rsvp-summary:not([hidden]),
  .orbit #rsvp-form:not([hidden]),
  .orbit .orbit-rsvp .rsvp-field-error:not([hidden]),
  .orbit #rsvp-status[data-kind="error"] {
    animation: orbit-reduced-fade .15s linear both;
  }
}

@keyframes orbit-reduced-fade {
  from { opacity: 0; }
}
