/* =========================================================
   Comunitatea Românească UK — o scrisoare, nu un site.
   Aged paper · ink · marginalia · wax seal.
   ========================================================= */

:root {
  /* Paper */
  --paper: #f0e4c8;
  --paper-shadow: #d4c39d;
  --paper-crease: #b8a37a;
  --paper-fold: rgba(80, 55, 20, 0.08);

  /* Ink */
  --ink: #1a1408;
  --ink-2: #2a1e10;
  --ink-faded: #3d2f18;
  --ink-blue: #1e2540;
  --ink-rust: #6b3a1a;

  /* Envelope-specific */
  --env-paper: #e8d9b0;
  --env-paper-2: #d9c493;
  --env-flap-back: #cdb884;
  --env-shadow: rgba(20, 10, 4, 0.4);

  /* Wax */
  --wax: #8b2a20;

  /* Desk (background around paper) */
  --desk-1: #2d1f10;
  --desk-2: #1a1208;

  --serif-print: "IM Fell English SC", "Cormorant Garamond", Georgia, serif;
  --serif-italic: "IM Fell English SC", Georgia, serif;
  --hand: "Caveat", "Bradley Hand", cursive;
  --hand-2: "Kalam", "Bradley Hand", cursive;
  --hand-signature: "Homemade Apple", cursive;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--hand);
  color: var(--ink);
  background: var(--desk-2);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.55;
  font-size: 20px;
  overflow-x: hidden;
}

/* =========================================================
   The desk — dark wood behind the paper
   ========================================================= */
.desk {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(120, 80, 30, 0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(70, 40, 15, 0.4) 0%, transparent 60%),
    linear-gradient(135deg, var(--desk-1) 0%, var(--desk-2) 100%);
}
.desk::before {
  /* wood grain noise */
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.2 0 0 0 0 0.1 0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.7;
  mix-blend-mode: multiply;
}

/* =========================================================
   The letter — paper
   ========================================================= */
.letter {
  position: relative;
  max-width: 760px;
  margin: 60px auto 80px;
  padding: clamp(48px, 6vw, 90px) clamp(36px, 5vw, 78px) clamp(60px, 8vw, 110px);
  background: var(--paper);
  color: var(--ink);
  box-shadow:
    0 2px 4px rgba(0,0,0,0.4),
    0 24px 60px rgba(0,0,0,0.5),
    0 60px 120px rgba(0,0,0,0.35);
  /* Paper texture */
  background-image:
    /* subtle fibers */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.32 0 0 0 0 0.18 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23p)'/%3E%3C/svg%3E"),
    /* corners darker */
    radial-gradient(ellipse at 50% 0%, rgba(180, 140, 80, 0.15) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 100%, rgba(180, 140, 80, 0.15) 0%, transparent 40%),
    radial-gradient(ellipse at 0% 50%, rgba(140, 100, 50, 0.1) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 50%, rgba(140, 100, 50, 0.1) 0%, transparent 40%),
    /* base */
    linear-gradient(180deg, #f2e6c9 0%, #e8d9b3 100%);
  background-blend-mode: multiply, normal, normal, normal, normal, normal;
  border-radius: 2px;
}

/* Deckle-edge feeling via jagged border shadow */
.letter::before, .letter::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 8px;
  background:
    linear-gradient(180deg, rgba(120, 80, 30, 0.2) 0%, transparent 100%);
  pointer-events: none;
}
.letter::before { top: 0; }
.letter::after {
  top: auto;
  bottom: 0;
  transform: scaleY(-1);
}

/* Horizontal fold line, decorative */
.letter {
  --fold: rgba(80, 55, 20, 0.12);
}
.letter > * { position: relative; z-index: 2; }

/* =========================================================
   Letterhead — printed at the top
   ========================================================= */
.letterhead {
  text-align: center;
  margin-bottom: clamp(32px, 5vw, 56px);
}
.masthead {
  font-family: var(--serif-print);
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.2;
}
.masthead span, .masthead-sub span {
  color: var(--ink-rust);
  padding: 0 6px;
  font-style: italic;
}
.masthead-sub {
  font-family: var(--serif-print);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-faded);
  margin: 6px 0 0;
  letter-spacing: 0.02em;
}
.masthead-sub em {
  font-style: italic;
  color: var(--ink-rust);
  font-weight: 400;
  padding: 0 2px;
}
.letterhead .rule {
  margin: 20px auto;
  width: 60%;
  height: 1px;
  background:
    linear-gradient(to right,
      transparent 0%,
      var(--ink-faded) 20%,
      var(--ink-faded) 80%,
      transparent 100%);
  opacity: 0.5;
}
.place-date {
  font-family: var(--hand);
  font-size: 1.1rem;
  color: var(--ink-2);
  margin: 8px 0 0;
  font-weight: 500;
}
.place-date em {
  font-style: italic;
  color: var(--ink-rust);
  font-weight: 500;
}

/* =========================================================
   Coffee stain
   ========================================================= */
.stain-coffee {
  position: absolute;
  top: 40px;
  right: -20px;
  width: 130px;
  height: 130px;
  z-index: 3;
  pointer-events: none;
  transform: rotate(15deg);
}

/* =========================================================
   Salutation
   ========================================================= */
.salutation {
  font-family: var(--hand);
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
  color: var(--ink);
  font-weight: 600;
  margin: 0 0 4px;
}
.salutation em {
  font-style: normal;
  color: var(--ink);
}
.salutation-2 {
  font-family: var(--hand);
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  color: var(--ink-2);
  font-weight: 500;
  margin: 0 0 clamp(24px, 4vw, 40px);
  line-height: 1.5;
}
.salutation-2 em {
  font-style: italic;
  color: var(--ink-rust);
  font-weight: 500;
}

/* =========================================================
   Body paragraphs
   ========================================================= */
.body { position: relative; }
.paragraph {
  font-family: var(--hand);
  font-size: clamp(1.15rem, 1.7vw, 1.32rem);
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 clamp(22px, 3vw, 34px);
  font-weight: 400;
  text-indent: 0;
  /* slight ink variation */
  text-shadow: 0 0 0 var(--ink);
}
.paragraph em {
  font-style: italic;
  color: var(--ink);
  font-weight: 500;
  /* underline like ink flourish */
  background-image: linear-gradient(to right, transparent, transparent);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
}
.paragraph-final {
  margin-top: clamp(28px, 4vw, 44px);
  padding-top: clamp(20px, 3vw, 28px);
  border-top: 1px dashed rgba(80, 55, 20, 0.25);
  font-style: italic;
  color: var(--ink-faded);
}

/* Dropcap on first paragraph */
.dropcap {
  font-family: var(--hand);
  float: left;
  font-size: 3.6rem;
  line-height: 0.9;
  font-weight: 700;
  color: var(--ink);
  padding: 6px 10px 0 0;
  margin-top: 4px;
}

/* =========================================================
   Struck-through corrections — hover to reveal original
   ========================================================= */
.paragraph s, .salutation-2 s {
  color: var(--ink-faded);
  text-decoration: none;
  position: relative;
  cursor: help;
  transition: color .3s var(--ease);
}
.paragraph s::before, .salutation-2 s::before {
  content: "";
  position: absolute;
  left: -2px; right: -2px;
  top: 55%;
  height: 2px;
  background: var(--ink);
  transform: rotate(-2deg);
  transform-origin: left;
  transition: opacity .3s var(--ease);
}
.paragraph s:hover, .salutation-2 s:hover {
  color: var(--ink);
  background: rgba(107, 58, 26, 0.08);
}
/* Show the "reason" tooltip natively via title attribute already;
   plus visually indicate hover with underline scribble */

/* =========================================================
   Invisible ink — dim, brighten on hover
   ========================================================= */
.invisible-ink {
  color: rgba(26, 20, 8, 0.14);
  transition: color .6s var(--ease);
  cursor: help;
  position: relative;
  padding-left: 10px;
  border-left: 1px dashed rgba(26, 20, 8, 0.15);
}
.invisible-ink em { color: rgba(26, 20, 8, 0.14); transition: color .6s var(--ease); }
.invisible-ink::after {
  content: "◇ trece cu mouse-ul peste rând";
  position: absolute;
  left: 12px;
  top: -18px;
  font-family: var(--hand-2);
  font-size: 0.72rem;
  color: var(--ink-rust);
  opacity: 0.7;
  letter-spacing: 0.04em;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.invisible-ink:hover, .invisible-ink:focus-within {
  color: var(--ink-2);
}
.invisible-ink:hover em, .invisible-ink:focus-within em { color: var(--ink); }
.invisible-ink:hover::after { opacity: 0; }

/* =========================================================
   Marginalia — note scrise pe margine, în altă mână,
   plasate imediat sub paragraful pe care îl adnotează.
   ========================================================= */
.margin {
  position: relative;
  display: block;
  max-width: 46ch;
  margin: -14px 0 22px 44px;
  padding: 8px 14px 8px 18px;
  font-family: var(--hand-2);
  font-weight: 400;
  color: var(--ink-rust);
  font-size: 0.98rem;
  line-height: 1.35;
  background: rgba(255, 240, 200, 0.35);
  border-left: 2px solid rgba(107, 58, 26, 0.45);
  border-radius: 0 3px 3px 0;
  transition: transform .3s var(--ease), background .3s var(--ease);
  transform: rotate(-0.6deg);
}
.margin-right {
  margin-left: auto;
  margin-right: 44px;
  border-left: 0;
  border-right: 2px solid rgba(107, 58, 26, 0.45);
  border-radius: 3px 0 0 3px;
  padding: 8px 18px 8px 14px;
  text-align: right;
  transform: rotate(0.6deg);
}
.margin:hover {
  transform: rotate(0);
  background: rgba(255, 235, 190, 0.55);
}
/* Small connector arrow before/after */
.margin::before {
  content: "↳";
  position: absolute;
  left: -14px; top: 3px;
  color: rgba(107, 58, 26, 0.7);
  font-family: var(--serif-print);
  font-size: 1.05em;
}
.margin-right::before {
  content: "↰";
  left: auto; right: -14px;
}
.margin .ink-hand {
  display: inline;
  color: var(--ink-rust);
  font-weight: 400;
}
.margin .attribution {
  display: block;
  margin-top: 2px;
  font-family: var(--hand-2);
  font-style: italic;
  font-size: 0.78rem;
  color: rgba(107, 58, 26, 0.75);
  font-weight: 300;
}

/* Superscript marker in the paragraph body (†, ‡, §, *) */
.margin-marker {
  display: inline-block;
  color: var(--ink-rust);
  font-family: var(--serif-print);
  font-weight: 600;
  font-size: 0.68em;
  padding: 0 2px 0 1px;
  vertical-align: super;
  line-height: 0;
  cursor: help;
  opacity: 0.85;
  transition: opacity .2s var(--ease);
}
.margin-marker:hover { opacity: 1; }

/* =========================================================
   Sign-off & signature
   ========================================================= */
.signoff {
  margin: clamp(40px, 6vw, 60px) 0 clamp(24px, 4vw, 40px);
  padding-left: 40%;
}
.signoff-line {
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--ink-2);
  margin: 0 0 4px;
}
.signoff-body {
  font-family: var(--hand);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.signature {
  display: block;
  width: 180px;
  height: 50px;
  margin-top: 10px;
  opacity: 0.9;
}

/* =========================================================
   Wax seal — Casa Regală a României style sigillum
   With physical paper-slit for ribbon attachment
   ========================================================= */
.seal-wrap {
  margin: clamp(28px, 4vw, 44px) 0 clamp(28px, 4vw, 44px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  padding-top: 20px;
}

/* The slit in the paper — where the ribbon threads through */
.paper-slit {
  display: block;
  width: 100px;
  height: 3px;
  background:
    linear-gradient(90deg,
      transparent 0%,
      rgba(60, 30, 10, 0.25) 15%,
      rgba(30, 15, 5, 0.65) 50%,
      rgba(60, 30, 10, 0.25) 85%,
      transparent 100%);
  border-radius: 4px;
  margin-bottom: -6px;
  z-index: 5;
  position: relative;
  /* subtle "cut" edge shadows */
  box-shadow:
    0 1px 0 rgba(200, 170, 120, 0.4),
    0 -1px 0 rgba(80, 45, 15, 0.3);
}
.paper-slit::before,
.paper-slit::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 6px;
  height: 9px;
  background: radial-gradient(ellipse at center,
    rgba(30, 15, 5, 0.5) 0%,
    transparent 70%);
  pointer-events: none;
}
.paper-slit::before { left: -3px; }
.paper-slit::after  { right: -3px; }

.wax-seal {
  background: none;
  border: 0;
  padding: 0;
  width: 240px;
  height: 425px;
  cursor: pointer;
  transition: transform .5s var(--ease), filter .5s var(--ease);
  filter: drop-shadow(0 12px 22px rgba(20, 5, 0, 0.55));
  position: relative;
  overflow: visible;
  display: block;
  transform-origin: 50% 15%;
}
.wax-seal svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.wax-seal:hover {
  transform: rotate(-1.2deg);
  filter: drop-shadow(0 16px 30px rgba(20, 5, 0, 0.65));
}
.wax-seal:active { transform: scale(0.99) rotate(-0.8deg); }

/* Ribbon subtle sway on hover */
.wax-seal .seal-ribbon {
  transform-origin: 50% 0;
  transition: transform .8s var(--ease);
}
.wax-seal:hover .seal-ribbon { transform: rotate(1deg); }

/* Seal-broken state (after click) — cracks and tilts */
.wax-seal.broken { animation: crack 1s var(--ease) forwards; }
@keyframes crack {
  0%   { transform: rotate(0); }
  20%  { transform: rotate(-4deg) scale(1.03); }
  50%  { transform: rotate(5deg) scale(0.98); }
  80%  { transform: rotate(-3deg); }
  100% { transform: rotate(-6deg) scale(0.94); opacity: 0.75; }
}

/* Message revealed under the seal */
.seal-message {
  text-align: center;
  font-family: var(--hand);
  color: var(--ink);
  max-width: 460px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .6s var(--ease) .3s, transform .6s var(--ease) .3s;
}
.seal-message[data-open] {
  opacity: 1;
  transform: translateY(0);
}
.seal-message p {
  margin: 0 0 12px;
  font-size: 1.15rem;
  line-height: 1.5;
}
.seal-message p:first-child {
  font-style: italic;
  color: var(--ink-rust);
  font-size: 1.25rem;
}
.seal-address {
  font-family: var(--serif-print);
  font-size: 0.95rem !important;
  color: var(--ink-2);
  line-height: 1.6 !important;
  padding: 12px 20px;
  border-top: 1px solid rgba(80, 55, 20, 0.25);
  border-bottom: 1px solid rgba(80, 55, 20, 0.25);
  margin: 8px auto !important;
}
.seal-address em {
  font-style: italic;
  color: var(--ink-rust);
  display: block;
  margin-bottom: 4px;
}
.seal-address a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink-rust);
  transition: color .2s var(--ease);
}
.seal-address a:hover { color: var(--wax); }
.seal-note {
  font-style: italic;
  font-size: 0.95rem !important;
  color: var(--ink-faded);
}

/* =========================================================
   Post scriptum
   ========================================================= */
.postscriptum {
  margin: clamp(32px, 4vw, 48px) 0 0;
  padding-top: clamp(20px, 3vw, 28px);
  border-top: 1px dashed rgba(80, 55, 20, 0.3);
}
.postscriptum p {
  font-family: var(--hand);
  font-size: 1.1rem;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 10px;
}
.postscriptum p:last-child { margin: 0; }
.ps-marker {
  font-family: var(--serif-print);
  font-weight: 400;
  color: var(--ink-rust);
  font-size: 0.9em;
  padding-right: 6px;
}
.ps-2 { color: var(--ink-faded); font-style: italic; }

/* =========================================================
   Folio (page number style)
   ========================================================= */
.folio {
  margin-top: clamp(40px, 6vw, 64px);
  text-align: center;
  font-family: var(--serif-print);
  font-size: 0.8rem;
  color: var(--ink-faded);
  letter-spacing: 0.08em;
  display: flex;
  justify-content: center;
  gap: 20px;
  opacity: 0.7;
}
.folio em {
  font-style: italic;
  color: var(--ink-rust);
  padding: 0 3px;
}

/* =========================================================
   Colophon — confrații de breaslă
   ========================================================= */
.colophon {
  margin: clamp(36px, 5vw, 56px) 0 clamp(28px, 4vw, 40px);
  padding: clamp(24px, 3vw, 32px) 0 clamp(20px, 2.5vw, 28px);
  border-top: 1px dashed rgba(80, 55, 20, 0.35);
  border-bottom: 1px dashed rgba(80, 55, 20, 0.35);
  text-align: center;
}
.colophon-title {
  margin: 0 0 20px;
  font-family: var(--serif-print);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-rust);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.colo-orn {
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols", "IM Fell English SC", serif;
  color: rgba(107, 58, 26, 0.55);
  font-size: 1.4rem;
  letter-spacing: 0;
  line-height: 1;
}
.colophon-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 6px 24px;
  font-family: var(--serif-print);
  font-size: 1rem;
  color: var(--ink-2);
  line-height: 1.5;
}
.colophon-list li {
  position: relative;
  white-space: nowrap;
}
.colophon-list li:not(:last-child)::after {
  content: "·";
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(107, 58, 26, 0.55);
  font-weight: 600;
  font-size: 1.1em;
  line-height: 1;
}
.colophon-list a {
  color: var(--ink-2);
  border-bottom: 1px dotted rgba(80, 55, 20, 0.4);
  padding-bottom: 1px;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.colophon-list a:hover {
  color: var(--wine, #8a2f24);
  border-bottom-color: var(--wine, #8a2f24);
  border-bottom-style: solid;
}
.colophon-list span {
  font-size: 0.72em;
  letter-spacing: 0.14em;
  color: var(--ink-rust);
  padding-left: 3px;
  vertical-align: 0.05em;
}
.colophon-note {
  margin: 0;
  font-family: var(--serif-print);
  font-size: 0.82rem;
  color: var(--ink-faded);
  font-style: italic;
}
.colophon-note em {
  color: var(--ink-faded);
  opacity: 0.85;
}

@media (max-width: 640px) {
  .colophon-list { flex-direction: column; gap: 8px; }
  .colophon-list li:not(:last-child)::after { display: none; }
  .colophon-title { font-size: 0.72rem; gap: 10px; }
  .colo-orn { font-size: 1.1rem; }
}

/* =========================================================
   Hint at the bottom (dismissable)
   ========================================================= */
.hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(240, 228, 200, 0.96);
  color: var(--ink-2);
  padding: 12px 18px 12px 20px;
  border-radius: 4px;
  border: 1px solid rgba(80, 55, 20, 0.3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-family: var(--hand-2);
  font-size: 0.9rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 40px);
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.hint[hidden] { display: none; }
.hint.gone { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }
.hint button {
  background: none;
  border: 0;
  color: var(--ink-rust);
  font-family: var(--serif-print);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

/* =========================================================
   ═══════════════════════════════════════════════════════
   ENVELOPE INTRO — plicul care se deschide la intrare
   ═══════════════════════════════════════════════════════
   ========================================================= */

/* Initial state: letter and page hint hidden behind envelope */
body.intro .letter,
body.intro .hint {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s var(--ease) 1.2s;
}
body:not(.intro) .letter { opacity: 1; }
body:not(.intro) .envelope-scene {
  opacity: 0;
  transform: scale(1.6);
  pointer-events: none;
  transition: opacity 1.4s var(--ease), transform 1.4s var(--ease);
}
body.dismissed .envelope-scene { display: none; }

.envelope-scene {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 32px;
  perspective: 1600px;
  overflow: hidden;
  animation: scene-in 1.2s var(--ease) both;
}
@keyframes scene-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.envelope-stage {
  position: relative;
  transform-style: preserve-3d;
  animation: env-float 4.5s ease-in-out infinite;
}
@keyframes env-float {
  0%, 100% { transform: translateY(0) rotate(-2.5deg); }
  50%      { transform: translateY(-6px) rotate(-1.5deg); }
}

/* ============ ENVELOPE ============ */
.envelope {
  position: relative;
  width: min(560px, 92vw);
  height: min(410px, 68vw);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .4s var(--ease);
  outline: none;
}
.envelope:hover { transform: translateY(-4px); }
.envelope:focus-visible {
  outline: 2px solid var(--gold, #c8a955);
  outline-offset: 12px;
}

/* Body of envelope (front face) */
.env-body {
  position: absolute;
  inset: 0;
  background:
    /* subtle fiber grain */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cfilter id='e'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='3' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.15 0 0 0 0.3 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23e)'/%3E%3C/svg%3E"),
    linear-gradient(140deg, var(--env-paper) 0%, var(--env-paper-2) 100%);
  background-blend-mode: multiply, normal;
  border: 1px solid rgba(80, 55, 20, 0.35);
  border-radius: 3px;
  box-shadow:
    inset 0 0 40px rgba(120, 80, 30, 0.15),
    0 4px 8px rgba(0,0,0,0.35),
    0 24px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}

/* No decorative fold lines on the body — the actual flap does the visual work */
.env-body::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Watermark: silhouette of the letter faintly visible */
.env-watermark {
  position: absolute;
  inset: 20% 25%;
  background:
    linear-gradient(180deg,
      transparent 0%,
      rgba(80, 55, 20, 0.04) 15%,
      rgba(80, 55, 20, 0.07) 30%,
      rgba(80, 55, 20, 0.07) 65%,
      rgba(80, 55, 20, 0.04) 85%,
      transparent 100%);
  border: 1px solid rgba(80, 55, 20, 0.06);
  pointer-events: none;
}
.env-watermark::before {
  content: "";
  position: absolute;
  inset: 15% 20% 40%;
  background:
    repeating-linear-gradient(180deg,
      transparent 0,
      transparent 6px,
      rgba(80, 55, 20, 0.08) 6px,
      rgba(80, 55, 20, 0.08) 7px);
}

/* Stamp (top-left) */
.env-stamp {
  position: absolute;
  top: 5%;
  left: 4%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border: 1.5px solid rgba(80, 30, 10, 0.55);
  background: rgba(210, 180, 130, 0.35);
  transform: rotate(-2.5deg);
  font-family: var(--serif-print);
  color: #4a1f08;
  line-height: 1.15;
  min-width: 110px;
}
.env-stamp .stamp-line-1 {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-align: center;
  border-bottom: 1px solid rgba(80, 30, 10, 0.45);
  padding-bottom: 3px;
  margin-bottom: 3px;
}
.env-stamp .stamp-line-2 {
  font-size: 0.7rem;
  font-style: italic;
  text-align: center;
  color: #5a2810;
}
.env-stamp .stamp-line-3 {
  font-size: 0.68rem;
  text-align: center;
  letter-spacing: 0.18em;
  color: #5a2810;
  padding-top: 2px;
  border-top: 1px dashed rgba(80, 30, 10, 0.35);
}

/* Postmark (top-right) */
.env-postmark {
  position: absolute;
  top: 5%;
  right: 5%;
  width: 90px;
  height: 90px;
  transform: rotate(12deg);
  opacity: 0.85;
}

/* Address block — hand-written, forwarded through many hands.
   Positioned in the lower half, below the wax seal. */
.env-address {
  position: absolute;
  top: 52%;
  left: 8%;
  right: 8%;
  bottom: 13%;
  font-family: var(--hand);
  color: var(--ink);
  line-height: 1.15;
  z-index: 1;
  overflow: hidden;
}
.addr-preamble {
  display: block;
  font-family: var(--serif-print);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  color: var(--ink-rust);
  margin-bottom: 2px;
}
.addr-main {
  margin: 0 0 2px;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
}
.addr-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-2);
  font-weight: 400;
  font-style: italic;
  line-height: 1.2;
}
.addr-sub-2 {
  margin: 0 0 4px;
  font-size: 0.76rem;
  color: var(--ink-faded);
  font-style: italic;
  line-height: 1.2;
}

/* Forwarded names block — the mystery */
.addr-forwarded {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px dashed rgba(80, 55, 20, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0;
  font-family: var(--hand-2);
  font-size: 0.76rem;
  line-height: 1.2;
}
.forwarded-eyebrow {
  font-family: var(--serif-print);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-rust);
  opacity: 0.75;
  margin-bottom: 1px;
}
.forwarded-name {
  color: var(--ink-2);
  padding-left: 6px;
}
.forwarded-name s {
  color: var(--ink-faded);
  text-decoration: none;
  position: relative;
}
.forwarded-name s::before {
  content: "";
  position: absolute;
  left: -2px; right: -2px;
  top: 55%;
  height: 1.5px;
  background: var(--ink);
  transform: rotate(-2deg);
}
/* Each crossed-out name has a slightly different stroke angle */
.forwarded-name:nth-child(2) s::before { transform: rotate(-3deg); }
.forwarded-name:nth-child(3) s::before { transform: rotate(-1deg); background: var(--ink-blue); }
.forwarded-name:nth-child(4) s::before { transform: rotate(-4deg); background: var(--ink-rust); }
.forwarded-name:nth-child(5) s::before { transform: rotate(-2.5deg); }
.addr-final {
  color: var(--ink) !important;
  font-family: var(--hand);
  font-weight: 600;
  font-size: 0.96rem;
  padding-left: 4px;
  margin-top: 2px;
  line-height: 1.2;
}
.addr-final em {
  color: var(--ink-rust);
  font-style: normal;
  font-weight: 700;
  border-bottom: 1.5px solid var(--ink-rust);
  padding: 0 3px;
}

/* Cipher (bottom edge, centered, doesn't overlap address) */
.env-cipher {
  position: absolute;
  bottom: 2.5%;
  left: 4%;
  font-family: var(--serif-print);
  font-size: 0.72rem;
  color: var(--ink-rust);
  letter-spacing: 0.08em;
  opacity: 0.85;
  cursor: help;
  z-index: 2;
  padding: 3px 6px;
  background: rgba(232, 217, 176, 0.6);
  border-radius: 2px;
}
.env-cipher span {
  color: var(--ink-rust);
  padding: 0 2px;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Handnote (bottom-right, in another hand, italic small script) */
.env-handnote {
  position: absolute;
  bottom: 3%;
  right: 5%;
  font-family: var(--hand-2);
  font-size: 0.78rem;
  color: var(--ink-blue);
  text-align: right;
  transform: rotate(-3deg);
  font-weight: 300;
  line-height: 1.25;
  max-width: 130px;
  z-index: 2;
}
.env-handnote em { font-style: italic; }

/* Burn mark (top-left corner subtle) */
.env-burn {
  position: absolute;
  top: 0;
  right: 0;
  width: 90px;
  height: 90px;
  background:
    radial-gradient(circle at 100% 0%,
      rgba(20, 5, 0, 0.9) 0%,
      rgba(80, 30, 10, 0.7) 8%,
      rgba(120, 60, 20, 0.4) 18%,
      rgba(180, 110, 50, 0.2) 30%,
      transparent 55%);
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* Fingerprint — removed the rainbow arc, keeping only a very subtle ink smudge */
.env-fingerprint {
  display: none;
}

/* ============ FLAP ============
   The flap is a triangle covering only the top-center of the envelope,
   leaving corners (with stamps) visible. Fully opaque. */
.env-flap-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48%;
  perspective: 1200px;
  pointer-events: none;
  z-index: 3;
}
.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  transform-origin: 50% 0;
  transform: rotateX(0);
  transition: transform 1.05s cubic-bezier(.55, .05, .35, 1);
  transform-style: preserve-3d;
}
/* Flap surface — a triangle inset from corners, opaque */
.env-flap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    /* fiber grain */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='3' seed='13'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.15 0 0 0 0.3 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #ddc98a 0%, #c9b478 60%, #b39d64 100%);
  background-blend-mode: multiply, normal;
  clip-path: polygon(18% 0, 82% 0, 50% 100%);
  filter: drop-shadow(0 4px 6px rgba(80, 55, 20, 0.35));
}
/* Fold shadow on the body under the flap edges */
.env-flap::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    /* left fold */
    linear-gradient(135deg, transparent 49.6%, rgba(60,35,10,0.35) 50%, transparent 50.4%),
    /* right fold */
    linear-gradient(-135deg, transparent 49.6%, rgba(60,35,10,0.35) 50%, transparent 50.4%);
  background-position: 18% 0, 82% 0;
  background-size: 42% 100%, 42% 100%;
  background-repeat: no-repeat;
  opacity: 0.6;
  pointer-events: none;
}

/* Wax seal on the flap tip — sits AT the flap's bottom point,
   sealing the flap to the body. */
.env-seal {
  position: absolute;
  bottom: -14%;
  left: 50%;
  transform: translateX(-50%);
  width: 108px;
  height: 108px;
  filter: drop-shadow(0 6px 12px rgba(20, 5, 0, 0.55));
  z-index: 4;
  pointer-events: auto;
  transition: transform .4s var(--ease);
}
.env-seal svg { width: 100%; height: 100%; overflow: visible; display: block; }
.envelope:hover .env-seal { transform: translateX(-50%) scale(1.04); }

/* Wax pulsing indicator when idle */
@keyframes seal-pulse {
  0%, 100% {
    filter: drop-shadow(0 6px 12px rgba(20, 5, 0, 0.55))
            drop-shadow(0 0 0 rgba(255, 100, 60, 0));
  }
  50% {
    filter: drop-shadow(0 6px 14px rgba(20, 5, 0, 0.65))
            drop-shadow(0 0 12px rgba(255, 100, 60, 0.35));
  }
}
.env-seal { animation: seal-pulse 3s ease-in-out infinite; }

/* ============ ENVELOPE OPENING SEQUENCE ============ */
.envelope[data-state="cracking"] .env-seal svg {
  animation: env-seal-crack .55s var(--ease) forwards;
}
@keyframes env-seal-crack {
  0%   { transform: scale(1) rotate(0); }
  40%  { transform: scale(1.1) rotate(-4deg); }
  75%  { transform: scale(0.95) rotate(5deg); opacity: 0.9; }
  100% { transform: scale(0.85) rotate(-8deg) translateY(4px); opacity: 0.6; }
}

.envelope[data-state="opening"] .env-flap,
.envelope[data-state="open"] .env-flap {
  transform: rotateX(-172deg);
}
.envelope[data-state="opening"] .env-seal,
.envelope[data-state="open"] .env-seal {
  opacity: 0.5;
  transition: opacity .5s var(--ease);
}

/* Interior of envelope (revealed when flap opens) — only in the top area
   where the flap used to sit. Below that, the body (address, stamps) stays visible. */
.env-interior {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44%;
  background: linear-gradient(180deg, #4a3210 0%, #2a1c08 100%);
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity .3s var(--ease) .35s;
  z-index: 2;
  box-shadow: inset 0 -12px 20px rgba(0,0,0,0.5);
}
.envelope[data-state="opening"] .env-interior,
.envelope[data-state="open"] .env-interior {
  opacity: 1;
}
.env-lining {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg,
      transparent 0,
      transparent 6px,
      rgba(232, 217, 176, 0.06) 6px,
      rgba(232, 217, 176, 0.06) 7px);
}

/* Letter peek visible inside envelope after opening */
.env-letter-peek {
  position: absolute;
  top: 20%;
  left: 8%;
  right: 8%;
  padding: 18px 22px;
  background: var(--paper);
  border-radius: 3px 3px 0 0;
  color: var(--ink);
  text-align: center;
  font-family: var(--serif-print);
  font-size: 0.85rem;
  transform: translateY(120%);
  opacity: 0;
  z-index: 3;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.35);
  transition: transform 1.2s var(--ease) .7s, opacity .6s var(--ease) .7s;
}
.envelope[data-state="opening"] .env-letter-peek,
.envelope[data-state="open"] .env-letter-peek {
  transform: translateY(-8%);
  opacity: 1;
}
.env-letter-peek span {
  display: block;
  line-height: 1.4;
}
.env-letter-peek em {
  color: var(--ink-rust);
  font-style: italic;
  padding: 0 4px;
}
.env-letter-peek .peek-body {
  margin-top: 8px;
  font-family: var(--hand);
  font-size: 1.15rem;
  color: var(--ink-2);
  line-height: 1.3;
}

/* Envelope-scene hint & footer */
.envelope-hint {
  margin: 0;
  font-family: var(--hand-2);
  font-size: 1rem;
  color: rgba(240, 228, 200, 0.85);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: hint-pulse 2.6s ease-in-out infinite;
  text-align: center;
}
.hint-caret {
  color: rgba(240, 228, 200, 0.6);
  font-family: var(--serif-print);
  font-size: 1.4rem;
  animation: hint-arrow 1.8s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.55; }
}
@keyframes hint-arrow {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}
.envelope-footer {
  position: absolute;
  bottom: 24px;
  left: 0; right: 0;
  text-align: center;
  margin: 0;
  font-family: var(--serif-print);
  font-style: italic;
  font-size: 0.82rem;
  color: rgba(240, 228, 200, 0.5);
  letter-spacing: 0.04em;
}

/* Responsive envelope */
@media (max-width: 640px) {
  .envelope { width: 92vw; height: 62vw; }
  .env-stamp { padding: 5px 8px; min-width: 92px; }
  .env-stamp .stamp-line-1 { font-size: 0.62rem; }
  .env-stamp .stamp-line-2 { font-size: 0.6rem; }
  .env-stamp .stamp-line-3 { font-size: 0.58rem; }
  .env-postmark { width: 66px; height: 66px; }
  .addr-main { font-size: 1.05rem; }
  .addr-sub { font-size: 0.88rem; }
  .addr-forwarded { font-size: 0.76rem; }
  .env-seal { width: 74px; height: 74px; }
  .env-cipher, .env-handnote { font-size: 0.7rem; }
  .env-handnote { max-width: 100px; }
  .envelope-footer { font-size: 0.72rem; bottom: 16px; }
}

/* Print — do not show envelope */
@media print {
  .envelope-scene { display: none; }
  body.intro .letter, body.intro .hint { opacity: 1 !important; }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
  body { font-size: 18px; }
  .letter { margin: 30px 16px 60px; padding: 44px 28px 60px; }
  .stain-coffee { top: 20px; right: -10px; width: 100px; height: 100px; }
  /* Marginalia — keep the same style but reduce indentation on small screens */
  .margin { margin-left: 24px; max-width: 100%; }
  .margin-right { margin-right: 24px; text-align: left;
    border-right: 0; border-left: 2px solid rgba(107, 58, 26, 0.45);
    border-radius: 0 3px 3px 0; padding: 8px 14px 8px 18px;
    transform: rotate(0.4deg); }
  .margin-right::before {
    content: "↳"; left: -14px; right: auto; top: 3px;
  }
  .signoff { padding-left: 20%; }
}

@media (max-width: 520px) {
  body { font-size: 17px; }
  .letter { margin: 16px 10px 40px; padding: 32px 20px 44px; }
  .paragraph, .invisible-ink { font-size: 1.1rem; }
  .salutation { font-size: 1.4rem; }
  .signoff { padding-left: 0; text-align: center; }
  .signature { margin-left: auto; margin-right: auto; }
  .invisible-ink::after { font-size: 0.68rem; top: -14px; }
  .stain-coffee { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================
   Print (yes — this letter is meant to be printable)
   ========================================================= */
@media print {
  body { background: white; }
  .desk, .hint { display: none; }
  .letter {
    box-shadow: none;
    margin: 0;
    max-width: 100%;
  }
  .invisible-ink { color: var(--ink-2) !important; }
  .invisible-ink::after { display: none; }
  .invisible-ink em { color: var(--ink) !important; }
  .seal-message { opacity: 1 !important; transform: none !important; }
}
