@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Sora:wght@300;400;500&display=swap");

:root {
  --ink: #141414;
  --ink-soft: #3a3a3a;
  --muted: #7a7670;
  --line: #e4e0d8;
  --paper: #f6f4f0;
  --paper-deep: #ebe7e0;
  --night: #121212;
  --night-soft: #1c1c1c;
  --cream: #f0ebe3;
  --gold: #9a8b72;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "Sora", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

html.is-locked,
body.is-locked {
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  margin: 0;
  color: var(--ink);
  background: #cfc9c0;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body.is-locked {
  position: fixed;
  inset: 0;
  width: 100%;
}

.invite {
  display: none;
}

body.is-unlocked .invite {
  display: block;
}

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

button,
input,
select {
  font: inherit;
}

.page {
  max-width: 780px;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 80px rgba(20, 20, 20, 0.18);
  overflow: hidden;
}

/* ——— Cover / Hero ——— */
.cover {
  position: relative;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, #fff8ef 0%, transparent 55%),
    linear-gradient(165deg, #f8f5ef 0%, #eae4da 100%);
  overflow: hidden;
  touch-action: manipulation;
}

body.is-locked .cover {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  height: 100%;
  min-height: 100%;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.5;
}

.cover-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 4vh, 36px);
}

.envelope {
  width: min(78vw, 360px);
  position: relative;
  cursor: pointer;
  perspective: 1400px;
  -webkit-perspective: 1400px;
  transition: transform 0.7s var(--ease);
  flex-shrink: 0;
}

.envelope:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 8px;
}

.envelope-body {
  aspect-ratio: 1.45 / 1;
  width: 100%;
  position: relative;
  background: linear-gradient(180deg, #efe9df 0%, #e5ddd1 100%);
  border: 1px solid #d2c8b8;
  box-shadow:
    0 20px 48px rgba(40, 32, 20, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  overflow: visible;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.envelope-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 52%;
  background: linear-gradient(180deg, #e8e0d4 0%, #ddd3c5 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 1.05s var(--ease);
  z-index: 3;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
}

.envelope-front {
  position: absolute;
  inset: 50% 0 0;
  background: linear-gradient(180deg, #ebe3d7 0%, #e2d9cb 100%);
  clip-path: polygon(0 0, 50% 42%, 100% 0, 100% 100%, 0 100%);
  z-index: 4;
}

.seal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: clamp(52px, 14vw, 68px);
  height: clamp(52px, 14vw, 68px);
  border-radius: 50%;
  background: var(--night);
  color: var(--cream);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(16px, 4.5vw, 20px);
  letter-spacing: 0.04em;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition:
    opacity 0.4s ease,
    transform 0.6s var(--ease);
}

.seal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid rgba(240, 235, 227, 0.25);
}

.cover-copy {
  position: relative;
  z-index: 7;
  text-align: center;
  width: 100%;
  padding: 0 8px;
}

body.is-unlocked .cover-copy {
  animation: riseIn 0.8s var(--ease) both;
}

.names {
  font-family: var(--font-display);
  font-size: clamp(40px, 11vw, 84px);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0;
}

.names em {
  font-style: italic;
  font-weight: 400;
}

.date-line {
  margin-top: 12px;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.open-btn {
  margin-top: 22px;
  appearance: none;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 13px 22px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.35s ease,
    color 0.35s ease,
    transform 0.35s var(--ease),
    opacity 0.4s ease;
  -webkit-tap-highlight-color: transparent;
}

.open-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.cover.opening .envelope-flap {
  transform: rotateX(178deg);
}

.cover.opening .seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  pointer-events: none;
  animation: none;
}

.cover.opening .envelope {
  transform: translateY(-10px) scale(0.98);
}

.cover.opening .open-btn {
  opacity: 0;
  pointer-events: none;
}

.cover.is-done {
  min-height: auto;
  height: auto;
  padding: 48px 20px 40px;
}

/* ——— Sections ——— */
section {
  padding: 88px 9%;
  position: relative;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}

.kicker .icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(38px, 7.5vw, 58px);
  line-height: 1.05;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 16px;
  color: var(--ink-soft);
}

.signature {
  font-family: var(--font-display);
  font-size: 28px;
  font-style: italic;
  margin-top: 36px;
  line-height: 1.2;
}

/* Reveal animation */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.9s var(--ease),
    transform 0.9s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.letter {
  min-height: 85vh;
  display: flex;
  align-items: center;
  background: var(--paper);
}

/* Photo — full bleed */
.photo {
  padding: 0;
  position: relative;
  overflow: hidden;
}

.photo img {
  width: 100%;
  min-height: 72vh;
  max-height: 920px;
  object-fit: cover;
  object-position: center 28%;
  filter: grayscale(1) contrast(1.05);
  transform: scale(1.04);
  transition: transform 1.4s var(--ease);
}

.photo.is-visible img {
  transform: scale(1);
}

.photo-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 48px 9% 36px;
  background: linear-gradient(transparent, rgba(10, 10, 10, 0.55));
  color: #f5f2ec;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
}

/* Details */
.details {
  text-align: center;
  background: var(--paper);
}

.info {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 16px;
  align-items: start;
  padding: 22px 4px;
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: 0;
}

.row .icon {
  width: 26px;
  height: 26px;
  margin-top: 6px;
  opacity: 0.85;
}

.label {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.value {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 30px);
  line-height: 1.25;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 32px;
  padding: 14px 24px;
  border: 1px solid currentColor;
  color: inherit;
  text-decoration: none;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition:
    background 0.35s ease,
    color 0.35s ease,
    transform 0.35s var(--ease);
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-2px);
}

.btn:hover .icon {
  filter: invert(1);
}

/* Countdown */
.countdown {
  background: var(--paper-deep);
  text-align: center;
}

.timer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 40px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.timer-cell {
  padding: 18px 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
}

.num {
  font-family: var(--font-display);
  font-size: clamp(36px, 8vw, 48px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.unit {
  margin-top: 10px;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Dress code */
.dress {
  text-align: center;
}

.palette {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 36px 0 8px;
}

.dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid #cfc7ba;
  transition: transform 0.45s var(--ease);
}

.dot:hover {
  transform: scale(1.08);
}

.d1 { background: #f5f1e9; }
.d2 { background: #ddd5ca; }
.d3 { background: #b8aea0; }
.d4 { background: #7d756b; }

/* RSVP */
.rsvp {
  background: var(--night);
  color: var(--cream);
  text-align: center;
}

.rsvp .kicker {
  color: #a8a29a;
}

.rsvp p {
  color: #c8c2b8;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.rsvp form {
  max-width: 440px;
  margin: 36px auto 0;
  text-align: left;
}

.field {
  margin: 0 0 18px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #a8a29a;
  margin-bottom: 8px;
}

.field label .icon {
  width: 14px;
  height: 14px;
  opacity: 0.85;
  filter: invert(1) brightness(0.9);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 14px 14px;
  background: transparent;
  border: 1px solid #4a4742;
  color: var(--cream);
  border-radius: 0;
  outline: none;
  transition: border-color 0.3s ease;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #6a6560;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #c8c2b8;
}

.field select option {
  color: #222;
  background: #fff;
}

.rsvp .btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  background: transparent;
  color: var(--cream);
  border-color: var(--cream);
  cursor: pointer;
}

.rsvp .btn:hover {
  background: var(--cream);
  color: var(--night);
}

.rsvp .btn:hover .icon {
  filter: none;
}

.rsvp .btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.status {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.6;
  min-height: 1.6em;
  text-align: center;
}

.status.is-ok {
  color: #c8d4b8;
}

.status.is-err {
  color: #e0b4a8;
}

/* Footer */
.footer {
  text-align: center;
  padding: 96px 9% 110px;
  background: var(--paper);
}

.footer .names {
  font-size: clamp(48px, 11vw, 68px);
  margin-top: 8px;
}

.small {
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

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

@keyframes floatSeal {
  0%,
  100% {
    transform: translate(-50%, -50%) translateY(0);
  }
  50% {
    transform: translate(-50%, -50%) translateY(-4px);
  }
}

body.is-locked .cover:not(.opening) .seal {
  animation: floatSeal 3.2s ease-in-out infinite;
}

@media (max-width: 540px) {
  section {
    padding: 68px 8%;
  }

  .cover {
    padding: max(12px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  }

  .cover-inner {
    gap: 16px;
  }

  .envelope {
    width: min(72vw, 300px);
  }

  .names {
    font-size: clamp(34px, 10.5vw, 52px);
  }

  .date-line {
    letter-spacing: 0.2em;
    font-size: 9px;
  }

  .open-btn {
    margin-top: 16px;
    padding: 12px 18px;
    width: 100%;
    max-width: 280px;
  }

  .photo img {
    min-height: 62vh;
  }

  .timer {
    gap: 6px;
  }

  .num {
    font-size: 32px;
  }

  .row {
    grid-template-columns: 36px 1fr;
    gap: 12px;
  }

  .cover.is-done {
    padding: 36px 16px 28px;
  }

  .cover.is-done .envelope {
    width: min(56vw, 220px);
  }
}

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

  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
