/* ==========================================================================
   The Autumn Scholar — styles
   Photographs carry the materials. CSS only places, lights and moves them.
   ========================================================================== */

@font-face { font-family: "Cormorant Garamond"; src: url("assets/fonts/cormorant-garamond-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("assets/fonts/cormorant-garamond-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("assets/fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("assets/fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("assets/fonts/eb-garamond-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("assets/fonts/eb-garamond-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url("assets/fonts/inter-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

/* --- Tokens: colors from the brief, fonts, motion --- */
:root {
  --ivory: #F1E8D9;
  --parchment: #DCCBB2;
  --envelope-ivory: #E9DECC;
  --burgundy: #692F3A;
  --walnut: #49352D;
  --olive: #77765B;
  --copper: #A68A64;

  --desk: #242321;            /* charcoal: page colour behind the desk photograph */
  --ink: #3B2B25;             /* printed text on the card */
  --ink-soft: #5F4A3F;
  --ink-label: #7A5C49;
  --on-desk: #EFE4D2;         /* text sitting on the dark desk */
  --on-desk-soft: #CDBDA5;

  --font-display: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --font-text: "EB Garamond", Garamond, Georgia, serif;
  --font-label: "Inter", "Helvetica Neue", Arial, sans-serif;   /* tiny labels only */

  --ease-paper: cubic-bezier(.55, .06, .26, 1);
  --ease-rise: cubic-bezier(.22, .61, .28, 1);
  --ease-settle: cubic-bezier(.33, 0, .2, 1);
  --t-press: 260ms;
  --t-flap: 900ms;
  --t-rise: 1150ms;
  --t-scene: 750ms;

  --env-w: min(84vw, 32rem, 56vh);
  --desk-tilt: 0deg;        /* every photograph is top-down, so the envelope lies flat */
  --desk-turn: -2.5deg;
  --window-light: linear-gradient(102deg, #FFFDF8 0%, #FAF4EA 50%, #EFE6D9 100%);

  /* Envelope geometry: set from photoConfig.geometry in script.js */
  --flap-h: .57;
  --seal-y: .54;
  --seal-size: .2;
  --card-top: .05;
  --card-side: .055;
  --card-h: .88;
}
/* Default photo paths, so the card still has its paper if JavaScript is off.
   script.js sets the same variables after checking that each file exists. */
:root {
  /* @photo-defaults-start */
  --img-deskPortrait: url("assets/photos/desk-portrait.webp");
  --img-deskLandscape: url("assets/photos/desk-landscape.webp");
  --img-cardSheet: url("assets/photos/card-sheet.webp");
  --img-cardInner: url("assets/photos/card-inner.webp");
  /* @photo-defaults-end */
}
@supports (height: 1svh) { :root { --env-w: min(84vw, 32rem, 56svh); } }

/* The desk is dark in every color scheme: it is a photographed object, not UI */
:root { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--desk);
  color: var(--on-desk);
  font-family: var(--font-text);
  font-size: clamp(1rem, .96rem + .2vw, 1.0625rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 1.5px solid var(--copper); outline-offset: 4px; }
[hidden] { display: none !important; }

/* --- Photo slots --------------------------------------------------------
   script.js sets --img-<name> for every photograph that loaded.
   A slot whose photograph is missing gets .is-missing and shows its file
   name inside a dashed frame, so nothing is silently faked. */
.slot { background-repeat: no-repeat; background-size: 100% 100%; }
.slot.is-missing {
  outline: 1px dashed rgba(239, 228, 210, .45);
  outline-offset: -1px;
}
.slot.is-missing::before {
  content: attr(data-missing);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: .15em .4em;
  font: italic 400 clamp(.62rem, .55rem + .3vw, .8rem)/1.3 var(--font-text);
  color: rgba(239, 228, 210, .8);
  background: rgba(46, 33, 28, .7);
  white-space: nowrap;
  pointer-events: none;
  z-index: 9;
}

.asset-notice {
  position: relative;
  z-index: 50;
  max-width: 34rem;
  margin: max(.75rem, env(safe-area-inset-top)) auto 0;
  width: calc(100% - 1.5rem);
  padding: .7rem 1rem;
  background: rgba(30, 21, 18, .92);
  border: 1px dashed rgba(239, 228, 210, .35);
  font-size: .88rem;
  line-height: 1.45;
  color: var(--on-desk);
}
.asset-notice p { margin: 0; }
.asset-notice p + p { margin-top: .25rem; color: var(--on-desk-soft); }
.asset-notice code { font-size: .85em; }
/* Spread the file-name labels so overlapping layers stay readable */
.desk-photo.is-missing::before { top: 1.25rem; transform: translateX(-50%); }
.layer--back.is-missing::before { top: 12%; }
.mini-card.is-missing::before { top: 3%; transform: translateX(-50%); }
.layer--pocket.is-missing::before { top: auto; bottom: 22%; transform: translateX(-50%); }
.seal.is-missing { border-radius: 50%; }

/* --- Scene one: the desk -------------------------------------------------- */
.scene { position: relative; min-height: 100svh; }
.scene--desk {
  height: 100vh;
  height: 100svh;                               /* exactly the viewport: keeps desk and light map aligned */
  display: grid;
  place-items: end center;
  overflow: hidden;
  transition: opacity var(--t-scene) var(--ease-settle);
}
.desk-photo {
  position: absolute;
  inset: 0;
  background-image: var(--img-deskPortrait);
  background-size: cover;
  background-position: center;
}
@media (min-aspect-ratio: 1/1) {
  .desk-photo { background-image: var(--img-deskLandscape); }
}
.desk-leaf {
  position: absolute;
  z-index: 1;
  left: -4%;
  top: 8%;                                       /* the opened card later rests partly over it */
  width: clamp(5.5rem, 24vw, 10rem);
  aspect-ratio: 489 / 510;
  background: var(--img-mapleLeaf) center / contain no-repeat;
  rotate: 148deg;                                /* resting angle; the breeze adds to it */
  transform-origin: 55% 60%;
  filter: drop-shadow(2px 4px 3px rgba(10, 8, 6, .55)) drop-shadow(5px 12px 14px rgba(10, 8, 6, .3));
  pointer-events: none;
  animation: breeze 12s ease-in-out 2s infinite;
}
/* A draught from the window now and then: the leaf's edge lifts, it turns a
   little and slides a few pixels, its shadow spreads while it is off the desk,
   then it settles. Long calm between gusts. */
@keyframes breeze {
  0%, 58%, 100% { transform: none; filter: drop-shadow(2px 4px 3px rgba(10, 8, 6, .55)) drop-shadow(5px 12px 14px rgba(10, 8, 6, .3)); }
  66% { transform: perspective(500px) translate(5px, -4px) rotateX(14deg) rotateY(-8deg) rotate(6deg) scale(1.04);
        filter: drop-shadow(6px 10px 6px rgba(10, 8, 6, .42)) drop-shadow(10px 22px 18px rgba(10, 8, 6, .22)); }
  73% { transform: perspective(500px) translate(9px, -2px) rotateX(6deg) rotateY(4deg) rotate(-2deg) scale(1.02);
        filter: drop-shadow(4px 7px 5px rgba(10, 8, 6, .48)) drop-shadow(8px 16px 16px rgba(10, 8, 6, .26)); }
  81% { transform: translate(7px, 0) rotate(2.5deg); }
  90% { transform: translate(3px, 0) rotate(.5deg); }
}
/* the envelope opening stirs the air: one stronger puff moves the leaf a
   little across the desk (it stays there), then the usual calm returns */
.scene--desk.is-stirred .desk-leaf {
  translate: 14px 2px;
  rotate: 153deg;
  transition: translate 1.7s cubic-bezier(.25, .6, .3, 1) .35s, rotate 1.7s cubic-bezier(.25, .6, .3, 1) .35s;
  animation: puff 1.9s cubic-bezier(.25, .6, .3, 1) .35s 1 both, breeze 12s ease-in-out 4.5s infinite;
}
@keyframes puff {
  0%, 100% { transform: none; }
  30% { transform: perspective(500px) translateY(-6px) rotateX(22deg) rotateY(-10deg) scale(1.06);
        filter: drop-shadow(8px 14px 8px rgba(10, 8, 6, .38)) drop-shadow(12px 26px 20px rgba(10, 8, 6, .2)); }
  65% { transform: perspective(500px) translateY(-1px) rotateX(5deg) scale(1.02); }
}
}
.desk-leaf.is-missing { display: none; }
.desk-content {
  position: relative;
  display: grid;
  justify-items: center;
  padding: calc(var(--env-w) * .62) 1rem max(18svh, 4.5rem);   /* room above for the rising card */
}
.desk-hint {
  position: relative;
  z-index: 3;
  margin: 2rem 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.15rem, 1.05rem + .5vw, 1.4rem);
  color: var(--on-desk);
  text-shadow: 0 1px 12px rgba(20, 13, 10, .6);
  transition: opacity 400ms ease;
}

/* --- The envelope: photographic layers, registered to one canvas -------- */
.envelope {
  position: relative;
  display: block;
  width: var(--env-w);
  aspect-ratio: var(--env-ratio, 1.2343);   /* the envelope canvas */
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1500px;
  -webkit-tap-highlight-color: transparent;
  /* lie flat on the desk, seen from the same camera angle as the photograph */
  transform: rotateX(var(--desk-tilt)) rotateZ(var(--desk-turn));
  transition: transform 600ms var(--ease-settle);
}
.envelope-stage { perspective: 1100px; perspective-origin: 50% 0%; }
.envelope > span { position: absolute; display: block; }
.layer--back, .layer--pocket { inset: 0; }
.layer--back { z-index: 0; --img: var(--img-envelopeBack); }
.layer--pocket { z-index: 3; --img: var(--img-envelopePocket); pointer-events: none; }
/* Window light on the studio cut-outs: a warm gradient multiplied into each
   photograph and masked by its own alpha, brighter on the window side */
.lit {
  background-image: var(--window-light), var(--img);
  background-size: 100% 100%;
  background-blend-mode: multiply, normal;
  -webkit-mask-image: var(--img);
          mask-image: var(--img);
  -webkit-mask-size: 100% 100%;
          mask-size: 100% 100%;
}

/* Contact shadow photographed under the envelope; light comes from the left */
.layer--shadow {
  z-index: -1;
  inset: -8% -10% -14% -6%;
  background-image: var(--img-envelopeShadow);
  mix-blend-mode: multiply;
  transition: opacity 500ms ease;
}
.layer--shadow.is-missing { outline: none; }
.layer--shadow.is-missing::before { top: auto; bottom: 1%; transform: translateX(-50%); }

/* The card inside, photographed cotton paper with live text */
.layer--card {
  z-index: 2;
  top: calc(var(--card-top) * 100%);
  left: calc(var(--card-side) * 100%);
  right: calc(var(--card-side) * 100%);
  height: calc(var(--card-h) * 100%);
  transition: transform var(--t-rise) var(--ease-rise);
}
.mini-card {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  background: var(--img-cardInner) center / 100% 100% no-repeat;   /* folded card: crease on top */
  color: var(--ink);
  filter: drop-shadow(0 1px 1px rgba(20, 13, 10, .28));
}

/* Cover print of the folded card. Pure container units, so it looks
   identical in the envelope and on the desk, at any size. */
.cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6cqw 9cqw 8cqw;
  text-align: center;
  color: var(--ink);
}
.cover > span { display: block; mix-blend-mode: multiply; }
.cover__kicker { font-family: var(--font-label); font-weight: 500; font-size: 2.3cqw; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-label); }
.cover__name { margin-top: 2cqw; font-family: var(--font-display); font-style: italic; font-size: 8.6cqw; line-height: 1.04; color: var(--walnut); overflow-wrap: anywhere; text-wrap: balance; }
.cover__year { margin-top: 3cqw; font-style: italic; font-size: 3.6cqw; color: var(--burgundy); }

/* The flap: hinged on the envelope's top edge */
.flap {
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--flap-h) * 100%);
  z-index: 4;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  transition: transform var(--t-flap) var(--ease-paper), z-index 0s linear calc(var(--t-flap) * .48);
  pointer-events: none;
}
.flap__face {
  position: absolute;
  inset: 0;
  display: block;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}
.flap__paper { position: absolute; inset: 0; display: block; --img: var(--img-flapOuter); }
.flap__face--outer { filter: drop-shadow(0 2px 2px rgba(40, 24, 16, .22)) drop-shadow(0 6px 10px rgba(40, 24, 16, .12)); }
/* flap-inner.png is cropped exactly as seen with the flap lying open */
.flap__face--inner { --img: var(--img-flapInner); transform: rotateX(180deg); }

/* The wax seal: its own photograph, pinned to the flap point */
.seal {
  position: absolute;
  display: block;
  left: 50%;
  top: calc(var(--seal-y) / var(--flap-h) * 100%);
  width: calc(var(--seal-size) * var(--env-w));
  aspect-ratio: 1;
  background-image: var(--img-seal);
  filter: drop-shadow(1px 3px 2px rgba(30, 10, 12, .45)) drop-shadow(2px 8px 10px rgba(30, 14, 10, .25));
  transform: translate(-50%, -50%) rotate(-6deg);
  transition: transform var(--t-press) var(--ease-settle), filter var(--t-press) ease;
}

@media (hover: hover) and (pointer: fine) {
  body[data-state="sealed"] .envelope:hover { transform: rotateX(var(--desk-tilt)) rotateZ(var(--desk-turn)) translateY(-3px); }
}
body:not([data-state="sealed"]) .envelope { cursor: default; outline: none; }
body:not([data-state="sealed"]) .desk-hint { opacity: 0; }

/* Opening sequence (classes added by script.js) */
.envelope.is-pressed .seal { transform: translate(-50%, -50%) rotate(-6deg) scale(.96); }
.envelope.is-flap-open .flap { transform: rotateX(180deg); z-index: 1; }
.envelope.is-emerging .layer--card { transform: translateY(-56%); }
/* Hand-off: the desk becomes the fixed surface under the card, the envelope is set aside */
.scene--desk.is-backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.envelope-stage { transition: opacity 650ms var(--ease-settle), transform 900ms var(--ease-settle); }
.scene--desk.is-set-aside .envelope-stage { opacity: 0; transform: translateY(3%); }
.no-transition, .no-transition * { transition: none !important; }

/* --- Scene two: the card on the desk -------------------------------------- */
.scene--letter {
  position: relative;                           /* no z-index: lets the light pass between card and UI */
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 1.75rem;
  padding: max(4.4rem, calc(env(safe-area-inset-top) + 4.2rem)) clamp(.75rem, 4vw, 2rem) max(3rem, env(safe-area-inset-bottom));
}

/* The card keeps the photograph's true proportions and fits the screen height
   on larger displays. Type is in container units, so it scales like print. */
.invitation {
  position: relative;
  z-index: 1;
  width: min(94vw, 34rem, calc((100svh - 6rem) * var(--card-ratio, .6522)));
  aspect-ratio: var(--card-ratio, .6522);
  container-type: inline-size;
  perspective: 1600px;
  color: var(--ink);
  text-align: center;
  transform-origin: 50% calc(var(--fold, .5053) * 150%);   /* centre of the folded card */
  transition: transform 1000ms var(--ease-rise);
}
.invitation.is-flying, .invitation.is-flying .panel--top { transition: none; }
.invitation.is-missing { outline-offset: -1px; color: var(--on-desk); }
.invitation.is-missing * { color: inherit !important; mix-blend-mode: normal !important; }
.invitation.is-missing::before { top: 1rem; transform: translateX(-50%); }

/* Two panels cut from one photograph along the measured crease */
.panel { position: absolute; left: 0; right: 0; }
.panel--top {
  top: 0;
  height: calc(var(--fold, .5053) * 100%);
  z-index: 2;
  transform-origin: 50% 100%;                  /* hinged on the crease */
  transform-style: preserve-3d;
  transform: rotateX(0deg);
  transition: transform 1150ms var(--ease-paper);
}
.panel--bottom {
  top: calc(var(--fold, .5053) * 100%);
  bottom: 0;
  z-index: 1;
  background: var(--img-cardSheet) center bottom / 100% calc(100% / (1 - var(--fold, .5053))) no-repeat;
  filter: drop-shadow(0 2px 2px rgba(10, 8, 6, .4)) drop-shadow(0 12px 18px rgba(10, 8, 6, .3));
}
.panel__face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}
.panel__face--inside {
  background: var(--img-cardSheet) center top / 100% calc(100% / var(--fold, .5053)) no-repeat;
  filter: drop-shadow(0 2px 2px rgba(10, 8, 6, .4)) drop-shadow(0 12px 18px rgba(10, 8, 6, .3));
}
.panel__face--cover {
  container-type: inline-size;
  transform: rotateX(180deg);
  background: var(--img-cardInner) center / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 2px rgba(10, 8, 6, .4)) drop-shadow(0 12px 18px rgba(10, 8, 6, .3));
}
/* folded: the upper panel lies over the lower one, cover up (lifted a hair to avoid z-fighting) */
.invitation.is-folded .panel--top { transform: rotateX(-180deg) translateZ(-1px); }

.panel__print {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5.5cqw 10cqw;
}
.panel__print > * { mix-blend-mode: multiply; }        /* ink sits in the paper fibres */
.panel__print p { margin: 0; }

/* --- Print on the card: the paper stays the centerpiece ------------------
   --fit (set by script.js) gently scales the print down if a long name or
   address would not fit its panel; it never goes below 0.8. */
.panel__print--top { padding: 6.5cqw 9cqw 3.5cqw; }
.panel__print--bottom { padding: 4.5cqw 9cqw 6.5cqw; }

.inv-laurel { width: calc(var(--fit, 1) * 17cqw); height: calc(var(--fit, 1) * 6.8cqw); flex: none; color: var(--copper); margin-bottom: 1.6cqw; }
.inv-intro { font-style: italic; font-size: calc(var(--fit, 1) * max(11.5px, 3.3cqw)); color: var(--ink-soft); }
.inv-kicker { margin-top: 2.6cqw !important; font-family: var(--font-label); font-weight: 500; font-size: calc(var(--fit, 1) * max(8.5px, 1.95cqw)); letter-spacing: .26em; text-transform: uppercase; color: var(--ink-label); }
.inv-name {
  margin: 1.4cqw 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: calc(var(--fit, 1) * max(23px, 8.4cqw));
  line-height: 1.02;
  color: var(--walnut);
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.inv-name:focus { outline: none; }
.inv-rule { display: block; flex: none; width: 13cqw; height: 0; margin: 3cqw auto; border-top: 1.25px solid var(--copper); }
.inv-degree { font-family: var(--font-display); font-weight: 500; font-size: calc(var(--fit, 1) * max(13px, 3.85cqw)); line-height: 1.22; color: var(--walnut); text-wrap: balance; }
.inv-spec { margin-top: .6cqw !important; font-style: italic; font-size: calc(var(--fit, 1) * max(11.5px, 3.3cqw)); color: var(--ink-soft); }
.inv-uni { margin-top: 1.6cqw !important; font-size: calc(var(--fit, 1) * max(12px, 3.4cqw)); color: var(--ink); }
.inv-year { margin-top: 2.8cqw !important; font-family: var(--font-display); font-weight: 500; font-size: calc(var(--fit, 1) * max(11.5px, 3.2cqw)); letter-spacing: .2em; text-transform: uppercase; color: var(--burgundy); font-variant-numeric: lining-nums; }

.inv-personal { max-width: 31ch; font-family: var(--font-display); font-style: italic; font-size: calc(var(--fit, 1) * max(13px, 3.8cqw)); line-height: 1.35; color: var(--ink-soft); text-wrap: balance; }
.panel__print--bottom .inv-rule { margin: 3.2cqw auto 3.4cqw; }
.details { display: grid; grid-template-columns: 1.6fr 1fr; gap: 2.8cqw 4cqw; margin: 0; width: 100%; }
.details__wide { grid-column: 1 / -1; }
.details dt { font-family: var(--font-label); font-weight: 500; font-size: calc(var(--fit, 1) * max(8px, 1.8cqw)); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-label); margin-bottom: .5cqw; }
.details dd { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: calc(var(--fit, 1) * max(13px, 3.8cqw)); line-height: 1.22; color: var(--walnut); font-variant-numeric: oldstyle-nums; }
.inv-invitation { max-width: 33ch; margin-top: 4cqw !important; font-style: italic; font-size: calc(var(--fit, 1) * max(11.5px, 3.3cqw)); line-height: 1.45; color: var(--ink-soft); text-wrap: balance; }
.inv-emblem { width: calc(var(--fit, 1) * 7.2cqw); height: calc(var(--fit, 1) * 7.2cqw); flex: none; margin-top: 3.2cqw; color: var(--burgundy); opacity: .9; }

.amp { font-size: .82em; color: var(--burgundy); }
.cover .amp { font-size: .82em; }
.is-placeholder { font-style: italic; color: var(--ink-label) !important; text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: .22em; }

/* --- On the desk, below the card ------------------------------------------ */
.desk-notes {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: min(94vw, 34rem);
  padding-top: .5rem;
  text-align: center;
  color: var(--on-desk);
  transition: opacity 700ms var(--ease-settle), transform 700ms var(--ease-settle);
}
.scene--letter.is-arriving .desk-notes { opacity: 0; transform: translateY(10px); }
.note { display: grid; justify-items: center; width: 100%; padding: 1.4rem 0; }
.note__title {
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.02rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--on-desk);
}
.note-rule { display: block; width: 2.6rem; height: 1px; background: var(--copper); opacity: .55; }
.note .is-placeholder { color: var(--on-desk-soft) !important; }

/* countdown: serif numerals, burgundy hairlines */
.countdown { list-style: none; display: flex; justify-content: center; margin: 0; padding: 0; }
.countdown li { display: flex; flex-direction: column; align-items: center; min-width: 4.4rem; padding: 0 .5rem; }
.countdown li + li { border-left: 1px solid rgba(146, 70, 84, .75); }
.countdown__num {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.1rem, 1.7rem + 1.8vw, 2.9rem);
  line-height: 1.05;
  color: var(--on-desk);
  font-variant-numeric: lining-nums tabular-nums;
}
.countdown__num.is-ticking { animation: tick 420ms var(--ease-settle); }
@keyframes tick { from { opacity: .35; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.countdown__unit { margin-top: .35rem; font-family: var(--font-label); font-weight: 500; font-size: .6rem; letter-spacing: .2em; text-transform: uppercase; color: var(--on-desk-soft); }
.countdown__message { max-width: 30ch; margin: 0; font-family: var(--font-display); font-style: italic; font-size: 1.3rem; color: var(--on-desk); }

/* the gathering */
.note__icon { width: 22px; height: 22px; color: var(--copper); margin-bottom: .55rem; }
.gathering__venue { margin: 0; font-family: var(--font-display); font-style: italic; font-size: 1.45rem; line-height: 1.25; color: var(--on-desk); }
.gathering__address { margin: .15rem 0 0; font-size: .95rem; color: var(--on-desk-soft); }
.gathering__when { margin: .45rem 0 0; font-size: 1rem; color: var(--on-desk-soft); }
.gathering__dot { margin: 0 .55em; color: var(--copper); }
.gathering__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; margin-top: 1.4rem; }
.pill {                                   /* square-cut outline buttons, not pills */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  min-width: 9.5rem;
  padding: .7rem 1.3rem;
  border: 1px solid rgba(166, 138, 100, .75);
  border-radius: 2px;
  background: rgba(36, 35, 33, .35);
  font-family: var(--font-label);
  font-weight: 500;
  font-size: .68rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--on-desk);
  text-decoration: none;
  cursor: pointer;
  transition: background 250ms ease, border-color 250ms ease, color 250ms ease;
}
.pill:hover { background: rgba(166, 138, 100, .16); border-color: var(--copper); }
.pill:active { transform: translateY(1px); }
.pill[aria-disabled="true"], .pill:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.note__hint { margin: .8rem 0 0; font-style: italic; font-size: .85rem; color: var(--on-desk-soft); }
.note__status { min-height: 1.4em; margin: .5rem 0 0; font-style: italic; font-size: .9rem; color: var(--on-desk-soft); }

/* closing */
.closing__sprig { width: 7rem; height: 1.75rem; color: var(--copper); opacity: .85; margin-bottom: 1rem; }
.closing__line { margin: 0; max-width: 24ch; font-family: var(--font-display); font-style: italic; font-size: 1.45rem; line-height: 1.3; color: var(--on-desk); text-wrap: balance; }
.closing__line--soft { margin-top: .45rem; font-size: 1.12rem; color: var(--on-desk-soft); }
.closing__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 1.4rem; margin-top: 1.6rem; }
.text-link {
  min-height: 44px;
  padding: .25rem .1rem;
  border: 0;
  background: none;
  font-family: var(--font-text);
  font-size: .98rem;
  color: var(--on-desk-soft);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .32em;
  text-decoration-color: rgba(239, 228, 210, .35);
  cursor: pointer;
}
.text-link:hover { color: var(--on-desk); }

/* --- Title on the desk ------------------------------------------------------ */
.desk-title {
  position: absolute;
  z-index: 3;
  top: max(1.4rem, calc(env(safe-area-inset-top) + .8rem));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  transition: opacity 500ms ease;
}
.desk-title p { margin: 0; }
.desk-title__name { font-family: var(--font-display); font-weight: 500; font-size: .9rem; letter-spacing: .32em; text-transform: uppercase; color: var(--on-desk); }
.desk-title__sub { margin-top: .3rem !important; font-style: italic; font-size: .88rem; color: var(--on-desk-soft); }
body:not([data-state="sealed"]) .desk-title { opacity: 0; }

.skip-link {
  position: relative;
  z-index: 3;
  margin-top: .5rem;
  font-size: .8rem;
  color: var(--on-desk-soft);
  opacity: .75;
  text-underline-offset: .25em;
}
body:not([data-state="sealed"]) .skip-link { visibility: hidden; }

/* --- Music: a small antique-brass medallion, opening screen only ---------
   It lives inside the opening scene (absolute, not fixed), so it never
   follows the scroll, and it fades away as soon as the envelope is opened. */
.music {
  position: absolute;
  z-index: 5;
  top: max(20px, calc(env(safe-area-inset-top) + 12px));
  right: max(20px, calc(env(safe-area-inset-right) + 12px));
  display: grid;
  justify-items: end;
  gap: 6px;
  transition: opacity 450ms var(--ease-settle), visibility 0s linear 450ms;
}
body:not([data-state="sealed"]) .music { opacity: 0; visibility: hidden; pointer-events: none; }
.music__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(166, 138, 100, .62);       /* hairline antique copper */
  border-radius: 50%;
  background: rgba(46, 38, 33, .38);                 /* translucent charcoal-brown */
  color: rgba(239, 228, 210, .82);                   /* warm ivory note */
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 500ms ease, border-color 500ms ease, background 500ms ease;
}
/* a second, finer ring just inside the edge, like a struck medallion */
.music__btn::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: .5px solid rgba(166, 138, 100, .35);
  border-radius: 50%;
}
.music__note { width: 17px; height: 17px; }
.music__btn:hover { border-color: rgba(166, 138, 100, .9); }
.music__btn:focus-visible { outline: 1.5px solid var(--copper); outline-offset: 3px; }
/* playing: the note warms to muted antique gold and the rim brightens slightly */
.music.is-playing .music__btn { color: #C9AC7C; border-color: rgba(166, 138, 100, .95); background: rgba(58, 44, 34, .45); }
.music.is-unavailable .music__btn { opacity: .38; cursor: not-allowed; }
.music__note-text {
  max-width: 14rem;
  margin: 0;
  padding: .35rem .6rem;
  font-style: italic;
  font-size: .78rem;
  line-height: 1.35;
  text-align: right;
  color: var(--on-desk-soft);
  background: rgba(36, 35, 33, .75);
}
/* narrow phones: tighten the centred title a touch so it never meets the medallion */
@media (max-width: 380px) { .desk-title__name { letter-spacing: .22em; font-size: .84rem; } }
@media (max-width: 340px) { .desk-title__name { letter-spacing: .15em; font-size: .8rem; } }

.scene--letter:focus { outline: none; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 380px) {
  .countdown li { min-width: 3.6rem; padding: 0 .3rem; }
  .countdown__num { font-size: 1.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-press: 1ms; --t-flap: 1ms; --t-rise: 1ms; --t-scene: 300ms; }
  .invitation, .panel--top, .envelope-stage, .desk-notes { transition-duration: 1ms !important; }
  .countdown__num.is-ticking, .desk-leaf { animation: none !important; }
}
