/* ==========================================================================
   Needle and thread: the home page's opening animation, and the stitched lines
   shared by the home, gallery, pricing and "page not found" pages.
   Loaded after styles.css on those pages. Works with js/thread.js.

   Everything is laid out in its finished place and look. The opening animation,
   the threads drawn on scroll and the slow loops only reveal or move what is
   already there, so nothing shifts, and without them (reduced motion, no script,
   a later visit) the page is simply shown finished.
   ========================================================================== */

/* Colors: one set per theme, switched by the same data-theme attribute as the rest of the site. */
:root {
  --thread: #9F89DB;
  --thread-accent: #4C2A94;
  --needle: #8C84A3;
  --btn-glow: rgba(76, 42, 148, 0.28);
  --logo-fill: #FFFFFF;
  /* The closing band is purple in light mode and lilac in dark mode, so its glow is its own. */
  --cta-glow: rgba(255, 255, 255, 0.34);
  --tape: #FFFDF6;
  --patch-weave: rgba(76, 42, 148, 0.035);
  --star-pale: #DAD0F0;
}
:root[data-theme='dark'] {
  --thread: #8A77C4;
  --thread-accent: #C4A5FF;
  --needle: #CFC8E0;
  --btn-glow: rgba(196, 165, 255, 0.3);
  --logo-fill: #2A2140;
  --cta-glow: rgba(42, 27, 82, 0.3);
  --tape: #3A2F58;
  --patch-weave: rgba(196, 165, 255, 0.045);
  --star-pale: #544874;
}

/* Building blocks -----------------------------------------------------------
   A thread is a dashed line. Its mask holds a solid copy of the same line ("sew-mask", uncovered
   by moving stroke-dashoffset from 1 to 0) or a plain block ("wipe-..."), and drawing the thread
   means uncovering it through that mask. Once drawn, its dashes slowly march along it. */
.thread-line { fill: none; stroke: var(--thread); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 7 7; }
.sew-mask { fill: none; stroke: #FFFFFF; stroke-width: 9; stroke-dasharray: 1; }
.wipe-down,
.wipe-right { fill: #FFFFFF; transform-box: fill-box; }
.wipe-down { transform-origin: 50% 0; }
.wipe-right { transform-origin: 0 50%; }

/* A stitched loop around a button, a little outside its edge. It is sized from the button, so it fits any layout. */
.btn-sewn,
.btn-breathe { position: relative; }
.btn-loop { position: absolute; left: -8px; top: -8px; width: calc(100% + 16px); height: calc(100% + 16px); max-width: none; overflow: visible; pointer-events: none; }
.loop-rect { width: calc(100% - 4px); height: calc(100% - 4px); }
.btn-loop .sew-mask { stroke-width: 6; }
/* The glow that slowly breathes around a button. */
.btn-breathe::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 5px var(--btn-glow), 0 0 26px 8px var(--btn-glow); opacity: 0.35; pointer-events: none; }

/* Hero ---------------------------------------------------------------------- */
.hero-mark { position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.hero-mark-logo { flex: none; width: 64px; height: 64px; }
.hero-mark-disc { fill: var(--logo-fill); }
.hero-mark-ring { fill: none; stroke: var(--thread-accent); stroke-width: 3; stroke-linecap: round; }
.hero-mark-stitch { fill: none; stroke: var(--thread-accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.6; }
.hero-mark-tc { fill: var(--thread-accent); font-family: var(--font-head); font-size: 23px; font-weight: 800; letter-spacing: -0.5px; }
/* Kept on one line, so the tagline can't re-wrap (and shift) when its font arrives. */
.hero-mark-line { color: var(--thread-accent); font-family: var(--font-script); font-size: 1.7rem; font-weight: 700; line-height: 1.1; white-space: nowrap; }

/* The thread that curves in from the top left to the logo, and the needle that pulls it (wide screens).
   The needle's path below is the same line as the thread's in index.html. */
.hero-lead { position: absolute; right: 100%; bottom: 24px; width: 240px; height: 116px; margin-right: -3px; pointer-events: none; }
.hero-lead svg { max-width: none; }
.needle { position: absolute; left: 0; top: 0; opacity: 0; offset-path: path('M0 0C50 70 110 10 160 40S228 79 269 79'); offset-rotate: auto; }
.needle path { fill: var(--needle); }
.needle-eye { fill: var(--bg); }

/* The thread down the left margin, beside the text and never over it, from the logo to the first button (wide screens). */
.hero-body { position: relative; }
.hero-seam { position: absolute; left: -22px; top: 0; width: 22px; height: calc(100% + 42px); max-width: none; overflow: visible; pointer-events: none; }
.seam-wipe { height: calc(100% + 110px); }

.underlined .thread-line { stroke-width: 3; }
.underlined .sew-mask { stroke-width: 14; }

/* "start here, it's free to ask!": below and to the right of the buttons, its arrow pointing up at the first one. */
.hero-note { display: flex; align-items: flex-end; gap: 6px; flex-basis: 100%; margin: 2px 0 0 168px; color: var(--thread-accent); font-family: var(--font-script); font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.hero-note svg { flex: none; }
.hero-note .thread-line { stroke: var(--thread-accent); stroke-dasharray: 4 4; }

/* "See what we make", below the checklist with clear space, and a short thread that keeps moving down. */
.scroll-cue { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 44px; color: var(--accent); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.scroll-cue:hover { text-decoration: none; }
.scroll-cue .thread-line { stroke-dasharray: 4 4; }

/* The tag that hangs from the header's "Start Your Order" button (wide screens). js/thread.js sets
   --tag-x / --tag-y (the bottom middle of the button, inside the header) and --tag-drop (how long
   the string is, so the tag clears the header). The box itself is that one point, and the string
   and tag swing about it together. It fades away once the page is scrolled, as the header stays. */
.header-tag { position: absolute; left: var(--tag-x, 0); top: var(--tag-y, 0); width: 0; height: 0; transform-origin: 0 0; pointer-events: none; visibility: hidden; opacity: 0; transition: opacity 0.25s ease, visibility 0s linear 0.25s; }
.header-tag.is-hung { visibility: visible; opacity: 1; transition: opacity 0.25s ease; }
.header-tag-string { position: absolute; left: -3px; top: 0; width: 6px; height: var(--tag-drop, 40px); max-width: none; }
.header-tag .thread-line { stroke: var(--thread-accent); stroke-dasharray: 4 4; }
.header-tag-card { position: absolute; left: 0; top: calc(var(--tag-drop, 40px) - 10px); transform: translateX(-50%); padding: 21px 14px 8px; border-radius: 10px; border: 1.5px dashed var(--thread-accent); background: var(--logo-fill); box-shadow: 0 8px 20px var(--shadow-drop); color: var(--thread-accent); font-family: var(--font-script); font-size: 1.3rem; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.header-tag-hole { position: absolute; left: 50%; top: 6px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 1px var(--thread-accent); }

/* The thread from "See what we make" into the next section. It is placed at the top left of the
   page and drawn in page coordinates, over the section backgrounds and under the header. */
.cue-thread { position: absolute; z-index: 1; left: 0; top: 0; width: 1px; height: 1px; max-width: none; overflow: visible; pointer-events: none; }

/* What we make ---------------------------------------------------------------
   The thread runs along the top edge of the cards, above their icons and text: one line behind
   every card, and a wavy piece in front of the first and third. */
.products { position: relative; isolation: isolate; }
.product-card { position: relative; }
/* The line behind the cards reaches up to 70px past them on each side (less where the screen has no
   room): the thread from the hero joins its left end, and the thread to the reviews leaves its right. */
.weave-back { --reach: clamp(0px, calc((100vw - 100%) / 2 - 40px), 70px); position: absolute; z-index: -1; left: calc(var(--reach) * -1); top: 0; width: calc(100% + var(--reach) * 2); height: 36px; max-width: none; pointer-events: none; }
.weave-front { position: absolute; left: 0; top: 0; width: 100%; height: 36px; pointer-events: none; }
/* Narrower than four cards across: one straight line down the middle, behind the cards. It starts
   just above them, where the thread from the hero joins it, and the thread to the reviews leaves
   from just below them. */
.weave-down { display: none; position: absolute; z-index: -1; left: 50%; top: -14px; width: 6px; height: calc(100% + 28px); margin-left: -3px; max-width: none; pointer-events: none; }

/* Card hover: a dashed border sews itself around the inside of the card and the icon tilts.
   Only where there is a real pointer, so touch screens get no hover effect. */
.product-card::after { content: ''; position: absolute; inset: 9px; border: 2px dashed var(--thread); border-radius: 13px; clip-path: inset(0 100% 0 0); pointer-events: none; }
.icon-chip { transition: transform 0.3s ease; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .product-card::after { transition: clip-path 0.8s ease; }
}
@media (hover: hover) and (pointer: fine) {
  .product-card:hover,
  .product-card:focus-within { transform: translateY(-4px); border-color: var(--accent-line); }
  .product-card:hover::after,
  .product-card:focus-within::after { clip-path: inset(0); }
  .product-card:hover .icon-chip,
  .product-card:focus-within .icon-chip { transform: rotate(-8deg); }
}

/* Kind words: review patches ---------------------------------------------------
   Each review sits on a "fabric patch": a card with a faint weave, a little tilted, with a dashed
   stitch around its inside edge. Everything is in its finished place and look by default. */
/* The three patches are the same height, with the name line at the bottom of each. */
.patches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; align-items: stretch; }
.patch {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 30px 28px 26px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background-color: var(--card);
  background-image:
    repeating-linear-gradient(0deg, var(--patch-weave) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, var(--patch-weave) 0 1px, transparent 1px 5px);
  box-shadow: var(--card-shadow);
  transform: rotate(var(--tilt, 0deg));
}
.patch:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 4px; }
.patch-border { position: absolute; left: 8px; top: 8px; width: calc(100% - 16px); height: calc(100% - 16px); max-width: none; overflow: visible; pointer-events: none; }
.patch-rect { width: calc(100% - 4px); height: calc(100% - 4px); }
.patch-border .sew-mask { stroke-width: 6; }
.patch-stars { display: block; flex: none; margin-bottom: 16px; }
/* A finished star is one solid shape. A half star is the same shape filled by a gradient with a
   hard edge down its middle: full color on the left, the pale "empty star" color on the right.
   The dashed outline ("star-lines") is only there while the stars are being stitched in. */
.star-fill { fill: var(--thread-accent); stroke: var(--thread-accent); stroke-width: 1.2; stroke-linejoin: round; }
.star-fill.is-half { fill: url(#half-star); stroke: url(#half-star); }
.star-on { stop-color: var(--thread-accent); }
.star-off { stop-color: var(--star-pale); }
.star-lines { fill: none; stroke: var(--thread-accent); stroke-width: 1.4; stroke-linejoin: round; stroke-dasharray: 2.6 1.6; opacity: 0; }
.star-sew { stroke-width: 4; }
/* The quote grows to fill the patch, so the name line sits at the bottom. Two big, faint quotation
   marks frame the words without touching them: one above the first line at the left, one below
   the last line at the right. */
.patch blockquote { position: relative; flex: 1 1 auto; margin: 0 0 14px; padding-top: 24px; }
.patch blockquote p { position: relative; margin: 0; padding-bottom: 26px; color: var(--text-strong); font-size: 1.02rem; line-height: 1.6; }
.patch-quote { position: absolute; left: -6px; top: -8px; color: var(--thread-accent); font-family: var(--font-head); font-size: 64px; font-weight: 800; line-height: 1; opacity: 0.25; transform-origin: 0 0; pointer-events: none; }
.patch-quote-end { left: auto; right: -2px; top: auto; bottom: -34px; transform-origin: 100% 0; }
/* The product and its little heart stay together on one line. If there is no room beside the
   name, the two move down together. */
.patch figcaption { flex: none; }
.patch figcaption strong { color: var(--heading); }
.patch-product { display: inline-block; color: var(--text); font-size: 0.93rem; white-space: nowrap; }
.patch-product::before { content: '· '; }
.patch-heart { display: inline-block; margin-left: 6px; vertical-align: -3px; }
.patch-heart .thread-line { stroke: var(--thread-accent); stroke-width: 1.5; stroke-dasharray: 3 2.6; }
.patch-heart .sew-mask { stroke-width: 5; }
.patch-dots { display: none; justify-content: center; gap: 10px; margin-top: 14px; }
.patch-dots i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px dashed var(--thread-accent); }
.patch-dots i.is-on { border-style: solid; background: var(--thread-accent); }
.patch-more { margin-top: 30px; font-size: 0.95rem; }
.patch-more a { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

/* A patch's stitches hold still (text sits right beside them). Hover or focus, with a real pointer:
   the patch straightens and lifts, and the stitches around its edge march. */
.patch .thread-line { animation-play-state: paused; }
@media (hover: hover) and (pointer: fine) {
  .patch:hover,
  .patch:focus-visible { transform: rotate(0deg) translateY(-4px); }
  .patch:hover .patch-border .thread-line,
  .patch:focus-visible .patch-border .thread-line { animation-play-state: running; }
}

/* Final call to action: thread in from the left, around the button, tied off in a small heart. */
.cta-band { overflow: hidden; }
.cta-sew { position: relative; display: inline-block; }
.cta-lead,
.cta-tail { position: absolute; top: 50%; margin-top: -20px; max-width: none; pointer-events: none; }
.cta-lead { right: 100%; margin-right: 6px; }
.cta-tail { left: 100%; margin-left: 6px; }
.cta-band .thread-line { stroke: var(--cta-text); }
.cta-band .btn-breathe::after { box-shadow: 0 0 0 5px var(--cta-glow), 0 0 26px 8px var(--cta-glow); }

/* Shared by every page that uses the thread ------------------------------------ */

/* A dashed border sewn around the inside of a card (data-stitch="border"). */
[data-stitch='border'] { position: relative; }
[data-stitch='border']::after { content: ''; position: absolute; inset: 9px; border: 2px dashed var(--thread); border-radius: 13px; pointer-events: none; }

/* A wavy stitch under the page's main heading (data-stitch="underline" on the h1, with the
   small SVG inside it). The heading keeps room for it, so nothing moves when it is drawn. */
[data-stitch='underline'] { position: relative; padding-bottom: 22px; }
.title-stitch { position: absolute; left: 50%; bottom: 4px; margin-left: -110px; max-width: none; pointer-events: none; }
.title-stitch .thread-line { stroke-width: 2.5; }

/* The thread along the bottom edge of the header: it fills from left to right as the page is
   scrolled. js/thread.js sets --scrolled (0 to 1). The outer piece slides in from the left while
   the dashes inside slide back by the same amount, so the dashes stay put and are only uncovered. */
.scroll-thread { position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; overflow: hidden; pointer-events: none; transform: translateX(calc((var(--scrolled, 0) - 1) * 100%)); }
.scroll-thread span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--thread) 0 8px, transparent 8px 14px); transform: translateX(calc((1 - var(--scrolled, 0)) * 100%)); }

/* Footer: a short thread runs from "Start your order" and ties off in a tiny heart. */
.footer-start { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; }
.footer-start a { color: var(--heading); font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.footer-start svg { flex: none; }
.site-footer .thread-line { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 4 4; }

/* A handwritten note with a short stitched arrow. */
.stitch-note { display: flex; align-items: flex-start; gap: 6px; margin: 0; color: var(--thread-accent); font-family: var(--font-script); font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stitch-note svg { flex: none; }
.stitch-note .thread-line { stroke: var(--thread-accent); stroke-dasharray: 4 4; }

/* Gallery: the clothesline -----------------------------------------------------
   The filter buttons hang from a dashed line that sags in the middle. Each tag is held by a
   small clothespin and hangs lower the nearer it is to the middle (--drop, set by js/thread.js). */
.filters[data-clothesline] { position: relative; flex-wrap: nowrap; padding: 26px 0 18px; margin-bottom: 26px; }
.clothesline-line { position: absolute; left: 0; top: 0; width: 100%; height: 44px; max-width: none; pointer-events: none; }
.filters[data-clothesline]::before,
.filters[data-clothesline]::after { content: ''; position: absolute; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--thread-accent); }
.filters[data-clothesline]::before { left: -4px; }
.filters[data-clothesline]::after { right: -4px; }
.filters[data-clothesline] .pill { position: relative; flex: none; transform: translateY(var(--drop, 11px)); transform-origin: 50% -16px; }
.filters[data-clothesline] .pill::before { content: ''; position: absolute; left: 50%; top: -20px; width: 7px; height: 18px; margin-left: -3.5px; border-radius: 3px; background: var(--thread-accent); }
/* The chosen tag is filled. */
.filters[data-clothesline] .pill[aria-pressed='true'] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }

/* Photos: a dashed border sews itself around the inside of the card on hover or focus, and photos
   further down fade up as they are scrolled to ("is-waiting" is set and cleared by js/thread.js). */
.masonry-item { position: relative; }
.masonry-item::after { content: ''; position: absolute; inset: 9px; border: 2px dashed var(--thread); border-radius: 13px; clip-path: inset(0 100% 0 0); pointer-events: none; }
.masonry-item.is-waiting { opacity: 0; transform: translateY(16px); }
@media (hover: hover) and (pointer: fine) {
  .masonry-item:hover::after { clip-path: inset(0); }
}
.masonry-item:focus-within::after { clip-path: inset(0); }

/* The lightbox: a dashed frame stitches around the photo each time one is shown. */
.lightbox-figure picture { position: relative; display: inline-flex; padding: 9px; }
.lightbox-figure picture::after { content: ''; position: absolute; inset: 0; border: 2px dashed var(--thread); border-radius: 18px; pointer-events: none; }

/* Pricing: the measuring tape -----------------------------------------------------
   A light strip with a short tick every fifth of a unit, a longer one at every unit and the
   numbers 0 to 10. A unit is 100px, so the ticks are 20px apart. */
.tape { --unit: 100px; --units: 10; display: block; width: calc(var(--unit) * var(--units) + 44px); max-width: 100%; height: 40px; margin: 30px auto 0; overflow: hidden; border-radius: 8px; }
.tape-strip {
  position: relative;
  display: block;
  width: calc(var(--unit) * var(--units) + 44px);
  height: 100%;
  border: 1.5px solid var(--thread);
  border-radius: 8px;
  background-color: var(--tape);
  background-image: linear-gradient(90deg, var(--thread-accent) 0 2px, transparent 2px), linear-gradient(90deg, var(--thread) 0 1px, transparent 1px);
  background-size: var(--unit) 16px, calc(var(--unit) / 5) 9px;
  background-position: 13px 0, 13px 0;
  background-repeat: repeat-x;
}
.tape-strip i { position: absolute; left: calc(13px + var(--unit) * var(--i) + 6px); bottom: 3px; color: var(--thread-accent); font: 700 0.7rem/1 var(--font-body); font-style: normal; }
.price-note { margin: 0 0 6px 14px; }

/* Page not found: a tangled thread that straightens out, with a needle at its end. */
.unstitched { display: block; width: 320px; max-width: 100%; height: auto; margin: 0 auto 6px; overflow: visible; }
.unstitched .needle-end path { fill: var(--needle); }
.unstitched .needle-end .needle-eye { fill: var(--bg); }
.unstitched-note { justify-content: center; margin-bottom: 22px; }
.notfound-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 30px; }

/* Timing --------------------------------------------------------------------
   When things happen in the opening animation, in seconds from the page appearing. */
.hero {
  --t-lead: 0.2s;
  --t-ring: 1s;
  --t-photo: 1.2s;
  --t-tc: 1.6s;
  --t-line: 1.65s;
  --t-head: 1.9s;
  --t-btn: 2s;
  --t-sub: 2.4s;
  --t-under: 2.5s;
  --t-seam: 2.6s;
  --t-loop: 3.3s;
  --t-trust: 3.4s;
  --t-cue: 3.6s;
  --t-glow: 3.9s;
  --t-note: 4.1s;
}

@media (prefers-reduced-motion: no-preference) {
  /* Always on: dashes march slowly along every thread, button glows breathe, the tag swings. */
  .thread-line { animation: thread-march 3.2s linear infinite; }
  .btn-breathe::after { animation: btn-breathe 1.7s ease-in-out infinite alternate; }
  .header-tag { animation: tag-swing 2.25s ease-in-out infinite alternate; }

  /* The opening animation: only while <html> has "intro-play" (see js/thread.js). */
  /* The needle slows as it arrives, so most of its glide is spent in view. */
  .intro-play .hero-lead .sew-mask { animation: sew 0.9s cubic-bezier(0.1, 0.6, 0.3, 1) var(--t-lead) both; }
  .intro-play .needle { animation: needle-glide 0.9s cubic-bezier(0.1, 0.6, 0.3, 1) var(--t-lead) both; }
  .intro-play .hero-mark-ring { stroke-dasharray: 1; animation: sew 0.7s ease-in-out var(--t-ring) both; }
  .intro-play .hero-mark-stitch { animation: fade-stitch 0.3s ease-out var(--t-tc) both; }
  .intro-play .hero-mark-tc { animation: fade-in 0.3s ease-out var(--t-tc) both; }
  .intro-play .hero-mark-line { animation: write-in 0.6s ease-out var(--t-line) both; }
  .intro-play .hero-in { animation: fade-up 0.5s ease-out var(--at) both; }
  .intro-play .hero-media { animation: fade-in 0.7s ease-out var(--t-photo) both; }
  .intro-play .underlined .sew-mask { animation: sew 0.5s ease-out var(--t-under) both; }
  .intro-play .seam-wipe { animation: wipe-down 0.7s ease-in-out var(--t-seam) both; }
  .intro-play .hero-actions .btn-loop .sew-mask { animation: sew 0.6s ease-in-out var(--t-loop) both; }
  .intro-play .hero-actions .btn-breathe::after { animation: btn-breathe 1.7s ease-in-out infinite alternate, hold-hidden var(--t-glow) step-end; }
  .intro-play .hero-note { animation: fade-in 0.5s ease-out var(--t-note) both; }

  /* On load, on the pages that have them: the stitch under the heading, the clothesline and its
     tags dropping in one by one, the tape unrolling, and the 404 thread untangling. */
  .title-stitch .sew-mask { animation: sew 0.6s ease-out 0.25s both; }
  .clothesline-line .sew-mask { animation: sew 0.8s ease-in-out 0.1s both; }
  .filters[data-clothesline] .pill { animation: tag-drop 0.45s ease-out calc(0.45s + var(--n, 0) * 0.12s) both; }
  .filters[data-clothesline] .pill.is-swinging { animation: tag-drop 0.45s ease-out calc(0.45s + var(--n, 0) * 0.12s) both, tag-swing-once 0.9s ease-in-out; }
  .masonry-item { transition: opacity 0.5s ease, transform 0.5s ease; }
  .masonry-item::after { transition: clip-path 0.8s ease; }
  .lightbox-figure picture::after { animation: stitch-around 0.7s ease-out both; }
  .tape-strip { animation: stitch-around 1.2s ease-out 0.2s both; }
  .unstitched .tangle { animation: untangle 1.6s ease-in-out 0.2s both; }
  .unstitched .needle-end,
  .unstitched-note { animation: fade-in 0.5s ease-out 1.8s both; }

  /* Stitched when scrolled to: anything marked data-stitch waits, undrawn, until js/thread.js gives
     it "is-sewn". The "sew-js" class (set in each page's <head>) means that script can do so.
     - data-stitch="draw": the threads inside it are drawn.
     - data-stitch="border": a dashed border is sewn around the inside of the element.
     Things arriving together go one after another (--stitch-order, 0.15s apart). */
  .sew-js [data-stitch]:not(.is-sewn) .sew-mask { stroke-dashoffset: 1; }
  .sew-js [data-stitch]:not(.is-sewn) .wipe-right { transform: scaleX(0); }
  .sew-js [data-stitch]:not(.is-sewn) .wipe-down { transform: scaleY(0); }
  [data-stitch='draw'].is-sewn .sew-mask { animation: sew 0.9s ease-in-out both; }
  .sew-js .cue-thread:not(.is-sewn) .sew-mask { stroke-dashoffset: 1; }
  .cue-thread.is-sewn .sew-mask { animation: sew 1.6s ease-in-out both; }
  /* The page thread's three pieces follow one another: down to the reviews, across them, on to the end. */
  .page-thread.is-sewn .sew-mask[data-part='a'] { animation: sew 0.4s ease-in both; }
  .page-thread.is-sewn .sew-mask[data-part='b'] { animation: sew 0.8s linear 0.35s both; }
  .page-thread.is-sewn .sew-mask[data-part='c'] { animation: sew 0.8s ease-out 1.1s both; }

  /* Review patches, stitched on when the section is scrolled to. While they wait they are a little
     faint and askew, but always readable. --n is the patch (0, 1, 2), --k the star (0 to 4). */
  .patch { transition: transform 0.3s ease; --land: calc(0.2s + var(--n, 0) * 0.2s); }
  .sew-js [data-stitch='patches']:not(.is-sewn) .patch { opacity: 0.6; transform: translateY(14px) rotate(calc(var(--tilt, 0deg) * 2.6)); transition: none; }
  .sew-js [data-stitch='patches']:not(.is-sewn) .star-fill,
  .sew-js [data-stitch='patches']:not(.is-sewn) .patch-quote { opacity: 0; }
  [data-stitch='patches'].is-sewn .patch { animation: patch-land 0.6s ease-out var(--land) backwards; }
  [data-stitch='patches'].is-sewn .patch-border .sew-mask { animation: sew 0.8s ease-in-out var(--land) both; }
  [data-stitch='patches'].is-sewn .star-sew { animation: sew 0.25s ease-out calc(var(--land) + 0.3s + var(--k, 0) * 0.15s) both; }
  [data-stitch='patches'].is-sewn .star-fill { animation: fade-in 0.2s ease-out calc(var(--land) + 0.5s + var(--k, 0) * 0.15s) both; }
  /* The dashed outlines show while the stars are stitched, then give way to the solid ones. */
  [data-stitch='patches'].is-sewn .star-lines { animation: stitches-out 0.25s ease-out calc(var(--land) + 1.3s) both; }
  [data-stitch='patches'].is-sewn .patch-quote { animation: quote-in 0.5s ease-out calc(var(--land) + 0.6s) both; }
  [data-stitch='patches'].is-sewn .patch-quote-end { animation: quote-in 0.4s ease-out calc(var(--land) + 0.9s) both; }
  [data-stitch='patches'].is-sewn .patch-heart .sew-mask { animation: sew 0.5s ease-out calc(var(--land) + 1.2s) both; }
  .sew-js [data-stitch='border']:not(.is-sewn)::after { clip-path: inset(0 100% 0 0); }
  [data-stitch='border']::after { transition: clip-path 0.8s ease calc(var(--stitch-order, 0) * 0.15s); }
  .products.is-sewn .wipe-right { animation: wipe-right 1.6s linear both; }
  .products.is-sewn .wipe-down { animation: wipe-down 1.4s ease-in-out both; }
  .products.is-sewn .product-card:nth-of-type(1) .sew-mask { animation: sew 0.36s linear 0.08s both; }
  .products.is-sewn .product-card:nth-of-type(3) .sew-mask { animation: sew 0.36s linear 0.82s both; }
  .cta-band.is-sewn .cta-lead .sew-mask { animation: sew 0.7s ease-in-out both; }
  .cta-band.is-sewn .btn-loop .sew-mask { animation: sew 0.7s ease-in-out 0.7s both; }
  .cta-band.is-sewn .cta-tail .sew-mask { animation: sew 0.6s ease-in-out 1.4s both; }
}
@keyframes thread-march { to { stroke-dashoffset: -14px; } }
@keyframes btn-breathe { to { opacity: 1; } }
@keyframes tag-swing { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes sew { from { stroke-dashoffset: 1; } }
@keyframes wipe-down { from { transform: scaleY(0); } }
@keyframes wipe-right { from { transform: scaleX(0); } }
@keyframes needle-glide { from { offset-distance: 0%; opacity: 1; } 85% { opacity: 1; } to { offset-distance: 100%; opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-stitch { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } }
@keyframes write-in { from { clip-path: inset(-0.2em 100% -0.2em 0); } to { clip-path: inset(-0.2em -0.3em -0.2em 0); } }
@keyframes hold-hidden { from, to { visibility: hidden; } }
@keyframes stitches-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes quote-in { from { opacity: 0; transform: scale(0.8); } }
@keyframes patch-land { from { opacity: 0.6; transform: translateY(14px) rotate(calc(var(--tilt, 0deg) * 2.6)); } }
@keyframes stitch-around { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes tag-drop { from { opacity: 0; transform: translateY(calc(var(--drop, 11px) - 18px)); } }
@keyframes tag-swing-once {
  0%, 100% { transform: translateY(var(--drop, 11px)) rotate(0); }
  25% { transform: translateY(var(--drop, 11px)) rotate(5deg); }
  50% { transform: translateY(var(--drop, 11px)) rotate(-4deg); }
  75% { transform: translateY(var(--drop, 11px)) rotate(2deg); }
}
/* The tangle and the wave are the same line with its points moved, so one can ease into the other. */
@keyframes untangle { from { d: path('M10 45C120 -10 150 100 60 70C-10 45 90 0 160 40C230 80 120 100 190 30C240 -10 290 90 310 50'); } }

/* Smaller screens ------------------------------------------------------------ */
@media (max-width: 1000px) {
  .weave-back,
  .weave-front { display: none; }
  .weave-down { display: block; }
}

/* Where the tags no longer fit on one sagging line, they sit in a row that scrolls sideways,
   on a straight thread that scrolls with them. No swinging here. */
@media (max-width: 900px) {
  .filters[data-clothesline] {
    justify-content: flex-start;
    margin-left: calc(var(--gutter) * -1);
    margin-right: calc(var(--gutter) * -1);
    padding: 26px var(--gutter) 14px;
    overflow-x: auto;
    scrollbar-width: none;
    background: repeating-linear-gradient(90deg, var(--thread) 0 7px, transparent 7px 14px) 0 10px / 100% 2px no-repeat local;
  }
  .filters[data-clothesline]::-webkit-scrollbar { display: none; }
  .filters[data-clothesline]::before,
  .filters[data-clothesline]::after,
  .clothesline-line { display: none; }
  .filters[data-clothesline] .pill { --drop: 0px !important; }
  .filters[data-clothesline] .pill.is-swinging { animation: tag-drop 0.45s ease-out calc(0.45s + var(--n, 0) * 0.12s) both; }
}

/* Phones and small tablets: the patches are one row to swipe through, one at a time, with the
   stitch dots underneath. Nothing slides by itself. */
@media (max-width: 760px) {
  .patches {
    display: flex;
    gap: 16px;
    margin: 0 calc(var(--gutter) * -1);
    padding: 14px var(--gutter) 18px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .patches::-webkit-scrollbar { display: none; }
  .patch { flex: 0 0 86%; scroll-snap-align: center; padding: 26px 22px 22px; }
  .patch-dots { display: flex; }
}

/* Phones: a shorter tape, 0 to 5, with smaller units so it fits. */
@media (max-width: 700px) {
  .tape { --unit: 60px; --units: 5; }
  .tape-strip i:nth-child(n + 7) { display: none; }
}

/* Phones and small tablets get the short version: logo ring and tagline, the stitch under the
   heading and the loop around the main button. No needle, no margin thread, no tag, and the
   photo is simply there. Without the needle the sequence starts sooner. */
@media (max-width: 880px) {
  .hero-mark { gap: 12px; margin-bottom: 16px; }
  .hero-mark-logo { width: 52px; height: 52px; }
  .hero-mark-line { font-size: clamp(1.1rem, 5.6vw, 1.5rem); }
  .hero-lead,
  .hero-seam,
  .header-tag { display: none; }
  .intro-play .hero-media { animation: none; }
  .hero-note { margin-left: 120px; }
  .hero {
    --t-ring: 0.1s;
    --t-tc: 0.7s;
    --t-line: 0.75s;
    --t-head: 1s;
    --t-btn: 1.2s;
    --t-sub: 1.4s;
    --t-under: 1.6s;
    --t-loop: 2s;
    --t-trust: 2.2s;
    --t-cue: 2.4s;
    --t-glow: 2.6s;
    --t-note: 2.8s;
  }
}

/* Phones: the buttons are full width and stacked, so the note sits between them. */
@media (max-width: 560px) {
  .hero-note { order: 1; margin: -2px 0 2px 14px; font-size: 1.35rem; }
  .hero-actions .btn-ghost { order: 2; }
  .scroll-cue { margin-top: 36px; }
}
