/* ==========================================================
   Chyna & Nathaniel: wedding website
   ========================================================== */

/* ---------- Tokens ---------- */
:root {
  --cream: #f6f3ee;
  --deep-red: #4f0b0b;
  --focus: #4f0b0b;
  --stage-ratio: 292.5 / 468;
  --cream-soft: rgba(246, 243, 238, 0.82);
  --cream-line: rgba(246, 243, 238, 0.7);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Headings: Ogg Display (Chyna's MyFonts web licence, the font in her Canva design).
     Everything else: Balgin (Chyna's Fontspring web licence), easier to read */
  --font-display: "Ogg Display", Georgia, "Times New Roman", serif;
  --font-body: "Balgin", "Helvetica Neue", Arial, sans-serif;

  --text-sm: 0.875rem;
  --text-body: 1.0625rem;
  --text-h2: clamp(2rem, 1.4rem + 2.4vw, 2.75rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
}

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Ogg Display";
  src: url("assets/fonts/ogg-display-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Balgin";
  src: url("assets/fonts/balgin-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Balgin";
  src: url("assets/fonts/balgin-light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

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

html,
body {
  margin: 0;
  background: var(--cream);
  color: var(--deep-red);
}

body {
  min-height: 100svh;
  -webkit-tap-highlight-color: transparent;
}

/* Utility: anything marked hidden stays hidden, whatever its layout */
[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--deep-red);
  color: var(--cream);
  font: 600 1rem/1.2 Georgia, serif;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Opening: the sealed envelope ---------- */
.opening {
  display: none;
}

.has-js .opening {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-7);
  padding: var(--space-5) var(--space-4);
}

.opening-backdrop {
  position: absolute;
  inset: 0;
  background: var(--cream);
  transition: opacity 1300ms ease-in-out 1900ms;
}

.is-sealed {
  overflow: hidden;
}

.envelope {
  position: relative;
  /* Small enough that the open flap still fits above it */
  width: min(84vw, 30rem, 42svh);
  aspect-ratio: 776 / 608;
  margin-top: calc(min(84vw, 30rem, 42svh) * 0.2);
  perspective: 2200px;
  transform-origin: 0 0;
  filter: drop-shadow(0 22px 30px rgba(58, 7, 8, 0.2)) drop-shadow(0 3px 6px rgba(58, 7, 8, 0.18));
  transition:
    transform 1300ms cubic-bezier(0.65, 0, 0.35, 1) 1900ms,
    filter 1300ms ease 1900ms,
    opacity 450ms ease 2750ms;
}

.envelope img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.envelope-body {
  position: relative;
  width: 100%;
  height: auto;
}

/* The shadow the closed flap casts on the pocket */
.envelope-shadow {
  position: absolute;
  left: -5.155%;
  top: -6.579%;
  width: 110.31%;
  height: auto;
  transition: opacity 700ms ease 350ms;
}

.envelope-flap {
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 100%;
  aspect-ratio: 776 / 454;
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  transform: rotateX(-180deg);
  transition: transform 1450ms cubic-bezier(0.45, 0, 0.2, 1) 350ms;
}

.flap-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flap-outside {
  transform: rotateX(180deg);
}

.seal {
  position: absolute;
  left: 50%;
  top: 70.7%;
  width: 27%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 5px rgba(30, 3, 4, 0.45)) drop-shadow(0 1px 1px rgba(30, 3, 4, 0.35));
  transition: transform 700ms var(--ease-out), opacity 550ms ease;
  animation: seal-invite 3.2s ease-in-out 1.5s infinite;
}

.seal img {
  width: 100%;
  height: 100%;
}

.seal:focus-visible {
  outline: 2px solid var(--deep-red);
  outline-offset: 6px;
}

@keyframes seal-invite {
  0%,
  100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.03); }
}

.opening-cue {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: opacity 400ms ease;
}

/* 1. The seal lifts away, 2. the flap opens, 3. the envelope settles into the flat lay */
.opening.is-opening .seal {
  animation: none;
  opacity: 0;
  transform: translate(-50%, -58%) scale(1.06);
}

.opening.is-opening .opening-cue,
.opening.is-opening .envelope-shadow {
  opacity: 0;
}

.opening.is-opening .envelope-flap {
  transform: rotateX(0deg);
}

.opening.is-opening .opening-backdrop {
  opacity: 0;
}

.opening.is-opening .envelope {
  transform: var(--settle, none);
  filter: drop-shadow(0 0 0 rgba(58, 7, 8, 0)) drop-shadow(0 0 0 rgba(58, 7, 8, 0));
  opacity: 0;
}

/* The flat lay appears as the backdrop dissolves */
.has-js .stage {
  transition: opacity 1300ms ease-in-out 1900ms;
}

.has-js.is-sealed .stage {
  opacity: 0;
}

/* ---------- Opening: the flat lay ---------- */
.stage {
  position: relative;
  width: min(100vw, calc(100svh * 292.5 / 468));
  margin: 0 auto;
  aspect-ratio: var(--stage-ratio);
}

.flat-lay {
  display: block;
  width: 100%;
  height: 100%;
}

/* The record is the play button */
.record-button {
  position: absolute;
  left: 3.37%;
  top: 45.5%;
  width: 35.07%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.record-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 6px;
}

/* "Play me" breathes until the song starts */
.play-label {
  fill: var(--deep-red);
  transition: opacity 500ms var(--ease-out);
  animation: breathe 2.6s ease-in-out infinite;
}

/* "Play me" stays, steady, while the song plays */
.is-playing .play-label {
  animation: none;
}

/* Chyna's heading lines in the flat lay, made a little bolder */
.flat-heading {
  stroke: var(--deep-red);
  stroke-width: 0.4;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* "Save the date · 28.04.28" on the card, a little bolder */
.card-heading {
  stroke: var(--deep-red);
  stroke-width: 0.3;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* Bolder letters: a fine outline in the same colour */
.play-label {
  stroke: var(--deep-red);
  stroke-width: 0.75;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* Faint play and pause in the middle of the record */
.record-icon {
  fill: var(--deep-red);
  opacity: 0.6;
  pointer-events: none;
}

.icon-pause,
.is-playing .icon-play {
  display: none;
}

.is-playing .icon-pause {
  display: inline;
}

@keyframes breathe {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- The details form ---------- */
.details {
  background: var(--deep-red);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  padding: var(--space-9) var(--space-5);
}

.details-inner {
  max-width: 34rem;
  margin: 0 auto;
}

.cypher {
  display: block;
  width: 5.5rem;
  aspect-ratio: 360 / 234;
  margin: 0 auto var(--space-7);
  background: var(--cream);
  -webkit-mask: url("assets/images/cypher-nc.webp") center / contain no-repeat;
  mask: url("assets/images/cypher-nc.webp") center / contain no-repeat;
}

.eyebrow {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

.details h2 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 400;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}

.intro {
  margin: 0 auto var(--space-7);
  max-width: 28rem;
  color: var(--cream-soft);
  text-align: center;
}

.details-form {
  display: grid;
  gap: var(--space-5);
}

.address {
  display: grid;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  border: 0;
}

.address legend {
  margin-bottom: var(--space-4);
  padding: 0;
  font-size: var(--text-sm);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: var(--space-1);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 10rem;
  gap: var(--space-5);
}

/* Field names read as small headings, in Ogg */
.field label {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  line-height: 1.3;
}

.address legend {
  font-family: var(--font-display);
}

.optional,
.hint {
  color: var(--cream-soft);
}

/* Guidance under each field, in a lighter Balgin */
.hint {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 300;
}

.field input,
.field textarea {
  width: 100%;
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 1px solid var(--cream-line);
  border-radius: 0;
  background: transparent;
  color: var(--cream);
  font: inherit;
  font-size: var(--text-body);
  font-weight: 300;
  transition: border-color 200ms var(--ease-out);
}

.field textarea {
  resize: vertical;
  min-height: 3.5rem;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 4px;
  border-bottom-color: var(--cream);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-bottom: 2px solid var(--cream);
}

.field-error,
.form-message {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

.field-error::before,
.form-message::before {
  content: "! ";
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: var(--space-3) var(--space-6);
  border: 0;
  background: var(--cream);
  color: var(--deep-red);
  font: inherit;
  font-size: var(--text-sm);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 200ms var(--ease-out);
}

.button:hover {
  opacity: 0.9;
}

.button:focus-visible,
.text-link:focus-visible,
.privacy a:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 4px;
}

.button[aria-busy="true"] {
  opacity: 0.7;
  cursor: progress;
}

.details-form .button {
  margin-top: var(--space-4);
}

.privacy {
  margin: 0;
  color: var(--cream-soft);
  font-size: var(--text-sm);
  text-align: center;
}

.privacy a,
.text-link {
  color: var(--cream);
  text-underline-offset: 0.2em;
}

.thanks {
  text-align: center;
}

.thanks-title:focus {
  outline: none;
}

.thanks .thanks-text {
  margin-bottom: var(--space-4);
}

.sign-off {
  margin: var(--space-6) 0 var(--space-7);
  font-weight: 300;
}

.sign-off-names {
  display: block;
  margin-top: var(--space-1);
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.3;
}

.calendar {
  display: grid;
  justify-items: center;
  gap: var(--space-5);
}

.calendar .text-link {
  display: inline-block;
  padding: var(--space-3) 0;
}

/* Lighter Balgin for the eyebrow, intro and privacy line */
.details .eyebrow,
.details .intro,
.privacy {
  font-weight: 300;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: var(--space-6) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}

.site-footer p {
  margin: 0;
}

/* Credit: quieter than the names above it */
.site-footer .credit {
  margin-top: var(--space-2);
  font-weight: 300;
  letter-spacing: 0.04em;
  text-transform: none;
  opacity: 0.75;
}

.site-footer a {
  display: inline-block;
  padding: var(--space-2) 0;
  color: inherit;
  text-underline-offset: 0.25em;
}

.site-footer a:focus-visible {
  outline: 2px solid var(--deep-red);
  outline-offset: 2px;
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  .stage {
    width: 100%;
  }

  .details {
    padding: var(--space-8) var(--space-4);
  }

  .details-form .button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .play-label,
  .seal {
    animation: none;
  }

  .envelope,
  .envelope-flap,
  .envelope-shadow,
  .seal,
  .opening-backdrop,
  .has-js .stage {
    transition: opacity 500ms ease;
  }

  .opening.is-opening .seal,
  .opening.is-opening .envelope-flap,
  .opening.is-opening .envelope {
    transform: none;
  }
}
