:root {
  --night-0: #050919;
  --night-1: #0b1433;
  --night-2: #1a2c66;
  --frost: #eef4ff;
  --ice: #cfe3ff;
  --silver: #c8d3e6;
  --silver-dim: #8e9dbb;
  --ink: #0e1a3a;
  --muted: #5b6b8c;
  --accent: #2c4a9e;
  --paper-letter: #f6f1e4;
  /* Paper texture: fine fibres plus soft cloudy mottling. */
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7 .45' numOctaves='3' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .34 0 0 0 0 .24 0 0 0 .8 -.3'/%3E%3C/filter%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .44 0 0 0 0 .34 0 0 0 .38 -.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  --display: "Cormorant Garamond", Georgia, serif;
  --engraved: "Cinzel", "Cormorant Garamond", Georgia, serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html.access-pending body > :not(#access-message):not(noscript),
html.access-denied body > :not(#access-message):not(noscript) {
  display: none !important;
}

.access-message {
  position: relative;
  z-index: 5;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.access-message[hidden] {
  display: none;
}

.access-message-card {
  width: min(100%, 540px);
  padding: clamp(28px, 7vw, 52px);
  border: 1px solid rgba(207, 227, 255, 0.35);
  border-radius: 20px;
  background: rgba(11, 20, 51, 0.88);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.access-message-card h1 {
  margin: 12px 0 18px;
  font-family: var(--display);
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 500;
  line-height: 1.05;
}

.access-message-card p {
  margin: 0;
  color: var(--silver);
  line-height: 1.6;
}

.access-message-card a {
  color: var(--ice);
}

/* Rapid taps shouldn't trigger double-tap zoom (it breaks the animations).
   Pinch-zoom still works, so the page stays accessible. */
html,
body,
button,
a,
dialog {
  touch-action: manipulation;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(64, 104, 190, 0.45), transparent 70%),
    radial-gradient(ellipse at 50% 120%, var(--night-2) 0%, var(--night-1) 45%, var(--night-0) 100%) fixed;
  color: var(--frost);
  font-family: var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Film grain over everything for depth. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Background ---------- */

#ambient-snow,
#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#ambient-snow {
  z-index: 0;
}

#fx {
  z-index: 3;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  filter: blur(60px);
  opacity: 0.42;
}

.aurora span {
  position: absolute;
  width: 70vmax;
  height: 30vmax;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: drift 24s ease-in-out infinite alternate;
}

.aurora span:nth-child(1) {
  top: -8vmax;
  left: -10vmax;
  background: radial-gradient(closest-side, rgba(80, 230, 190, 0.7), transparent);
}

.aurora span:nth-child(2) {
  top: 0;
  right: -20vmax;
  background: radial-gradient(closest-side, rgba(90, 140, 255, 0.6), transparent);
  animation-duration: 30s;
}

.aurora span:nth-child(3) {
  top: 10vmax;
  left: 20vmax;
  background: radial-gradient(closest-side, rgba(170, 110, 255, 0.45), transparent);
  animation-duration: 38s;
}

@keyframes drift {
  from { transform: translate(0, 0) rotate(-8deg); }
  to { transform: translate(8vmax, 4vmax) rotate(6deg); }
}

.draft-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  padding: 6px 14px;
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  background: #b4232a;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Landing ---------- */

.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5svh, 48px);
  padding: 64px 16px 40px;
  transition: transform 0.8s ease, opacity 0.8s ease;
}

/* Dim (not blur) the scene behind the card: blurring the whole scene while the title is
   being written made slow phones drop frames. */
body.revealed .stage {
  transform: scale(0.94);
  opacity: 0.2;
}

.heading {
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--engraved);
  font-size: clamp(0.75rem, 2.4vw, 0.95rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  color: var(--silver);
}

.title {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  line-height: 1;
  color: #e9f0ff;
  text-shadow: 0 0 24px rgba(170, 200, 255, 0.45), 0 1px 0 rgba(255, 255, 255, 0.4);
  perspective: 600px;
}

/* ---------- Envelope ---------- */

.envelope-btn {
  --w: min(76vw, 420px, 70svh);
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 20px;
  -webkit-tap-highlight-color: transparent;
  /* no text selection or long-press menu while tapping away at the ice */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.envelope-btn:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 22px;
}

.shaker {
  display: block;
  position: relative;
  transform-origin: 50% 85%;
  will-change: transform;
}

.envelope {
  position: relative;
  display: block;
  width: var(--w);
  aspect-ratio: 3 / 2;
  perspective: 1100px;
  filter: drop-shadow(0 26px 30px rgba(0, 0, 0, 0.45));
}

.env-back {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #0c1533, #111d45);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
}

.letter {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 7%;
  height: 86%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 21%;
  gap: 0.5em;
  border-radius: 4px;
  background:
    var(--paper-grain),
    radial-gradient(ellipse at 50% 0%, rgba(255, 253, 246, 0.8), transparent 70%),
    var(--paper-letter);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.25);
  color: var(--ink);
  transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.letter::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(120, 95, 50, 0.25);
  border-radius: 2px;
}

/* ---------- Stamp: icy ink impression of the Armada logo ---------- */

.ink-stamp {
  position: absolute;
  overflow: visible;
  pointer-events: none;
  opacity: 0.85;
  mix-blend-mode: multiply;
  transform: rotate(-12deg);
}

/* Postage stamp on the letter inside the envelope. */
.stamp {
  position: absolute;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 1.5px 1.5px rgba(70, 50, 15, 0.35));
}

.letter-stamp {
  top: 7%;
  right: 6%;
  width: 13%;
  transform: rotate(7deg);
}

.card-stamp {
  top: 18px;
  left: 20px;
  width: 60px;
}

.letter-kicker {
  font-family: var(--engraved);
  font-size: calc(var(--w) * 0.026);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.letter-title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: calc(var(--w) * 0.066);
  line-height: 1;
  white-space: nowrap;
}

.envelope.letter-out .letter {
  transform: translateY(-62%);
}

/* Once opened, the letter takes over as the heading. */
.heading {
  transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

body.envelope-open .heading {
  opacity: 0;
  transform: translateY(-24px);
}

.env-front {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
}

.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: 100%;
  height: 59%;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
}

.env-flap svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.4));
}

.envelope.flap-open .env-flap {
  animation: flap-open 1s cubic-bezier(0.55, 0, 0.25, 1) forwards;
}

@keyframes flap-open {
  0% { transform: rotateX(0); z-index: 4; }
  49% { z-index: 4; }
  50% { z-index: 1; }
  100% { transform: rotateX(178deg); z-index: 1; }
}

.seal {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 21%;
  aspect-ratio: 1;
  transform: translate(-50%, -64%);
  backface-visibility: hidden;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45));
}

.seal svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Ice ---------- */

.ice {
  position: absolute;
  inset: -8% -6% -9% -7%;
  z-index: 6;
  display: block;
  border-radius: 22px 30px 18px 34px / 26px 18px 30px 22px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(210, 232, 255, 0.28), rgba(120, 170, 230, 0.12) 50%, rgba(220, 240, 255, 0.24));
  -webkit-backdrop-filter: blur(2.5px) saturate(1.15);
  backdrop-filter: blur(2.5px) saturate(1.15);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.45),
    inset 0 0 28px rgba(255, 255, 255, 0.3),
    inset 0 -14px 34px rgba(80, 140, 220, 0.25),
    0 24px 50px rgba(0, 0, 0, 0.35);
}

/* display:none, not visibility:hidden. Chrome keeps painting backdrop-filter
   on hidden elements, which left the envelope blurred after the ice broke. */
.ice.gone {
  display: none;
}

.ice-frost {
  position: absolute;
  inset: 0;
  background: url("../assets/frost.webp") center / cover;
  opacity: 0.4;
  mix-blend-mode: screen;
}

.ice-shine {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 18%, rgba(255, 255, 255, 0.32) 26%, transparent 34%, transparent 58%, rgba(255, 255, 255, 0.16) 63%, transparent 69%),
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, 0.25), transparent 50%);
}

.ice::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px 26px 14px 30px / 22px 14px 26px 18px;
  pointer-events: none;
}

.cracks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cracks path {
  stroke-linecap: round;
  stroke-linejoin: miter;
}

/* Crack layers (see drawCracks in js/envelope.js) */
.crack-planes path {
  fill: rgba(230, 244, 255, 0.26);
}

.crack-shadows path {
  fill: none;
  stroke: rgba(10, 28, 65, 0.45);
  stroke-width: 0.9;
}

.crack-cores path {
  fill: rgba(255, 255, 255, 0.95);
}

.crack-chord {
  fill: none !important;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 0.9;
}

.crack-hackles path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.65);
  stroke-width: 0.55;
}

.crack-glints path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.8;
}

.crack-micro {
  fill: none;
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 0.6;
}

.hint {
  min-height: 1.4em;
  margin: 0;
  font-family: var(--engraved);
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-transform: uppercase;
  color: rgba(220, 235, 255, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* ---------- Invitation card ---------- */

.card {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100svh - 24px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  overflow: auto;
  background:
    var(--paper-grain),
    radial-gradient(ellipse at 50% 0%, rgba(255, 253, 246, 1), transparent 60%),
    linear-gradient(180deg, #fbf8ef, #f1ebdc);
  color: var(--ink);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 70px rgba(160, 200, 255, 0.28);
}

.card::backdrop {
  background: rgba(4, 8, 26, 0.35);
}

/* Sizes below scale with viewport height too, so the whole card fits without scrolling. */
.card-inner {
  position: relative;
  padding: clamp(16px, 3.2svh, 40px) clamp(16px, 4vw, 28px) clamp(16px, 3svh, 30px);
  text-align: center;
}

.card-inner::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(140, 115, 70, 0.3);
  border-radius: 14px;
  pointer-events: none;
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(14, 26, 58, 0.06);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.close:hover {
  background: rgba(14, 26, 58, 0.12);
}

.kicker {
  margin: 0 0 clamp(4px, 1svh, 10px);
  font-family: var(--engraved);
  font-size: clamp(0.62rem, 1.5svh, 0.72rem);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
}

.recipient {
  margin: 0 0 clamp(4px, 1svh, 8px);
  font-family: var(--display);
  font-size: clamp(1.05rem, 2.8svh, 1.35rem);
  font-style: italic;
  color: #284c82;
}

/* Title: handwritten letters as SVG outlines (tools/make_title_svg.py), traced in on open. */
.card h1 {
  margin: 0 0 clamp(2px, 0.6svh, 6px);
  line-height: 0;
}

.title-art {
  display: inline-block;
  height: calc(2.2 * clamp(2.2rem, min(10vw, 6.2svh), 4rem));
  max-width: 100%;
  overflow: visible;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.9)) drop-shadow(0 0 6px rgba(150, 200, 245, 0.45));
}

.tagline {
  margin: clamp(2px, 0.8svh, 8px) 0 0;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1rem, 2.6svh, 1.35rem);
  color: #3b5b9a;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 70%;
  margin: clamp(8px, 2svh, 20px) auto;
  color: #7fa3d8;
}

.divider-flake {
  flex: none;
  width: clamp(24px, 4svh, 32px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 3px rgba(150, 200, 245, 0.55)) drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8));
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor);
}

.divider::after {
  background: linear-gradient(90deg, currentColor, transparent);
}

.intro {
  max-width: 40ch;
  margin: 0 auto clamp(10px, 2.4svh, 24px);
  font-size: clamp(0.85rem, 1.9svh, 1rem);
  line-height: 1.5;
  color: #33415f;
}

/* Special guest: its own centred row in the middle of the details */
.details .wide {
  grid-column: 1 / -1;
}

.details .guest-name {
  font-size: clamp(1.15rem, 2.9svh, 1.5rem);
}

.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 2.2svh, 20px) 14px;
  margin: 0 0 clamp(14px, 3svh, 28px);
}

.details dt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: clamp(2px, 0.6svh, 6px);
  font-family: var(--engraved);
  font-weight: 600;
  font-size: clamp(0.66rem, 1.6svh, 0.78rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.details dt::before,
.details dt::after {
  content: "";
  width: 12px;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}

.details dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.02rem, 2.5svh, 1.3rem);
  line-height: 1.2;
}

.tz,
.venue-address {
  display: block;
  margin-top: 2px;
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(0.72rem, 1.6svh, 0.8rem);
  color: var(--muted);
}

a.venue-address[href] {
  color: var(--accent);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: clamp(10px, 1.7svh, 14px) 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1b2e6b, var(--accent));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(27, 46, 107, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-icon {
  flex: none;
  margin: -3px 0;
  transform: rotate(-15deg); /* tip the ticket up a little */
}

.cta > span {
  white-space: nowrap;
}

@media (max-width: 400px) {
  .cta {
    gap: 8px;
    padding-left: 20px;
    padding-right: 20px;
  }
}

.cta[href]:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(27, 46, 107, 0.45);
}

.cta[aria-disabled="true"] {
  cursor: not-allowed;
}

.note,
.contact {
  max-width: 40ch;
  margin: clamp(6px, 1.4svh, 14px) auto 0;
  font-size: clamp(0.74rem, 1.7svh, 0.85rem);
  line-height: 1.45;
  color: var(--muted);
}

.contact a[href] {
  color: var(--accent);
}

/* Unfilled config values: loud on purpose. */
.needs-input {
  outline: 2px dashed #e5484d;
  outline-offset: 2px;
  border-radius: 4px;
  background-color: rgba(229, 72, 77, 0.1);
}

.noscript {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 16px;
}

/* Short screens: tighten vertical rhythm so the whole card still fits without scrolling. */
@media (max-height: 700px) {
  .divider {
    margin: 6px auto;
  }
  .intro {
    margin-bottom: 8px;
  }
}

@media (max-width: 480px) {
  /* room for the stamp in the top-left corner */
  .card-inner {
    padding-top: 54px;
  }
  .card-stamp {
    top: 14px;
    right: auto;
    left: 12px;
    width: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .envelope.flap-open .env-flap {
    transform: rotateX(178deg);
    z-index: 1;
  }
}
