/* Tend — album quilt.
   Dyed cotton on a deep indigo ground. The eight word fills are the only
   saturated colour on the page; everything structural is indigo, thread, or
   unbleached muslin. See index.html's direction contract. */

:root {
  /* Dyed cotton. Semantic product data, ported from the app's words.ts —
     each fill's meaning is fixed, so never repurpose one as a UI accent. */
  --w-cl: #EFA33C;  --i-cl: #43290A;
  --w-wa: #F6C878;  --i-wa: #4A3312;
  --w-se: #F9E4C3;  --i-se: #6B4E23;
  --w-st: #E8E4DC;  --i-st: #56493B;
  --w-of: #C9A3A9;  --i-of: #472A31;
  /* `distant` carries a near-white ink in the app (words.ts). On its own fill
     that is 2.9:1 — under AA — so the web build darkens the ink to clear 5:1.
     The fill, which is the part that carries meaning, is untouched. */
  --w-di: #7E94AC;  --i-di: #1B2A3A;
  --w-te: #55476A;  --i-te: #EFE9F6;
  --w-re: #46B09E;  --i-re: #0B3A32;

  /* Indigo-dyed ground, cotton thread, unbleached muslin. */
  --ink-0: #14192B;
  --ink-1: #1B2135;
  --ink-2: #242C44;
  --thread: #D8CDB0;
  --thread-dim: rgba(216, 205, 176, 0.26);
  --muslin: #F0EADC;
  /* Sashing is dyed indigo, not muslin: a cream lattice inverts the page's
     value structure and demotes the ground the eight fills are meant to sing
     against. Binding is a contrasting warm cloth, as binding usually is. */
  --sashing: #2C3552;
  --binding: #CFC3A4;
  --muslin-ink: #22202B;
  --muslin-ink-2: #5C5647;
  --paper: #F2ECDE;
  --paper-2: #A7AFC6;
  --coral: #D85A30;

  /* Two elevations. Cloth laid on cloth casts one kind of shadow; the whole
     quilt lifted off the ground casts a deeper one. */
  --lift-card: 0 16px 34px -15px rgba(0, 0, 0, 0.6);
  --lift-panel: 0 22px 50px -18px rgba(0, 0, 0, 0.64);

  --pad: clamp(1.25rem, 4vw, 3.5rem);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink-0);
  color: var(--paper);
  font-family: Archivo, system-ui, sans-serif;
  font-variation-settings: 'wdth' 100, 'wght' 420;
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-x: hidden;
  overflow-wrap: break-word;
  /* A woven tooth over the dye, so the ground reads as cloth and not as a
     dark-mode panel. Two offset hairline grids, both nearly invisible. */
  background-image:
    repeating-linear-gradient(90deg, rgba(242, 236, 222, 0.05) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(242, 236, 222, 0.038) 0 1px, transparent 1px 4px);
}

img { max-width: 100%; display: block; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--thread);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  background: var(--muslin);
  color: var(--muslin-ink);
  padding: 0.75rem 1.25rem;
  font-size: 0.86rem;
}
.skip:focus { left: 0.75rem; top: 0.75rem; }

/* ---------- type ---------- */

h1 {
  font-variation-settings: 'wdth' 110, 'wght' 700;
  /* Sized so the three authored lines each fit at every breakpoint: the page's
     largest object must not break against sense. */
  font-size: clamp(1.9rem, 3.35vw, 3.1rem);
  line-height: 0.98;
  letter-spacing: 0.004em;
  text-transform: uppercase;
  text-wrap: balance;
}

h2 {
  font-variation-settings: 'wdth' 104, 'wght' 630;
  font-size: clamp(1.62rem, 2.6vw, 2.3rem);
  line-height: 1.08;
  letter-spacing: -0.016em;
  text-wrap: balance;
  max-width: 26ch;
}

h3 {
  font-variation-settings: 'wdth' 100, 'wght' 620;
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muslin-ink-2);
}

p { max-width: 66ch; }

.measure > h2 + p { margin-top: 1.35rem; }
.measure > p + p { margin-top: 1rem; }

/* Word names in running copy appear as scraps of their own cloth. */
.w {
  font-style: normal;
  font-variation-settings: 'wdth' 100, 'wght' 600;
  background: var(--f);
  color: var(--k);
  padding: 0.06em 0.4em 0.1em;
  border-radius: 2px;
  white-space: nowrap;
}

/* ---------- hero ---------- */

.hero {
  max-width: 96rem;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(19rem, 36rem) minmax(0, 1fr);
  gap: clamp(1.75rem, 3.5vw, 3.5rem);
  align-items: center;
  min-height: min(86svh, 46rem);
  padding: clamp(2rem, 4vw, 3rem) var(--pad) clamp(2.5rem, 5vw, 4rem);
}

/* the label sewn onto the top */
.label-patch {
  --patch-pad: clamp(1.6rem, 2.6vw, 2.4rem);
  position: relative;
  background-color: var(--muslin);
  background-image:
    repeating-linear-gradient(90deg, rgba(34, 32, 43, 0.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(34, 32, 43, 0.035) 0 1px, transparent 1px 4px);
  color: var(--muslin-ink);
  padding: var(--patch-pad);
  box-shadow: var(--lift-panel);
}

.label-patch::after {
  content: '';
  position: absolute;
  inset: 9px;
  border: 1px dashed rgba(34, 32, 43, 0.32);
  pointer-events: none;
}

.label-patch .lede {
  margin-top: 1.15rem;
  font-size: clamp(0.95rem, 1.2vw, 1.0625rem);
  line-height: 1.6;
  color: var(--muslin-ink-2);
  max-width: 42ch;
}

.quilt-col { display: grid; gap: clamp(0.9rem, 1.8vw, 1.35rem); }

.quilt-caption {
  font-size: 0.86rem;
  color: var(--paper-2);
  max-width: 50ch;
  padding-right: var(--pad);
}

/* ---------- the quilt ---------- */

/* Indigo sashing carries every block and a warm bound edge closes the quilt.
   Both are load-bearing construction, not ornament: blocks floating straight on
   the page ground read as a contribution graph, and a cream sashing inverts the
   page's value structure. Dyed cloth a step up from the ground does neither. */
.quilt {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.5rem, 1.1vw, 0.85rem);
  background-color: var(--sashing);
  background-image:
    repeating-linear-gradient(90deg, rgba(242, 236, 222, 0.05) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(242, 236, 222, 0.04) 0 1px, transparent 1px 4px);
  padding: clamp(0.5rem, 1.1vw, 0.85rem);
  border: clamp(6px, 0.8vw, 10px) solid var(--binding);
  box-shadow: var(--lift-panel);
  animation: settle 1.6s var(--ease);
}

/* Quilting: the stitching runs over the whole field, blocks included, which is
   what keeps the panel reading as a worked quilt rather than a card. */
.quilt::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(242, 236, 222, 0.13) 0 1px, transparent 1px 4px, transparent 4px 28px),
    repeating-linear-gradient(-45deg, rgba(242, 236, 222, 0.09) 0 1px, transparent 1px 4px, transparent 4px 28px);
}

@keyframes settle { from { transform: scale(0.985); } }

.month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  /* Sashing between every block: wide enough that two dark fills meeting —
     tense beside distant through February — never merge into one shape. */
  gap: 3px;
  align-content: start;
}

.month-name {
  grid-column: 1 / -1;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--thread);
  opacity: 0.8;
  margin-bottom: 0.35rem;
}

.blk {
  aspect-ratio: 1;
  border-radius: 1px;
  /* One fill, or two meeting on the diagonal — the half-square triangle the
     app already draws for a day the two of them read differently. */
  background: linear-gradient(135deg, var(--f) 0 50%, var(--f2, var(--f)) 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(20, 25, 43, 0.26);
  /* Pieced in date order, a day every 4ms — the year assembles the way it was
     lived. Default state is the finished block, so a browser that never runs
     the animation still shows a whole quilt. */
  animation: piece 0.5s var(--ease) backwards;
  animation-delay: calc(var(--d, 0) * 4ms);
}

@keyframes piece {
  from { opacity: 0; transform: scale(0.66); }
}

/* Dye lot: no two pieces cut from the same bolt read quite alike. */
.blk[data-j="1"] { filter: brightness(1.045); }
.blk[data-j="2"] { filter: brightness(0.955); }
.blk[data-j="3"] { filter: saturate(1.12) brightness(1.02); }

.blk[data-a=cl], .rung[data-w=cl], .w[data-w=cl], .big-blk[data-a=cl] { --f: var(--w-cl); --k: var(--i-cl); }
.blk[data-a=wa], .rung[data-w=wa], .w[data-w=wa], .big-blk[data-a=wa] { --f: var(--w-wa); --k: var(--i-wa); }
.blk[data-a=se], .rung[data-w=se], .w[data-w=se], .big-blk[data-a=se] { --f: var(--w-se); --k: var(--i-se); }
.blk[data-a=st], .rung[data-w=st], .w[data-w=st], .big-blk[data-a=st] { --f: var(--w-st); --k: var(--i-st); }
.blk[data-a=of], .rung[data-w=of], .w[data-w=of], .big-blk[data-a=of] { --f: var(--w-of); --k: var(--i-of); }
.blk[data-a=di], .rung[data-w=di], .w[data-w=di], .big-blk[data-a=di] { --f: var(--w-di); --k: var(--i-di); }
.blk[data-a=te], .rung[data-w=te], .w[data-w=te], .big-blk[data-a=te] { --f: var(--w-te); --k: var(--i-te); }
.blk[data-a=re], .rung[data-w=re], .w[data-w=re], .big-blk[data-a=re] { --f: var(--w-re); --k: var(--i-re); }

.blk[data-b=cl], .big-blk[data-b=cl] { --f2: var(--w-cl); }
.blk[data-b=wa], .big-blk[data-b=wa] { --f2: var(--w-wa); }
.blk[data-b=se], .big-blk[data-b=se] { --f2: var(--w-se); }
.blk[data-b=st], .big-blk[data-b=st] { --f2: var(--w-st); }
.blk[data-b=of], .big-blk[data-b=of] { --f2: var(--w-of); }
.blk[data-b=di], .big-blk[data-b=di] { --f2: var(--w-di); }
.blk[data-b=te], .big-blk[data-b=te] { --f2: var(--w-te); }
.blk[data-b=re], .big-blk[data-b=re] { --f2: var(--w-re); }

/* ---------- store badges on the binding ---------- */

.binding { display: flex; flex-wrap: wrap; gap: 0.85rem; margin-top: 1.75rem; }

/* The patch's bound edge, in the same contrasting cloth that binds the quilt:
   the badges sit on the binding, not on a rule drawn near it. */
.label-patch .binding {
  margin: 1.6rem calc(var(--patch-pad) * -1) calc(var(--patch-pad) * -1);
  padding: 1.15rem var(--patch-pad);
  background: var(--binding);
  border-top: 1px dashed rgba(34, 32, 43, 0.26);
}

.badge { display: block; border-radius: 6px; }
.badge img { height: 42px; width: auto; }
.badge:hover { opacity: 0.86; }

.binding-close {
  background: var(--binding);
  padding: 1rem 1.15rem;
  border-radius: 3px;
  width: fit-content;
  box-shadow: var(--lift-card);
}

/* ---------- sections ---------- */

.section {
  max-width: 82rem;
  margin-inline: auto;
  padding: clamp(3.25rem, 7vw, 6.5rem) var(--pad);
}

.seam-top { border-top: 1px dashed var(--thread-dim); }

.measure { max-width: 66ch; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.split .measure { max-width: none; }

/* ---------- the word ladder ---------- */

.ladder { list-style: none; display: grid; gap: 3px; }

.rung {
  background: var(--f);
  color: var(--k);
  border-radius: 2px;
  padding: 0.72rem 1.1rem;
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  align-items: baseline;
  column-gap: 1rem;
  box-shadow: inset 0 0 0 1px rgba(242, 236, 222, 0.16);
  cursor: pointer;
}

.rung-word { font-variation-settings: 'wdth' 100, 'wght' 620; font-size: 1.1rem; }

.rung-terr {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.84;
  grid-column: 2;
  justify-self: end;
}

.rung-hint { grid-column: 1 / -1; font-size: 0.86rem; opacity: 0.9; margin-top: 0.15rem; }

.ladder.detached { margin-top: 1.25rem; margin-left: auto; width: 76%; }
.ladder.detached .rung { box-shadow: inset 0 0 0 1px rgba(242, 236, 222, 0.32); }

/* ---------- hold to tend (JS adds the controls) ---------- */

.tend-demo:not(:empty) {
  margin-top: clamp(1.5rem, 3vw, 2rem);
  display: grid;
  gap: 0.9rem;
  justify-items: start;
}

.tend-btn {
  font: inherit;
  font-size: 0.95rem;
  font-variation-settings: 'wdth' 100, 'wght' 620;
  background: var(--ink-2);
  color: var(--paper);
  border: 1px solid var(--thread-dim);
  border-radius: 3px;
  padding: 0.95rem 1.5rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
}

.tend-btn:disabled { cursor: not-allowed; color: var(--paper-2); }
.tend-btn:not(:disabled):hover { border-color: var(--thread); }
.tend-btn span { position: relative; z-index: 1; }

/* the thread filling as you hold */
.tend-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  right: auto;
  width: var(--held, 0%);
  background: var(--w-cl);
  opacity: 0.92;
}
.tend-btn.holding { color: var(--i-cl); }

.tend-help { font-size: 0.86rem; color: var(--paper-2); max-width: 46ch; }

.tend-strip { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; min-height: 36px; }
.tend-strip .blk { width: 32px; }
.tend-empty { font-size: 0.86rem; color: var(--paper-2); font-variation-settings: 'wdth' 100, 'wght' 420; }

/* ---------- the sealed reveal ---------- */

.reveal-stage { display: grid; gap: clamp(1.5rem, 3vw, 2.25rem); }

.reveal-pair { display: flex; gap: clamp(0.75rem, 1.6vw, 1.25rem); flex-wrap: wrap; }

.reveal-side { display: grid; gap: 0.65rem; align-content: start; }

.reveal-day {
  padding-left: clamp(0.75rem, 1.6vw, 1.25rem);
  border-left: 1px dashed var(--thread-dim);
}

.reveal-side figcaption { font-size: 0.86rem; color: var(--paper-2); max-width: 11rem; }
.reveal-side figcaption b {
  display: block;
  font-variation-settings: 'wdth' 100, 'wght' 620;
  color: var(--paper);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}

.big-blk {
  width: clamp(72px, 8.4vw, 104px);
  aspect-ratio: 1;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--f) 0 50%, var(--f2, var(--f)) 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(242, 236, 222, 0.18);
  transition: background 0.5s var(--ease);
}

/* the back of the cloth: muslin, with the stitching showing through */
.big-blk.facedown {
  background:
    repeating-linear-gradient(45deg, rgba(34, 32, 43, 0.09) 0 2px, transparent 2px 7px),
    var(--muslin);
  box-shadow: inset 0 0 0 1px rgba(34, 32, 43, 0.2);
}

/* The day itself while it is still sealed: your half pieced, their half still
   face-down. A solid block here would say the day was finished when it isn't. */
.big-blk.half-sealed {
  background:
    linear-gradient(135deg, var(--f) 0 50%, transparent 50% 100%),
    repeating-linear-gradient(45deg, rgba(34, 32, 43, 0.09) 0 2px, transparent 2px 7px),
    var(--muslin);
}

.reveal-result { display: grid; gap: 0.9rem; justify-items: start; }
.reveal-note { font-size: 0.86rem; color: var(--paper-2); max-width: 40ch; }

.reveal-btn {
  font: inherit;
  font-size: 0.86rem;
  font-variation-settings: 'wdth' 100, 'wght' 600;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--thread-dim);
  border-radius: 3px;
  padding: 0.72rem 1.15rem;
  cursor: pointer;
}
.reveal-btn:hover { background: var(--ink-2); border-color: var(--thread); }

/* ---------- appliqué patches ---------- */

.appliques {
  margin-top: clamp(2rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(1.25rem, 2.5vw, 2rem);
  align-items: start;
}

.patch {
  position: relative;
  background-color: var(--muslin);
  background-image:
    repeating-linear-gradient(90deg, rgba(34, 32, 43, 0.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(34, 32, 43, 0.035) 0 1px, transparent 1px 4px);
  color: var(--muslin-ink);
  padding: clamp(1.25rem, 2vw, 1.75rem);
  box-shadow: var(--lift-card);
}

.patch::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(34, 32, 43, 0.3);
  pointer-events: none;
}

.patch p { color: var(--muslin-ink-2); font-size: 0.95rem; margin-top: 0.8rem; }

.patch .entry {
  color: var(--muslin-ink);
  border-top: 1px dashed rgba(34, 32, 43, 0.3);
  padding-top: 0.85rem;
  margin-top: 1.1rem;
}

.patch .entry-meta {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muslin-ink-2);
  margin-top: 0.6rem;
}

.patch-lg { grid-column: 1 / span 3; transform: rotate(-0.8deg); }
.patch-sm { grid-column: 4 / span 3; margin-top: 2.25rem; transform: rotate(0.65deg); }
.patch-md { grid-column: 2 / span 4; margin-top: 0.5rem; transform: rotate(-0.4deg); }

/* ---------- the hearth ---------- */

.states {
  margin-top: 1.75rem;
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--thread);
}

blockquote {
  margin-top: 1.75rem;
  border-top: 1px dashed var(--thread-dim);
  padding-top: 1.5rem;
}

blockquote p {
  font-variation-settings: 'wdth' 96, 'wght' 460;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.45;
  max-width: 40ch;
}

blockquote cite {
  display: block;
  margin-top: 0.9rem;
  font-style: normal;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--paper-2);
}

/* ---------- the three facts ---------- */

/* A stack, not a row of equal cards: each fact is a seam under the last. */
.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.25rem, 2.5vw, 1.75rem);
  align-self: start;
}

.fact { border-top: 1px dashed var(--thread-dim); padding-top: 1.1rem; }

.fact dt { font-variation-settings: 'wdth' 100, 'wght' 620; font-size: 1.0625rem; }
.fact dd { color: var(--paper-2); font-size: 0.95rem; margin-top: 0.3rem; }

/* Pulled out of the copy column so it sits beside the heading rather than
   leaving the page slack on the right. */
.split > blockquote { margin-top: 0; align-self: start; }

/* ---------- close + footer ---------- */

/* The close is the one centred passage on the page — it echoes the footer and
   stops the last screen reading as another left-aligned column. */
.close .measure { margin-inline: auto; text-align: center; }
.close h2, .close p { margin-inline: auto; }
.close .binding { margin-top: 2.25rem; justify-content: center; margin-inline: auto; }

footer {
  border-top: 1px dashed var(--thread-dim);
  max-width: 82rem;
  margin-inline: auto;
  padding: clamp(2.5rem, 5vw, 4rem) var(--pad) clamp(2.5rem, 5vw, 3.5rem);
  text-align: center;
}

/* The one serif on the page. The italic-serif wordmark with an upright period
   is an existing brand commitment (PRODUCT.md), so it is loaded rather than
   left to whatever serif the visitor's OS happens to ship. */
.wordmark {
  font-family: Petrona, Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 2.35rem;
  color: var(--paper);
  margin: 0 auto;
}
.wordmark .dot { font-style: normal; color: var(--coral); }

.tagline { margin: 0.35rem auto 0; font-size: 0.86rem; color: var(--paper-2); }

.legal { margin-top: 1.75rem; display: flex; gap: 1.5rem; justify-content: center; }
.legal a { font-size: 0.86rem; color: var(--paper-2); text-decoration-color: var(--thread-dim); }
.legal a:hover { color: var(--paper); }

/* ---------- adaptation ---------- */

@media (max-width: 1040px) {
  /* Headline first: the quilt is the argument, but it can't be the thing that
     buries the offer on a phone. */
  .hero {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    min-height: 0;
    padding: clamp(1.75rem, 5vw, 2.5rem) var(--pad) clamp(2.5rem, 6vw, 4rem);
    gap: clamp(1.75rem, 5vw, 2.75rem);
  }
  .label-patch { max-width: 40rem; }
  .quilt-caption { padding-right: 0; }
  .quilt { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .patch-lg, .patch-sm, .patch-md { grid-column: 1 / -1; margin-top: 0; }
  .patch-sm { margin-top: 0.25rem; }
}

@media (max-width: 620px) {
  .quilt { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
  .rung { grid-template-columns: minmax(0, 1fr); }
  .rung-terr { grid-column: 1; justify-self: start; margin-top: 0.15rem; }
  .ladder.detached { width: 100%; margin-left: 0; }
  .reveal-day { border-left: 0; padding-left: 0; }
  .patch-lg, .patch-sm, .patch-md { transform: none; }
  .legal { flex-direction: column; gap: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    /* Without this the staggered blocks sit at opacity 0 for their delay —
       the finished quilt has to be there instantly, not eventually. */
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
