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

:root {
  --bg: #0a0a0a;
  --ink: #f5f1ea;
  --ink-soft: #c9c2b6;
  --accent: #e8dcc4;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --card-pad: max(24px, env(safe-area-inset-bottom));
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ========== Password Gate ========== */

#gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 28px;
  animation: gate-fade-in 0.8s ease both;
}

#gate.is-leaving {
  animation: gate-fade-out 0.6s ease both;
  pointer-events: none;
}

#gate.is-gone { display: none; }

.gate-mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(2.8rem, 14vw, 4.5rem);
  color: var(--ink);
  letter-spacing: 0.01em;
  opacity: 0.85;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 320px;
}

.gate-input {
  width: 100%;
  background: transparent;
  color: var(--ink);
  border: none;
  border-bottom: 1px solid rgba(245,241,234,0.25);
  font-family: var(--serif);
  font-size: 1.2rem;
  padding: 12px 4px;
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
  letter-spacing: 0.1em;
}

.gate-input:focus { border-bottom-color: var(--accent); }
.gate-input::placeholder { color: var(--ink-soft); opacity: 0.5; font-style: italic; letter-spacing: 0.05em; }

.gate-button {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(245,241,234,0.25);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 14px 20px;
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.gate-button:hover,
.gate-button:focus { border-color: var(--accent); color: var(--ink); outline: none; }
.gate-button:disabled { opacity: 0.4; cursor: not-allowed; }

.gate-hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-soft);
  opacity: 0.65;
  text-align: center;
  min-height: 1.2em;
}

.gate-hint.is-error { color: #d9b7a3; opacity: 1; animation: shake 0.4s; }

@keyframes gate-fade-in {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes gate-fade-out {
  from { opacity: 1; } to { opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ========== Content ========== */

main {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  visibility: hidden;
}

main.is-ready { visibility: visible; }

.card {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--card-pad);
  position: relative;
}

.card--opener { justify-content: center; }
.card--text { text-align: center; }

.card--photo {
  padding: 0;
  justify-content: flex-end;
  align-items: stretch;
}

.card--signoff {
  text-align: right;
  align-items: flex-end;
  justify-content: flex-end;
  padding-bottom: max(140px, calc(env(safe-area-inset-bottom) + 120px));
  overflow: hidden;
}

.sun {
  position: absolute;
  bottom: max(148px, calc(env(safe-area-inset-bottom) + 128px));
  left: 10%;
  width: clamp(72px, 18vw, 110px);
  height: auto;
  opacity: 0.9;
  pointer-events: none;
}

.flowers {
  position: absolute;
  bottom: max(82px, calc(env(safe-area-inset-bottom) + 62px));
  left: 7%;
  width: clamp(96px, 24vw, 150px);
  height: auto;
  opacity: 0.85;
  pointer-events: none;
}

.name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.5rem, 18vw, 6.5rem);
  letter-spacing: 0.01em;
  color: var(--ink);
  font-style: italic;
}

.line {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.35rem, 5.2vw, 1.85rem);
  line-height: 1.35;
  color: var(--ink);
  max-width: 22ch;
  margin-inline: auto;
  will-change: opacity, transform;
}

.line--delay { margin-top: 0.9em; }
.line--soft { color: var(--ink-soft); font-style: italic; }
.card--text .line { padding: 0 8px; }

.photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  will-change: transform, opacity;
}

.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10,10,10,0.15) 0%, rgba(10,10,10,0.0) 30%, rgba(10,10,10,0.0) 50%, rgba(10,10,10,0.85) 100%);
  pointer-events: none;
}

.photo--dim::after {
  background: linear-gradient(to bottom, rgba(10,10,10,0.55) 0%, rgba(10,10,10,0.25) 40%, rgba(10,10,10,0.9) 100%);
}

.caption {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0 24px 56px;
  text-align: center;
}

.caption--bottom { margin-top: auto; }
.caption .line { color: var(--ink); text-shadow: 0 1px 24px rgba(0,0,0,0.6); }

.signoff {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  color: var(--ink);
  line-height: 1.2;
}

.signoff--name { margin-top: 0.2em; color: var(--accent); }

/* ========== Mute Button ========== */

.mute-btn {
  position: fixed;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  right: max(20px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 241, 234, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, border-color 0.25s, background 0.25s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.mute-btn.is-visible {
  opacity: 0.85;
  pointer-events: auto;
}

.mute-btn:hover,
.mute-btn:focus-visible {
  opacity: 1;
  border-color: var(--accent);
  background: rgba(10, 10, 10, 0.75);
  outline: none;
}

.mute-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.mute-btn .mute-icon--off { display: none; }
.mute-btn[data-muted="true"] .mute-icon--on { display: none; }
.mute-btn[data-muted="true"] .mute-icon--off { display: block; }

@media (min-width: 768px) {
  .card { padding: 48px; }
  .card--photo { padding: 0; }
  .card--signoff { padding: 0 48px 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .line, .photo, .signoff, .name, #gate {
    transition: none !important;
    animation: none !important;
  }
}
