/*
 * Mobile-first invite. The page is a short poster: a name, a headline,
 * a subtitle, and two sticker-like buttons. Wider screens keep that
 * poster and just put a card behind it.
 *
 * Palette, if you want to retune it:
 *   The saturated colors are the BMW M stripes: light blue, dark blue, red.
 *   Paper, the highlighter, and the corner washes stay light pastels of those.
 *   m-light   Yes button
 *   m-mid     focus ring
 *   m-red     No button
 *   ink       type and sticker borders, a deep navy rather than pure black
 */

:root {
  --ink: #0b1f33;
  --ink-soft: #3d5570;
  --paper: #f4f8fb;
  --card: #ffffff;
  --m-light: #00adef;
  --m-mid: #1c69d4;
  --m-dark: #003d7c;
  --m-red: #e22718;
  --pastel-sky: #c5ebf9;
  --pastel-blush: #f8d2ce;
  --btn-ink: #0b1f33;
  /* Panels that sit on the card: calendar, time chips, secondary buttons. */
  --surface: #ffffff;
  --weekend: rgba(197, 235, 249, 0.75);
  --day-muted: rgba(11, 31, 51, 0.32);
  --font-display: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  --font-body: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8f2fb;
    --ink-soft: #a8bfd4;
    --paper: #0b1f33;
    --card: #132a42;
    /* Keep the marker soft — a heavy sky wash reads as a solid bar on dark paper. */
    --pastel-sky: rgba(0, 173, 239, 0.18);
    --pastel-blush: rgba(226, 39, 24, 0.16);
    --m-dark: #7eb6ef;
    --btn-ink: #0b1f33;
    --surface: #1a3a58;
    --weekend: rgba(0, 173, 239, 0.32);
    --day-muted: rgba(232, 242, 251, 0.38);
    color-scheme: dark;
  }

  /* Stickers keep dark type on bright fills in both themes. */
  .btn-yes,
  .option-card.is-chosen {
    color: var(--btn-ink);
  }

  .defer-time.is-selected,
  .cal-day.is-selected,
  .cal-day.is-weekend.is-selected,
  .time-slot.is-selected {
    color: var(--btn-ink);
  }
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--pastel-sky);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    1.25rem
    max(1.75rem, env(safe-area-inset-bottom));
  color: var(--ink);
  font-family: var(--font-body);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 0% 0%, var(--pastel-blush), transparent 42%),
    radial-gradient(circle at 100% 0%, rgba(0, 173, 239, 0.35), transparent 36%),
    radial-gradient(circle at 100% 100%, rgba(28, 105, 212, 0.18), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(197, 235, 249, 0.95), transparent 38%);
}

/* A soft blob that drifts behind the card. Decorative only. */
body::before {
  content: "";
  position: fixed;
  z-index: 0;
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  top: -4rem;
  right: -5rem;
  background: rgba(197, 235, 249, 0.95);
  pointer-events: none;
  animation: drift 9s ease-in-out infinite;
}

.stage,
.status {
  position: relative;
  z-index: 1;
  width: min(100%, 26rem);
}

.status {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

/* The [hidden] attribute is enough in modern browsers; this keeps it honest if a display rule lands later. */
.stage[hidden],
.status[hidden] {
  display: none;
}

/* Author display rules (like the grown Yes button) would otherwise beat the hidden attribute. */
[hidden] {
  display: none !important;
}

.kicker {
  /* Block, not inline: an inline badge shares a line with the headline and collides with it. */
  display: block;
  width: fit-content;
  margin: 0 0 1.25rem;
  padding: 0.35rem 0.75rem;
  border: 2.5px solid var(--m-dark);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}

.headline {
  display: inline;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 12vw, 4.25rem);
  font-weight: 600;
  line-height: 0.96;
  letter-spacing: -0.03em;
  text-wrap: balance;
  /* Highlighter stroke under each line, like a marker on paper. */
  background-image: linear-gradient(var(--pastel-sky), var(--pastel-sky));
  background-repeat: no-repeat;
  background-size: 100% 0.32em;
  background-position: 0 88%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.subtitle {
  margin: 1.15rem 0 0;
  max-width: 30ch;
  color: var(--ink-soft);
  font-size: 1.15rem;
  line-height: 1.45;
  text-wrap: balance;
}

.actions {
  display: grid;
  gap: 0.8rem;
  margin-top: 2rem;
}

.btn {
  width: 100%;
  border: 2.5px solid var(--m-dark);
  border-radius: 999px;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.btn:focus-visible {
  outline: 3px solid var(--m-mid);
  outline-offset: 3px;
}

/* Yes is the big sticker. No is a little smaller, on purpose. */
.btn-yes {
  min-height: 3.6rem;
  padding: 1rem 1.25rem;
  background: var(--m-light);
  color: var(--btn-ink);
  font-size: 1.25rem;
  box-shadow: 4px 4px 0 var(--m-dark);
}

.btn-yes:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--m-dark);
}

.btn-yes:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--m-dark);
}

.btn-no {
  min-height: 3.1rem;
  padding: 0.8rem 1.1rem;
  background: var(--m-red);
  color: #fff;
  font-size: 1rem;
  box-shadow: 3px 3px 0 var(--m-dark);
}

.btn-no:hover {
  transform: translateY(-2px) rotate(-0.4deg);
  box-shadow: 4px 5px 0 var(--m-dark);
}

.btn-no:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--m-dark);
}

/*
 * Once No flees, both buttons are position:fixed on the body.
 * Hover translations would fight the slide, so they turn off here.
 * The slide itself is left/top, which is what dodge() writes.
 */
.btn-yes.is-growing,
.btn-no.is-loose {
  position: fixed;
  z-index: 4;
  width: auto;
  margin: 0;
  min-height: 0;
  touch-action: none;
  user-select: none;
}

.btn-yes.is-growing {
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: balance;
  transition: left 170ms ease-out, top 170ms ease-out, width 170ms ease-out, height 170ms ease-out, font-size 170ms ease-out;
}

.btn-no.is-loose {
  z-index: 6;
  overflow: hidden;
  white-space: nowrap;
  transition: left 170ms ease-out, top 170ms ease-out, width 170ms ease-out, height 170ms ease-out, font-size 170ms ease-out, border-width 170ms ease-out;
}

.btn-yes.is-growing:hover,
.btn-yes.is-growing:active,
.btn-no.is-loose:hover,
.btn-no.is-loose:active {
  transform: none;
}

/* Entrance: fade up, staggered. Base opacity stays 1 so reduced-motion users still see the invite. */
.stage.is-ready .kicker,
.stage.is-ready .headline,
.stage.is-ready .subtitle,
.stage.is-ready .actions {
  animation: rise 0.55s ease both;
}

.stage.is-ready .headline {
  animation-delay: 0.06s;
}

.stage.is-ready .subtitle {
  animation-delay: 0.14s;
}

.stage.is-ready .actions {
  animation-delay: 0.22s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* The kicker is rotated, so its own keyframes have to keep that tilt. */
.stage.is-ready .kicker {
  animation-name: rise-kicker;
}

@keyframes rise-kicker {
  from {
    opacity: 0;
    transform: translateY(12px) rotate(-2deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(-2deg);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-14px, 18px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Same poster, framed, once there is room around it. */
@media (min-width: 720px) {
  .stage {
    padding: 2.6rem 2.3rem 2.2rem;
    border: 2.5px solid var(--m-dark);
    border-radius: 2rem;
    background: color-mix(in srgb, var(--card) 90%, transparent);
    box-shadow: 10px 10px 0 rgba(0, 61, 124, 0.12);
  }
}

.stage.is-broken .headline {
  font-size: clamp(2.1rem, 9vw, 3.2rem);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 2px 2px 0 var(--m-dark);
}

/*
 * Pick screen. The stage grows with the cards and the page scrolls,
 * so a tall list is never stuck under the centered ask layout.
 */
body.is-picking {
  display: block;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

body.is-picking .stage {
  width: min(100%, 28rem);
  margin: 0 auto;
}

.gaslight {
  margin: 0.85rem 0 0;
  color: var(--m-dark);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
}

.options {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.35rem;
}

.option-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  min-height: 5.25rem;
  padding: 0.95rem 1rem;
  border: 2.5px solid var(--m-dark);
  border-radius: 1.35rem;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 4px 4px 0 rgba(0, 61, 124, 0.12);
}

.option-card:focus-visible {
  outline: 3px solid var(--m-mid);
  outline-offset: 3px;
}

.option-emoji {
  font-size: 2rem;
  line-height: 1;
}

.option-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.option-desc {
  display: block;
  margin-top: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.35;
}

/* The picked card pops. The others get out of the way. */
.option-card.is-chosen {
  background: var(--m-light);
  transform: scale(1.04);
  box-shadow: 6px 6px 0 var(--m-dark);
  transition: transform 280ms ease, box-shadow 280ms ease, background 280ms ease;
}

.option-card.is-dimmed {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
}

.picked {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  margin-top: 1.5rem;
  text-align: center;
}

.picked-emoji {
  font-size: 3.5rem;
  line-height: 1;
}

.picked-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 600;
  line-height: 1;
}

.btn-back {
  width: auto;
  min-height: 2.6rem;
  margin: 0.85rem auto 0;
  padding: 0.55rem 1.1rem;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.95rem;
  box-shadow: none;
}

.btn-back:hover {
  color: var(--ink);
  transform: none;
  box-shadow: none;
  text-decoration: underline;
}

.btn-back:active {
  transform: none;
  box-shadow: none;
}

.stage.is-confirmed .btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Celebration is centered. The form under it stays left-aligned so the field is easy to fill. */
.stage.is-confirmed {
  text-align: center;
}

.stage.is-confirmed .kicker {
  margin-left: auto;
  margin-right: auto;
}

.stage.is-confirmed .subtitle {
  max-width: 34ch;
  margin-left: auto;
  margin-right: auto;
}

.stage.is-confirmed .reply {
  text-align: left;
}

.phone-block {
  margin-top: 1.15rem;
}

.phone-caption {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.phone-link {
  display: inline-block;
  margin-top: 0.15rem;
  color: var(--m-dark);
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 600;
  line-height: 1.1;
  text-decoration: none;
}

.phone-link:focus-visible {
  outline: 3px solid var(--m-mid);
  outline-offset: 3px;
}

/* The reply sits under the confirmation line and can scroll with the page. */
.reply {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.when-label,
.reply-caption {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.reply-caption {
  margin-top: 0.35rem;
}

.when-note {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.35;
}

.defer-time {
  width: 100%;
  min-height: 3rem;
  margin-top: 0.7rem;
  border: 2.5px solid var(--m-dark);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--m-dark);
}

.defer-time.is-selected {
  background: var(--m-light);
  box-shadow: 2px 2px 0 var(--m-dark);
}

.defer-time:focus-visible {
  outline: 3px solid var(--m-mid);
  outline-offset: 2px;
}

.calendar {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.35rem;
  padding: 0.75rem;
  border: 2.5px solid var(--m-dark);
  border-radius: 1.25rem;
  background: var(--surface);
  color: var(--ink);
}

.cal-head {
  display: grid;
  grid-template-columns: 2.4rem 1fr 2.4rem;
  align-items: center;
  gap: 0.35rem;
}

.cal-month {
  margin: 0;
  text-align: center;
  font-weight: 700;
}

.cal-nav {
  width: 2.4rem;
  height: 2.4rem;
  border: 2.5px solid var(--m-dark);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.cal-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.cal-nav:focus-visible,
.cal-day:focus-visible,
.time-slot:focus-visible {
  outline: 3px solid var(--m-mid);
  outline-offset: 2px;
}

.cal-weekdays,
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.2rem;
}

.cal-weekday {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cal-day {
  aspect-ratio: 1;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.cal-day.is-weekend:not(:disabled) {
  background: var(--weekend);
}

.cal-day.is-today {
  box-shadow: inset 0 0 0 2px var(--m-mid);
}

.cal-day.is-selected,
.cal-day.is-weekend.is-selected {
  background: var(--m-light);
  box-shadow: 2px 2px 0 var(--m-dark);
}

.cal-day:disabled {
  color: var(--day-muted);
  background: transparent;
  cursor: default;
}

.time-block {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.time-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.time-slot {
  min-height: 2.75rem;
  border: 2px solid var(--m-dark);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.time-slot.is-selected {
  background: var(--m-light);
  box-shadow: 2px 2px 0 var(--m-dark);
}

.reply-preview {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--ink) 8%, var(--surface));
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.reply .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-copy {
  min-height: 3.1rem;
  padding: 0.8rem 1.1rem;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  box-shadow: 3px 3px 0 var(--m-dark);
}

.btn-copy:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--m-dark);
}

.btn-copy:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--m-dark);
}

.reply-note {
  min-height: 1.2em;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
}

/* Confetti is painted over the page and must never steal a tap. */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 8;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/*
 * These sit after the base rules on purpose. An earlier dark block was
 * losing to body, the corner blob, and the headline marker.
 */
@media (prefers-color-scheme: dark) {
  body {
    background-image:
      radial-gradient(circle at 0% 0%, rgba(226, 39, 24, 0.16), transparent 42%),
      radial-gradient(circle at 100% 0%, rgba(0, 173, 239, 0.18), transparent 36%),
      radial-gradient(circle at 100% 100%, rgba(28, 105, 212, 0.22), transparent 40%),
      radial-gradient(circle at 0% 100%, rgba(0, 173, 239, 0.12), transparent 38%);
  }

  body::before {
    background: rgba(0, 173, 239, 0.16);
  }

  .headline {
    background-size: 100% 0.18em;
    background-position: 0 90%;
  }
}
