:root {
  color-scheme: light;
  --cream: #f9efe2;          /* exact paper colour of the supplied artwork */
  --cream-light: #fdf7ef;
  --pumpkin: #d06a33;
  --peach: #eeb08a;
  --sage: #8c9a6c;
  --olive: #6c7350;
  --brown: #4a382a;
  --ink: #5b4637;
  --muted: #8b7663;
  --line: rgba(150, 110, 75, .28);
  --display: "Cormorant Garamond", "Times New Roman", serif;
  --body: "Lora", Georgia, serif;
  --script: "Parisienne", "Brush Script MT", cursive;
  /* Side border width: one strip fills the screen height. --border-aspect (width / height)
     is read from the border image in script.js, so a new image keeps its proportions. */
  --bw: min(calc(100vh * var(--border-aspect, .36)), 19vw);
}
@media (max-width: 700px) { :root { --bw: 36px; --gutter: 8px; } }
@media (max-width: 380px) { :root { --bw: 30px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 300px; background: var(--cream); color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.is-intro { overflow: hidden; height: 100svh; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }

/* ---------- Fixed side borders ---------- */
.border { position: fixed; top: 0; bottom: 0; z-index: 1; width: var(--bw); pointer-events: none; background-repeat: repeat-y; background-size: 100% auto; }
.border--left { left: 0; background-position: left top; }
.border--right { right: 0; background-position: right top; }
.is-intro .border { opacity: 0; }

/* ---------- The letter ---------- */
.invite { position: relative; z-index: 2; min-height: 100svh; transition: opacity .6s ease; }
.is-intro .invite { opacity: 0; visibility: hidden; }
.letter {
  container-type: inline-size;
  width: min(980px, calc(100vw - 2 * var(--bw) - var(--gutter, 24px)));
  margin: 0 auto;
  padding: 28px clamp(8px, 4cqi, 28px) 40px;
  text-align: center;
  background: var(--cream);
}
.art { margin-inline: auto; }
.art--garland { width: min(100%, 470px); margin-bottom: clamp(18px, 5cqi, 34px); }
.art--trio { width: min(100%, 470px); margin-top: clamp(26px, 6cqi, 44px); }

.eyebrow { margin: 0 0 6px; font-family: var(--display); font-weight: 600; font-size: clamp(13px, 2.6cqi, 16px); letter-spacing: .26em; text-transform: uppercase; color: var(--muted); }
.headline { margin: 0; font-weight: normal; line-height: 1; }
.headline__host { display: block; font-family: var(--display); font-weight: 600; font-size: clamp(50px, 14cqi, 96px); letter-spacing: -.01em; color: var(--brown); }
.headline__title { display: block; margin-top: .08em; font-family: var(--script); font-size: clamp(40px, 11.5cqi, 80px); line-height: 1.15; color: var(--pumpkin); }
.message { text-wrap: pretty; max-width: 30em; margin: clamp(16px, 4cqi, 26px) auto 0; font-size: clamp(17px, 3cqi, 23px); line-height: 1.65; white-space: pre-line; }

.rule { display: flex; align-items: center; justify-content: center; gap: 14px; margin: clamp(22px, 6cqi, 38px) auto; max-width: 420px; }
.rule span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line) 30%, var(--line) 70%, transparent); }
.rule img { width: 22px; }
.rule--bats img { width: 52px; }
.rule--bats img:last-child { width: 34px; }
.rule--bats .rule__moon { width: 26px; }

.block { margin: 0 auto; }
.caps { text-wrap: balance; margin: 4px 0; font-family: var(--display); font-weight: 600; font-size: clamp(17px, 3.3cqi, 22px); letter-spacing: .14em; text-transform: uppercase; color: var(--brown); }
.caps--lg { font-size: clamp(19px, 4.6cqi, 28px); letter-spacing: .1em; }
.caps--sm { font-size: 13px; letter-spacing: .2em; color: var(--muted); }
.address { margin: 6px 0 0; font-size: clamp(17px, 3cqi, 22px); line-height: 1.6; white-space: pre-line; }
.text-link { display: inline-block; margin-top: 10px; font-size: clamp(14px, 2cqi, 17px); color: var(--olive); text-decoration: none; border-bottom: 1px solid rgba(108, 115, 80, .4); }
.text-link:hover { color: var(--pumpkin); border-color: currentColor; }

.block--evening { margin-top: clamp(30px, 7cqi, 48px); }
.sprig-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.sprig-row img { width: 34px; }
.flip { transform: scaleX(-1); }
.script-heading { margin: 0; font-family: var(--script); font-weight: normal; font-size: clamp(32px, 7cqi, 44px); color: var(--olive); }
.evening-item { margin-top: 14px; }
.evening-item p { margin: 0; font-size: clamp(17px, 3cqi, 22px); line-height: 1.6; white-space: pre-line; }
.evening-item .label { margin-bottom: 2px; font-family: var(--display); font-weight: 600; font-size: clamp(13px, 2cqi, 16px); letter-spacing: .22em; text-transform: uppercase; color: var(--pumpkin); }

.rsvp { position: relative; max-width: 520px; margin: 4px auto 0; padding: 26px clamp(18px, 5cqi, 34px) 30px; border: 1.5px solid var(--line); border-radius: 26px; background: var(--cream-light); }
.rsvp__title { margin: 0; font-family: var(--display); font-weight: 600; font-size: clamp(30px, 6cqi, 38px); letter-spacing: .12em; color: var(--brown); }
.rsvp__note { margin: 12px auto 18px; max-width: 26em; font-size: clamp(17px, 2.6cqi, 20px); line-height: 1.6; white-space: pre-line; }
.rsvp__button { display: inline-block; padding: 13px 28px; border-radius: 999px; background: var(--pumpkin); color: #fff8ee; font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; box-shadow: 0 6px 16px -8px rgba(160, 70, 20, .7); transition: transform .2s ease, background .2s ease; }
.rsvp__button:hover { background: #bf5c27; transform: translateY(-1px); }
.rsvp__heart { width: 30px; margin: 18px auto 0; }

.closing { margin-top: clamp(30px, 7cqi, 46px); }
.closing__text { margin: 0; font-family: var(--script); font-size: clamp(30px, 7cqi, 46px); line-height: 1.25; color: var(--pumpkin); white-space: pre-line; }
.closing__sign { margin: 10px 0 0; font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.closing__art { width: min(100%, 520px); margin: 22px auto 0; }

[data-optional].is-empty { display: none; }

/* ---------- Opening scene ---------- */
.stage { position: fixed; inset: 0; z-index: 30; overflow: hidden; }
.stage::before { content: ""; position: absolute; inset: 0; opacity: var(--stage-bg, 1); background: radial-gradient(ellipse 70% 60% at 50% 46%, var(--cream-light), var(--cream) 75%); }

.envelope { position: absolute; left: 0; top: 0; will-change: transform; opacity: 0; transition: opacity .5s ease, filter .3s ease; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.envelope.is-ready { opacity: 1; }
.envelope:focus-visible { outline: 2px solid var(--sage); outline-offset: 12px; border-radius: 6px; }
.envelope > * { position: absolute; pointer-events: none; }
.envelope img { max-width: none; }
.envelope__shadow { z-index: 0; left: 4%; right: 4%; bottom: -6%; height: 16%; border-radius: 50%; background: radial-gradient(closest-side, rgba(110, 60, 25, .28), transparent); filter: blur(6px); }
.envelope__back, .envelope__pocket { left: 0; top: 0; width: 100%; height: 100%; }
.envelope__back { z-index: 1; }
.envelope__pocket { z-index: 4; filter: drop-shadow(0 -1px 1px rgba(120, 50, 10, .18)); }
.well { z-index: 3; left: -100vw; right: -100vw; top: -300vh; bottom: 1.5%; overflow: hidden; }
.flap { z-index: 5; left: 0; top: 0; width: 100%; transform-origin: 50% 0; transform-style: preserve-3d; }
.flap.is-behind { z-index: 2; }
.flap img { position: absolute; left: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flap__outside { top: 0; height: 100%; filter: drop-shadow(0 3px 3px rgba(110, 45, 10, .22)); }
.flap__inside { bottom: 100%; transform-origin: 50% 100%; transform: rotateX(180deg); }
.envelope__seal { z-index: 6; filter: drop-shadow(0 4px 5px rgba(100, 40, 10, .3)); }
.envelope:hover:not(:disabled) { filter: brightness(1.02); }

.stage__hint { position: absolute; left: 0; right: 0; margin: 0; text-align: center; font-family: var(--display); font-style: italic; font-weight: 500; font-size: 20px; letter-spacing: .04em; color: var(--muted); transition: opacity .4s ease; animation: hint 2.4s ease-in-out infinite; }
.stage__hint.is-hidden { animation: none; opacity: 0; }
@keyframes hint { 50% { opacity: .55; } }

/* The rising letter: a scaled clone of the real letter, so the hand-off is seamless. */
.card { position: absolute; left: 0; top: 0; overflow: hidden; border-radius: 3px; background: var(--cream); }
.card--shadow { box-shadow: 0 22px 44px -20px rgba(90, 45, 15, .5), 0 2px 6px rgba(90, 45, 15, .14); }
.card .letter { margin: 0; }
.card a { pointer-events: none; }

/* ---------- Customize editor (edit mode only) ---------- */
.edit-fab { position: fixed; right: 18px; bottom: 18px; z-index: 40; padding: 12px 20px; border: 0; border-radius: 999px; background: var(--brown); color: #fff8ee; font-family: var(--body); font-size: 15px; cursor: pointer; box-shadow: 0 10px 24px -10px rgba(60, 30, 10, .6); }
.editor { position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); display: flex; flex-direction: column; background: #fffaf3; border-left: 1px solid var(--line); box-shadow: -18px 0 40px -24px rgba(60, 30, 10, .4); transform: translateX(105%); transition: transform .35s cubic-bezier(.2, .7, .2, 1); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--brown); }
.editor.is-open { transform: none; }
.letter { transition: transform .35s cubic-bezier(.2, .7, .2, 1); }
@media (min-width: 1000px) { body.editor-open .letter { transform: translateX(-190px); } }
.editor__head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 8px; }
.editor__kicker { margin: 0; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--pumpkin); }
.editor__head h2 { margin: 2px 0 0; font-family: var(--display); font-size: 28px; }
.editor__close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(74, 56, 42, .06); font-size: 22px; cursor: pointer; }
.editor__form { flex: 1; overflow-y: auto; padding: 4px 22px 16px; }
.editor__form fieldset { margin: 14px 0 0; padding: 0; border: 0; }
.editor__form legend { margin-bottom: 6px; font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.editor__form label { display: block; margin-bottom: 10px; font-size: 13px; }
.editor__form input, .editor__form textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid rgba(74, 56, 42, .18); border-radius: 10px; background: #fff; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; resize: vertical; }
.editor__form input:focus, .editor__form textarea:focus { outline: 2px solid rgba(208, 106, 51, .35); border-color: var(--pumpkin); }
.editor__actions { display: grid; gap: 8px; padding: 14px 22px 6px; border-top: 1px solid var(--line); }
.btn { padding: 11px 14px; border: 1px solid rgba(74, 56, 42, .2); border-radius: 12px; background: #fff; font-size: 14px; cursor: pointer; }
.btn--primary { border-color: var(--pumpkin); background: var(--pumpkin); color: #fff8ee; font-weight: 600; }
.btn--quiet { border-color: transparent; background: none; color: var(--muted); }
.editor__foot { margin: 0; padding: 4px 22px 16px; font-size: 12px; color: var(--muted); }
@media (max-width: 700px) {
  .editor { top: auto; width: 100vw; height: 62svh; border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; transform: translateY(105%); }
}

@media (prefers-reduced-motion: reduce) {
  .stage__hint { animation: none; }
}
