/* Stationery: the invite's script and red ink on cool embossed paper. */
:root {
  /* Ink: the invite's red, and the same ink darker for long reading. Opacity lets the paper show through the ink,
     darkness mixes in black, and --blend is how the ink sits on the paper (normal, multiply, darken, color-burn). */
  --ink-base: #7f1416; --ink-text-base: #4b1517; --ink-a: .8; --ink-dark: 12; --blend: normal;
  --ink: color-mix(in oklab, color-mix(in oklab, var(--ink-base), #000 calc(var(--ink-dark) * 1%)), transparent calc((1 - var(--ink-a)) * 100%));
  --ink-text: color-mix(in oklab, color-mix(in oklab, var(--ink-text-base), #000 calc(var(--ink-dark) * 1%)), transparent calc((1 - var(--ink-a)) * 100%));
  --ink-faint: #8a0f1259;
  --paper: #ecebee;        /* cool, slightly lilac grey; not cream */
  --sheet: #f6f5f7;
  --deckle: #cfc9d2;
  /* The embossed frame (public/frame.js), in px. */
  --f-in: 19; --f-gap: 12; --f-rise: 61; --f-notch: 27; --f-step: 33; --f-pad: 17; --f-top: 33; --f-max: 760; --f-emb: .4; --f-line: 2.5; --f-line2: 1.6; --f-soft: .7;
  /* Ink pressed into the paper: light edge below, shade above. */
  --p-edge: .45; --p-shade: .18; --p-depth: .75; --p-blur: .25;
  /* The rest of the paper. Printed: lettering, ornaments, rules to write on (in --ink). Blind: impressions with no ink,
     like the frame: dividers are embossed lines drawn like the frame, buttons are raised plates that press in. Pen: what guests write.
     The reply area is pressed into the invite. */
  --blind: 66 52 72;       /* shade of a blind impression on this paper */
  --pen: #26314a;          /* blue-black fountain pen */
  --d-emb: .85; --d-line: 1.2; --d-soft: 1.1;   /* dividers, embossed like the frame (public/frame.js) */
  /* The note card: perforated off the invite (cut length and gap, how far pressed, how dark and wide the holes), with its own arch. */
  /* Cardstock texture over the paper (public/frame.js): strength, bump depth, grain size, stretched into fibres, roughness. */
  --tex-a: .54; --tex-depth: 1.3; --tex-size: 1; --tex-fibre: 1.8; --tex-rough: 2;
  --perf-dash: 4; --perf-gap: 3; --perf-depth: 1.1; --perf-hole: .35; --perf-cut: .8; --n-rise: 30;
  /* One light for every impression: the direction it comes from, in degrees (180 left, 225 top left, 270 top).
     Shadows fall toward it inside anything pressed in, and away from it under anything raised. The frame uses it too. */
  --light: 210; --lx: cos(var(--light) * 1deg); --ly: sin(var(--light) * 1deg);
  --c-style: notched; --c-emb: 1.15; --c-soft: 1; --c-line: 1; --c-floor: .025; --c-round: 6;   /* reply card: panel, line or notched outline, lit like the frame (public/frame.js) */
  --info: open;   /* Good to know: rows that open, or printed open */
  --b-style: panel; --b-emb: .65; --b-soft: 1.5; --b-line: 1.2; --raise: -2.6; --b-light: .2; --b-shade: .14; --b-border: 0; --b-fill: 0; --b-round: 4; /* buttons; raise below 0 presses them in */
  /* Printed shapes (ornament, checkboxes, arrows) pressed into the paper like the lettering. */
  --press: drop-shadow(calc(var(--lx) * var(--p-depth) * -1px) calc(var(--ly) * var(--p-depth) * -1px) 0 rgb(255 255 255 / var(--p-edge))) drop-shadow(calc(var(--lx) * var(--p-depth) * 1px) calc(var(--ly) * var(--p-depth) * 1px) calc(var(--p-blur) * 1px) rgb(60 0 0 / var(--p-shade)));
  /* Daylight: soft shadows of a window and leaves falling over the page from --light (public/frame.js). */
  --sun-a: .18; --sun-blur: 9; --sun-size: 1; --sun-window: .15; --sun-wall: .35; --sun-leaves: .8; --sun-sway: 1; --sun-speed: 11; --sun-tint: blue;
  /* The branches: how many, where they grow in from (degrees off the light; 0 is straight from it), fanned how wide,
     how far in, leaf size, softness relative to the window's, twigs per step, and which random arrangement. */
  --leaf-count: 7; --leaf-from: 0; --leaf-spread: 90; --leaf-reach: 1; --leaf-size: 1; --leaf-soft: .6; --leaf-twigs: .07; --leaf-seed: 7;
  /* Wide screens: the page as one edge-to-edge sheet, or a sheet of paper lying on a desk, lit by the same light. */
  --layout: desk; --desk-h: 28; --desk-s: 28; --desk-l: 89; --desk-grain: .25; --desk-m: 56;
  --desk: hsl(calc(var(--desk-h) * 1deg) calc(var(--desk-s) * 1%) calc(var(--desk-l) * 1%));
  --s-len: 6.5; --s-blur: 6; --s-dark: .04; --s-contact: .1; --s-rim: .5; --s-fall: .25;
  color-scheme: light;
}
@media (min-width: 740px) {
  :root { --f-in: 22; --f-gap: 22; --f-rise: 64; --f-notch: 22; --f-pad: 64; --f-top: 40;
    --sun-a: .38; --sun-blur: 11; --sun-size: 2.9; --sun-window: .1; --sun-wall: 1; --sun-leaves: .25; --sun-sway: 3; --sun-speed: 10;
    --leaf-count: 12; --leaf-from: 10; --leaf-spread: 115; --leaf-reach: 1.2; --leaf-size: 1.15; --leaf-soft: .4; --leaf-twigs: .01; --leaf-seed: 52;
    --tex-a: .5; --tex-depth: 2; --tex-fibre: 2.5; --tex-rough: 3; --n-rise: 23; }
}
* { box-sizing: border-box; }
/* The whole page is the paper; the grain is a tile of the invite's own blank paper. */
html { background: var(--tex) 0 0 / 256px, #e2dfe2 url(/paper.webp) 0 0 / 256px; background-blend-mode: overlay, normal; }
body {
  margin: 0;
  /* Drawn edge to edge on phones (viewport-fit=cover), so the paper and the sun run under the notch and the toolbar;
     the content itself stays clear of them. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font: 400 1.1875rem/1.5 'EB Garamond', Garamond, Georgia, serif;
  color: var(--ink-text);
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
}

.sheet {
  --line: calc((var(--f-in) + var(--f-gap)) * 1px);
  position: relative;
  width: min(100%, var(--f-max) * 1px);
  margin: 0 auto;
  padding: calc(var(--line) + (var(--f-rise) + var(--f-top)) * 1px) calc(var(--line) + var(--f-pad) * 1px);
}
.frame, .rules { position: absolute; inset: 0; pointer-events: none; }
.frame { mix-blend-mode: overlay; }
/* Daylight over everything: shade only, so the paper and ink keep their colours where the sun falls. */
.sun { position: fixed; inset: -150px 0; /* past the screen's edges, under the status bar and toolbar */ z-index: 8; pointer-events: none; overflow: hidden; mix-blend-mode: multiply; opacity: var(--sun-a); }
.sun div { position: absolute; left: 50%; top: 50%; background: no-repeat 0 0 / 100% 100%; will-change: transform; transform: translate(-50%, -50%); }
.sun .panes { opacity: var(--sun-window); }
.sun .leaves { opacity: var(--sun-leaves); animation: sway calc(var(--sun-speed) * 1s) ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: translate(-50%, -50%); }
  35% { transform: translate(calc(-50% + var(--sun-sway) * 5px), calc(-50% + var(--sun-sway) * 2px)) rotate(calc(var(--sun-sway) * .35deg)); }
  70% { transform: translate(calc(-50% - var(--sun-sway) * 2px), calc(-50% + var(--sun-sway) * 3px)) rotate(calc(var(--sun-sway) * -.2deg)); }
}
@media (prefers-reduced-motion: reduce) { .sun .leaves { animation: none; } }
/* Paper on a desk (wide screens): the surface with a little grain, the sheet lifted off it. Shadows fall away from
   the light, the edge facing the light catches it, and the sheet is a touch brighter on the light's side. */
@media (min-width: 740px) {
  html[data-layout=desk] {
    --veil: color-mix(in srgb, var(--desk), transparent calc(var(--desk-grain) * 100%));
    background: linear-gradient(var(--veil), var(--veil)),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 220px,
      var(--desk);
  }
  html[data-layout=desk] .sheet {
    margin: calc(var(--desk-m) * 1px) auto;
    background: var(--tex) 0 0 / 256px, #e2dfe2 url(/paper.webp) 0 0 / 256px;
    background-blend-mode: overlay, normal;
    box-shadow:
      inset calc(var(--lx) * -1px) calc(var(--ly) * -1px) 0 rgb(255 255 255 / var(--s-rim)),
      calc(var(--lx) * -.6px) calc(var(--ly) * -.6px) 1.5px rgb(30 22 30 / var(--s-contact)),
      calc(var(--lx) * var(--s-len) * -1px) calc(var(--ly) * var(--s-len) * -1px) calc(var(--s-blur) * 1px) rgb(30 22 30 / var(--s-dark)),
      calc(var(--lx) * var(--s-len) * -2.5px) calc(var(--ly) * var(--s-len) * -2.5px) calc(var(--s-blur) * 3px) rgb(30 22 30 / calc(var(--s-dark) * .5));
  }
  html[data-layout=desk] .sheet::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light;
    background: linear-gradient(calc((var(--light) - 90) * 1deg), rgb(255 255 255 / calc(var(--s-fall) * 2)), transparent 50%, rgb(0 0 0 / calc(var(--s-fall) * 2)));
  }
}
/* Each piece blends on its own, so overlapping pieces (a card and the line inside it) don't hide each other. */
.rules svg { position: absolute; mix-blend-mode: overlay; }
.frame svg { position: absolute; display: block; }
.rules svg.holes { mix-blend-mode: multiply; }


h1, h2, .hello { font-family: 'Pinyon Script', cursive; font-weight: 400; color: var(--ink); }
h1 { margin: 0; text-align: center; font-size: clamp(1.9rem, 8.2vw, 3rem); line-height: 1.2; }
h1 span { display: block; }
h1 .and { font-size: .62em; margin: .1em 0; }
h2 { font-size: 2.4rem; line-height: 1.1; text-align: center; margin: 3.2rem 0 1.4rem; }
.hero { text-align: center; }
.invite {
  font-family: 'Pinyon Script', cursive; color: var(--ink);
  font-size: 1.5rem; line-height: 1.4; margin: 1.1rem auto .6rem; max-width: 24ch; text-wrap: balance;
}
.place { font-style: italic; margin: 0; }

.sprig { display: block; width: 120px; height: 20px; margin: 2rem auto 1.6rem; color: var(--ink); opacity: .8;
  filter: var(--press); }

/* Unlock */
.unlock { display: grid; gap: .7rem; justify-items: center; text-align: center; }
.unlock label { font-style: italic; max-width: 30ch; }
/* Opened from a personal link: addressed to them in pen, and only the button. */
.unlock .for-whom { display: none; margin: 0 0 .4rem; font-size: 1.35rem; font-style: italic; color: var(--pen); }
.unlock.for .for-whom { display: block; }
.unlock.for label, .unlock.for input { display: none; }
/* Opening: the cover lifts off, then the invitation unfolds from the top like a card. */
#locked.lift { animation: lift .45s ease-in forwards; }
@keyframes lift { to { opacity: 0; transform: translateY(-14px) scale(.985); filter: blur(1px); } }
#open.unfold { animation: unfold .9s cubic-bezier(.2, .7, .2, 1) both; transform-origin: 50% 0; }
@keyframes unfold { from { opacity: 0; transform: perspective(900px) rotateX(-16deg) translateY(-12px); } }
/* Lines to write on: a printed rule pressed into the paper (ink line, light edge under it). Writing on it darkens
   the rule a little, the way a line you're writing on stands out; no box or glow. */
input, textarea {
  --rule: var(--ink-faint);
  font: inherit; color: var(--pen); caret-color: var(--pen); width: 100%;
  border: 0; border-radius: 0; padding: .3rem .1rem;
  background: linear-gradient(var(--rule) 0 0) 0 calc(100% - 1px) / 100% 1px no-repeat,
    linear-gradient(rgb(255 255 255 / var(--p-edge)) 0 0) 0 100% / 100% 1px no-repeat;
}
.unlock input { text-align: center; max-width: 20rem; font-size: 1.3rem; }
::placeholder { color: rgb(75 21 23 / .4); font-style: italic; }
/* Ruled lines to write on, printed faintly; they scroll with the writing. */
textarea { border: 0; padding: .3rem .1rem 0; line-height: 1.8rem; resize: vertical;
  background: repeating-linear-gradient(transparent 0 calc(1.8rem - 2px), var(--rule) 0 calc(1.8rem - 1px), rgb(255 255 255 / var(--p-edge)) 0 1.8rem) 0 .3rem local; }
input:focus, textarea:focus { outline: none; --rule: rgb(127 20 22 / .6); }
/* A raised plate, blind embossed; it presses in when tapped. (With --raise below 0 it starts pressed in.) */
button {
  font: italic 400 1.05rem 'EB Garamond', serif; color: var(--ink); cursor: pointer;
  padding: .45rem 1.3rem; border: 1px solid rgb(var(--blind) / var(--b-border)); border-radius: calc(var(--b-round) * 1px);
  background: rgb(255 255 255 / var(--b-fill));
  --r: calc(var(--raise) * var(--press, 1)); --dir: clamp(-1, var(--r) * 10, 1);
  box-shadow: inset calc(var(--lx) * var(--dir) * -1px) calc(var(--ly) * var(--dir) * -1px) 0 rgb(255 255 255 / var(--b-light)), inset calc(var(--lx) * var(--dir) * 1px) calc(var(--ly) * var(--dir) * 1px) 0 rgb(var(--blind) / var(--b-shade)),
    calc(var(--lx) * var(--r) * -1px) calc(var(--ly) * var(--r) * -1px) calc(max(var(--r), -1 * var(--r)) * 2px) rgb(var(--blind) / calc(clamp(0, var(--r), 1) * var(--b-shade))),
    calc(var(--lx) * 1 * -1px) calc(var(--ly) * 1 * -1px) 0 rgb(255 255 255 / calc(clamp(0, -1 * var(--r), 1) * var(--b-light))),
    inset calc(var(--lx) * max(0, -1 * var(--r)) * -1px) calc(var(--ly) * max(0, -1 * var(--r)) * -1px) calc(max(0px, -2px * var(--r))) rgb(var(--blind) / calc(clamp(0, -1 * var(--r), 1) * var(--b-shade) * 1.4));
}
button:hover { background-color: rgb(255 255 255 / calc(var(--b-fill) * 2)); }
/* When frame.js draws the buttons (any style but plate), the plate's own edges go. */
.sheet:not([data-btn=plate]) form button { border-color: transparent; box-shadow: none; }
button:active { --press: -1; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.err { text-align: center; color: var(--ink); font-style: italic; }

/* Greeting */
.hello { font-size: 2.1rem; line-height: 1.2; text-align: center; margin: 0; text-wrap: balance; }
.kindly { text-align: center; font-style: italic; margin: .3rem auto 0; max-width: 34ch; }

/* Events: each one a short passage, separated by a hairline. */
.event { padding: 2.6rem 0 2.7rem; }
.event:first-child { padding-top: 0; }
.event h3 {
  font: 500 1.5rem/1.25 'EB Garamond', serif; color: var(--ink);
  margin: 0; text-align: center; letter-spacing: .01em;
}
.event .when { text-align: center; font-style: italic; margin: .4rem 0 .35rem; }
.event .where { text-align: center; margin: 0; }
.event .where a { color: inherit; text-decoration-color: var(--ink-faint); text-underline-offset: 3px; }
.event .body { margin: 1.6rem auto 0; max-width: 30em; padding: 0 .55rem; font-size: 1.09rem; line-height: 1.75; letter-spacing: .012em; word-spacing: .04em; }
.event .body p { margin: 0 0 1.25em; text-wrap: pretty; }
.event .body p:last-child { margin-bottom: 0; }
.event .extras { text-align: center; font-size: 1rem; margin: 1.6rem 0 0; font-style: italic; line-height: 1.8; }
.event .extras a { color: var(--ink); text-underline-offset: 3px; }

/* Reply card */
/* The reply area: a panel pressed down into the invite; frame.js lights its edges the same way as the frame. */
.reply { margin: 1.3rem auto 0; max-width: 26rem; padding: .8rem 1.1rem .9rem; background: rgb(var(--blind) / var(--c-floor));
  border-radius: calc(var(--c-round) * 1px); }
.reply .person + .person { margin-top: .7rem; padding-top: .7rem; } /* the line between people is embossed by frame.js */
.reply .name { font-family: 'Pinyon Script', cursive; color: var(--ink); font-size: 1.55rem; line-height: 1.2; }
.reply .wait { font-style: italic; font-size: .95rem; color: var(--ink); margin-left: .4rem; }
.choices { display: flex; flex-wrap: wrap; gap: .1rem 1.4rem; }
.choices button {
  position: relative; border: 0; background: none; box-shadow: none; padding: .2rem 0; font-size: 1.05rem; color: var(--ink-text);
  display: inline-flex; align-items: center; gap: .5rem;
}
.choices button:hover { background: none; color: var(--ink); }
.choices button::before {
  content: ''; width: .95rem; height: .95rem; border: 1px solid var(--ink); flex: none;
  filter: var(--press);
}
.choices button[aria-pressed="true"] { color: var(--ink); }
.choices button[aria-pressed="true"]::after {
  content: ''; position: absolute; left: -.15rem; top: 50%; width: 1.45rem; height: 1.45rem; translate: 0 -62%; background: center / contain no-repeat;
  /* A pen tick: thin where it starts, heavy at the turn, flicked thin at the end, running past the box. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M2.8 10.2C4.6 11.1 6.2 12.8 7.4 15C9.6 9.8 12.8 5.6 17.9 2.1C18.2 1.9 18.5 2.3 18.2 2.5C13.6 6.4 10.6 10.8 8.5 16.6C8.2 17.4 7.3 17.5 6.9 16.8C5.9 14.6 4.6 12.5 2.7 10.8C2.4 10.6 2.5 10.1 2.8 10.2Z' fill='%2326314a' fill-opacity='.92'/%3E%3C/svg%3E");
}

/* Good to know */
.info summary {
  cursor: pointer; list-style: none; padding: .7rem 0; font-size: 1.2rem; color: var(--ink);
  display: flex; justify-content: space-between; align-items: center;
}
.info summary::-webkit-details-marker { display: none; }
.info summary::after { content: ''; width: .45rem; height: .45rem; border: solid var(--ink); border-width: 0 1px 1px 0; transform: rotate(45deg); transition: transform .2s; margin-right: .3rem; filter: var(--press); }
.info details[open] summary::after { transform: rotate(-135deg); }
.info details > p, .info details > div { margin: 0 0 1rem; }
/* Printed open, like an insert card: small-caps headings, centered text, a short embossed rule between items. */
.sheet[data-info=open] .info summary { cursor: default; justify-content: center; font-variant: small-caps; letter-spacing: .09em;
  font-size: 1.15rem; padding: 1.7rem 0 .5rem; }
.sheet[data-info=open] .info summary::after { display: none; }
.sheet[data-info=open] .info details:first-child summary { padding-top: 0; }
.sheet[data-info=open] .info details > p { text-align: center; max-width: 30em; margin: 0 auto 1.4rem; text-wrap: pretty; }
.sheet[data-info=open] .info details:last-child > p { margin-bottom: 0; }
.sheet[data-info=open] .info details > div { margin: 0 auto 1.6rem; max-width: 24rem; text-align: center; }
.sheet[data-info=open] .diet input { text-align: center; }
.diet { margin: .6rem 0; }
.diet label { font-family: 'Pinyon Script', cursive; color: var(--ink); font-size: 1.4rem; }

/* The end of the invite, then a scored line: below it is an extra card, optional. */
.done { margin-top: 3rem; }
.done .sprig { margin-bottom: 1rem; }
/* The note card's room inside its own frame, and the invite's room above the perforation, like the sheet's own padding. */
.extra { margin-top: calc(var(--line) + (var(--f-rise) + var(--f-top)) * 1px); padding-top: calc(var(--line) + (var(--n-rise) + var(--f-top)) * 1px); }
/* A card after another card has the small arch above it too. */
.extra + .extra { margin-top: calc(var(--line) + (var(--n-rise) + var(--f-top)) * 1px); }
/* Photos being sent: a short list in pen. */
.sent { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; justify-items: center; color: var(--pen); font-style: italic; font-size: 1rem; }
.sent:empty { display: none; }
.sheet:has(#open:not([hidden])) { padding-bottom: calc(var(--line) + (var(--n-rise) + var(--f-top)) * 1px); }
.kicker { text-align: center; font-variant: small-caps; letter-spacing: .09em; font-size: .95rem; margin: 0 0 .5rem; color: var(--ink-text); }
.extra h2 { margin-top: 0; }
.note { display: grid; gap: .8rem; justify-items: center; }
.note label { font-style: italic; text-align: center; }
.foot { text-align: center; margin: 3rem 0 0; font-size: 1rem; font-style: italic; }
.foot a { color: var(--ink-text); text-decoration-color: var(--ink-faint); }

@media (min-width: 740px) {
  body { padding: 40px 0 56px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Ink pressed into the paper, like the frame: a faint light edge below, a faint shadow above. */
.sheet :is(h1, h2, h3, p, .hello, label, summary, .name, .when, .where, .extras, button) { mix-blend-mode: var(--blend); text-shadow: calc(var(--lx) * var(--p-depth) * -1px) calc(var(--ly) * var(--p-depth) * -1px) 0 rgb(255 255 255 / var(--p-edge)), calc(var(--lx) * var(--p-depth) * 1px) calc(var(--ly) * var(--p-depth) * 1px) calc(var(--p-blur) * 1px) rgb(60 0 0 / var(--p-shade)); }
