:root {
  --ink: #111111;
  --muted: #6b6b68;
  --line: #d9d9d3;
  --pol: clamp(145px, 17.3vw, 300px);   /* polaroid width */
  --top: clamp(72px, 12vh, 140px);    /* same as the homepage hero */
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: #fff;
  color: var(--ink);
  font-family: "Instrument Serif", Georgia, serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-align: center;
  overflow-x: clip;
}
img { display: block; height: auto; }
.sr, .hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Layout: polaroids either side of the centre ── */
.page {
  display: grid;
  grid-template-columns: var(--pol) minmax(0, 1fr) var(--pol);
  grid-template-areas: "left centre right";
  gap: clamp(20px, 3vw, 56px);
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 clamp(24px, 2.6vw, 48px) 10px;
}
.centre {
  grid-area: centre;
  padding-top: var(--top);
  display: flex; flex-direction: column; align-items: center;
}
.stack { padding-top: 34px; }
.stack--left { grid-area: left; }
.stack--right { grid-area: right; }

/* The photos run taller than the centre, so it stays in view while they scroll past.
   On shorter screens it only sticks once its last line is showing (--centre-h: its height). */
@media (min-width: 821px) {
  .centre {
    --centre-h: calc(870px + var(--top));
    position: sticky; top: min(0px, calc(100vh - var(--centre-h)));
    align-self: start;
  }
}

/* ── Centre ── */
.heading {
  font-weight: 400;
  font-size: clamp(64px, 8.3vw, 132px);
  line-height: .88;
  letter-spacing: -.018em;
  word-spacing: .02em;
  /* Instrument Serif has one weight, so a hairline outline in the text colour adds the bold.
     Smaller text (.date, .claim) needs proportionally more to look equally bold. */
  -webkit-text-stroke: .003em currentColor;
}
.by { margin-top: -4px; font-style: italic; font-size: clamp(22px, 1.8vw, 27px); line-height: 1.1; }
.crest {
  width: clamp(150px, 12.5vw, 190px);
  margin-top: 30px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.crest img {
  width: 100%;
  transform: perspective(600px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--grow, 1));
  transition: transform .45s var(--ease);
}
.date, .joined { font-size: clamp(35px, 3vw, 44px); line-height: 1.1; letter-spacing: -.02em; -webkit-text-stroke: .011em currentColor; }
.date { margin-top: 32px; }
.invite {
  margin-top: 6px;
  max-width: 400px;
  font-weight: 400;
  font-size: 21px;
  line-height: 1.3;
  color: var(--muted);
  text-wrap: balance;
}
.form { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 460px; }
/* Holds the form, then the confirmation in the same space, so the line below never moves. */
.signup { display: flex; justify-content: center; align-items: center; width: 100%; margin-top: 24px; }
/* One line at every width: matches .date where it fits, shrinks where it would not. */
.joined { font-size: min(clamp(35px, 3vw, 44px), 3.4vw); white-space: nowrap; text-decoration: underline; text-decoration-thickness: .045em; text-underline-offset: .18em; animation: joined .6s var(--ease); }
.joined:empty { display: none; }
@keyframes joined { from { opacity: 0; transform: translateY(10px); } }
.input, .btn { border-radius: 12px; font-family: inherit; -webkit-appearance: none; appearance: none; }
.input {
  width: 100%; height: 62px;
  padding: 0 20px;
  font-size: 21px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  outline: none;
  transition: border-color .3s var(--ease);
}
.input::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .input:focus { border-color: var(--ink); }
.btn {
  height: 50px;
  padding: 0 32px;
  font-size: 19px;
  white-space: nowrap;
  color: #fff;
  background: var(--ink);
  border: 0;
  cursor: pointer;
  transition: transform .35s var(--ease);
}
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.crest:focus-visible, .input:focus-visible, .btn:focus-visible, footer a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.claim { margin-top: 14px; max-width: 400px; font-size: 18px; line-height: 1.35; color: var(--ink); text-wrap: balance; font-style: italic; -webkit-text-stroke: .009em currentColor; }
@media (min-width: 1100px) {
  .claim { max-width: none; white-space: nowrap; }
}
/* Highlighter in the polaroids' border colour, drawn left to right on hover. */
.hl {
  margin: 0 -.1em;
  padding: .02em .1em;
  border-radius: 3px;
  background: linear-gradient(#f8ebd0, #f8ebd0) no-repeat 0 0 / 0% 100%;
  transition: background-size .5s var(--ease);
}
.hl:hover { background-size: 100% 100%; }

.status { margin-top: 12px; font-size: 19px; line-height: 1.35; }
.status:empty { margin: 0; }

/* ── Polaroids ── */
.stack { display: flex; flex-direction: column; align-items: center; }
.polaroid {
  position: relative;
  width: 100%;
  border-radius: 3% / 2%;
  box-shadow: 0 1px 3px rgba(60, 45, 25, .28), 0 16px 30px -12px rgba(60, 45, 25, .4);
  transform: translateX(var(--x, 0)) rotate(var(--r, 0deg));
  transition: transform .6s var(--ease);
  animation: lay .9s var(--ease) backwards;
}
.polaroid + .polaroid { margin-top: -20%; }
/* Earlier ones sit on top, so no handwritten title is ever covered. */
.polaroid:nth-child(1) { z-index: 5; }
.polaroid:nth-child(2) { z-index: 4; }
.polaroid:nth-child(3) { z-index: 3; }
.polaroid:nth-child(4) { z-index: 2; }
.polaroid:nth-child(5) { z-index: 1; }
@keyframes lay { from { opacity: 0; transform: translate(var(--x, 0), -26px) rotate(calc(var(--r, 0deg) * 2.4)); } }
.polaroid:nth-child(2) { animation-delay: .1s; }
.polaroid:nth-child(3) { animation-delay: .2s; }
.polaroid:nth-child(4) { animation-delay: .3s; }
.polaroid:nth-child(5) { animation-delay: .4s; }

.stack--left  .polaroid:nth-child(1) { --r: -4.5deg; --x: -2%; }
.stack--left  .polaroid:nth-child(2) { --r: 3.5deg;  --x: 5%; }
.stack--left  .polaroid:nth-child(3) { --r: -2.5deg; --x: -4%; }
.stack--left  .polaroid:nth-child(4) { --r: 5deg;    --x: 3%; }
.stack--left  .polaroid:nth-child(5) { --r: -3.5deg; --x: -1%; }
.stack--right .polaroid:nth-child(1) { --r: 3.5deg;  --x: 2%; }
.stack--right .polaroid:nth-child(2) { --r: -5deg;   --x: -4%; }
.stack--right .polaroid:nth-child(3) { --r: 2.5deg;  --x: 4%; }
.stack--right .polaroid:nth-child(4) { --r: -3deg;   --x: -3%; }
.stack--right .polaroid:nth-child(5) { --r: 4.5deg;  --x: 1%; }

@media (hover: hover) {
  .stack .polaroid:hover { z-index: 6; transform: translateX(var(--x, 0)) rotate(0deg) scale(1.06); }
}

footer { padding: 8px 24px 44px; font-size: 18px; }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--ink); }

/* ── Phones: centre first, the two stacks side by side beneath it ── */
@media (max-width: 820px) {
  .page {
    --pol: 1fr;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "centre centre" "left right";
    gap: 48px 20px;
    padding: 0 24px 48px;
  }
  .stack--right { margin-top: 36px; }
  .joined { font-size: min(35px, 5.9vw); }
}
@media (prefers-reduced-motion: reduce) {
  .polaroid, .crest img, .hl, .joined { animation: none; transition: none; }
}
