@font-face {
  font-family: Lora;
  src: url("../fonts/lora.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Dancing Script";
  src: url("../fonts/dancing-script.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
:root {
  color-scheme: light;
  --paper: #f6f1e8;
  --ink: #57473e;
  --muted: #76665a;
  --accent: #9b6658;
  --line: #dfd5c7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Lora, Georgia, serif; }
button, textarea, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }

.intro {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 32px 20px;
  text-align: center;
}
.envelope {
  position: relative;
  display: block;
  width: min(320px, 85vw);
  height: 207px;
  margin: 0 auto;
  border: 0;
  background: transparent;
  perspective: 1000px;
  isolation: isolate;
  transition: transform .4s;
}
.envelope:hover:not(:disabled) { transform: translateY(-5px); }
.envelope-back {
  position: absolute;
  inset: 0;
  background: #deccb0;
  border-radius: 5px;
  box-shadow: 0 22px 35px -18px #77604970, 0 3px 8px #77604915;
}
.envelope-paper {
  position: absolute;
  left: 7%;
  top: 8%;
  width: 86%;
  height: 86%;
  padding: 20px 26px;
  background: #faf6ef;
  text-align: left;
  z-index: 1;
  border-radius: 3px;
  transition: transform .65s .45s;
}
.envelope-paper i { display: block; height: 1px; margin-top: 17px; background: var(--line); width: 85%; }
.envelope-paper i:last-child { width: 55%; }
.envelope-front, .envelope-front::after, .envelope-flap { position: absolute; inset: 0; }
.envelope-front {
  z-index: 3;
  border-radius: 4px;
  background: #e8d9c0;
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
}
.envelope-front::after { content: ""; background: #ecdfca; clip-path: polygon(0 100%, 50% 46%, 100% 100%); }
.envelope-flap {
  background: #e4d3b7;
  clip-path: polygon(0 0, 100% 0, 50% 57%);
  z-index: 4;
  transform-origin: top;
  transition: transform .45s ease, z-index 0s .23s;
}
.envelope-name, .envelope-paper > span {
  font: 30px/1.3 "Dancing Script", Lora, cursive;
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.envelope-name { position: absolute; left: 25px; right: 25px; bottom: 25px; z-index: 5; color: #806756; text-align: left; }
.seal {
  position: absolute;
  z-index: 5;
  left: calc(50% - 19px);
  top: calc(55% - 19px);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #a97666;
  color: #f4e8dd;
  font: italic 21px/1 Georgia, serif;
  box-shadow: inset 0 0 0 4px #ffffff15, 0 2px 4px #503d3820;
  transition: opacity .2s;
}
.open-hint { font-size: 13px; color: var(--muted); margin: 28px 0 0; font-style: italic; }
.letter-unavailable { margin: 0; color: var(--accent); font-size: clamp(22px, 5vw, 32px); font-weight: 500; }
.intro.opening .envelope-flap { transform: rotateX(180deg); z-index: 0; }
.intro.opening .envelope-paper { transform: translateY(-125px); }
.intro.opening .seal, .intro.opening .open-hint { opacity: 0; }
.intro.leaving { opacity: 0; transition: opacity .4s; }

.letter {
  max-width: 684px;
  padding: 70px 42px 54px;
  margin: 0 auto;
  animation: arrive .6s ease both;
  outline: none;
}
.letter article { font: 26px/1.75 "Dancing Script", Lora, cursive; overflow-wrap: anywhere; white-space: pre-line; }
.letter h1 { font-size: 49px; line-height: 1.35; font-weight: 400; margin: 0 0 29px; color: var(--accent); }
.letter p { margin: 0 0 25px; }
.letter strong { font-weight: 650; color: #775044; }
.letter .letter-signoff { font-size: 29px; text-align: right; margin-top: 38px; }
.cursor { color: var(--accent); animation: blink 1s step-end infinite; font-weight: 400; padding-left: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width:600px) {
  .envelope { height: 195px; width: min(300px, 85vw); }
  .letter { padding: 52px 24px 36px; }
  .letter article { font-size: 24px; line-height: 1.8; }
  .letter h1 { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
