/* Thread & Hoop. Colors are named after the stranded cotton they mimic. */
:root {
  --paper: #EEF1EC;      /* bleached linen */
  --card: #FBFCFA;
  --ink: #1F2A44;        /* navy, like DMC 939 */
  --muted: #586174;
  --red: #C72B3B;        /* Christmas red, like DMC 321 */
  --red-ink: #A51F2F;
  --green: #4F7A45;      /* like DMC 3346 */
  --hoop: #B98A55;       /* beechwood hoop */
  --line: #D3D9D1;
  --focus: #2F6FD6;
  --radius: 10px;
  --wrap: 1120px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151A24; --card: #1D2431; --ink: #E8ECE5; --muted: #A5AEBD; --red: #E5566A; --red-ink: #F07A8A;
    --green: #8DBB7E; --hoop: #D2A774; --line: #2E3747; color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 18px/1.6 Figtree, system-ui, sans-serif; }
[hidden] { display: none !important; }
img, canvas, svg { max-width: 100%; }
a { color: var(--red-ink); text-underline-offset: 3px; }
a:hover { color: var(--red); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
main { padding: 28px 0 56px; }

h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
h1, .display { font-family: "Pixelify Sans", Figtree, sans-serif; font-weight: 700; font-size: clamp(2.2rem, 5.4vw, 3.6rem); letter-spacing: .01em; }
h2 { font-family: "Pixelify Sans", Figtree, sans-serif; font-weight: 500; font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 1em; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 38rem; }
.small { font-size: .92rem; color: var(--muted); }
.read { max-width: 46rem; }

/* header */
.site-head { background: #1F2A44; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-head { background: #0E1422; border-bottom: 1px solid var(--line); } }
.head-row { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: "Pixelify Sans", sans-serif; font-weight: 700; font-size: 1.35rem; }
.brand:hover { color: #fff; }
.logo { width: 32px; height: 32px; --hoop: #D2A774; --red: #F06A78; --green: #9CCB8C; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav a { color: #DCE2EE; text-decoration: none; padding: 8px 12px; border-radius: 6px; white-space: nowrap; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current] { color: #fff; box-shadow: inset 0 -3px 0 var(--hoop); border-radius: 0; }
@media (max-width: 760px) {
  .head-row { gap: 0; padding-top: 10px; }
  .nav { margin: 0 -20px; padding: 4px 14px 8px; width: calc(100% + 40px); }
}

/* footer */
.site-foot { border-top: 1px solid var(--line); padding: 28px 0 40px; font-size: .9rem; color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.site-foot a { color: var(--ink); }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 8px; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink); font: 700 1rem Figtree, sans-serif; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--paper); color: var(--ink); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-ink); border-color: var(--red-ink); color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { font-weight: 600; }
input[type=number], input[type=text], select { font: inherit; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); min-height: 44px; }
input[type=range] { width: 100%; accent-color: var(--red); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--red); vertical-align: -4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 14px; }

/* home hero: the stitched picture is the one loud element */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; padding: 20px 0 36px; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); }
.hoop-frame { position: relative; aspect-ratio: 1; border-radius: 50%; padding: 18px; background: var(--hoop);
  box-shadow: inset 0 0 0 6px rgba(0,0,0,.12), 0 18px 40px -20px rgba(31,42,68,.55); }
.hoop-frame::before { content: ""; position: absolute; top: -14px; left: 50%; width: 46px; height: 26px; transform: translateX(-50%); background: var(--hoop); border-radius: 6px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); }
.hoop-frame canvas { width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover; background: #F7F6F1; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } .hoop-frame { max-width: 360px; margin: 10px auto 0; } }

.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.tool { display: block; padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.tool:hover { border-color: var(--ink); color: var(--ink); }
.tool h3 { margin: 0 0 4px; }
.tool p { margin: 0; color: var(--muted); font-size: .95rem; }
.swatches { display: flex; gap: 4px; margin-bottom: 12px; }
.swatches i { width: 18px; height: 18px; border-radius: 3px; display: block; }
.guide-list { list-style: none; padding: 0; margin: 0; columns: 2 18rem; column-gap: 32px; }
.guide-list li { break-inside: avoid; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.guide-list a { font-weight: 700; color: var(--ink); }
.guide-list span { display: block; color: var(--muted); font-size: .92rem; }
section + section { margin-top: 48px; }

/* pattern maker */
.maker { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; margin-top: 16px; }
.maker > * { min-width: 0; }
@media (max-width: 900px) { .maker { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.maker .panel.controls { position: sticky; top: 12px; }
@media (max-width: 900px) { .maker .panel.controls { position: static; } }
.field { margin-bottom: 18px; }
.field label, .field .lab { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field output { font-weight: 700; color: var(--red-ink); }
.drop { display: grid; place-items: center; text-align: center; gap: 8px; padding: 22px 14px; border: 2px dashed var(--muted); border-radius: var(--radius); cursor: pointer; background: var(--paper); }
.drop.over { border-color: var(--red); background: var(--card); }
.drop strong { font-size: 1.05rem; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: 600 .92rem Figtree, sans-serif; padding: 9px 12px; min-height: 40px; border: 0; background: var(--card); color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.view { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.view-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.canvas-box { overflow: auto; max-height: 72vh; border-radius: 6px; background: #E4E7E1; text-align: center; }
.canvas-box canvas { display: block; margin: 0 auto; max-width: none; }
.canvas-box.fit canvas { max-width: 100%; height: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.stats div { background: var(--paper); border-radius: 8px; padding: 10px 12px; }
.stats b { display: block; font-size: 1.15rem; }
.stats span { font-size: .85rem; color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 700; }
.table-scroll { overflow-x: auto; }
.sw { display: inline-block; width: 26px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); vertical-align: middle; }
.sym { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--muted); border-radius: 4px; font-weight: 700; font-size: .9rem; }
.busy { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 8px; background: #FCEDEF; color: #7A1424; border: 1px solid #F2C3CA; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .notice { background: #3A1C22; color: #F6C9D0; border-color: #6A2E39; } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* DMC chart */
.dmc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dmc { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: .88rem; }
.dmc i { display: block; height: 54px; }
.dmc div { padding: 6px 9px 8px; }
.dmc b { display: block; font-size: 1rem; }
.dmc span { color: var(--muted); }
.finder { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.finder input[type=color] { width: 64px; height: 48px; border: 1.5px solid var(--line); border-radius: 8px; padding: 2px; background: var(--card); }
.match { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.match .dmc { width: 160px; }

/* prose */
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.3em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose table { margin: 1em 0 1.4em; }
.prose .card { margin-top: 2em; }
.eyebrow { color: var(--green); font-weight: 700; font-size: .95rem; margin-bottom: .3em; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .site-head, .site-foot, .controls, .view-bar, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .canvas-box { max-height: none; overflow: visible; background: #fff; }
}

/* starter pictures */
.tpls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.tpls button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 4px; border: 1.5px solid var(--line); border-radius: 8px; background: #FBFCFA; cursor: pointer; font: 600 .7rem/1.15 Figtree, sans-serif; color: #1F2A44; }
.tpls button img { width: 100%; max-width: 56px; height: auto; }
.tpls button span { min-height: 2.3em; display: flex; align-items: center; text-align: center; }
.tpls button:hover { border-color: var(--ink); }
.tpls button[aria-pressed="true"] { border-color: var(--red); box-shadow: 0 0 0 2px var(--red) inset; }
.pats { display: grid; grid-template-columns: repeat(4, minmax(0, 190px)); gap: 12px; }
@media (max-width: 700px) { .pats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.pat-img { background: #F7F6F1; aspect-ratio: 1; display: grid; place-items: center; padding: 8px; }
.pat-img img, .pat-img canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.pat-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pat-body h3 { font-size: 1rem; }
.pat-body .small { font-size: .8rem; }
.pat-body .btn { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.pat-body h3 { margin: 0; }
.pat-body p { margin: 0 0 6px; }
.pat-body .btn { margin-top: auto; }

/* illustrated guide cards: compact rows */
.gcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; max-width: 900px; }
@media (max-width: 700px) { .gcards { grid-template-columns: 1fr; } }
.gcard { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--gc); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--ink); }
.gcard:hover { color: var(--ink); border-color: var(--gc); }
.gcard:hover h3 { text-decoration: underline; text-decoration-color: var(--gc); }
.gcard-art { background: var(--gt); display: grid; place-items: center; flex: 0 0 64px; }
.gcard-art svg { width: 48px; height: 46px; }
.gcard-body { padding: 8px 12px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.gcard-body h3 { margin: 0; font-size: 1rem; line-height: 1.25; }
.gcard-body p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.35; }
.gtag, .gmore { display: none; }
.mini-pats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 760px) { .mini-pats { grid-template-columns: repeat(3, 1fr); } }
.mini-pat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; background: #FBFCFA; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: #1F2A44; font-weight: 600; font-size: .9rem; text-align: center; }
.mini-pat:hover { border-color: var(--ink); color: #1F2A44; }
.mini-pat img { width: 100%; max-width: 96px; height: auto; }
h1, h2, .display, .brand { font-variant-ligatures: none; font-feature-settings: "liga" 0, "clig" 0; }

