:root {
  --bord: #6e1423;
  --dark: #4f0913;
  --cream: #f6ede2;
  --paper: #fcf5ed;
  --line: #d9c3b6;
  --mute: #8c5c61;
  --text: #3f0b12;
  --script: 'Pinyon Script', cursive;
  --serif: 'EB Garamond', Georgia, serif;
  --caps: 'Cormorant SC', 'EB Garamond', serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--dark); color: var(--text);
  font-family: var(--serif); font-size: 17px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img, video { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* script glyphs overhang their box; Safari clips the overhang inside animated layers, so give them room */
.script { font-family: var(--script); font-weight: 400; line-height: 1.15; padding-left: .2em; padding-right: .2em; }
.big { font-size: clamp(46px, 13vw, 58px); margin: 0; }
.caps { font-family: var(--caps); letter-spacing: .2em; text-transform: lowercase; font-variant: small-caps; margin: 0; }
.strong { font-weight: 600; color: var(--bord); font-size: 18px; }
.italic { font-style: italic; }
.muted { color: var(--mute); }
.light { color: var(--cream); }

/* ---------- 01 envelope ---------- */
.envelope-screen {
  min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px 16px; text-align: center; background: var(--dark);
  transition: opacity .6s ease;
}
.envelope-screen.leaving { opacity: 0; }
.envelope-screen .caps { font-size: 17px; letter-spacing: .3em; }
.names { font-size: 14px; letter-spacing: .05em; opacity: .75; margin: 0; }
.envelope-screen p { margin: 0; }
.envelope {
  position: relative; width: min(300px, 84vw); aspect-ratio: 3 / 2; margin: 18px 0 6px;
  border: 0; padding: 0; background: none; perspective: 900px;
}
.env-back, .env-front, .env-flap, .env-letter { position: absolute; inset: 0; border-radius: 8px; }
.env-back { background: #efe2d3; }
.env-letter {
  inset: 10px 14px auto 14px; height: 150%; clip-path: inset(0 0 38% 0 round 6px); background: var(--paper); border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding-top: 22px;
  color: var(--bord); box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: transform 1s cubic-bezier(.2,.8,.2,1) .35s, clip-path .3s linear .35s; z-index: 1;
}
.env-letter .l-kicker { font-style: italic; font-size: 17px; color: var(--mute); }
.env-letter .l-title { font-family: var(--script); font-size: 54px; line-height: 1.15; display: inline-block; padding: 0 .3em .08em; }
.env-letter .l-rule { width: 50px; height: 1px; background: var(--bord); margin: 6px 0 4px; }
.env-letter .l-date { font-family: var(--caps); font-weight: 600; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--text); }
.env-front {
  z-index: 2; background:
    linear-gradient(to top right, #f8eee2 50%, transparent 50.5%) left / 50% 100% no-repeat,
    linear-gradient(to top left, #f8eee2 50%, transparent 50.5%) right / 50% 100% no-repeat;
  filter: drop-shadow(0 -1px 0 #d9c7b5);
}
.env-flap {
  z-index: 3; height: 58%; background: #f3e6d7;
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top center;
  transition: transform .7s ease, z-index 0s .35s;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.08));
}
.seal {
  position: absolute; z-index: 4; left: 50%; top: 58%; width: 72px; height: 72px; margin: -36px 0 0 -36px;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #8c2333, var(--bord) 60%, #4f0913);
  box-shadow: 0 3px 8px rgba(0,0,0,.35), inset 0 0 0 4px rgba(255,255,255,.06);
  color: var(--cream); font-size: 44px; display: flex; align-items: center; justify-content: center;
  transition: transform .4s ease, opacity .4s ease;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.06); } }
.seal .script { display: inline-block; transform: translate(-0.17em, 0.1em); line-height: 1; }
.envelope.open .seal { opacity: 0; transform: scale(.6); animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope { transition: transform .8s ease .2s; }
.env-letter > span { opacity: 0; transition: opacity .4s ease .7s; }
.envelope.open { transform: translateY(70px); }
.envelope.open .env-letter { transform: translateY(-62%); clip-path: inset(0 0 0 0 round 6px); }
.envelope.open .env-letter > span { opacity: 1; }
.envelope-screen.opening > p, .envelope-screen.opening > h1 { opacity: 0; transition: opacity .4s ease; }

/* ---------- layout ---------- */
main { max-width: 480px; margin: 0 auto; background: var(--cream); min-height: 100svh; }
section { padding: 40px 16px; text-align: center; }

/* ---------- 02 invitation (variant A: calm) ---------- */
.invitation {
  background: #fcf5ed; min-height: 100svh; padding: 24px 16px 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.wreath { width: min(260px, 66vw); height: auto; margin: 0 auto 6px; }
.headline { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.25; color: var(--text); margin: 0 0 24px; }
.info {
  width: 100%; max-width: 360px; margin: 0; padding: 18px 20px; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 12px;
}
.info div { display: grid; grid-template-columns: 92px 1fr; align-items: baseline; gap: 10px; }
.info dt { font-family: var(--caps); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.info dd { margin: 0; font-size: 17px; color: var(--text); }
.countdown { font-style: italic; font-size: 17px; color: var(--bord); margin: 24px 0 20px; font-variant-numeric: tabular-nums; }
.countdown span { font-style: normal; font-weight: 500; display: inline-block; min-width: 1.2em; text-align: right; }
.countdown span[data-k="d"] { min-width: 0; }
.countdown.done { font-family: var(--script); font-style: normal; font-size: 40px; }
.button {
  display: inline-block; background: var(--bord); color: var(--cream); text-decoration: none; border: 0;
  padding: 15px 30px; border-radius: 40px; font-family: var(--serif); font-size: 17px; font-weight: 500;
}
.button.small { padding: 10px 22px; font-size: 15px; }

/* ---------- 03 calendar ---------- */
.calendar { background: var(--cream); padding-bottom: 56px; }
.calendar > p { margin: 6px 0 22px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  height: 150px; border-radius: 14px; border: 1.5px solid var(--bord); background: var(--bord); color: var(--cream);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 8px;
}
.tile .num { font-size: 46px; font-weight: 500; line-height: 1; }
.tile .mon { font-family: var(--caps); font-size: 13px; letter-spacing: .2em; text-transform: uppercase; margin: 4px 0 2px; }
.tile .lbl { font-size: 15px; }
.tile.open { background: var(--paper); color: var(--bord); box-shadow: 0 4px 12px rgba(79,9,19,.12); }
.tile.open .lbl { font-style: italic; }
.tile.today { animation: glow 2.2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 5px rgba(110,20,35,.18); } }
.tile.locked { cursor: default; opacity: .97; }
.tile.wide { grid-column: span 2; height: 112px; }
.from { font-family: var(--script); font-size: 30px; color: var(--bord); margin-top: 34px; }

/* ---------- door view ---------- */
.door { position: fixed; inset: 0; z-index: 10; background: var(--cream); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.door.dark { background: var(--dark); color: var(--cream); }
.door-inner { max-width: 480px; margin: 0 auto; padding: 18px 16px 48px; text-align: center; }
.back { border: 0; background: none; color: var(--mute); font-size: 16px; padding: 6px 0; display: block; text-align: left; }
.door.dark .back { color: #e5cfc8; }
.kicker { font-size: 15px; letter-spacing: .25em; color: var(--bord); margin-top: 14px; }
.door.dark .kicker { color: var(--cream); }
.door-title { font-size: clamp(44px, 12vw, 54px); margin: 6px 0 12px; color: var(--bord); }
.door.dark .door-title { color: var(--cream); }
#door-body p { margin: 8px auto; max-width: 340px; }

/* guests */
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 10px; margin-top: 14px; perspective: 800px; }
.card {
  width: 104px; padding: 6px 6px 8px; border: 1.5px solid var(--bord); border-radius: 12px; background: var(--paper);
  box-shadow: 0 4px 10px rgba(79,9,19,.18); opacity: 0; transform: rotateY(90deg);
  animation: deal .6s ease forwards;
}
@keyframes deal { to { opacity: 1; transform: none; } }
.card .corner { font-family: var(--caps); font-weight: 600; font-size: 12px; color: var(--bord); text-align: left; letter-spacing: .05em; }
.card img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; margin: 2px auto; }
.card .nm { font-family: var(--script); font-size: 24px; color: var(--bord); line-height: 1.2; }
.card .rl { font-family: var(--caps); font-size: 10px; letter-spacing: .12em; color: var(--dark); text-transform: uppercase; }

/* dresscode */
.bow { width: 150px; margin: 20px auto 10px; }
.dc-head { font-size: 28px; font-weight: 500; color: var(--bord); }

/* drink */
.drink-media { width: min(320px, 88vw); margin: 8px auto 4px; border-radius: 16px; overflow: hidden; background: var(--bord); }
.drink-media video, .drink-media img { width: 100%; height: auto; }
.drink-name { font-size: 38px; margin: 10px 0 0; }

/* song */
.player { background: var(--dark); color: var(--cream); border-radius: 18px; padding: 20px; margin-top: 12px; }
.player img { width: 180px; height: 180px; object-fit: cover; border-radius: 10px; margin: 0 auto 12px; }
.player .t { font-size: 22px; font-weight: 500; }
.player .a { font-style: italic; opacity: .8; font-size: 14px; margin-bottom: 12px; }
.player audio { width: 100%; }

/* sneak */
.sneak { width: min(320px, 86vw); margin: 6px auto 8px; border-radius: 8px; box-shadow: 0 8px 22px rgba(79,9,19,.2); }

/* truths */
.statement {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; margin: 10px 0;
  padding: 14px 16px; border: 1.2px solid var(--bord); border-radius: 14px; background: var(--paper); color: var(--text);
}
.statement .n { font-family: var(--script); font-size: 34px; color: var(--bord); line-height: 1; }
.statement.picked { background: var(--bord); color: var(--cream); }
.statement.picked .n { color: var(--cream); }

/* skål */
.skaal-video { width: min(260px, 70vw); margin: 4px auto 14px; border-radius: 16px; overflow: hidden; background: var(--bord); aspect-ratio: 9/16; }
.skaal-video video, .skaal-video img { width: 100%; height: 100%; object-fit: cover; }
.sound-btn { background: var(--cream); color: var(--bord); margin: 0 0 16px; }
.placeholder { display: flex; align-items: center; justify-content: center; padding: 24px; font-style: italic; color: var(--cream); height: 100%; min-height: 180px; }

/* reactions */
.reactions { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.door.dark .reactions { border-color: rgba(246,237,226,.25); }
.like {
  border: 1.5px solid var(--bord); background: var(--paper); color: var(--bord); border-radius: 30px;
  padding: 8px 18px; font-size: 18px; transition: transform .15s ease;
}
.like:active { transform: scale(1.12); }
.like.liked { background: var(--bord); color: var(--cream); }
.comment-form { display: grid; gap: 8px; margin: 16px 0 12px; }
.comment-form input, .comment-form textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fffaf4; color: var(--text); resize: vertical;
}
.comment-form button { justify-self: center; }
.comments { list-style: none; padding: 0; margin: 0; text-align: left; }
.comments li { background: var(--paper); border-radius: 12px; padding: 10px 14px; margin: 8px 0; color: var(--text); }
.comments b { color: var(--bord); font-weight: 500; }
.comments small { color: var(--mute); margin-left: 6px; }
.err { color: #b3261e; font-size: 14px; }
.install {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; max-width: 360px; margin: 26px auto 0;
  padding: 12px 12px 12px 14px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line);
}
.install img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install-text { flex: 1; font-size: 14px; line-height: 1.35; color: var(--text); }
.install-text b { display: block; font-weight: 500; font-size: 15px; color: var(--bord); }
.share-ico { display: inline-block; font-size: 13px; border: 1px solid var(--line); border-radius: 4px; padding: 0 3px; }
.install-btn { border: 0; background: var(--bord); color: var(--cream); border-radius: 20px; padding: 8px 14px; font-size: 14px; }
.install-x { border: 0; background: none; color: var(--mute); font-size: 22px; line-height: 1; padding: 0 2px; align-self: flex-start; }
.preview-badge {
  position: fixed; z-index: 20; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: #1f6f4a; color: #fff; text-decoration: none; font-size: 13px; padding: 6px 14px; border-radius: 20px;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
}

@media (min-width: 520px) {
  body { padding: 0; }
  main { box-shadow: 0 0 40px rgba(0,0,0,.35); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card { opacity: 1; transform: none; }
}
