/* ==========================================================================
   The Invitation — shared styles
   Dark medieval-fae: parchment, forest canopy, candlelight. Mobile-first.
   ========================================================================== */

:root {
  --ink: #10160f;
  --forest-deep: #182620;
  --forest: #223a2f;
  --parchment: #ece2c8;
  --parchment-dim: #c9bd9c;
  --gold: #c9a24b;
  --gold-soft: #e0bf72;
  --gold-dim: #8a723e;

  --font-display: "Cinzel", "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "EB Garamond", "Iowan Old Style", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, var(--forest) 0%, var(--forest-deep) 45%, var(--ink) 100%);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 1.08rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Soft vignette overlay, purely decorative */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.display-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 1.7rem;
  color: var(--parchment);
  text-shadow: 0 0 18px rgba(201, 162, 75, 0.25);
  margin: 0 0 0.5rem;
}

.subtitle {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--parchment-dim);
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  margin: 0;
}

/* Vine divider — subtle repeating tile, decorative only */
.vine-divider {
  height: 20px;
  margin: 0 auto 2rem;
  max-width: 260px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='20' viewBox='0 0 120 20'><path d='M0 10 Q15 2 30 10 T60 10 T90 10 T120 10' stroke='%23c9a24b' stroke-width='1.3' fill='none' opacity='0.55'/><path d='M15 10 q-4 -7 -10 -5' stroke='%23c9a24b' stroke-width='1.1' fill='none' opacity='0.4'/><path d='M45 10 q4 -7 10 -5' stroke='%23c9a24b' stroke-width='1.1' fill='none' opacity='0.4'/><path d='M75 10 q-4 -7 -10 -5' stroke='%23c9a24b' stroke-width='1.1' fill='none' opacity='0.4'/><path d='M105 10 q4 -7 10 -5' stroke='%23c9a24b' stroke-width='1.1' fill='none' opacity='0.4'/></svg>");
  background-repeat: repeat-x;
  background-position: center;
  opacity: 0.7;
}

/* ---- Prose ---- */

.prose {
  flex: 1;
  font-size: 1.05rem;
}

.prose p {
  margin: 0 0 1.2em;
  text-wrap: pretty;
}

.prose p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 2.6em;
  float: left;
  line-height: 0.8;
  padding: 0.05em 0.08em 0 0;
  color: var(--gold-soft);
}

.prose .signature {
  font-style: italic;
  color: var(--parchment-dim);
  margin-top: 1.6em;
}

.prose .postscript {
  font-style: italic;
  font-size: 0.95em;
  color: var(--parchment-dim);
  padding-top: 1em;
  border-top: 1px solid rgba(201, 162, 75, 0.2);
}

/* Hidden acrostic letters. At rest they're indistinguishable from normal
   text — capitalization is the only clue. A click marks a letter as
   found and gives it the color/glow treatment, in place. */
.rune {
  cursor: pointer;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.rune:focus-visible {
  text-decoration: underline;
  text-decoration-color: currentColor;
  outline: none;
}

.rune.found {
  color: var(--gold-soft);
  font-weight: 600;
  text-shadow: 0 0 8px rgba(224, 191, 114, 0.45);
  cursor: default;
  text-decoration: none;
}

/* ---- Modal backdrop, shared by the unlock prompt and the parchment reveal ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(8, 12, 8, 0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.4s ease;
}

/* [hidden] vs. .modal-backdrop's own `display: flex` are equal specificity;
   without this, the transparent backdrop still renders full-viewport and
   swallows clicks (including on the runes) even while "hidden". */
.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
  background: rgba(8, 12, 8, 0.78);
}

/* ---- Unlock modal ---- */

.unlock {
  width: 100%;
  max-width: 320px;
  padding: 1.5rem 1.5rem 1.6rem;
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  text-align: center;
  background: rgba(24, 38, 32, 0.97);
  opacity: 0;
  transform: scale(0.92);
}

.modal-backdrop.visible .unlock {
  animation: modal-pop 0.35s ease forwards;
}

#unlock-form {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#unlock-input {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--parchment);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  padding: 0.55rem 0.8rem;
  min-width: 0;
  flex: 1 1 10rem;
  max-width: 14rem;
}

#unlock-input:focus-visible {
  outline: none;
  border-color: var(--gold);
}

#unlock-form button {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--gold-soft);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

#unlock-form button:hover,
#unlock-form button:focus-visible {
  background: var(--gold);
  box-shadow: 0 0 18px rgba(224, 191, 114, 0.45);
  outline: none;
}

/* ---- Parchment modal (secondary prose, unfurls on top of the page) ----
   Textured, not just cream-colored: layered stains, a fiber-grain SVG
   turbulence texture, and a torn (clip-path) edge instead of a clean
   rectangle. filter:drop-shadow is used instead of box-shadow so the
   shadow follows the torn silhouette rather than the bounding box. */

.parchment-card {
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  color: var(--ink);
  padding: 2.5rem 2rem;
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 18% 12%, rgba(110, 80, 35, 0.14), transparent 55%),
    radial-gradient(ellipse at 85% 88%, rgba(90, 65, 30, 0.16), transparent 60%),
    radial-gradient(ellipse at 60% 35%, rgba(150, 120, 70, 0.1), transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0.3 0 0 0 0 0.24 0 0 0 0 0.13 0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-blend-mode: multiply, multiply, multiply, multiply;
  clip-path: polygon(
    0% 2%, 12.5% 0%, 25% 3%, 37.5% 1%, 50% 4%, 62.5% 0%, 75% 3%, 87.5% 1%, 100% 3%,
    100% 97%, 87.5% 100%, 75% 96%, 62.5% 99%, 50% 96%, 37.5% 100%, 25% 97%, 12.5% 99%, 0% 97%
  );
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.5));
  opacity: 0;
  transform-origin: top center;
}

.modal-backdrop.visible .parchment-card {
  animation: parchment-unfurl 0.8s cubic-bezier(0.22, 0.7, 0.3, 1) forwards;
}

.parchment-content p {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 1em;
}

.parchment-content p:last-child {
  margin-bottom: 0;
}

@keyframes modal-pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes parchment-unfurl {
  0% { transform: scaleY(0.06) rotate(-4deg) translateY(-12px); opacity: 0; }
  55% { transform: scaleY(1.04) rotate(1.5deg) translateY(2px); opacity: 1; }
  75% { transform: scaleY(0.98) rotate(-0.5deg) translateY(-1px); }
  100% { transform: scaleY(1) rotate(0deg) translateY(0); opacity: 1; }
}

/* ---- Secret page (Page 2) ---- */

.secret-page .page {
  max-width: 480px;
  padding-top: 4rem;
  padding-bottom: 4rem;
  justify-content: center;
}

.secret-page .prose {
  font-size: 1.08rem;
}

.secret-page .prose p {
  margin-bottom: 1.4em;
}

/* ---- Motion ---- */

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop.visible .unlock,
  .modal-backdrop.visible .parchment-card {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ---- Small-phone tightening ---- */

@media (max-width: 360px) {
  .page {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }
  .display-title {
    font-size: 1.45rem;
  }
}

/* ---- Wider viewports ---- */

@media (min-width: 700px) {
  .page {
    padding-top: 4.5rem;
  }
  .display-title {
    font-size: 2.1rem;
  }
  .prose {
    font-size: 1.15rem;
  }
}
