/* The Stitch Pattern
   ---------------------------------------------------------------------------
   Every colour token below is a real DMC floss number. That is the whole
   conceit: the site is painted out of the same box of thread it sells charts
   for, and the footer prints the card so you can see it.
   --------------------------------------------------------------------------- */

@font-face {
  font-family: 'Zilla Slab';
  src: url('fonts/zillaslab-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Zilla Slab';
  src: url('fonts/zillaslab-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

:root {
  /* DMC 823 Blue Dark */        --ink: #000b44;
  /* DMC 336 Blue */             --ink-lift: #0c275e;
  /* DMC 3865 Winter White */    --linen: #fffdf9;
  /* DMC 932 Antique Blue Lt */  --pearl: #93a0af;
  /* DMC 666 Red Bright */       --flame: #ce1b33;
  /* DMC 725 Topaz */            --topaz: #f9c15b;
  /* DMC 3753 Antique Blue UVL */--mist: #d9e6ec;
  /* DMC 712 Cream */            --cream: #f6efda;
  /* DMC 501 Blue Green Dark */  --pine: #2f5446;

  --display: 'Zilla Slab', Rockwell, 'Roboto Slab', Georgia, serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, monospace;

  --gutter: clamp(1.25rem, 4vw, 4rem);
  --measure: 1180px;
  --radius: 3px;

  --stitch: 6px; /* the weave unit the background grid is built from */
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--linen);
  background-color: var(--ink);
  /* Aida weave: two hairline grids at the stitch unit, so the whole page sits
     on the same square count as the charts it makes. */
  background-image:
    repeating-linear-gradient(0deg, rgba(255,253,249,0.045) 0 1px, transparent 1px var(--stitch)),
    repeating-linear-gradient(90deg, rgba(255,253,249,0.045) 0 1px, transparent 1px var(--stitch));
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.06; margin: 0; }
p { margin: 0 0 1em; }
a { color: inherit; }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--topaz); color: var(--ink); padding: 0.7em 1.2em; font-weight: 600;
}
.skip:focus { left: 0; }

/* --- buttons -------------------------------------------------------------- */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 0.62em 1.15em;
  cursor: pointer;
  background: none;
  color: inherit;
  display: inline-block;
  text-align: center;
  text-decoration: none;   /* buttons are also used as links */
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 0.85em 1.6em; font-size: 1.05rem; }
.btn-sm { padding: 0.45em 0.8em; font-size: 0.85rem; }

.btn-primary { background: var(--flame); color: var(--linen); }
.btn-primary:hover { background: #e12a44; }
.btn-ghost { border-color: rgba(255,253,249,0.35); color: var(--linen); }
.btn-ghost:hover { border-color: var(--topaz); color: var(--topaz); }
.btn-quiet { color: var(--pearl); text-decoration: underline; text-underline-offset: 4px; padding-inline: 0.2em; }
.btn-quiet:hover { color: var(--topaz); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* --- masthead ------------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  padding: 1.1rem var(--gutter);
  max-width: var(--measure);
  margin: 0 auto;
}
.wordmark {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--display); font-weight: 700; font-size: 1.22rem;
  letter-spacing: -0.01em; text-decoration: none; color: var(--linen);
}
.mark { width: 22px; height: 22px; color: var(--flame); flex: none; }
.mast-nav { display: flex; gap: 1.6rem; margin-left: auto; font-size: 0.94rem; }
.mast-nav a { color: var(--pearl); text-decoration: none; }
.mast-nav a:hover { color: var(--linen); }

@media (max-width: 720px) {
  .mast-nav { display: none; }
  .masthead .btn-ghost { margin-left: auto; }
}

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

.hero {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) var(--gutter) clamp(3rem, 8vw, 6rem);
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--topaz);
  margin-bottom: 1.1rem;
}
.hero h1 {
  font-size: clamp(2.5rem, 6.4vw, 4.35rem);
  letter-spacing: -0.022em;
  margin-bottom: 1.1rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--topaz);
  /* the underline is a row of stitches, not a rule */
  background-image: repeating-linear-gradient(90deg, var(--flame) 0 7px, transparent 7px 12px);
  background-size: 100% 5px;
  background-position: 0 100%;
  background-repeat: repeat-x;
  padding-bottom: 6px;
}
.lede { font-size: 1.1rem; color: #d5dde6; max-width: 34em; }

.hero-actions { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin: 1.9rem 0 2.2rem; }

.hero-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.85rem; border-top: 1px solid rgba(255,253,249,0.14); padding-top: 1.4rem; }
.hero-facts li { font-size: 0.93rem; color: var(--pearl); padding-left: 1.6rem; position: relative; }
.hero-facts li::before {
  content: ""; position: absolute; left: 0; top: 0.42em;
  width: 9px; height: 9px; background: var(--topaz);
}
.hero-facts strong { color: var(--linen); font-weight: 600; }

/* the hoop: a soft ring around the live demo, echoing an embroidery hoop */
.hero-demo { margin: 0; }
.hoop {
  background: var(--cream);
  padding: clamp(0.9rem, 2vw, 1.6rem);
  border: 10px solid #b98a4e;
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45), inset 0 0 0 2px rgba(0,0,0,0.12);
  display: flex;
}
.hoop canvas { display: block; margin: auto; max-width: 100%; image-rendering: pixelated; }
.hero-demo figcaption {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 0.9rem; font-family: var(--mono); font-size: 0.76rem;
  letter-spacing: 0.06em; color: var(--pearl); text-transform: uppercase;
}
.tick { color: var(--topaz); }

/* --- studio --------------------------------------------------------------- */

.studio {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 7vw, 5rem);
  scroll-margin-top: 1rem;
}
.studio[hidden] { display: none; }

.studio-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.studio-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); }

.studio-grid { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 880px) { .studio-grid { grid-template-columns: 1fr; } }

.controls { display: grid; gap: 1rem; }
.panel {
  background: var(--ink-lift);
  border: 1px solid rgba(255,253,249,0.12);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.25rem;
}
.panel h3, .panel > summary {
  font-family: var(--display); font-size: 0.98rem; font-weight: 700;
  letter-spacing: 0.02em; margin: 0 0 0.9rem;
}
.panel > summary { cursor: pointer; margin-bottom: 0; list-style-position: outside; }
.panel[open] > summary { margin-bottom: 0.9rem; }

.field { display: block; margin-bottom: 1rem; }
.field-label { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.85rem; color: var(--pearl); margin-bottom: 0.45rem; }
.field-label output { font-family: var(--mono); color: var(--topaz); }

input[type="range"] { width: 100%; accent-color: var(--flame); height: 22px; }

select {
  width: 100%; font: inherit; font-size: 0.9rem; padding: 0.5em 0.6em;
  background: var(--ink); color: var(--linen);
  border: 1px solid rgba(255,253,249,0.22); border-radius: var(--radius);
}

.check { display: flex; align-items: center; gap: 0.55rem; font-size: 0.9rem; cursor: pointer; }
.check input { accent-color: var(--flame); width: 16px; height: 16px; }
.check-inline { color: var(--pearl); }

.readout {
  font-family: var(--mono); font-size: 0.82rem; color: var(--topaz);
  margin: 0.2rem 0 0; padding-top: 0.8rem; border-top: 1px dashed rgba(255,253,249,0.18);
}
.hint { font-size: 0.8rem; color: var(--pearl); margin: 0.8rem 0 0; }

.stage { display: grid; gap: 1rem; min-width: 0; }
.stage-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.seg { display: inline-flex; border: 1px solid rgba(255,253,249,0.22); border-radius: var(--radius); overflow: hidden; }
.seg-btn {
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  background: none; color: var(--pearl); border: 0; padding: 0.45em 0.9em;
}
.seg-btn + .seg-btn { border-left: 1px solid rgba(255,253,249,0.22); }
.seg-btn.is-on { background: var(--topaz); color: var(--ink); }

.stage-status { margin-left: auto; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--topaz); }

.canvas-wrap {
  background: var(--cream);
  border: 1px solid rgba(255,253,249,0.14);
  border-radius: var(--radius);
  padding: 0.9rem;
  display: flex; justify-content: center; align-items: center;
  /* A definite height keeps the chart from resizing itself every render. */
  height: clamp(300px, 56vh, 620px);
  /* the checkerboard shows through where a chart has transparency */
  background-image:
    linear-gradient(45deg, rgba(0,0,0,0.035) 25%, transparent 25% 75%, rgba(0,0,0,0.035) 75%),
    linear-gradient(45deg, rgba(0,0,0,0.035) 25%, transparent 25% 75%, rgba(0,0,0,0.035) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.canvas-wrap canvas { display: block; max-width: 100%; image-rendering: pixelated; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px; margin: 0;
  background: rgba(255,253,249,0.14);
  border: 1px solid rgba(255,253,249,0.14);
  border-radius: var(--radius);
  overflow: hidden;
}
.stats > div { background: var(--ink-lift); padding: 0.75rem 0.9rem; }
.stats dt { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--pearl); }
.stats dd { margin: 0.25rem 0 0; font-family: var(--mono); font-size: 0.95rem; color: var(--linen); }

.floss h3 { font-size: 0.98rem; margin-bottom: 0.7rem; }
.floss-strip { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono); font-size: 0.74rem;
  padding: 0.28rem 0.5rem; border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.28);
}
.chip .sym { font-weight: 700; }

/* --- buy bar -------------------------------------------------------------- */

.buybar {
  margin-top: 1.75rem;
  display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; justify-content: space-between;
  background: var(--ink-lift);
  border: 1px solid var(--topaz);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
}
.buybar-price { font-family: var(--display); font-size: 1.25rem; margin: 0 0 0.3rem; }
.buybar-price .amount { color: var(--topaz); font-size: 1.7rem; }
.buybar-detail { margin: 0; font-size: 0.9rem; color: var(--pearl); max-width: 46ch; }
.buybar-actions { text-align: right; }
.buybar-note { margin: 0.55rem 0 0; font-size: 0.78rem; color: var(--pearl); }
@media (max-width: 620px) { .buybar-actions { text-align: left; } }

/* --- what you get --------------------------------------------------------- */

.section-title { font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: -0.02em; margin-bottom: 2rem; }

.included {
  background: var(--cream);
  color: #23303c;
  padding: clamp(3rem, 7vw, 5rem) var(--gutter);
}
.included .section-title { color: var(--ink); }
.included > * { max-width: var(--measure); margin-inline: auto; }

.deliverables {
  list-style: none; counter-reset: sheet; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.5rem;
  max-width: var(--measure); margin-inline: auto;
}
/* numbered because the PDF really is assembled in this order, front to back */
.deliverables li { counter-increment: sheet; border-top: 3px solid var(--ink); padding-top: 0.9rem; }
.deliverables li::before {
  content: "Sheet " counter(sheet);
  display: block; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--flame); margin-bottom: 0.6rem;
}
.deliverables h3 { font-size: 1.18rem; color: var(--ink); margin-bottom: 0.4rem; }
.deliverables p { font-size: 0.92rem; color: #4a5764; margin: 0; }

/* --- pricing -------------------------------------------------------------- */

.pricing {
  max-width: var(--measure); margin: 0 auto;
  padding: clamp(3rem, 7vw, 5rem) var(--gutter);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}
@media (max-width: 820px) { .pricing { grid-template-columns: 1fr; } }

.price-card {
  background: var(--ink-lift);
  border: 1px solid rgba(255,253,249,0.16);
  border-top: 4px solid var(--flame);
  border-radius: var(--radius);
  padding: 1.8rem;
}
.price-amount { font-family: var(--display); font-size: 3.4rem; line-height: 1; margin: 0.2rem 0 0.5rem; color: var(--topaz); }
.price-sub { color: var(--pearl); font-size: 0.92rem; }

.ticks { list-style: none; margin: 1.4rem 0 1.8rem; padding: 0; display: grid; gap: 0.6rem; }
.ticks li { padding-left: 1.5rem; position: relative; font-size: 0.94rem; }
.ticks li::before {
  content: ""; position: absolute; left: 0; top: 0.45em; width: 9px; height: 9px;
  background: var(--flame);
}
.ticks-quiet li::before { background: var(--pine); }
.price-aside h3 { font-size: 1.25rem; margin-bottom: 0.7rem; }
.price-aside p { color: var(--pearl); }
.price-aside .ticks li { color: var(--pearl); }

/* --- faq ------------------------------------------------------------------ */

.faq { max-width: 820px; margin: 0 auto; padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(3rem, 8vw, 5rem); }
.faq-list { border-top: 1px solid rgba(255,253,249,0.16); }
.faq details { border-bottom: 1px solid rgba(255,253,249,0.16); }
.faq summary {
  cursor: pointer; padding: 1.05rem 0; font-family: var(--display); font-weight: 700; font-size: 1.06rem;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--mono); color: var(--topaz); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "\2013"; }
.faq details p { color: var(--pearl); font-size: 0.95rem; margin: 0 0 1.1rem; max-width: 62ch; }
.faq a { color: var(--topaz); }

/* --- footer --------------------------------------------------------------- */

.site-foot { border-top: 1px solid rgba(255,253,249,0.14); }

/* the thread card: the page's own palette, printed like a DMC colour card */
.thread-card { display: flex; height: 44px; }
.thread-card::before { content: ""; flex: 1; }

.foot-inner { max-width: var(--measure); margin: 0 auto; padding: 2rem var(--gutter) 3rem; }
.foot-note { color: var(--pearl); font-size: 0.88rem; max-width: 48ch; }
.foot-legal { display: flex; flex-wrap: wrap; gap: 1.2rem; font-size: 0.85rem; color: var(--pearl); margin: 1.2rem 0 0; }
.foot-legal a { color: var(--pearl); }
.foot-legal a:hover { color: var(--topaz); }
.foot-legal span { color: var(--linen); font-weight: 600; }
.foot-fine { font-size: 0.76rem; opacity: 0.75; }

.swatch-card { flex: 1; display: flex; align-items: flex-end; padding: 0 0 4px 6px; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.04em; }

/* --- prose pages (guides, terms, privacy) --------------------------------- */

.doc { max-width: 760px; margin: 0 auto; padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(3rem, 8vw, 5rem); }
.doc h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.02em; margin-bottom: 0.6rem; }
.doc .standfirst { font-size: 1.1rem; color: #d5dde6; margin-bottom: 2.2rem; max-width: 60ch; }
.doc h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); margin: 2.4rem 0 0.8rem; }
.doc h3 { font-size: 1.1rem; margin: 1.6rem 0 0.5rem; color: var(--topaz); }
.doc p, .doc li { color: var(--pearl); }
.doc p { max-width: 68ch; }
.doc ul, .doc ol { max-width: 66ch; padding-left: 1.2rem; }
.doc li { margin-bottom: 0.5rem; }
.doc a { color: var(--topaz); }
.doc strong { color: var(--linen); }
.doc table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; font-size: 0.92rem; }
.doc th, .doc td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid rgba(255,253,249,0.16); }
.doc th { color: var(--linen); font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }
.doc td { color: var(--pearl); }
.doc td:first-child { font-family: var(--mono); color: var(--linen); }
.doc .updated { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--topaz); }

.callout {
  background: var(--ink-lift);
  border-left: 4px solid var(--flame);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  margin: 2rem 0;
}
.callout p { margin-bottom: 0.9rem; color: #d5dde6; }
.callout p:last-child { margin-bottom: 0; }

.crumbs { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--pearl); margin-bottom: 1.4rem; }
.crumbs a { color: var(--pearl); text-decoration: none; }
.crumbs a:hover { color: var(--topaz); }

.readmore { list-style: none; padding: 0; margin: 2.6rem 0 0; border-top: 1px solid rgba(255,253,249,0.16); }
.readmore li { border-bottom: 1px solid rgba(255,253,249,0.16); margin: 0; }
.readmore a { display: block; padding: 1rem 0; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.05rem; color: var(--linen); }
.readmore a:hover { color: var(--topaz); }

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--linen); color: var(--ink);
  padding: 0.8rem 1.2rem; border-radius: var(--radius);
  font-size: 0.92rem; font-weight: 600; z-index: 60;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  max-width: min(90vw, 460px);
}
.toast[hidden] { display: none; }
.toast.is-bad { background: var(--flame); color: var(--linen); }

/* --- drag state ----------------------------------------------------------- */

body.is-dragging::after {
  content: "Drop the photo anywhere";
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  font-family: var(--display); font-size: 1.6rem; color: var(--ink);
  background: rgba(249,193,91,0.92);
  pointer-events: none;
}

/* --- working spinner ------------------------------------------------------ */

.is-working { opacity: 0.55; transition: opacity 0.15s ease; }
