/* ==========================================================================
   Akvilė & Antoine — wedding invitation
   ========================================================================== */

:root {
  --ink: #1e2336;
  --ink-soft: #545a70;
  --blue: #4a5d8f;
  --blue-deep: #34446f;
  --blue-soft: #a9b5d6;
  --paper: #fbfaf6;
  --line: #d9dde9;
  --stage-bg: #eef1f7;
  --stage-backdrop: radial-gradient(120% 80% at 50% 45%, #fdfcf9 0%, var(--stage-bg) 55%, #dfe5f0 100%);

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --text: "Cormorant Garamond", Garamond, Georgia, serif;
  --script: "Pinyon Script", "Snell Roundhand", cursive;

  /* envelope + card sizing (JS reads the resulting pixel sizes) */
  --env-w: min(86vw, 34rem, 60vh);
  --card-w: min(90vw, 40rem, calc(86vh / 1.4143));
  --track: 425vh; /* total scroll length of the envelope sequence */
}
@supports (height: 1svh) {
  :root {
    --env-w: min(86vw, 34rem, 60svh);
    --card-w: min(90vw, 40rem, calc(86svh / 1.4143));
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: clamp(1.125rem, 1rem + .4vw, 1.3rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--blue); }

/* ==========================================================================
   1. Intro — sticky stage with the envelope
   ========================================================================== */

.intro {
  position: relative;
  height: var(--track);
  background: var(--stage-backdrop);
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  overflow: clip;
}

.scene {
  position: relative;
  width: var(--env-w);
  aspect-ratio: 1.4;
  container-type: inline-size;
}

.env-layer,
.card-clip {
  position: absolute;
  inset: 0;
  will-change: transform, opacity;
}
.env-layer svg { width: 100%; height: 100%; }

.env-back {
  z-index: 1;
  border-radius: 3px;
  overflow: hidden;
  box-shadow:
    0 1.8cqw 4cqw -1cqw rgba(35, 45, 80, .28),
    0 .3cqw .8cqw rgba(35, 45, 80, .12);
}

/* flap: z-index flips below the card once it passes 90° (set by JS) */
.env-flap {
  z-index: 6;
  transform-origin: 50% 0;
}
.env-flap svg { filter: drop-shadow(0 .5cqw .6cqw rgba(70, 55, 30, .2)); }
.env-flap .flap-inner { display: none; }
.env-flap.is-open { z-index: 2; }
.env-flap.is-open svg { filter: none; }
.env-flap.is-open .flap-outer { display: none; }
.env-flap.is-open .flap-inner { display: inline; }

/* card is clipped just above the envelope's bottom edge while it sits inside
   (so it can't show through the edge's anti-aliasing) */
.card-clip {
  z-index: 3;
  clip-path: inset(-400vh -400vw 3% -400vw);
}
.card-clip.is-free { z-index: 7; clip-path: none; }

.env-pocket { z-index: 4; }

/* guest's names, written on the flap (top half) — they turn away with it */
.env-guest {
  position: absolute;
  left: 20%; right: 20%;   /* stays inside the flap's triangle; long names wrap */
  top: 24%;
  translate: 0 -50%;
  margin: 0;
  text-align: center;
  text-wrap: balance;
  font-family: var(--script);
  font-size: 7.4cqw;
  line-height: 1.1;
  color: var(--blue-deep);
  opacity: 0;
  transition: opacity .8s ease;
}
.env-guest.is-visible { opacity: .92; }
.env-flap.is-open .env-guest { visibility: hidden; }

.open-btn {
  position: absolute;
  inset: 0;
  z-index: 9;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.open-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 6px; border-radius: 4px; }
.open-btn[hidden] { display: none; }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: max(4svh, 1.5rem);
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  color: var(--blue);
  font-family: var(--text);
  font-size: .8rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
.scroll-hint svg { animation: nudge 2s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { transform: translateY(0); opacity: .5; }
  50%      { transform: translateY(6px); opacity: 1; }
}

/* ---------- the invitation card (recreated from the printed faire-part) ---------- */

.card {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--card-w);
  aspect-ratio: 1190 / 1683;
  margin-left: calc(var(--card-w) / -2);
  transform-origin: 50% 0;
  will-change: transform;
  background: #fff url("../assets/card-bg.jpg") center / 100% 100% no-repeat;
  box-shadow:
    0 3cqw 6cqw -2cqw rgba(30, 40, 75, .35),
    0 .3cqw .8cqw rgba(30, 40, 75, .15);
  container-type: inline-size;
}

.card-panel {
  position: absolute;
  left: 16.7%;
  right: 16.8%;
  top: 16.3%;
  bottom: 16.4%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-family: var(--serif);
  color: #111;
}

.card-names {
  margin: 14.2cqw 0 0;
  display: flex;
  flex-direction: column;
  font-weight: 400;
  font-size: 9.6cqw;
  line-height: 1.17;
  letter-spacing: .06em;
}
.card-names .amp {
  font-style: italic;
  letter-spacing: 0;
}

.card-date {
  margin: 12.9cqw 0 0;
  display: flex;
  align-items: center;
  font-size: 5cqw;
  line-height: 1;
  font-variant-numeric: oldstyle-nums;
}
.card-date i {
  display: inline-block;
  width: .2cqw;
  min-width: 1px;
  height: 1.06em;
  margin: 0 .35em;
  background: currentColor;
}

.card-place {
  margin: 2.6cqw 0 0;
  font-size: 5cqw;
  line-height: 1;
}

/* ==========================================================================
   2. Details
   ========================================================================== */

.details { background: var(--paper); }

.block {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(3.5rem, 9vw, 6rem) 1.25rem;
  text-align: center;
}

h2 {
  margin: 0 0 2.2rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 1.4rem + 3vw, 2.9rem);
  line-height: 1.15;
  letter-spacing: .03em;
}
h2::after {
  content: "";
  display: block;
  width: 3.5rem;
  height: 1px;
  margin: 1.1rem auto 0;
  background: var(--blue-soft);
}

h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.3;
}

.band {
  height: clamp(3.5rem, 8vw, 5rem);
  background: url("../assets/band.jpg") center / cover;
  opacity: .85;
}

/* welcome */
.greeting {
  margin: 0 0 1rem;
  font-family: var(--script);
  font-size: clamp(2.4rem, 1.8rem + 3vw, 3.4rem);
  line-height: 1.2;
  color: var(--blue-deep);
}
.lead {
  max-width: 32rem;
  margin: 0 auto;
  font-size: 1.2em;
}
.lead strong { font-weight: 600; }

.countdown {
  display: flex;
  justify-content: center;
  gap: clamp(1rem, 5vw, 2.5rem);
  margin-top: 2.5rem;
}
.countdown div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
}
.countdown span {
  font-family: var(--serif);
  font-size: clamp(2rem, 1.5rem + 2.5vw, 2.8rem);
  line-height: 1.1;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--blue-deep);
}
.countdown small {
  font-size: .75rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* programme */
.timeline {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 26rem;
}
.timeline li {
  position: relative;
  padding: 0 0 2.4rem;
}
.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: .7rem;
  width: 1px;
  height: 1.1rem;
  background: var(--blue-soft);
}
.timeline time {
  display: block;
  font-size: .8rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--blue);
}
.timeline p { margin: .2rem 0 0; color: var(--ink-soft); }

/* venue */
.venue-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
}
.venue-address {
  margin: .3rem 0 1.8rem;
  font-style: normal;
  color: var(--ink-soft);
}
.map {
  aspect-ratio: 16 / 10;
  margin-bottom: 1.6rem;
  border: 1px solid var(--line);
  padding: .4rem;
  background: #fff;
}
.map iframe {
  width: 100%;
  height: 100%;
  border: 0;
  filter: saturate(.75);
}

/* good to know */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
  text-align: center;
}
.info-grid article {
  padding: 1.6rem 1.4rem;
  background: #fff;
  border: 1px solid var(--line);
}
.info-grid p { margin: .5rem 0 0; color: var(--ink-soft); }

/* buttons */
.btn {
  display: inline-block;
  padding: .9rem 2.2rem;
  border: 1px solid var(--blue);
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-family: var(--text);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, color .2s, opacity .2s;
}
.btn:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-ghost:hover { background: var(--blue); color: #fff; }

/* ==========================================================================
   3. RSVP
   ========================================================================== */

.rsvp-deadline { margin: -1rem 0 2rem; color: var(--ink-soft); }

.rsvp-form {
  max-width: 30rem;
  margin: 0 auto;
  text-align: left;
}
[hidden] { display: none !important; }

.rsvp-for {
  margin: 0 0 1.5rem;
  text-align: center;
  font-size: 1.15em;
}
.rsvp-for strong { font-family: var(--serif); font-weight: 400; }

.rsvp-previous {
  margin: -.8rem 0 1.5rem;
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
}

.choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
  margin: 0 0 1.6rem;
  padding: 0;
  border: 0;
}
.choice legend {
  grid-column: 1 / -1;
  margin-bottom: .7rem;
  padding: 0;
  width: 100%;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.25rem;
}
.choice label { position: relative; }
.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.choice span {
  display: block;
  padding: .85rem .6rem;
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
  line-height: 1.25;
  transition: border-color .2s, background .2s, color .2s;
}
.choice input:checked + span { border-color: var(--blue); background: var(--blue); color: #fff; }
.choice input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.field {
  display: block;
  margin-bottom: 1.3rem;
}
.field > span {
  display: block;
  margin-bottom: .3rem;
  font-size: .8rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field em { text-transform: none; letter-spacing: 0; font-size: .95rem; }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: max(16px, 1rem); /* avoids iOS zoom on focus */
}
.field textarea { resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: var(--blue); }

.rsvp-form .btn { display: block; width: 100%; margin-top: .6rem; }

.form-msg {
  min-height: 1.6em;
  margin: 1rem 0 0;
  text-align: center;
}
.form-msg.is-ok { color: var(--blue-deep); }
.form-msg.is-error { color: #a33b3b; }

/* floating RSVP shortcut */
.rsvp-fab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 20;
  padding: .7rem 1.4rem;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .2em;
  text-decoration: none;
  box-shadow: 0 6px 20px -6px rgba(30, 40, 75, .5);
  opacity: 0;
  translate: 0 1rem;
  pointer-events: none;
  transition: opacity .35s, translate .35s;
}
.rsvp-fab.is-visible { opacity: 1; translate: 0 0; pointer-events: auto; }

/* footer */
.footer {
  padding: 3rem 1.25rem 4rem;
  text-align: center;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}
.footer p { margin: 0; }
.footer-names {
  font-family: var(--serif);
  font-size: 1.6rem;
  color: var(--ink);
}
.footer-names span { font-style: italic; }

/* ==========================================================================
   Without a valid guest code: only the names and "pagal kvietimą"
   (the class on <html> is set in index.html and js/app.js)
   ========================================================================== */

.gate { display: none; }
.is-gate .intro,
.is-gate .details,
.is-gate .rsvp-fab { display: none; }

.is-gate .gate {
  display: grid;
  place-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 2rem 1.25rem;
  text-align: center;
  background: var(--stage-backdrop);
}
.gate > * { animation: fade-in 1.2s ease both; }
.gate > * + * { animation-delay: .4s; }
@keyframes fade-in { from { opacity: 0; } }

.gate-names {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 8.4vw, 4.6rem);
  line-height: 1.15;
  letter-spacing: .04em;
}
.gate-names .amp { font-style: italic; }
.gate-note {
  margin: 1.1rem 0 0;
  font-style: italic;
  font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem);
  letter-spacing: .04em;
  color: var(--ink-soft);
}

/* password box: a star per digit typed, gentle shake when wrong */
.gate-form { margin: 2.6rem 0 0; }
.gate-box {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: min(20rem, 100%);
  height: 4.4rem;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .7);
  box-shadow: 0 14px 34px -22px rgba(30, 40, 75, .45);
  color: var(--blue-deep);
  transition: border-color .25s, box-shadow .25s, background-color .25s;
}
.gate-box:focus-within {
  border-color: var(--blue-soft);
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(74, 93, 143, .1), 0 14px 34px -22px rgba(30, 40, 75, .45);
}
/* the real field lies invisibly over the box; the stars show what's typed */
.gate-box input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  opacity: 0;
  font-size: 16px; /* stops iPhones zooming in */
  cursor: text;
}
.gate-slots {
  display: flex;
  gap: clamp(.75rem, 3.5vw, 1.05rem);
  pointer-events: none;
}
.gate-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
}
.gate-slot::before { /* empty: a faint dot */
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-soft);
}
.gate-star { /* the title font's asterisk, centred on the slot */
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -.394em; /* -.5em centres the line; the glyph sits .106em high, measured */
  text-align: center;
  font-family: var(--serif);
  font-size: 2.2rem;
  line-height: 1;
}
.gate-slot.is-filled::before { display: none; }
.gate-slot.is-filled .gate-star { display: block; animation: pop .2s ease-out; }
.gate-box:focus-within .gate-slot.is-next::before {
  background: var(--blue);
  animation: breathe 1.1s ease-in-out infinite;
}
.gate-box.is-wrong { border-color: #d9a7a7; animation: shake .45s ease; }
.gate-box.is-wrong .gate-slot { color: #a33b3b; }
.gate-box.is-right { border-color: var(--blue); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes shake {
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* while the guest code is being checked (a fraction of a second):
   closed envelope only, nothing to scroll, soft dots in place of the hint */
.is-pending .intro { height: 100vh; height: 100svh; }
.is-pending .details,
.is-pending .rsvp-fab,
.is-pending .open-btn,
.is-pending .scroll-hint > * { display: none; }
.is-pending .scroll-hint::before {
  content: "• • •";
  animation: breathe 1.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .3; } }

/* ==========================================================================
   General information page (the password on the gate page): the details,
   without the envelope and the RSVP
   ========================================================================== */

.info-header { display: none; }
.is-info .intro,
.is-info .band-rsvp,
.is-info #rsvp,
.is-info .rsvp-fab { display: none; }

.is-info .info-header {
  display: grid;
  place-content: center;
  min-height: 62vh;
  min-height: 62svh;
  padding: 3rem 1.25rem 2rem;
  text-align: center;
  background: var(--stage-backdrop);
}
.is-info .details { animation: fade-in .9s ease both; }
.info-date {
  margin: 1.3rem 0 0;
  font-size: min(1.4rem, 4.4vw);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--blue);
}

/* ==========================================================================
   Reduced motion: show the opened invitation straight away
   ========================================================================== */

.reduced .intro { height: 100vh; height: 100svh; }
.reduced .scroll-hint, .reduced .open-btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-hint svg, .scroll-hint::before, .gate > *, .gate-star, .gate-box.is-wrong,
  .gate-box .gate-slot::before, .is-info .details { animation: none !important; }
}
