/* ThreadCount — threadcount.app
   Palette named after actual DMC floss. Redwork sampler: red thread, ecru cloth. */

:root {
  --cloth: #F6F1E7;        /* ecru aida */
  --cloth-deep: #EFE8D9;   /* hooped section band */
  --grid: rgba(94, 74, 56, 0.10);
  --ink: #2A211B;          /* DMC 3371 black brown */
  --ink-soft: #6B5D51;     /* DMC 640 beige gray */
  --red: #B02E2E;          /* DMC 347 salmon very dark */
  --red-deep: #7C1F2B;     /* DMC 815 garnet medium */
  --snow: #FCFBF7;         /* DMC B5200 snow white */
  --card: #FBF8F1;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cloth: #201A15;      /* night stitching */
    --cloth-deep: #191410;
    --grid: rgba(214, 193, 166, 0.08);
    --ink: #EFE7DA;
    --ink-soft: #A8988A;
    --red: #D65454;
    --red-deep: #A83A48;
    --snow: #F6F1E7;
    --card: #2A2219;
  }
}

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

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--cloth);
  /* aida weave: fine crossing lines every 14px */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 14px 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--red); text-underline-offset: 3px; }
a:hover { color: var(--red-deep); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */

header.site {
  padding: 20px 0;
}
header.site .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  display: flex; align-items: center; gap: 10px;
}
.wordmark img { width: 34px; height: 34px; border-radius: 8px; }
.wordmark .x { color: var(--red); }
nav.site a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
  margin-left: 22px;
}
nav.site a:hover { color: var(--red); }
nav.site a[aria-current="page"] { color: var(--ink); border-bottom: 2px solid var(--red); padding-bottom: 2px; }

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

.hero { padding: 56px 0 72px; }
.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 56px;
  align-items: center;
}
@media (max-width: 820px) {
  .hero .wrap { grid-template-columns: 1fr; gap: 40px; }
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5.2vw, 3.6rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: 20px;
}
.hero .lede {
  font-size: 1.12rem;
  color: var(--ink-soft);
  max-width: 44ch;
  margin-bottom: 30px;
}
.cta-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  background: var(--red);
  color: var(--snow);
  font-weight: 600;
  text-decoration: none;
  padding: 13px 26px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--red-deep); color: var(--snow); }
.cta-note { font-size: 0.9rem; color: var(--ink-soft); }

/* ---------- the chart (signature) ---------- */

.chart-card {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 18px 40px -24px rgba(42, 33, 27, 0.35);
}
.chart-frame { display: flex; justify-content: center; }
#chart {
  display: grid;
  gap: 0;
  border: 1px solid var(--grid);
  touch-action: manipulation;
}
#chart button {
  width: var(--cell, 22px);
  height: var(--cell, 22px);
  border: none;
  background: transparent;
  box-shadow: inset 0 0 0 0.5px var(--grid);
  padding: 0;
  position: relative;
  cursor: pointer;
  border-radius: 0;
}
#chart button:disabled { cursor: default; }
#chart button.selected {
  z-index: 1;
  box-shadow: inset 0 0 0 2px #1683ff;
  background: color-mix(in srgb, #1683ff 18%, transparent);
}
#chart button .sym {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-soft);
  opacity: 0.75;
}
/* a stitched X: two crossing threads */
#chart button.stitched .sym { display: none; }
#chart button.stitched::before,
#chart button.stitched::after {
  content: "";
  position: absolute;
  left: 14%; right: 14%;
  top: calc(50% - 1.5px);
  height: 3.5px;
  border-radius: 3px;
  background: var(--thread);
  box-shadow: 0 0.5px 1px rgba(0,0,0,0.28);
}
#chart button.stitched::before { transform: rotate(45deg); }
#chart button.stitched::after { transform: rotate(-45deg); }
#chart button.pop::before, #chart button.pop::after { animation: lay 0.18s ease-out; }
@keyframes lay {
  from { transform: rotate(45deg) scaleX(0.2); opacity: 0; }
}
#chart button.pop::after { animation-name: lay2; }
@keyframes lay2 {
  from { transform: rotate(-45deg) scaleX(0.2); opacity: 0; }
}

.chart-legend {
  margin-top: 18px;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 0.88rem;
}
.chart-legend .row { display: flex; align-items: center; gap: 10px; }
.chart-legend .swatch {
  width: 18px; height: 18px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.12);
}
.chart-legend .code { font-family: var(--mono); font-size: 0.8rem; }
.chart-legend .count { margin-left: auto; font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); }
.chart-legend .count.done { color: var(--red); }
.chart-hint {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
}
.chart-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.chart-actions button {
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 8px 12px;
  font: 600 0.78rem var(--sans);
  color: var(--ink);
  background: var(--cloth);
  cursor: pointer;
}
.chart-actions button:last-child {
  color: var(--snow);
  background: var(--red);
  border-color: transparent;
}
.chart-actions button:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 420px) {
  .chart-actions { flex-wrap: wrap; justify-content: center; }
}
.chart-progress {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  display: flex; justify-content: space-between; align-items: center;
}
.chart-bar {
  flex: 1; height: 6px; margin: 0 12px;
  background: var(--grid);
  border-radius: 3px; overflow: hidden;
}
.chart-bar i {
  display: block; height: 100%;
  width: 0%;
  background: var(--red);
  transition: width 0.25s ease;
}

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

section { padding: 72px 0; }
section.band { background: var(--cloth-deep); }
h2 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.section-lede { color: var(--ink-soft); max-width: 58ch; margin-bottom: 44px; }

/* steps: a true sequence */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.step .k {
  font-family: var(--mono);
  color: var(--red);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  display: block;
  margin-bottom: 10px;
}
.step h3 { font-family: var(--serif); font-size: 1.25rem; margin-bottom: 8px; }
.step p { color: var(--ink-soft); font-size: 0.97rem; }

/* Features use an explicit positive marker. A bare cross-stitch X reads too
   easily as "not supported" when it sits beside a capability list. */
.features {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 48px;
  list-style: none;
}
@media (max-width: 720px) { .features { grid-template-columns: 1fr; } }
.features li {
  padding: 14px 0 14px 40px;
  position: relative;
  border-bottom: 1px solid var(--grid);
}
.features li::before {
  content: "\2713";
  position: absolute;
  left: 2px;
  top: 15px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--snow);
  background: var(--red);
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(42, 33, 27, 0.16);
}
.features b { display: block; font-weight: 600; }
.features span { color: var(--ink-soft); font-size: 0.95rem; }

/* screenshots */
.shots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 44px;
  max-width: 820px;
  margin: 0 auto;
}
.shots figure { margin: 0; }
.shots img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--grid);
  box-shadow: 0 18px 40px -24px rgba(42, 33, 27, 0.35);
}
.shots figcaption {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  text-align: center;
}

/* privacy strip */
.plain {
  text-align: center;
  max-width: 620px;
  margin: 0 auto;
}
.plain h2 { margin-bottom: 16px; }
.plain p { color: var(--ink-soft); }
.plain .vow {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin: 22px 0;
}

/* ---------- prose pages (support / privacy) ---------- */

main.prose { padding: 40px 0 80px; max-width: 720px; margin: 0 auto; }
main.prose { padding-left: 24px; padding-right: 24px; }
main.prose h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 4.5vw, 2.7rem);
  line-height: 1.15;
  margin: 20px 0 12px;
}
main.prose .updated { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 36px; }
main.prose h2 { font-size: 1.35rem; margin: 40px 0 10px; }
main.prose p, main.prose li { color: var(--ink-soft); }
main.prose p { margin-bottom: 14px; }
main.prose ul { margin: 0 0 14px 22px; }
main.prose strong { color: var(--ink); }

details.faq {
  border-bottom: 1px solid var(--grid);
  padding: 4px 0;
}
details.faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  padding: 14px 0;
  list-style: none;
  position: relative;
  padding-right: 30px;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after {
  content: "\2715";
  position: absolute; right: 4px; top: 14px;
  color: var(--red);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
details.faq[open] summary::after { transform: rotate(0deg); }
details.faq div { padding: 0 0 18px; }

.contact-card {
  margin-top: 44px;
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 14px;
  padding: 26px;
}
.contact-card h2 { margin-top: 0; }

/* ---------- complete user guide ---------- */

.guide { padding-bottom: 72px; }
.guide-hero {
  padding: 64px 0 58px;
  border-bottom: 1px solid var(--grid);
}
.guide-hero h1 {
  max-width: 760px;
  font-family: var(--serif);
  font-size: clamp(2.35rem, 5vw, 3.7rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}
.guide-hero .lede {
  max-width: 680px;
  color: var(--ink-soft);
  font-size: 1.12rem;
}
.guide-jump {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-top: 28px;
}
.guide-jump a:not(.btn), .text-link {
  font-weight: 600;
  text-underline-offset: 4px;
}
.guide-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 740px);
  justify-content: space-between;
  gap: 64px;
  padding-top: 52px;
}
.guide-toc {
  align-self: start;
  position: sticky;
  top: 24px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 14px;
  font-size: 0.86rem;
}
.guide-toc p {
  font-family: var(--mono);
  color: var(--red);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.guide-toc ol { list-style: none; }
.guide-toc li + li { margin-top: 5px; }
.guide-toc a {
  display: block;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.35;
  padding: 2px 0;
}
.guide-toc a:hover { color: var(--red); }
.guide-content { min-width: 0; }
.guide-section {
  scroll-margin-top: 24px;
  padding: 0 0 64px;
}
.guide-section + .guide-section {
  padding-top: 64px;
  border-top: 1px solid var(--grid);
}
.guide-section h2 {
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  line-height: 1.15;
  margin-bottom: 18px;
}
.guide-section h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 28px 0 8px;
}
.guide-section p, .guide-section li { color: var(--ink-soft); }
.guide-section p { margin-bottom: 16px; }
.guide-section strong { color: var(--ink); }
.guide-section > ul, .guide-section > ol {
  margin: 16px 0 18px 22px;
}
.guide-section > ul li + li, .guide-section > ol li + li { margin-top: 10px; }
.section-number {
  font-family: var(--mono);
  color: var(--red) !important;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px !important;
}
.task-list {
  list-style: none;
  counter-reset: guide-task;
  margin-left: 0 !important;
}
.task-list li {
  counter-increment: guide-task;
  position: relative;
  padding: 2px 0 16px 42px;
}
.task-list li::before {
  content: counter(guide-task);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--red);
  color: var(--snow);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
}
.guide-grid, .format-cards, .platform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.guide-grid > div, .format-cards > div, .platform-grid > div {
  padding: 20px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: var(--card);
}
.guide-grid h3, .format-cards h3, .platform-grid h3 { margin-top: 0; }
.guide-grid p:last-child, .format-cards p:last-child, .platform-grid p:last-child { margin-bottom: 0; }
.view-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.format-label {
  display: inline-block;
  margin-bottom: 14px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--red);
  color: var(--snow);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.guide-note, .guide-warning {
  margin: 24px 0;
  padding: 17px 19px;
  border-left: 4px solid var(--red);
  background: var(--cloth-deep);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
}
.guide-warning { border-left-color: #C47A20; }
.guide-figure { margin: 28px 0; }
.guide-figure img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border: 1px solid var(--grid);
  border-radius: 14px;
  box-shadow: 0 18px 40px -24px rgba(42, 33, 27, 0.35);
}
.guide-figure figcaption {
  max-width: 64ch;
  margin: 10px auto 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  text-align: center;
}
.guide-figure-portrait {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.control-table {
  margin: 24px 0;
  border-top: 1px solid var(--grid);
}
.control-table [role="row"] {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--grid);
}
.control-table span { color: var(--ink-soft); }
kbd {
  padding: 2px 6px;
  border: 1px solid var(--grid);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8em;
}
.guide-section details.faq div { padding-left: 0; }
.guide-help {
  padding: 48px !important;
  border: 1px solid var(--grid) !important;
  border-radius: 16px;
  background: var(--card);
}
.guide-help .btn { margin-right: 18px; }

@media (max-width: 860px) {
  .guide-layout { grid-template-columns: 1fr; gap: 36px; }
  .guide-toc {
    position: static;
    columns: 2;
  }
  .guide-toc p { column-span: all; }
  .guide-toc li { break-inside: avoid; }
}
@media (max-width: 620px) {
  .guide-hero { padding: 42px 0; }
  .guide-layout { padding-top: 28px; }
  .guide-toc { columns: 1; }
  .guide-section { padding-bottom: 48px; }
  .guide-section + .guide-section { padding-top: 48px; }
  .guide-grid, .format-cards, .platform-grid, .view-grid { grid-template-columns: 1fr; }
  .control-table [role="row"] { grid-template-columns: 1fr; gap: 3px; }
  .guide-help { padding: 28px 22px !important; }
  .guide-help .btn { margin-bottom: 14px; }
}

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

footer.site {
  border-top: 1px solid var(--grid);
  padding: 36px 0 48px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
footer.site .wrap {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
footer.site a { color: var(--ink-soft); }
footer.site a:hover { color: var(--red); }
