/* Stitchchart MD site. Graph paper and thread: a midnight-ink hero over chart-paper sections,
   raspberry thread for accents, running-stitch rules. Keep the focus ring, the skip link and
   the three-width check (npm run shots). */
:root {
  --ink: #111a35;
  --ink-2: #1b2748;
  --paper: #f7f9fc;
  --paper-2: #edf1f8;
  --grid: #dde5f1;
  --grid-major: #c4d0e4;
  --text: #1a2340;
  --muted: #55607c;
  --thread: #e5395f;
  --thread-deep: #c92a4f;
  --teal: #0e9f8e;
  --gold: #f2b233;
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: "Hanken Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1180px;
  --stitch: repeating-linear-gradient(90deg, currentColor 0 9px, transparent 9px 15px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0; color: var(--text); font: 17px/1.62 var(--body);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
body > main, body > footer, body > header { flex: none; }
body > main.lost { flex: 1 0 auto; }
body > footer { margin-top: auto; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--thread-deep); text-underline-offset: .2em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--ink); text-decoration-thickness: 3px; }
:focus-visible { outline: 3px solid var(--thread); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.08; margin: 0; text-wrap: balance; font-variation-settings: "opsz" 96; }
h2 { font-size: clamp(30px, 4vw, 46px); letter-spacing: -.015em; }
h3 { font-size: 22px; letter-spacing: -.005em; }
p { margin: 0; }
code, pre { font-family: var(--mono); font-size: .86em; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: 12px; top: -56px; background: var(--thread-deep); color: #fff; padding: 9px 16px; z-index: 20; border-radius: 4px; font-weight: 700; }
.skip:focus { top: 12px; }

/* The running stitch: a dashed line that looks sewn. */
.stitched { height: 3px; color: var(--thread); background: var(--stitch); }
.kicker { font: 600 13px/1.5 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--thread-deep); display: flex; align-items: baseline; gap: 10px; }
.kicker::before { content: ""; width: 26px; height: 3px; background: var(--stitch); color: var(--thread); flex: none; align-self: flex-start; margin-top: .62em; }

/* Header */
.top { background: var(--ink); color: #fff; position: relative; z-index: 3; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; flex-wrap: wrap; }
.wordmark { display: inline-flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 700; font-size: 21px; color: #fff; text-decoration: none; letter-spacing: -.01em; }
.wordmark img { width: 34px; height: 34px; border-radius: 9px; }
.wordmark:hover { color: #fff; text-decoration: none; }
.wordmark span { color: var(--gold); }
.nav { display: flex; gap: 24px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.nav a { color: #d7def0; text-decoration: none; font-size: 15px; font-weight: 600; padding: 0; min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover { color: #fff; text-decoration: underline; text-decoration-color: var(--thread); text-decoration-thickness: 3px; }

/* Hero */
.hero { background: var(--ink); color: #fff; position: relative; overflow-x: clip; padding: clamp(48px, 7vw, 96px) 0 clamp(64px, 8vw, 110px); isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px, 220px 220px, 220px 220px;
  mask-image: radial-gradient(120% 100% at 70% 40%, #000 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(120% 100% at 70% 40%, #000 30%, transparent 85%);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }
.hero .kicker { color: var(--gold); }
.hero .kicker::before { color: var(--gold); }
.hero h1 { font-size: clamp(40px, 5.6vw, 72px); letter-spacing: -.025em; margin-top: 20px; font-weight: 600; }
.hero h1 em { font-style: italic; font-weight: 500; color: #fff; background: linear-gradient(var(--thread), var(--thread)) 0 100% / 100% .12em no-repeat; padding-bottom: .02em; }
.lede { font-size: 20px; color: #c6d0ea; margin-top: 24px; max-width: 54ch; line-height: 1.55; }
.cta { display: flex; gap: 18px 12px; flex-wrap: wrap; margin-top: 34px; }
.btn { display: inline-block; background: var(--thread-deep); color: #fff; text-decoration: none; padding: 14px 24px; border-radius: 10px; font-weight: 700; font-size: 16px; border: 2px solid var(--thread-deep); box-shadow: 0 6px 0 #9b1f3c; transition: transform .12s, box-shadow .12s; }
.btn:hover { color: #fff; transform: translateY(3px); box-shadow: 0 3px 0 #9b1f3c; text-decoration: none; }
.btn:active { transform: translateY(6px); box-shadow: 0 0 0 #9b1f3c; }
.btn-quiet { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); box-shadow: 0 6px 0 rgba(255,255,255,.18); }
.btn-quiet:hover { color: #fff; box-shadow: 0 3px 0 rgba(255,255,255,.18); border-color: #fff; }
.one-liner { margin-top: 30px; }
.one-liner code { display: inline-block; background: rgba(255,255,255,.08); border: 1px dashed rgba(255,255,255,.4); color: #fff; padding: 10px 14px; border-radius: 8px; overflow-wrap: anywhere; line-height: 1.5; }
.hero-facts { display: flex; gap: 10px 26px; flex-wrap: wrap; margin: 34px 0 0; padding: 0; list-style: none; font: 600 13px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #9fb0d8; }
.hero-facts li::before { content: "×"; color: var(--thread); margin-right: 8px; font-weight: 700; }

.hero-art { position: relative; aspect-ratio: 1 / 1.1; width: 100%; }
.sheet { position: absolute; width: 56%; background: #fff; border-radius: 3px; box-shadow: 0 2px 4px rgba(0,0,0,.25), 0 30px 60px rgba(0,0,0,.45); transition: transform .25s; }
.sheet img { border-radius: 3px; }
.sheet-a { left: 0; top: 4%; transform: rotate(-7deg); }
.sheet-b { right: 0; top: 0; transform: rotate(6deg); }
.sheet-c { left: 22%; bottom: 0; transform: rotate(-1.5deg); z-index: 2; box-shadow: 0 2px 4px rgba(0,0,0,.25), 0 40px 80px rgba(229,57,95,.28), 0 30px 60px rgba(0,0,0,.5); }
.sheet:hover { transform: rotate(0) translateY(-6px) scale(1.02); z-index: 4; }

.hem { height: 14px; background: var(--ink); position: relative; }
.hem::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 4px; color: var(--thread); background: var(--stitch); }

/* Sections */
section { padding: clamp(64px, 8vw, 112px) 0; }
.section-head { max-width: 62ch; margin-bottom: clamp(32px, 4vw, 52px); }
.section-head h2 { margin-top: 16px; }
.section-lede { color: var(--muted); margin-top: 14px; font-size: 18px; }
.band { background: var(--paper-2); border-block: 1px solid var(--grid-major); background-image: none; }
.band-white { background: #fff; background-image: none; border-block: 1px solid var(--grid); }

/* What every chart has */
.facts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.facts li { background: var(--paper); border: 1.5px solid var(--ink); border-radius: 14px; padding: 22px 22px 24px; box-shadow: 5px 5px 0 var(--ink); }
.facts b { display: block; font-family: var(--display); font-size: 21px; line-height: 1.2; margin-bottom: 8px; font-weight: 600; }
.facts p { color: var(--muted); font-size: 16px; }
.glyph { display: block; width: 34px; height: 34px; margin-bottom: 16px; color: var(--thread); }

/* How it works */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; counter-reset: step; }
.steps > li { counter-increment: step; position: relative; background: #fff; border: 1.5px solid var(--ink); border-radius: 14px; padding: 30px 24px 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.steps > li::before { content: counter(step); position: absolute; top: -20px; left: 22px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--thread); color: #fff; font: 700 19px/1 var(--display); border: 2px solid var(--ink); }
.steps h3 { margin-top: 6px; }
.steps p { color: var(--muted); font-size: 16px; }
.snippet { margin: auto 0 0; background: var(--ink); color: #eaf0ff; border-radius: 10px; padding: 14px 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; border: 1px dashed rgba(255,255,255,.35); }
.snippet .bad { color: #ff9db3; }
.snippet .ok { color: #7be0c6; }
.ask { margin: 40px 0 0; font-family: var(--display); font-size: clamp(22px, 2.6vw, 30px); line-height: 1.3; font-style: italic; max-width: 40ch; border-left: 4px solid var(--thread); padding-left: 22px; }

/* Themes */
.themes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px; margin: 0; padding: 0; list-style: none; }
.themes figure { margin: 0; }
.themes a.shot { display: block; background: #fff; border-radius: 3px; box-shadow: 0 1px 2px rgba(17,26,53,.18), 0 14px 30px rgba(17,26,53,.2); transition: transform .2s, box-shadow .2s; }
.themes a.shot:hover { transform: translateY(-6px) rotate(-.6deg); box-shadow: 0 2px 4px rgba(17,26,53,.2), 0 24px 40px rgba(17,26,53,.28); }
.themes figcaption { margin-top: 18px; font-size: 15px; color: var(--muted); line-height: 1.45; }
.themes figcaption b { display: block; font-family: var(--display); font-size: 20px; color: var(--ink); margin-bottom: 4px; font-weight: 600; }

/* Examples */
.examples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px 22px; margin: 0; padding: 0; list-style: none; }
.example a { display: block; text-decoration: none; color: inherit; }
.example .thumb { display: block; background: #fff; border-radius: 3px; box-shadow: 0 1px 2px rgba(17,26,53,.18), 0 10px 22px rgba(17,26,53,.16); overflow: hidden; transition: transform .2s; aspect-ratio: 1 / 1.414; }
.example a:hover .thumb { transform: translateY(-5px); }
.example img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.example h3 { font-size: 19px; margin-top: 14px; }
.example p { font-size: 14.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.example a:hover h3 { text-decoration: underline; text-decoration-color: var(--thread); text-decoration-thickness: 3px; text-underline-offset: 4px; }

/* Install */
.install { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.install > div { min-width: 0; }
.install h3 { margin-bottom: 4px; }
.install p { color: var(--muted); font-size: 15px; }
.install pre { margin: 14px 0 0; background: var(--ink); color: #eef2ff; padding: 18px; border-radius: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; border: 2px dashed rgba(229,57,95,.7); box-shadow: 5px 5px 0 var(--thread); }
.note { color: var(--muted); margin-top: 28px; font-size: 16px; }

/* Footer */
.foot { background: var(--ink); color: #b9c4e0; padding: 48px 0 60px; font-size: 15px; position: relative; }
.foot::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; color: var(--thread); background: var(--stitch); }
.foot a { color: #fff; text-decoration-color: var(--thread); display: inline-block; padding: 10px 2px; margin: -10px -2px; }
.foot a:hover { color: var(--gold); }
.foot-row { display: grid; gap: 12px; }
.foot .wordmark { font-size: 20px; }

.lost { flex: 1 0 auto; min-height: 62vh; display: flex; align-items: center; background: var(--paper); }
.lost h1 { font-size: clamp(38px, 5vw, 60px); margin-top: 14px; }
.lost .lede { color: var(--muted); }
.lost .btn-quiet { color: var(--ink); border-color: var(--ink); box-shadow: 0 6px 0 rgba(17,26,53,.18); }
.lost .btn-quiet:hover { color: var(--ink); box-shadow: 0 3px 0 rgba(17,26,53,.18); }

@media (max-width: 1100px) {
  .themes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .examples { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 56px; }
  .hero-art { max-width: 520px; margin: 0 auto; }
  .steps, .install { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .wrap { padding: 0 18px; }
  .nav { gap: 6px 16px; }
  .lede { font-size: 18px; }
  .examples { gap: 22px 14px; }
  .example h3 { font-size: 17px; }
  .example p { font-size: 13.5px; }
  .facts li { box-shadow: 4px 4px 0 var(--ink); }
}
