/* ==========================================================================
   layout.css: the material layer, the page frame, the card and its bands
   (top strip, striped header, lace edges, body, striped footer), the two
   panels, and where the two patches sit (position, size, resting tilt).
   Colours and sizes: css/tokens.css. Images: assets/trim/ (drawn stand-ins)
   and assets/art/ (photographic materials, listed in css/art.css and switched
   on per slot by html[data-art~="SLOT"]; shared contracts E2 and E3).
   The card's border is symmetric: outline, pink binding, lace (scallops pointing
   into the card), cocoa band, embroidered ribbon trim, lace onto the body; the
   footer mirrors the header exactly.
   ========================================================================== */

/* ---------- material layer: every surface reads these; each art slot swaps its own ---------- */
:root {
  --mat-page: url("../assets/trim/dots.svg");      /* page background */
  --mat-page-size: var(--dots-w) var(--dots-w);
  --mat-band: url("../assets/trim/stripe.svg");    /* header and footer bands, mocha ribbons */
  --mat-band-size: var(--stripe-w) var(--stripe-w);
  --mat-cream: none;                               /* panels, tiles, labels (flat cream without the fabric) */
  --mat-blush: none;                               /* fact boxes */
  --mat-petal: url("../assets/trim/dots-petal.svg"); /* petal cloth: text ribbon, active tile, order pill */
  --mat-petal-size: var(--dots-w) var(--dots-w);
  --mat-petal-color: var(--c-petal);
  --mat-petal-blend: normal;
  --mat-ribbon: var(--mat-cream);                  /* title and menu ribbons: cream weave multiplied over taupe */
  --mat-ribbon-size: var(--mat-size);
  --mat-ribbon-color: var(--c-mocha-700);
  --mat-size: 256px;                               /* fabric tile size */
  --mat-lace: url("../assets/trim/lace-down.svg"); /* lace edges */
  --mat-lace-w: 22px;                              /* stand-in scallop width (26px desktop) */
  --mat-lace-h: 13px;                              /* lace edge height (15px desktop; image: 28px / 38px) */
  --mat-lace-repeat: round no-repeat;
  --mat-body: url("../assets/trim/dots-light.svg"); /* card body around the panels */
  --mat-body-size: var(--dots-w) var(--dots-w);
  --mat-body-blend: normal;
  --mat-floral: url("../assets/trim/floral.svg");  /* tab tiles */
  --mat-floral-size: 64px;
  --mat-trim: url("../assets/trim/ribbon.svg");    /* embroidered ribbon: band trims and dividers */
  --mat-trim-ar: 3;                                /* tile width / height */
  --mat-trim-h: 14px;                              /* band trim height (18px desktop) */
  --mat-corner: none;                              /* the bouquet on the home panel's bottom left corner (empty until its image exists) */
  --mat-corner-ar: 2;
  /* small embroideries (E4): each place stays empty until its image exists; there is no drawn stand-in */
  --mat-spray-plate: none;  --mat-spray-plate-ar: 2;   /* daisy vine either side of the plate title */
  --mat-butterfly: none;    --mat-butterfly-ar: 1;     /* either side of "my links", fact boxes */
  --mat-bowknot: none;      --mat-bowknot-ar: 1;       /* panels' bottom corners, fact boxes */
  --mat-blossoms: none;     --mat-blossoms-ar: 1;      /* centre of the dividers, fact boxes */
  --lay-z-skip: calc(var(--z-marquee) + 1);        /* skip link above the ribbon */
  --lay-air: 10px;                                 /* the least air between a piece and any edge, trim or frame (14px desktop) */
  --lay-band-top: calc(var(--strip-h) + var(--mat-lace-h) + var(--lay-air) + 2px); /* header padding above the content */
}
html[data-art~="fabric-blush"] {
  --mat-page: var(--art-fabric-blush); --mat-page-size: var(--mat-size); --mat-blush: var(--art-fabric-blush);
  --mat-petal: var(--art-fabric-blush); --mat-petal-size: var(--mat-size); --mat-petal-color: var(--c-petal-base); --mat-petal-blend: multiply;
}
html[data-art~="fabric-cocoa"] {
  --mat-band: var(--art-fabric-cocoa); --mat-band-size: var(--mat-size);
  /* the title ribbon becomes a deeper piece of the same striped cloth */
  --mat-ribbon: var(--art-fabric-cocoa); --mat-ribbon-color: var(--c-ribbon-base);
}
html[data-art~="fabric-cream"] { --mat-cream: var(--art-fabric-cream); }
/* the body cloth: the blush fabric lightened (lighten keeps blush-50 and lets only the paler dots and threads through) */
html[data-art~="fabric-blush"] { --mat-body: var(--art-fabric-blush); --mat-body-size: var(--mat-size); --mat-body-blend: lighten; }
/* the print is sized by eye from the tile's own pixels: buds of about 8 to 12 CSS px, several per tab tile */
html[data-art~="fabric-floral"] { --mat-floral: var(--art-fabric-floral); --mat-floral-size: calc(var(--art-fabric-floral-w) * .5px) auto; } /* the tile is drawn for 256 CSS px: buds about 10px, 32px apart */
html[data-art~="ribbon"] { --mat-trim: var(--art-ribbon); --mat-trim-ar: var(--art-ribbon-ar); }
html[data-art~="corner"] { --mat-corner: var(--art-corner); --mat-corner-ar: var(--art-corner-ar); }
html[data-art~="spray-plate"] { --mat-spray-plate: var(--art-spray-plate); --mat-spray-plate-ar: var(--art-spray-plate-ar); }
html[data-art~="butterfly"] { --mat-butterfly: var(--art-butterfly); --mat-butterfly-ar: var(--art-butterfly-ar); }
html[data-art~="bowknot"] { --mat-bowknot: var(--art-bowknot); --mat-bowknot-ar: var(--art-bowknot-ar); }
html[data-art~="blossoms"] { --mat-blossoms: var(--art-blossoms); --mat-blossoms-ar: var(--art-blossoms-ar); }
html[data-art~="lace"] {
  --mat-lace: var(--art-lace);
  --mat-lace-h: 28px;
  --mat-lace-lap: 3px;             /* the real lace overlaps the edge it hangs from */
  --strip-h: 16px;                 /* a pink binding that still reads above the real lace */
  --mat-lace-w: calc(var(--mat-lace-h) * var(--art-lace-ar));
  --mat-lace-repeat: repeat-x;
  --lay-band-top: calc(var(--strip-h) - var(--mat-lace-lap) + var(--mat-lace-h) + var(--lay-air)); /* clear air under the lace */
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--c-blush);
  background-image: var(--mat-page);
  background-size: var(--mat-page-size);
}
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  color: var(--c-body);
  font-family: var(--font-text);
  font-size: var(--fs-text);
  font-weight: var(--text-weight);
  line-height: var(--text-lh);
  -webkit-tap-highlight-color: transparent;
}
/* the hand font's own spacing fix, only where it sets body copy */
:where(.richtext, .order-note, .menu-footnote, .panel-status) { letter-spacing: var(--text-track, normal); word-spacing: var(--text-word, normal); }
h1, h2, h3, p, ul, ol, figure, figcaption { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; text-align: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* focus: deep cocoa ring on every surface; the rose text ribbon switches --focus-color to cream */
:focus-visible { outline: var(--focus-w) solid var(--focus-color); outline-offset: var(--focus-offset); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px; top: 8px;
  z-index: var(--lay-z-skip);
  display: inline-flex;
  align-items: center;
  padding: 6px 20px;
  min-height: var(--tap);
  background-color: var(--c-cream);
  color: var(--c-cocoa);
  font-family: var(--font-label);
  font-size: var(--fs-sub);
  font-weight: var(--label-bold);
  border: 2px solid var(--c-cocoa);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-panel);
  translate: 0 -200%;
  --focus-color: var(--c-cocoa-900);
}
.skip-link:focus { translate: 0 0; }

.noscript-note {
  margin: 0 auto 28px;
  width: fit-content;
  max-width: calc(100vw - 32px);
  padding: 8px 20px;
  background-color: var(--c-cream);
  background-image: var(--mat-cream);
  background-size: var(--mat-size);
  color: var(--c-cocoa);
  font-family: var(--font-label);
  font-size: var(--fs-sub);
  font-weight: var(--label-bold);
  text-align: center;
  border: 2px solid var(--c-rose-200);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-panel);
}

/* ---------- text ribbon: a pale petal ribbon lying above the card, cocoa lettering, rose hearts ---------- */
.marquee {
  position: relative;
  z-index: var(--z-marquee);
  display: flex;
  align-items: center;
  height: var(--marquee-h);
  overflow: hidden;
  background-color: var(--mat-petal-color);
  background-image: var(--mat-petal);
  background-size: var(--mat-petal-size);
  background-blend-mode: var(--mat-petal-blend);
  color: var(--c-cocoa-900);
  font-family: var(--font-label);
  font-size: var(--fs-marquee);
  font-weight: var(--label-bold);
  line-height: var(--label-lh);
  box-shadow: 0 1px 2px var(--c-cocoa-a12), 0 4px 10px -4px var(--c-cocoa-a22);
  --sp-fill: var(--c-rose);
}
.marquee-viewport { width: 100%; overflow: hidden; }
.marquee-track {
  display: flex;
  align-items: center;
  width: max-content;
  white-space: nowrap;
  will-change: transform;
}
.marquee-clone { display: flex; align-items: center; flex: none; }
.marquee-item { flex: none; }
.marquee-sep { flex: none; width: 13px; height: 13px; margin: 0 18px; }
/* Reduced motion: no animation, no clone, the items wrap. */
.marquee.is-static { height: auto; min-height: var(--marquee-h); padding: 6px 12px; }
/* the ribbon's own height holds the lines; nothing clips them (their tails and long lines) */
.marquee.is-static .marquee-viewport { overflow: visible; }
.marquee.is-static .marquee-item { flex: 0 1 auto; min-width: 0; text-align: center; overflow-wrap: anywhere; }
.marquee.is-static .marquee-track {
  width: auto;
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 2px;
  white-space: normal;
  will-change: auto;
}
.marquee.is-static .marquee-sep:last-child { display: none; }

/* ---------- stage and card ---------- */
/* overflow-x: clip keeps a patch's entrance pop from ever widening the page */
.stage { position: relative; padding: 16px 0 30px; overflow-x: clip; }

.quilt {
  position: relative;
  z-index: var(--z-quilt);
  width: var(--quilt-w);
  margin: 0 auto;
  border: var(--binding) solid var(--c-cocoa);
  border-radius: var(--r-quilt);
  background-color: var(--c-rose-200); /* the binding colour: nothing else can show between outline and strip */
  box-shadow: var(--sh-card);
  overflow: clip;
}

/* ---------- lace edges (four): one image hanging down, flipped where it stands up (footer side).
   The repeat is centred, so both corners cut the same scallop at the same point. A flip also flips the
   shadow, so every lace casts its shadow the way its scallops point. ---------- */
.quilt-top::after,
.quilt-body::before,
.quilt-foot::before,
.hem-lace {
  content: "";
  position: absolute;
  z-index: 1;
  left: 0; right: 0;
  height: var(--mat-lace-h);
  background-image: var(--mat-lace);
  background-size: var(--mat-lace-w) var(--mat-lace-h);
  background-repeat: var(--mat-lace-repeat);
  background-position: center top;
  filter: drop-shadow(0 1.5px 1.5px var(--c-cocoa-a22));
  pointer-events: none;
}
/* embroidered ribbon trim on the band's inner edge, sewn over the lace heading */
.hem-ribbon {
  position: absolute;
  z-index: 2;
  left: 0; right: 0;
  height: var(--mat-trim-h);
  background-image: var(--mat-trim);
  background-size: auto 100%;
  background-repeat: repeat-x;
  background-position: center;
  box-shadow: 0 1px 2px var(--c-cocoa-a22);
  pointer-events: none;
}

/* ---------- header band: rose strip, hanging lace, cocoa fabric ---------- */
.quilt-top {
  position: relative;
  padding: var(--lay-band-top) 12px calc(var(--mat-trim-h) + var(--lay-air) + 2px);
  background-color: var(--c-mocha);
  background-image: var(--mat-band);
  background-size: var(--mat-band-size);
  color: var(--c-cream);
}
.quilt-top::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0; left: 0; right: 0;
  height: var(--strip-h);
  background-color: var(--c-rose-200);
  pointer-events: none;
}
.quilt-top::after { top: calc(var(--strip-h) - 1px - var(--mat-lace-lap, 0px)); }
.quilt-top > .hem-ribbon { bottom: 0; }

.profile {
  position: relative;
  z-index: 3; /* the photo frame sits over the hanging lace */
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.profile-text {
  display: flex;
  flex-direction: column;
  align-items: stretch; /* the name label fills the room beside the photo */
  gap: 8px;
  min-width: 0;
  flex: 1;
}

/* no name and no tagline: the label is hidden (js/render-profile.mjs); the photo stands alone in the middle on
   phones, and on desktop the tabs take the whole height beside it, so no empty row is left above them */
.profile-text:has(> .name-ribbon[hidden]) { display: none; }
.profile:has(.name-ribbon[hidden]) { justify-content: center; }

.tabs {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* ---------- body: lace hanging under the header, then the two panels ---------- */
.quilt-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--gap-m);
  padding: calc(var(--mat-lace-h) + 8px) var(--gap-m) calc(var(--mat-lace-h) + 14px);
  background-color: var(--c-blush-50);
  background-image: var(--mat-body);
  background-size: var(--mat-body-size);
  background-blend-mode: var(--mat-body-blend);
}
.quilt-body::before { top: calc(-1px - var(--mat-lace-lap, 0px)); }
.col { display: contents; }

/* panels: cream cloth, a soft shadow, one dashed stitch frame inside (positioned, never a stacking context) */
.block {
  position: relative;
  min-width: 0;
  border-radius: var(--r-block);
  background-color: var(--c-cream);
  background-image: var(--mat-cream);
  background-size: var(--mat-size);
  box-shadow: var(--sh-panel);
}
.block::before {
  content: "";
  position: absolute;
  inset: var(--stitch-inset);
  border: var(--stitch) dashed var(--c-stitch);
  border-radius: calc(var(--r-block) - var(--stitch-inset));
  pointer-events: none;
}
.panel-block { order: 1; display: flex; flex-direction: column; padding: 18px 16px 24px; }
/* the links panel's top padding puts the script ink of "my links" 10px under the stitch frame (less what its box can be counted on to hold, --ink-hold) */
.links-block { order: 2; padding: calc(var(--stitch-inset) + var(--stitch) + 10px - var(--ink-hold, 0px)) 16px 24px; }
/* room for the bowknot inside the frame's bottom corner: frame inset + 8px + knot + 10px of air to the text */
html[data-art~="bowknot"] :is(.panel-block:not(:has(> .panel--home)), .links-block) { padding-bottom: calc(var(--stitch-inset) + 18px + var(--knot-w)); }

/* ---------- footer band: the header's border mirrored. From the body down: lace standing on the band,
   ribbon trim, cocoa fabric, lace with its scallops pointing up, pink binding, outline ---------- */
.quilt-foot {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: var(--lay-foot-h);
  padding: calc(var(--mat-trim-h) + 12px) 16px var(--lay-band-top);
  background-color: var(--c-mocha);
  background-image: var(--mat-band);
  background-size: var(--mat-band-size);
}
:root { --lay-foot-h: calc(var(--lay-band-top) + var(--mat-trim-h) + 26px); } /* a hem of fabric shows between the trims, not an empty band */
.quilt-foot::before {
  top: calc(var(--mat-lace-h) * -1 + 1px + var(--mat-lace-lap, 0px));
  transform: scaleY(-1);
}
.quilt-foot > .hem-ribbon { top: 0; }
.quilt-foot > .hem-lace { bottom: calc(var(--strip-h) - 1px - var(--mat-lace-lap, 0px)); transform: scaleY(-1); }
.quilt-foot::after {
  content: "";
  position: absolute;
  z-index: 2;
  bottom: 0; left: 0; right: 0;
  height: var(--strip-h);
  background-color: var(--c-rose-200);
  pointer-events: none;
}
.foot-label:has(> .foot-text[hidden]) { display: none; }

/* ---------- the two patches: position, size, resting tilt (drawing: css/patches.css) ---------- */
.patch { position: absolute; z-index: var(--z-patch); }
/* bow: top centre on the photo's lace frame */
.patch-bow {
  width: 44px;
  top: -12px;
  left: calc(50% - 22px);
  --patch-tilt: -5deg;
}
/* the satin bow photo is wider than tall: give it a wider box, same centre */
html[data-art~="bow"] .patch-bow {
  --lay-bow-w: 52px;
  width: var(--lay-bow-w);
  aspect-ratio: var(--art-bow-ar);
  left: calc(50% - var(--lay-bow-w) / 2);
  top: calc(var(--frame-d) * .1 - var(--lay-bow-w) / var(--art-bow-ar) / 2); /* on the doily's top edge, overlapping the photo a little */
  --patch-tilt: -6deg;
}

/* ---------- desktop: header in two columns, body in two columns ---------- */
@media (min-width: 960px) {
  :root { --mat-lace-w: 26px; --mat-lace-h: 15px; --lay-air: 14px; }
  html[data-art~="lace"] { --mat-lace-h: 36px; --mat-lace-w: calc(var(--mat-lace-h) * var(--art-lace-ar)); }
  .stage { padding: 14px 0 28px; }

  .quilt-top {
    display: grid;
    grid-template-columns: var(--frame-d) minmax(0, 1fr);
    column-gap: 30px;
    row-gap: 14px;
    align-items: center;
    padding: var(--lay-band-top) 28px calc(var(--mat-trim-h) + 18px) 30px; /* the tab tiles keep clear of the hem ribbon */
  }
  .profile { display: contents; }
  .photo-patch { position: relative; z-index: 3; grid-column: 1; grid-row: 1 / 3; }
  .profile-text {
    position: relative;
    z-index: 3;
    grid-column: 2;
    grid-row: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center; /* the name label runs the whole width of the row of tabs */
    column-gap: 22px;
    row-gap: 6px;
  }
  .tabs { grid-column: 2; grid-row: 2; gap: 14px; }
  .quilt-top:has(.name-ribbon[hidden]) .tabs { grid-row: 1 / 3; }

  .quilt-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side-w);
    align-items: stretch;
    gap: 18px;
    padding: calc(var(--mat-lace-h) + var(--lay-air)) 22px calc(var(--mat-lace-h) + 10px);
  }
  .col { display: flex; flex-direction: column; min-width: 0; }
  /* the links column keeps its own height: on a short tab the page panel stretches to end on the same
     line, on a long tab the links end after the order note and follow the scroll (class set by js/app.mjs) */
  .col-side { align-self: start; }
  .col-side.is-sticky { position: sticky; top: 14px; }
  .block { flex: 1 0 auto; }
  .block::before { --stitch: 2px; }
  .panel-block { padding: 20px 28px 28px; }
  /* 1px more than on phones: at 36px a capital with a hook above (Ỷ) rises 1px past the box's top edge */
  .links-block { padding: calc(var(--stitch-inset) + var(--stitch) + 11px - var(--ink-hold, 0px)) 24px 28px; }
  html[data-art~="bowknot"] :is(.panel-block:not(:has(> .panel--home)), .links-block) { padding-bottom: calc(var(--stitch-inset) + 22px + var(--knot-w)); }

  :root { --mat-trim-h: 18px; }
  .quilt-foot { padding-left: 40px; padding-right: 40px; }

  .patch-bow { width: 54px; top: -16px; left: calc(50% - 27px); }
  html[data-art~="bow"] .patch-bow { --lay-bow-w: 72px; }
}

@media (max-width: 359px) {
  .tabs { gap: 5px; }
  .quilt-top { padding-left: 9px; padding-right: 9px; }
  .profile { gap: 10px; }
  .quilt-body { padding-left: 8px; padding-right: 8px; gap: 10px; }
  .panel-block, .links-block { padding-left: 16px; padding-right: 16px; }
}
