/* ───────────────────────────────────────────────────────────
   Creatures of Comfort — RSVP
   ─────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Tilda Grande";
  src: url("assets/fonts/tilda-grande.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ITC Cushing Std";
  src: url("assets/fonts/cushing-book.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ITC Cushing Std";
  src: url("assets/fonts/cushing-book-italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "ITC Cushing Std";
  src: url("assets/fonts/cushing-medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ITC Cushing Std";
  src: url("assets/fonts/cushing-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* palette — pulled from Figma */
  --blue:           #3455c0;
  --blue-deep:      #2a448a;
  --paper:          #ece2cc;   /* kraft paper fallback */
  --paper-edge:     #d8c8a8;
  --cream:          #f9efd7;   /* submit button */
  --ink:            #1d1b20;
  --ink-soft:       #4a4459;   /* secondary container text */
  --outline:        #79747e;
  --seg-yes:        #bbe3fc;
  --seg-no:         #e8def8;
  --check-fill:     #2c2c2c;

  /* type */
  --script: "Tilda Grande", "Allura", "Brush Script MT", cursive;
  --serif:  "ITC Cushing Std", "Fraunces", "Times New Roman", Georgia, serif;

  /* layout */
  --app-max: 440px;
  --pad-x: clamp(18px, 5vw, 24px);

  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  color: #fff;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    url("assets/form-bg.png") center top / cover no-repeat fixed,
    var(--blue);
}

img { display: block; max-width: 100%; }

a { color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ────────── App ────────── */

.app {
  width: 100%;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

/* No-JS: all states render in flow. With JS, only the active state shows. */
.state { display: block; }

.has-js .state                       { display: none; }
.has-js .state.is-active             { display: block; animation: fade-in .6s var(--ease); }
.has-js .state--form.is-active,
.has-js .state--done.is-active       { display: flex; }
.has-js .state--landing.is-active    { display: flex; justify-content: center; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ────────── State 1 · Landing ────────── */

.state--landing {
  position: relative;
  padding: 24px var(--pad-x) 32px;
  min-height: 100vh;
  min-height: 100dvh;
}

.landing {
  position: relative;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.landing__poster {
  width: 100%;
  max-width: 394px;
  height: auto;
  display: block;
}

.cta {
  position: relative;
  display: block;
  width: 100%;
  max-width: 355px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .35s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.cta:hover  { transform: scale(1.03); }
.cta:active { transform: scale(.98); }

.cta__img {
  width: 100%;
  height: auto;
  transition: opacity .4s var(--ease);
}

.cta__img--hover {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.cta:hover .cta__img--default,
.cta:focus-visible .cta__img--default { opacity: 0; }
.cta:hover .cta__img--hover,
.cta:focus-visible .cta__img--hover   { opacity: 1; }

.cta:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 6px;
  border-radius: 16px;
}

/* ────────── States 2 & 3 · shared blue painted bg ────────── */

.state--form,
.state--done {
  position: relative;
  padding: 60px var(--pad-x) 56px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.form-wrap {
  width: 100%;
  max-width: var(--app-max);
}

/* ────────── State 2 · Form ────────── */

.form-rabbits {
  display: block;
  width: 84%;
  max-width: 330px;
  height: auto;
  margin: 0 auto -28px;
  opacity: .5;
  pointer-events: none;
}

.form-title {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(72px, 19vw, 96px);
  line-height: 1.05;
  color: #fff;
  text-align: center;
  letter-spacing: .005em;
  margin-bottom: 28px;
  text-shadow: 0 2px 0 rgba(0,0,0,.06);
}

.rsvp-form {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* paper "note" card */
.note {
  position: relative;
  background:
    linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)),
    url("assets/paper-texture.png") center/cover no-repeat,
    var(--paper);
  padding: 40px 24px;
  border-radius: 2px;
  box-shadow:
    0 4px 16px rgba(0,0,0,.18),
    inset 0 0 60px rgba(168,138,98,.12);
  display: flex;
  flex-direction: column;
  gap: 36px;
  color: var(--ink);
}

/* slight paper-edge feel */
.note::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
  border-radius: inherit;
}

.field { display: flex; flex-direction: column; gap: 8px; }

fieldset.field { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset.field > legend { display: block; padding: 0; }

.field__label,
.field > legend {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  line-height: 1.15;
  color: #000;
  padding: 0;
}

.field__sublabel {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 2px;
}

/* underlined text input */
.line-input {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.line-input__field {
  width: 100%;
  font: inherit;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  color: #000;
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 0 8px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

.line-input__field--small {
  font-weight: 400;
  font-size: 18px;
}

.line-input__field:focus { background: transparent; }
.line-input__field:focus-visible { background: transparent; }

/* number-spinner buttons – hide for the gentler aesthetic */
.line-input__field[type="number"]::-webkit-outer-spin-button,
.line-input__field[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.line-input__field[type="number"] { -moz-appearance: textfield; }

.line-input__rule {
  display: block;
  width: 100%;
  height: 2px;
  background: #000;
  border-radius: 1px;
}

.line-input:focus-within .line-input__rule { background: #000; }

/* ────────── Segmented (Material 3) ────────── */

.field--segmented { gap: 28px; }
.field--segmented > legend { margin-bottom: 28px; }

.segmented {
  display: flex;
  width: 100%;
  padding: 4px 0;
}

.segmented__seg {
  position: relative;
  flex: 1 0 0;
  display: flex;
  cursor: pointer;
}

.segmented__seg input {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.segmented__inner {
  flex: 1 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: .005em;
  transition: background .25s var(--ease), color .25s var(--ease);
  overflow: hidden;
}

.segmented__seg--start .segmented__inner { border-radius: 100px 0 0 100px; margin-right: -1px; }
.segmented__seg--end   .segmented__inner { border-radius: 0 100px 100px 0; }

.segmented__check {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: none;
  color: var(--ink-soft);
}

.segmented__seg input:checked + .segmented__inner .segmented__check { display: inline; }

.segmented__seg--start input:checked + .segmented__inner {
  background: var(--seg-yes);
  color: var(--ink-soft);
  z-index: 1;
  border-color: var(--outline);
}

.segmented__seg--end input:checked + .segmented__inner {
  background: var(--seg-no);
  color: var(--ink-soft);
  z-index: 1;
  border-color: var(--outline);
}

.segmented__seg:hover .segmented__inner { background: rgba(0,0,0,.04); }
.segmented__seg input:checked:hover + .segmented__inner { background: var(--seg-yes); }
.segmented__seg--end input:checked:hover + .segmented__inner { background: var(--seg-no); }

.segmented__seg input:focus-visible + .segmented__inner {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ────────── Conditional reveal ────────── */

.reveal {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.reveal[hidden] { display: none; }

/* ────────── Dietary checkboxes ────────── */

.field--diet { gap: 28px; }
.field--diet > legend { margin-bottom: 28px; }

.checks {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 28px;
}

.check input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  cursor: pointer;
  z-index: 1;
}

.check__box {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #757575;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}

.check__box svg {
  width: 16px; height: 16px;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .15s var(--ease), transform .2s var(--ease);
}

.check input:checked + .check__box {
  background: var(--check-fill);
  border-color: var(--check-fill);
}

.check input:checked + .check__box svg {
  opacity: 1;
  transform: scale(1);
}

.check input:focus-visible + .check__box {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.check__label {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.4;
  color: #1e1e1e;
}

/* ────────── Submit ────────── */

.submit {
  position: relative;
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .005em;
  color: var(--ink-soft);
  background: var(--cream);
  border: none;
  border-radius: 16px;
  padding: 24px 48px;
  cursor: pointer;
  opacity: .4;
  pointer-events: none;
  transition: opacity .35s var(--ease), transform .2s var(--ease);
}

.submit.is-enabled {
  opacity: 1;
  pointer-events: auto;
}

.submit:hover  { transform: translateY(-1px); }
.submit:active { transform: translateY(0); }

.submit:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.submit__loading { display: none; }

.submit.is-loading .submit__label   { visibility: hidden; }
.submit.is-loading .submit__loading {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
}

.form-error {
  margin-top: -10px;
  background: rgba(255,255,255,.85);
  color: #b3261e;
  border: 1px solid rgba(179,38,30,.4);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 15px;
  text-align: center;
}

/* Honeypot — invisible to humans, present in DOM for bots.
   Avoid display:none / visibility:hidden, which some bots detect. */
.hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.hp-field input { opacity: 0; pointer-events: none; }

/* Turnstile widget — sits inside the form, centered. */
.cf-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px;
  margin-top: -4px;
}

/* ────────── State 3 · Done (both variants) ────────── */

.state--done {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.done {
  position: relative;
  flex: 1 0 0;
  width: 100%;
  max-width: var(--app-max);
  padding: 162px var(--pad-x) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.done__title {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(48px, 13vw, 64px);
  line-height: 1.1;
  color: #fff;
  text-align: center;
  letter-spacing: .005em;
  margin-bottom: 24px;
  text-shadow: 0 2px 0 rgba(0,0,0,.06);
}

.done__body {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.45;
  color: #fff;
  text-align: center;
  max-width: 30ch;
  opacity: .96;
}

.done__art {
  margin-top: auto;
  width: 100%;
  max-width: 460px;
  align-self: center;
  margin-left: auto;
  margin-right: auto;
  padding-top: 40px;
}

/* Animated rabbit "gif" — 3 frames crossfade 500ms ease-out, hold 800ms */
.done__art--anim {
  position: relative;
  aspect-ratio: 943 / 928;
}

.done__art--anim .done__frame {
  position: absolute;
  inset: 40px 0 0 0;
  width: 100%;
  height: auto;
  opacity: 0;
  animation: rabbit-cycle 3.9s infinite;
  animation-timing-function: ease-out;
}

.done__art--anim .done__frame--1 { animation-delay: 0s; }
.done__art--anim .done__frame--2 { animation-delay: 1.3s; }
.done__art--anim .done__frame--3 { animation-delay: 2.6s; }

/* Per-frame: fade in 500ms (0 → 12.82%), hold 800ms (→ 33.33%),
   fade out 500ms (→ 46.15%), invisible the rest. */
@keyframes rabbit-cycle {
  0%     { opacity: 0; }
  12.82% { opacity: 1; }
  33.33% { opacity: 1; }
  46.15% { opacity: 0; }
  100%   { opacity: 0; }
}

/* ────────── Reduced motion ────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .cta:hover, .cta:active { transform: none; }
  .done__art--anim .done__frame { animation: none; }
  .done__art--anim .done__frame--1 { opacity: 1; }
}

/* ────────── Mobile + tablet · content fills viewport ────────── */

@media (max-width: 1023px) {
  :root {
    --app-max: none;
  }
}

/* ────────── Desktop ────────── */

@media (min-width: 1024px) {
  .state--form { padding-top: 80px; padding-bottom: 80px; }
  .state--done { padding-top: 0; padding-bottom: 0; }
  .done { padding-top: 120px; }
}
