/* ---------- Fonts ----------
   Spirits (Latinotype) is the only typeface; check web licence before launch (see README).
   "Nothing You Could Do" (Google Fonts) is the handwritten accent. */
@font-face { font-family: "Spirits"; src: url("assets/fonts/Spirits-Neutral-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Spirits"; src: url("assets/fonts/Spirits-Neutral.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Spirits"; src: url("assets/fonts/Spirits-Neutral-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Spirits"; src: url("assets/fonts/Spirits-Neutral-Black.woff2") format("woff2"); font-weight: 900; font-display: swap; }
@font-face { font-family: "Baligo"; src: url("assets/fonts/Baligo-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Baligo"; src: url("assets/fonts/Baligo-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Baligo"; src: url("assets/fonts/Baligo-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Spirits Sharp"; src: url("assets/fonts/Spirits-Sharp-Black.woff2") format("woff2"); font-weight: 900; font-display: swap; }

/* ---------- Palette: the mood board swatches + one dark ---------- */
:root {
  --powder: #F7F6EE;
  --orange: #F19134;
  --blue:   #AFCDE9;
  --butter: #F3E7B2;
  --dark:   #322C17;
  --sky-top: #A4ADAA;   /* sampled from the photo so the edges never show */

  --serif: "Spirits", Georgia, serif;
  --hand: "Nothing You Could Do", cursive;
  --hand-sm: "Baligo", "Nothing You Could Do", cursive;
  --hand-sm-track: -0.06em;   /* Baligo is loosely spaced out of the box */
  --gutter: clamp(20px, 6vw, 96px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }  /* no double-tap zoom; pinch still works */
body {
  margin: 0;
  background: var(--powder);
  color: var(--dark);
  font-family: var(--serif);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }

.hand { font-family: var(--hand); font-weight: 400; }
.hand-sm { font-family: var(--hand-sm); font-weight: 400; letter-spacing: var(--hand-sm-track); }

/* ---------- Scene: fixed to the window, content scrolls between the two layers ---------- */
.scene {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100lvh;                  /* large viewport: doesn't jump when iOS hides its toolbar */
  overflow: hidden;
  pointer-events: none;            /* clicks go through to the page */
}
.scene--back  { z-index: 0; background: var(--sky-top); }
.page         { position: relative; z-index: 1; }
.scene--front { z-index: 2; }

.intro { position: relative; height: 100svh; }

/* JS sets --img-w/--img-h/--img-x/--img-y so both photo layers line up exactly */
.layer img {
  position: absolute;
  left: 0; top: 0;
  width: var(--img-w, 100%);
  height: var(--img-h, auto);
  max-width: none;
  transform: translate3d(var(--img-x, 0px), var(--img-y, 0px), 0);
  will-change: transform;          /* keep both photos on their own GPU layers while the title moves */
  user-select: none;
  -webkit-user-drag: none;
}

.layer--wash {
  position: absolute;
  inset: 0;
  background: url("assets/img/paper.png") 0 0 / 384px 384px, var(--powder);
  opacity: 0;                      /* main.js fades this in with scroll */
  will-change: opacity;
}

.hero__title {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  top: var(--title-top, 18svh);
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-weight: 500;
  color: var(--orange);
  text-transform: uppercase;
  line-height: 0.86;
  font-size: var(--title-size, 22vw);
  pointer-events: none;
}
.hero__title .line {
  display: block;
  width: fit-content;
  margin-inline: auto;
  transform-origin: 50% 100%;
  will-change: transform;          /* main.js sinks each line at its own pace as you scroll */
  animation: rise 1.1s cubic-bezier(.2, 1.4, .4, 1) both;
}
.hero__title .line:nth-child(2) { animation-delay: .12s; }
.hero__title .line:nth-child(3) { animation-delay: .24s; }
.hero__title .tt { letter-spacing: 0.06em; }  /* the TT crossbars touch by default */

@keyframes rise {
  from { translate: 0 60%; opacity: 0; }
  to   { translate: 0 0;   opacity: 1; }
}

.hero__cue {
  position: absolute;
  right: var(--gutter);
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px;
  font-family: var(--hand-sm);
  font-weight: 400;
  letter-spacing: var(--hand-sm-track);
  font-size: 26px;
  color: var(--powder);
  transform: rotate(-4deg);
  transition: opacity .25s ease;
}
.hero__cue.is-gone { opacity: 0; }
.hero__cue svg { animation: nudge 2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(5px); } }

/* ---------- Save the date (after the card inspo: one ink, hand-lettered, doodles) ---------- */
.std {
  position: relative;
  isolation: isolate;
  /* bottom padding (set by main.js) lets the last line scroll up clear of the couple */
  padding: clamp(40px, 8vw, 90px) var(--gutter) var(--tail, 50vh);
  text-align: center;
  overflow-x: clip;        /* stop doodles widening the page, but never crop vertically (Save the Date leads upward) */
}
.std__inner {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
}
.std__details { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 5; }   /* above the floating hearts, so an open calendar menu is never covered */
/* the details (and heart) wait for "Save the Date" to be written, then fade in
   one after another, in quick succession, rather than as a single block */
.js .std__details > * {
  opacity: 0;
  translate: 0 12px;
  transition: opacity 1s cubic-bezier(.45, 0, .3, 1) var(--fd, 0s), translate 1.2s cubic-bezier(.25, .6, .3, 1) var(--fd, 0s);
}
.js .std__details > :nth-child(2) { --fd: .12s; }
.js .std__details > :nth-child(3) { --fd: .24s; }
.js .std__details > :nth-child(4) { --fd: .36s; }
.js .std__details > :nth-child(5) { --fd: .48s; }
.js .std__details > :nth-child(6) { --fd: .60s; }
.js .std .heart { opacity: 0; transition: opacity 1s cubic-bezier(.45, 0, .3, 1) .75s, transform .2s ease; }
.js .std.is-written .std__details > * { opacity: 1; translate: 0 0; }
.js .std.is-written .heart { opacity: 1; }

/* big marker-ish lettering: "Nothing You Could Do" glyphs as inline SVG (see make-lettering.py),
   thickened like a felt pen. font-size still sets the scale: the SVG is sized in em. */
.std__title {
  position: relative;
  margin: 0 0 30px;
  font-size: clamp(64px, 17vw, 132px);
  line-height: 0.92;
  color: var(--orange);
}
.lettering { display: block; width: 4.245em; height: 1.84em; overflow: visible; }   /* 4347 x 1884 font units */
.lettering .ink { fill: currentColor; stroke: currentColor; stroke-width: 36; stroke-linejoin: round; paint-order: stroke fill; }
.lettering .pen { fill: none; stroke: #fff; stroke-width: 175; stroke-linecap: round; stroke-linejoin: round; }

.doodle { position: absolute; overflow: visible; }
.doodle path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.doodle--sparkles { width: 0.42em; height: 0.56em; left: -0.62em; top: 0.85em; color: var(--orange); }
.doodle .ink { fill: currentColor; stroke: currentColor; stroke-width: 1.6; vector-effect: non-scaling-stroke; }  /* marker-tip corners */
.doodle .tick { stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.doodle--star { width: 0.3em; height: 0.3em; right: -0.52em; top: -0.16em; color: var(--orange); transform: rotate(12deg); }

.std__names {
  font-weight: 400;
  font-size: clamp(27px, 7vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.rule { display: block; width: 110px; height: 10px; margin: 16px auto 22px; overflow: visible; color: var(--blue); }
.std .rule path { stroke-width: 2.8; }  /* pale blue needs a touch more weight */
.rule--short { width: 80px; margin: 22px auto 26px; }
.rule path, .doodle--heart path, .doodle--arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: var(--draw, 0);
  transition: stroke-dashoffset .6s cubic-bezier(.6, 0, .2, 1) var(--d, .1s);
}
.js .reveal { --draw: 1; }
.js .reveal.is-in { --draw: 0; }
.js .reveal:not(.is-in), .js .reveal:not(.is-in) * { transition: none !important; }  /* hide instantly, animate only on the way in */

/* drawing order: sparkles, star, underline, underline, arrow, heart */
.doodle--sparkles { --d: .05s; }
.doodle--star     { --d: .2s; }
.rule             { --d: .35s; }
.rule--short      { --d: .75s; }
.std__countdown   { --d: 1.15s; }
.doodle--heart    { --d: 1.05s; }

.std__date {
  font-weight: 900;
  font-size: clamp(46px, 12vw, 76px);
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: lining-nums;
}
.std__date .sep { display: inline-block; margin: 0 0.18em; }

.std__place { margin-top: 10px; font-size: clamp(27px, 7.2vw, 36px); line-height: 1.2; }

.doodle--heart { position: static; display: block; width: 40px; height: 40px; color: var(--orange); transform: rotate(-6deg); }
.std .doodle--heart path {
  stroke-width: 2.6;
  fill: currentColor;
  fill-opacity: 0;
  transition: stroke-dashoffset .6s cubic-bezier(.6, 0, .2, 1) var(--d, .1s), fill-opacity .35s ease;
}

/* ---------- Desktop: "Save the Date" on the left, details on the right, the couple in between ---------- */
@media (min-width: 1000px) and (min-aspect-ratio: 1/1) {
  .std { padding-top: clamp(60px, 9vh, 120px); }
  .std__inner {
    max-width: none;
    margin: 0;
    display: grid;
    /* left: Save the Date · middle: the couple (and the heart above them) · right: details.
       main.js sizes the columns from where the couple actually stands in the photo. */
    grid-template-columns: var(--cols, 1fr clamp(220px, 21vw, 400px) 1fr);
    align-items: start;
  }
  .std__title   { grid-column: 1; grid-row: 1; }
  .std__details { grid-column: 3; grid-row: 1; margin-top: var(--details-drop, 9vh); }   /* sits lower than Save the Date */
  /* the heart floats over the couple's heads; main.js sets the lift so the page ends with it there */
  .heart { grid-column: 2; grid-row: 1; justify-self: center; align-self: end; margin: 0 0 var(--heart-lift, 0px); }
  /* reaches past its column into the sky above the couple (main.js sets how far); 0.35em = room for the staggered "the Date" */
  .std__title { justify-self: end; margin: 10px calc(0.35em - var(--title-overhang, 0px)) 0 0;
    font-size: var(--std-title-size, clamp(72px, 7vw, 150px)); }
  .std__names, .std__date { white-space: nowrap; }
  .std__names { font-size: clamp(28px, 2.85vw, 54px); }
  .std__date { font-size: clamp(48px, 5.2vw, 76px); }
  .std__details { align-items: flex-start; text-align: left; }
  /* bigger doodles on desktop */
  .doodle--sparkles { width: 0.62em; height: 0.83em; left: -0.82em; top: 0.7em; }
  .doodle--star { width: 0.46em; height: 0.46em; right: -0.62em; top: -0.3em; }
  .rule { margin-left: 4px; margin-right: 0; }
}

/* ---------- Easter egg: click the heart, it fills and sends a heart floating up ---------- */
.heart {
  margin-top: 30px;               /* phones; the desktop layout positions it separately */
  padding: 6px;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;      /* quick taps don't trigger iOS double-tap zoom */
  translate: var(--heart-x, 0px) 0; /* main.js centres it on the couple's heads */
  transition: transform .2s ease;
}
.heart:hover { transform: scale(1.08) rotate(-3deg); }
.heart:focus-visible { outline: 2px dashed var(--orange); outline-offset: 2px; border-radius: 50%; }
.heart.is-full .doodle--heart path { fill-opacity: 1; transition-duration: .6s, .12s; }
.heart.is-squish .doodle--heart { animation: squish .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes squish {
  0%   { scale: 1; }
  35%  { scale: 1.28 0.86; }
  70%  { scale: 0.92 1.1; }
  100% { scale: 1; }
}

.floater {
  position: absolute;
  z-index: 4;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;   /* centred on its start point */
  pointer-events: none;
  color: var(--orange);
}
.floater path { fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* countdown sits under the calendar button, its arrow pointing back up at it. The note takes no width
   (width: 0, text overflows to the right), so the group is exactly as wide as the button: the button stays
   centred on phones, and the arrow tip always lands just inside the button's left edge. */
.std__calwrap { display: flex; flex-direction: column; align-items: flex-start; }
.std__countdown {
  display: flex; align-items: flex-end; gap: 2px;
  width: 0;
  margin: 6px 0 0 24px;
  font-size: 25px;
  line-height: 1;
  color: var(--dark);
  white-space: nowrap;
  transform: rotate(-3deg);
}
.std__countdown[hidden] { display: none; }
.std__countdown span { margin-bottom: 4px; }
/* the note is "written" left to right once its arrow has finished drawing (arrow: --d 1.15s + .6s) */
.js .std__countdown span {
  clip-path: inset(-20% 100% -20% 0);
  transition: clip-path .75s cubic-bezier(.45, .05, .4, 1) 1.7s;
}
.js .std__countdown.is-in span { clip-path: inset(-20% 0 -20% 0); }
.doodle--arrow { position: static; flex: none; width: 38px; height: 44px; color: var(--orange); }

/* ---------- Add to calendar (felt-pen frame) ---------- */
.cal { position: relative; }
.pen {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  overflow: visible;
  pointer-events: none;
}
.pen path {
  fill: none;
  stroke: var(--dark);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.pen .pen__fill { fill: transparent; stroke: none; transition: fill .18s ease; }

.cal__button {
  position: relative;
  display: inline-flex; align-items: center;
  min-height: 54px;
  padding: 2px 26px 0;
  border: 0;
  background: none;
  color: var(--dark);
  font-family: var(--hand-sm);
  font-weight: 700;              /* Baligo Bold */
  font-size: 27px;
  letter-spacing: var(--hand-sm-track);
  cursor: pointer;
}
.cal__button > span { position: relative; }
.cal__button:hover .pen__fill,
.cal__button[aria-expanded="true"] .pen__fill { fill: var(--butter); }
.cal__button:focus-visible,
.cal__menu a:focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }

.cal__menu {
  position: absolute;
  left: 50%; bottom: calc(100% + 10px);
  translate: -50% 0;
  z-index: 5;
  min-width: 100%;
  text-align: left;
}
.cal__menu .pen__fill { fill: var(--powder); }
.cal__menu ul { position: relative; margin: 0; padding: 8px 0; list-style: none; }
.cal__menu a {
  display: block;
  padding: 8px 24px;
  color: var(--dark);
  text-decoration: none;
  font-family: var(--hand-sm);
  font-weight: 700;
  font-size: 25px;
  letter-spacing: var(--hand-sm-track);
  white-space: nowrap;
}
.cal__menu a:hover, .cal__menu a:focus { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; text-decoration-color: var(--orange); }


/* little pop for the filled doodles */
.js .pop { opacity: 0; scale: 0.4; transition: opacity .3s ease var(--d, 0s), scale .5s cubic-bezier(.3, 1.8, .5, 1) var(--d, 0s); }
.js .is-in .pop { opacity: 1; scale: 1; }
/* once they've popped in, the sparkles and star drift gently in place (each at its own pace) */
.js .is-in .doodle--sparkles { animation: drift-a 6.5s ease-in-out calc(var(--d, 0s) + .6s) infinite; }
.js .is-in .doodle--star     { animation: drift-b 5.2s ease-in-out calc(var(--d, 0s) + .6s) infinite; }
@keyframes drift-a {
  0%, 100% { translate: 0 0;      rotate: 0deg; }
  30%      { translate: 1px -3px; rotate: -4deg; }
  65%      { translate: -1px 2px; rotate: 3deg; }
}
@keyframes drift-b {
  0%, 100% { translate: 0 0;       rotate: 0deg; }
  40%      { translate: -2px -3px; rotate: 6deg; }
  75%      { translate: 1px 1px;   rotate: -3deg; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .js .std__countdown span { clip-path: none; transition: none; }
  .hero__title .line, .hero__cue svg { animation: none; transform: none; }
  .js .reveal { --draw: 0; }
  .js .pop { opacity: 1; scale: 1; }
  .js .is-in .doodle--sparkles, .js .is-in .doodle--star { animation: none; }
}
