/* The high tea invitation. Burgundy and cream, with the reception's fonts.
   Written so the page is complete and still without any script:
   - html.intro  the sealed envelope will be shown first (set by hightea.js)
   - html.go     the envelope has opened, so the page plays its own movement */

@font-face { font-family: "Cormorant Garamond"; font-weight: 500; font-display: swap; src: url("../fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 400; font-display: swap; src: url("../fonts/eb-garamond-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 500; font-display: swap; src: url("../fonts/eb-garamond-latin-500-normal.woff2") format("woff2"); }

:root {
  --cream: #f1ebe4;
  --desk: #e6dccf;
  --paper: #f7f2ec;
  --bur: #5c1e2c;
  --bur-dark: #3d1019;
  --display: "Cormorant Garamond", Garamond, serif;
  --body: "EB Garamond", Garamond, serif;
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body { margin: 0; background: var(--cream); color: var(--bur); font: 1.125rem/1.5 var(--body); }
h1, h2, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--bur); outline-offset: 3px; }

/* ---- The page ---- */
.page { max-width: 28.75rem; min-height: 100svh; margin: 0 auto; padding: 3.2rem 1.5rem 1.5rem; text-align: center; }
.intro:not(.go) .page, .intro:not(.go) .built-by { visibility: hidden; }

.kicker { font: 500 1.4rem/1.2 var(--display); letter-spacing: .06em; }
h1 { font-weight: 400; }
h1 .title { display: block; margin-top: .1rem; font: 500 clamp(3.8rem, 20vw, 5.2rem)/.95 var(--display); letter-spacing: .01em; }
h1 .subtitle { display: block; font: 500 2.1rem/1.1 var(--display); letter-spacing: .03em; }
/* The script "and" is artwork from the reception card, drawn in burgundy. */
.and { display: block; width: 9.4rem; height: 1.6rem; margin: .35rem auto .1rem; background: var(--bur);
  -webkit-mask: url("../art/and.svg") center / contain no-repeat; mask: url("../art/and.svg") center / contain no-repeat; }

/* ---- The teapot scene ---- */
.scene { display: block; width: min(86vw, 20.6rem); margin: .9rem auto 0; overflow: visible; }
.scene * { fill: none; stroke: var(--bur); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.scene .solid { fill: var(--bur); }
.scene .ripple { stroke: var(--cream); opacity: 0; transform-box: fill-box; transform-origin: center; }
.pot { transform-box: view-box; transform-origin: 100px 90px; }
.stream { transform-box: view-box; transform-origin: 176px 78px; transform: scaleY(0); }
.scene .tea { transform: translateY(8px); }
.steam { opacity: .7; }

/* ---- Date and place ---- */
.when { margin-top: 1.5rem; padding: 1.2rem .8rem 1.3rem; border-radius: 1.75rem; background: var(--bur); color: var(--cream); box-shadow: 0 4px 10px rgb(61 16 25 / .25); }
.when .day { display: block; font: 500 1.75rem/1.15 var(--display); }
.when .time { font: 500 1.35rem/1.3 var(--display); letter-spacing: .08em; }
.when .where { margin-top: .4rem; font-size: 1rem; }

/* ---- RSVP panel ---- */
.rsvp { position: relative; margin-top: 2.8rem; padding: 1.7rem 1.3rem 1.5rem; border-radius: 0 0 1.6rem 1.6rem; background: var(--bur); color: var(--cream); }
.rsvp::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 13px;
  background: radial-gradient(circle at 10px 13px, var(--bur) 10px, transparent 10.6px) 0 0 / 20px 13px repeat-x; }
.rsvp h2 { font: 500 2rem/1.05 var(--display); }
.rsvp p { margin-top: .3rem; }
.rsvp h2 + p { margin-bottom: 1.1rem; }
.rsvp form { margin: 0; }
.in { display: block; width: 100%; margin-bottom: .8rem; padding: .75rem 1rem; border: 1px solid var(--cream); border-radius: .9rem; background: var(--cream); color: var(--bur); font: inherit; }
.in::placeholder { color: rgb(92 30 44 / .6); }
.in[aria-invalid="true"] { border-color: #ffd9d0; box-shadow: 0 0 0 2px #ffd9d0; }
.rsvp fieldset { min-width: 0; margin: .2rem 0 .3rem; padding: 0; border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.rsvp fieldset label { display: block; }
.rsvp input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.rsvp fieldset span { display: flex; flex-direction: column; align-items: center; gap: .4rem; height: 100%; padding: 1rem .4rem .9rem; border: 1px solid rgb(241 235 228 / .75); border-radius: .9rem; line-height: 1.15; cursor: pointer; transition: background .25s, color .25s, transform .25s; }
.rsvp input:checked + span { background: var(--cream); color: var(--bur); transform: translateY(-3px); }
.rsvp input:focus-visible + span { outline: 2px solid var(--cream); outline-offset: 3px; }
.rsvp fieldset i { display: block; font-style: normal; }
.rsvp fieldset .cupart { width: 4.75rem; height: 4.75rem; stroke-width: 3.4; }
.btn { display: block; width: 100%; margin-top: .9rem; padding: .9rem; border: 0; border-radius: .9rem; background: var(--cream); color: var(--bur); font: 500 1.1rem var(--body); letter-spacing: .05em; cursor: pointer; }
.btn[disabled] { opacity: .6; cursor: default; }
.rsvp .err { margin: -.3rem 0 .6rem; font-size: .98rem; color: #ffd9d0; }
.rsvp h2 + p + .err, .rsvp p + .err { margin-top: 0; }
.rsvp .notice { margin-top: 1rem; padding: .7rem .9rem; border: 1px solid rgb(241 235 228 / .6); border-radius: .9rem; font-size: 1rem; }
.rsvp .fine { margin-top: .9rem; font-size: .95rem; opacity: .8; }
.done-art .cupart { display: block; width: 6.5rem; height: 6.5rem; margin: 0 auto .3rem; stroke-width: 3; }
.done-art.on-yes .tea { transform: none; }

/* A cup, drawn with lines in the colour of the text around it. */
.cupart { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.cupart .tea { fill: currentColor; stroke: none; transform: translateY(46px); transition: transform 1.4s ease-in-out; }
.rsvp:has(input[value="yes"]:checked) .fillable .tea { transform: none; }
.cupart .stm { opacity: .8; }
.cup-letter { fill: currentColor; stroke: none; font: 500 32px var(--display); }

/* ---- Plain message pages ---- */
.plain { padding-top: 22vh; }
.plain-title { font: 500 2.2rem/1.1 var(--display); }
.plain p { margin-top: .8rem; }
.text-link { color: var(--bur); }

/* ---- Credit ---- */
.built-by { display: flex; justify-content: center; align-items: center; height: 3.5rem; padding-bottom: .5rem; }
.built-by a { display: inline-flex; align-items: baseline; gap: .5em; padding: .6rem .8rem; color: var(--bur); font-size: 1rem; line-height: 1.2; text-decoration: none; opacity: .75; }
.built-by svg { flex: none; height: .65em; width: 1.165em; }
.built-by a:hover, .built-by a:focus-visible { opacity: 1; }

/* ---- The sealed envelope. Hidden unless the script will play it. ---- */
.cover { display: none; }
.intro .cover { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--desk); cursor: pointer; transition: opacity .7s ease; }
.cover:focus { outline: none; }
.cover.gone { opacity: 0; pointer-events: none; }
.env { position: relative; width: min(84vw, 34rem); aspect-ratio: 3 / 2; perspective: 900px; transform: translateY(7vh); transition: transform 1s ease-in, opacity .8s; }
.cover.grow .env { transform: translateY(30vh); opacity: 0; }
.env > * { position: absolute; }
.env-back { inset: 0; z-index: 1; border-radius: 3px; background: var(--bur-dark); }
.card { left: 6%; right: 6%; top: 9%; height: 86%; z-index: 2; container-type: inline-size; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  border: 1px solid rgb(92 30 44 / .35); border-radius: 3px; background: var(--cream); box-shadow: 0 2px 8px rgb(61 16 25 / .2); transition: transform 1.2s cubic-bezier(.3, .75, .2, 1) 1.15s; }
.card .mini { transition: opacity .45s; }
.card.big { border-color: transparent; box-shadow: none; }
.card.big .mini { opacity: 0; }
.card small { display: block; font: 500 5.4cqw/1 var(--display); letter-spacing: .06em; }
.card b { display: block; margin-top: .35em; font: 500 11cqw/1 var(--display); }
.card .and { width: 27cqw; height: 4.6cqw; margin: 1cqw auto .6cqw; }
.card span { display: block; font: 500 6.2cqw/1.1 var(--display); }
.cover.open .card { transform: translateY(-64%); }
.env-front { inset: 0; z-index: 3; background: var(--bur); clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%); }
.flap { left: 0; right: 0; top: 0; height: 62%; z-index: 4; background: #6a2433; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0; }
.cover.open .flap { animation: flap .9s ease-in-out .2s both; }
@keyframes flap {
  0% { transform: rotateX(0); z-index: 4; background: #6a2433; }
  49% { transform: rotateX(88deg); z-index: 4; }
  50% { transform: rotateX(92deg); z-index: 0; background: var(--bur-dark); }
  100% { transform: rotateX(180deg); z-index: 0; background: var(--bur-dark); }
}
.seal { left: 50%; top: 54%; width: 3.5rem; height: 3.5rem; margin: -1.75rem 0 0 -1.75rem; z-index: 5; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: var(--cream); color: var(--bur); box-shadow: 0 2px 6px rgb(0 0 0 / .28); cursor: pointer; transition: opacity .3s, transform .3s; }
.seal::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 1px solid var(--bur); opacity: 0; }
.seal .cupart { width: 2.2rem; height: 2.2rem; stroke-width: 5; }
.seal .cup-letter { font-size: 30px; }
.cover.open .seal { opacity: 0; transform: scale(.6); }
.hint { margin-top: 7vh; font: 500 1.1rem var(--display); letter-spacing: .06em; transition: opacity .4s; }
.cover.open .hint { opacity: 0; }

/* ---- Movement. Without it, or with reduced motion, everything simply sits in place. ---- */
@media (prefers-reduced-motion: no-preference) {
  .seal::after { animation: ring 2.4s ease-out infinite; }
  .cover.open .seal::after { animation: none; }
  .cupart .stm { animation: stm 3s ease-in-out infinite; }
  .cupart .stm2 { animation-delay: 1.2s; }
  .steam { animation: steam 3.2s ease-in-out infinite; }
  .steam.s2 { animation-delay: .7s; }

  .go .kicker { animation: fadein .9s ease-out both; }
  .go h1 .title { animation: wipe 1.1s cubic-bezier(.3, .7, .2, 1) .15s both; }
  .go h1 .and { animation: write 1.3s ease-in-out .9s both; }
  .go h1 .subtitle { animation: fadein .9s ease-out 1.9s both; }
  .go .when { animation: fadein 1s ease-out 3.6s both; }
  .go .rsvp { animation: fadein 1s ease-out 3.9s both; }

  .go .pot { animation: tilt 4.6s ease-in-out 1.3s both; }
  .go .stream { animation: stream 3.3s ease-in-out 1.75s both; }
  .go .scene .tea { animation: pour 3s ease-in-out 1.9s both; }
  .go .ripple { animation: ripple 1s ease-out 2s 3 both; }
  .go .steam { animation: steam 3.2s ease-in-out 5s infinite both; }
  .go .steam.s2 { animation-delay: 5.7s; }

  /* A new accepted reply: the cup fills. */
  .done-art.celebrate .tea { animation: fill-cup 1.6s ease-out .4s both; }
}
@media (prefers-reduced-motion: reduce) {
  .cupart .tea { transition: none; }
  .rsvp fieldset span { transition: none; }
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 -20% 0); } }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 -2% 0 0); } }
@keyframes tilt { 0% { transform: rotate(0); } 15%, 80% { transform: rotate(24deg); } 100% { transform: rotate(0); } }
@keyframes stream { 0% { transform: scaleY(0); } 8%, 90% { transform: scaleY(1); } 100% { transform: scaleY(0); } }
@keyframes pour { from { transform: translateY(46px); } to { transform: translateY(8px); } }
@keyframes fill-cup { from { transform: translateY(46px); } to { transform: none; } }
@keyframes steam { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: .85; } 100% { opacity: 0; transform: translateY(-10px); } }
@keyframes stm { 0% { opacity: 0; transform: translateY(4px); } 40% { opacity: .85; } 100% { opacity: 0; transform: translateY(-8px); } }
@keyframes ripple { from { opacity: .8; transform: scale(.3); } to { opacity: 0; transform: scale(1.1); } }
@keyframes ring { 0% { transform: scale(.85); opacity: .6; } 100% { transform: scale(1.5); opacity: 0; } }
