/* Colours are taken from the photographs: the warm cloth, the glacier blues of the yarn,
   and the cranberry-to-rose of the bobble rim. */
:root {
  --bg: #1c1917;
  --bg2: #221e1b;
  --panel: #27221f;
  --cloth: #776c65;
  --fg: #efe8de;
  --soft: #cfc5b8;
  --mute: #9e9389;
  --line: #3a332e;
  --glacier: #a6d3e3;
  --deep: #6f9cc4;
  --cranberry: #b5483d;
  --rose: #e5a093;
  --amber: #f1c97a;
  --serif: "Cormorant Garamond", "Noto Serif SC", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "PingFang SC", sans-serif;
  --zh-serif: "Noto Serif SC", "Songti SC", serif;
  --wrap: 1180px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; overflow-x: clip; background: var(--bg); color: var(--fg); font-family: var(--sans); font-weight: 300; line-height: 1.7; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2 { font-family: var(--serif); font-weight: 300; line-height: 1.08; margin: 0; letter-spacing: .005em; }
html[lang^="zh"] h1, html[lang^="zh"] h2 { font-family: var(--zh-serif); font-weight: 400; letter-spacing: .08em; }
::selection { background: rgba(229, 160, 147, .35); }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 12px max(16px, calc((100vw - var(--wrap)) / 2 + 16px));
  background: rgba(28, 25, 23, .78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid rgba(58, 51, 46, .6); }
.top .mark { font-family: var(--serif); font-style: italic; font-size: 1.1rem; text-decoration: none; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[lang^="zh"] .top .mark { font-family: var(--zh-serif); font-style: normal; letter-spacing: .2em; }
.top .links { display: flex; gap: 22px; margin-left: auto; }
.top .links a { text-decoration: none; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); transition: color .2s; }
html[lang^="zh"] .top .links a { letter-spacing: .2em; font-size: .85rem; }
.top .links a:hover { color: var(--fg); }

/* ---------- hero: the photo's own cloth fades into the page ---------- */
.hero { position: relative; max-width: var(--wrap); margin: 0 auto; padding: 56px 16px 72px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 48px; align-items: center; min-height: min(88vh, 860px); }
.hero-photo { position: relative; margin: 0; isolation: isolate; }
.hero-photo::before { content: ""; position: absolute; z-index: -1; inset: -24%; pointer-events: none;
  background: radial-gradient(closest-side, #73685f 0%, #6c625a 52%, rgba(28, 25, 23, .55) 78%, rgba(28, 25, 23, 0) 100%); }
.hero-photo img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  -webkit-mask-image: radial-gradient(closest-side, #000 76%, transparent 100%); mask-image: radial-gradient(closest-side, #000 76%, transparent 100%); }
.kicker { margin: 0 0 22px; font-size: .74rem; letter-spacing: .28em; text-transform: uppercase; color: var(--rose); }
html[lang^="zh"] .kicker { letter-spacing: .4em; font-size: .85rem; }
.hero h1 { font-size: clamp(2.6rem, 5.4vw, 4.4rem); }
html[lang^="zh"] .hero h1 { font-size: clamp(3rem, 6.4vw, 5rem); letter-spacing: .2em; }
.alt-title { margin: 18px 0 30px; color: var(--glacier); font-family: var(--zh-serif); font-weight: 300; font-size: clamp(1.15rem, 2vw, 1.45rem); letter-spacing: .5em; }
html[lang^="zh"] .alt-title { font-family: var(--serif); font-style: italic; letter-spacing: .03em; font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
.lede { font-family: var(--serif); font-size: clamp(1.25rem, 1.9vw, 1.5rem); line-height: 1.5; color: var(--fg); max-width: 26em; margin: 0 0 26px; }
html[lang^="zh"] .lede { font-family: var(--zh-serif); font-weight: 300; font-size: 1.15rem; line-height: 1.9; }
.meta { color: var(--mute); font-size: .82rem; letter-spacing: .04em; margin: 0; padding-top: 18px; border-top: 1px solid var(--line); max-width: 30em; }

/* ---------- sections ---------- */
main { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
section { padding: 88px 0 24px; }
.sec-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 18px; }
.sec-head .num { font-family: var(--serif); font-style: italic; font-size: 1.1rem; color: var(--rose); min-width: 2.2em; padding-top: 2px; border-top: 1px solid var(--rose); }
h2 { font-size: clamp(2rem, 3.6vw, 2.8rem); }
.lens { margin: -6px 0 14px; font-size: .74rem; letter-spacing: .22em; text-transform: uppercase; color: var(--rose); }
html[lang^="zh"] .lens { font-size: .85rem; letter-spacing: .25em; }
.intro { color: var(--soft); max-width: 44em; margin: 0 0 32px; font-size: 1.02rem; }
html[lang^="zh"] .intro { line-height: 1.95; }

/* ---------- photographs: a separate panel ---------- */
.album { border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; background: var(--bg); color: var(--fg); }
.album::backdrop { background: rgba(16, 14, 13, .9); }
.album-in { max-width: var(--wrap); margin: 0 auto; padding: 24px 16px 64px; }
.album header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.album h2 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
.album .close { font-size: 1.4rem; line-height: 1; padding: 6px 13px; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.gallery figure { margin: 0; }
.zoom { display: block; padding: 0; border: 0; border-radius: 0; background: none; width: 100%; cursor: zoom-in; overflow: hidden; }
.zoom img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; transition: transform .8s cubic-bezier(.2, .7, .2, 1); }
.zoom:hover img { transform: scale(1.025); }
figcaption { font-family: var(--serif); font-style: italic; color: var(--soft); font-size: 1.05rem; margin-top: 10px; line-height: 1.45; }
html[lang^="zh"] figcaption { font-family: var(--zh-serif); font-style: normal; font-size: .92rem; }
.meta .more { display: inline-block; margin-left: 14px; color: var(--rose); text-decoration: none; border-bottom: 1px solid rgba(229, 160, 147, .4); }
.meta .more::after { content: " →"; }
.meta .more:hover { border-bottom-color: var(--rose); }

.lightbox { border: 0; padding: 0; background: transparent; max-width: min(92vw, 1100px); max-height: 94vh; color: var(--fg); }
.lightbox::backdrop { background: rgba(16, 14, 13, .92); }
.lightbox img { max-height: 84vh; width: auto; margin: 0 auto; }
.lightbox p { text-align: center; font-family: var(--serif); font-style: italic; color: var(--soft); margin: 12px 0 0; }
.lightbox .close { position: fixed; z-index: 2; top: 16px; right: 16px; font-size: 1.4rem; line-height: 1; padding: 6px 13px; }

/* ---------- render showcase: blends into the page, no frames ---------- */
.showcase { padding-top: 24px; }
.showcase figure { margin: 0; }
.sc-main img, .sc-main video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  -webkit-mask-image: radial-gradient(ellipse closest-side, #000 62%, transparent 100%); mask-image: radial-gradient(ellipse closest-side, #000 62%, transparent 100%); }
.sc-main { position: relative; }
.sc-main video { cursor: pointer; }
.sc-skel { position: absolute; top: 4%; right: 3%; width: 27%; pointer-events: none; }
.sc-skel canvas { display: block; width: 100%; aspect-ratio: 16 / 9; }
.sc-skel p { margin: 2px 0 0; text-align: right; font-family: var(--serif); font-style: italic; font-size: .92rem; color: var(--soft); }
html[lang^="zh"] .sc-skel p { font-family: var(--zh-serif); font-style: normal; font-size: .82rem; }
.sc-pause { position: absolute; left: 3%; bottom: 6%; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; color: var(--soft); background: rgba(28, 25, 23, .55); border-color: rgba(207, 197, 184, .35); opacity: .75; }
.sc-pause:hover { opacity: 1; }
.sc-cap { margin: 14px 0 0; font-family: var(--serif); font-style: italic; color: var(--mute); font-size: 1rem; }
html[lang^="zh"] .sc-cap { font-family: var(--zh-serif); font-style: normal; font-size: .9rem; }

/* ---------- interactive stages ---------- */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.viewer { position: relative; background: #1a1715; overflow: hidden; aspect-ratio: 4 / 3; border: 1px solid var(--line); }
.viewer canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); }
.labels { position: absolute; inset: 0; pointer-events: none; }
.labels span { position: absolute; transform: translate(-50%, -140%); font-size: .78rem; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: rgba(26, 23, 21, .86); white-space: nowrap; }
.labels .new { color: var(--amber); border: 1px solid var(--amber); }
.labels .band { color: var(--deep); border: 1px solid var(--deep); transform: translate(-50%, 40%); }
.labels .old { color: var(--fg); border: 1px solid var(--mute); }
.sub { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(92%, 640px); margin: 0; padding: 9px 16px; background: rgba(20, 18, 16, .78); color: var(--fg); font-family: var(--serif); font-size: 1.12rem; line-height: 1.4; text-align: center; opacity: 0; transition: opacity .5s; pointer-events: none; }
html[lang^="zh"] .sub { font-family: var(--zh-serif); font-size: .98rem; }
.sub.on { opacity: 1; }

.panel { background: var(--panel); border: 1px solid var(--line); padding: 18px; display: grid; gap: 16px; }
.viewer.wide { aspect-ratio: 16 / 9; }
.panel.bar { margin-top: 16px; grid-template-columns: 300px minmax(0, 1fr); gap: 16px 36px; align-items: start; }
.bar-left { display: grid; gap: 14px; }
.caption.big { min-height: 0; font-family: var(--serif); font-size: 1.28rem; line-height: 1.5; color: var(--fg); max-width: 34em; padding-top: 4px; }
html[lang^="zh"] .caption.big { font-family: var(--zh-serif); font-weight: 300; font-size: 1.05rem; line-height: 1.9; }
/* telling the viewer what they can do */
.howto { font-size: .92rem; color: var(--soft); margin: -18px 0 14px; max-width: 52em; padding-left: 14px; border-left: 2px solid var(--rose); }
.howto b { color: var(--rose); font-weight: 500; }
.steps-h { margin: 0 0 -6px; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
html[lang^="zh"] .steps-h { letter-spacing: .04em; text-transform: none; }
.drag-hint { position: absolute; top: 12px; left: 12px; font-size: .8rem; color: var(--fg); background: rgba(26, 23, 21, .78); border: 1px solid #5a514a; border-radius: 999px; padding: 3px 12px 3px 10px; pointer-events: none; transition: opacity .6s; }
.drag-hint::before { content: "\21BB"; margin-right: 6px; color: var(--rose); }
.drag-hint.gone { opacity: 0; }
.state-tag { position: absolute; top: 12px; right: 12px; font-family: var(--serif); font-size: 1.08rem; color: var(--fg); background: rgba(20, 18, 16, .72); padding: 4px 14px; pointer-events: none; white-space: nowrap; }
html[lang^="zh"] .state-tag { font-family: var(--zh-serif); font-size: .95rem; }
/* the two stitches */
.stitches { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 44px; margin: 0 0 36px; }
.stitches h3 { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; margin: 0 0 6px; color: var(--fg); display: flex; align-items: center; gap: 10px; }
html[lang^="zh"] .stitches h3 { font-family: var(--zh-serif); font-size: 1.15rem; }
.stitches p { margin: 0; color: var(--soft); font-size: .96rem; }
html[lang^="zh"] .stitches p { line-height: 1.9; }
.stitches i { font-style: italic; }
.step-fig { margin: 0 0 40px; }
.step-fig h3 { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; margin: 0 0 6px; color: var(--fg); }
html[lang^="zh"] .step-fig h3 { font-family: var(--zh-serif); font-size: 1.15rem; }
.step-fig > p { margin: 0 0 18px; color: var(--soft); font-size: .96rem; max-width: 52em; }
html[lang^="zh"] .step-fig > p { line-height: 1.9; }
.step-svg { display: block; width: 100%; height: auto; background: #1a1715; border: 1px solid var(--line); }
.step-legend { list-style: none; margin: 14px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: .84rem; color: var(--mute); }
.step-legend li { display: flex; align-items: center; gap: 6px; }
.step-legend svg { width: 28px; height: 20px; flex: none; }
.step-caps { display: grid; grid-template-columns: 250fr 300fr 310fr; gap: 0 18px; margin-top: 8px; font-size: .86rem; color: var(--soft); }
.step-caps figcaption { padding: 0 6px; }
.dot { width: .7em; height: .7em; border-radius: 50%; display: inline-block; flex: none; }
.dot.blue { background: linear-gradient(135deg, #b2ddef, #6f93cc); }
.dot.red { background: linear-gradient(135deg, #e3a093, #9a3832); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 6px 8px; cursor: pointer; color: var(--mute); transition: color .25s, background .25s; }
.steps li:hover { color: var(--soft); background: rgba(239, 232, 222, .04); }
.steps li:hover b { border-color: var(--soft); }
.steps li b { font-variant-numeric: lining-nums; width: 1.9em; height: 1.9em; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); font-family: var(--serif); font-weight: 500; font-size: .9rem; flex: none; transition: border-color .25s, color .25s; }
.steps li.on { background: rgba(229, 160, 147, .07); color: var(--fg); }
.steps li.on b { border-color: var(--rose); color: var(--rose); }
.caption { margin: 0; min-height: 7.2em; font-size: .9rem; color: var(--soft); line-height: 1.6; }
.controls { display: flex; gap: 10px; align-items: center; }
.controls input { flex: 1; accent-color: var(--rose); min-width: 0; }
.controls select { font: inherit; font-size: .8rem; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px; }
button { font: inherit; font-size: .82rem; font-weight: 400; color: var(--fg); background: transparent; border: 1px solid #5a514a; border-radius: 999px; padding: 4px 14px; cursor: pointer; transition: border-color .2s, background .2s, color .2s; }
button:hover { border-color: var(--soft); }
button:disabled { opacity: .55; cursor: default; }
button.on { border-color: var(--rose); color: var(--rose); }
button.accent { border-color: var(--cranberry); background: rgba(181, 72, 61, .16); }
button.accent:hover { background: rgba(181, 72, 61, .3); }
.toggles { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: .84rem; color: var(--mute); }
.toggles input { accent-color: var(--rose); }
.views { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .84rem; color: var(--mute); }
.views span { margin-right: 4px; }

.notes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 40px; margin-top: 28px; }
.notes p { margin: 0; }

/* ---------- prose ---------- */
.prose p { max-width: 44em; color: var(--soft); }
.prose a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--rose); text-underline-offset: 3px; }
.prose a:hover { color: var(--rose); }
.prose b { color: var(--rose); font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.12em; }
html[lang^="zh"] .prose b { font-family: var(--zh-serif); font-style: normal; font-size: 1em; font-weight: 500; }
html[lang^="zh"] .prose p { line-height: 1.95; }
/* follow along: the crochet order on the flat pattern */
.follow { margin-top: 56px; }
.follow h3 { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; margin: 0 0 10px; color: var(--fg); }
html[lang^="zh"] .follow h3 { font-family: var(--zh-serif); font-size: 1.35rem; letter-spacing: .06em; }
.flw-canvas { background: #1a1715; border: 1px solid var(--line); }
.flw-canvas canvas { display: block; width: 100%; }
.flw-head { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; color: var(--soft); }
.flw-head span:last-child { color: var(--mute); font-variant-numeric: tabular-nums; }
.follow select { font: inherit; font-size: .8rem; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.follow .controls input { flex: none; }
#flwScrub { width: 100%; accent-color: var(--rose); }

/* the mathematics: text beside its picture, then the details */
.mstep { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr); gap: 20px 44px; align-items: center; margin: 44px 0; }
.mstep.text-only { grid-template-columns: minmax(0, 1fr); }
.mstep.stack { grid-template-columns: minmax(0, 1fr); }
.mstep.stack .mtext p { max-width: 52em; }
.shear-pair { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 12px; }
.shear-flat { aspect-ratio: 2.1 / 1; }
.shear-cowl { aspect-ratio: auto; }
.shear-info { margin: 10px 0 0; font-size: .9rem; color: var(--soft); font-variant-numeric: tabular-nums; }
.mtext h3, .deeper h3 { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; margin: 0 0 10px; color: var(--fg); }
html[lang^="zh"] .mtext h3, html[lang^="zh"] .deeper h3 { font-family: var(--zh-serif); font-size: 1.35rem; letter-spacing: .06em; }
.mtext p { margin: 0; }
.mfig { margin: 0; }
.mpair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mpair figure { margin: 0; }
.mpair figcaption { text-align: center; margin-top: 8px; font-size: .9rem; color: var(--soft); }
.lace-cv { background: #1a1715; border: 1px solid var(--line); }
.lace-cv canvas { display: block; width: 100%; }
.mcap1 { margin-top: 8px; }
.mctl { margin-top: 10px; }
.mctl .toggles { margin-left: 8px; }
.mctl input[type=range] { accent-color: var(--rose); vertical-align: middle; width: 120px; }
.deeper { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
#mathBody { columns: 2 22em; column-gap: 48px; }
#mathBody p { break-inside: avoid; margin: 0 0 1.2em; }
.refs { display: block; font-size: .82rem; line-height: 1.6; color: var(--mute); }
.refs i { font-style: italic; }

footer { max-width: var(--wrap); margin: 72px auto 0; padding: 28px 16px 56px; color: var(--mute); font-family: var(--serif); font-style: italic; font-size: 1rem; border-top: 1px solid var(--line); text-align: center; }

@media (max-width: 960px) {
  .top .links { display: none; }
  .top .lang { margin-left: auto; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 8px; padding-top: 32px; min-height: 0; }
  .hero-photo { order: 2; max-width: 520px; width: 100%; margin: 0 auto; }
  section { padding-top: 64px; }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .gallery { grid-template-columns: 1fr; }
  .viewer.wide { aspect-ratio: 4 / 3; }
  .panel.bar { grid-template-columns: minmax(0, 1fr); }
  .meta .more { display: block; margin: 10px 0 0; width: max-content; }
  .caption { min-height: 0; }
  .sub { font-size: .92rem; bottom: 8px; }
  .notes { grid-template-columns: 1fr; }
  .stitches { grid-template-columns: 1fr; }
  .shear-pair { grid-template-columns: minmax(0, 1fr); }
  .shear-cowl { aspect-ratio: 4 / 3; }
  .step-caps { grid-template-columns: 1fr; gap: 4px; }
  .mstep { grid-template-columns: minmax(0, 1fr); }
  .sc-skel { position: static; width: 100%; display: grid; grid-template-columns: 56% 1fr; gap: 12px; align-items: center; margin-top: 10px; }
  .sc-skel canvas { background: #1a1715; border: 1px solid var(--line); }
  .sc-main { container-type: inline-size; }
  .sc-pause { bottom: auto; top: calc(56.25cqw - 46px); left: 12px; }
  .sc-skel p { margin: 0; text-align: left; font-size: .9rem; }
}
