/* NerdQuilts — shared styles
   Look: gallery (Instrument Serif + Work Sans, mostly white, faint grid)
   with drafting-table details (IBM Plex Mono labels, thin ruled frames). */
:root {
  --ink: #161616;
  --ink-soft: #55575A;
  --muted: #7A7C7F;
  --rule: #E4E4E0;
  --rule-strong: #C9CBCF;
  --accent: #2F4B7C;          /* indigo, used sparingly */
  --paper: #FFFFFF;
  --wash: #F6F6F4;
  --grid: rgba(0, 0, 0, .045);
  --heading: 'Instrument Serif', Georgia, serif;
  --body: 'Work Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --wrap: 1200px;
}

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

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.65;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--ink); text-underline-offset: 4px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Type */
h1, h2, h3 { font-family: var(--heading); font-weight: 400; letter-spacing: -0.01em; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(48px, 7vw, 96px); line-height: 1; }
h2 { font-size: clamp(32px, 4vw, 46px); }
h3 { font-size: 26px; }
h1 em, h2 em { font-style: italic; }
p { margin: 0; }
.lede { font-size: 19px; line-height: 1.6; color: var(--ink-soft); max-width: 600px; }
.muted { color: var(--ink-soft); }
.note { font-family: var(--mono); font-size: 13px; line-height: 1.4; letter-spacing: .02em; color: var(--accent); }
.note--tilt { display: inline-block; }
.accent { color: var(--accent); font-style: italic; }

/* Buttons and links */
.btn { display: inline-block; text-decoration: none; padding: 13px 24px; font-size: 15px; font-weight: 500; letter-spacing: .02em; border: 1px solid var(--ink); border-radius: 2px; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--outline { background: #fff; color: var(--ink); }
.btn--outline:hover { border-color: var(--accent); color: var(--accent); }
.btn--small { padding: 9px 16px; font-size: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.more { font-family: var(--mono); font-size: 14px; padding: 10px 0; text-decoration: none; }
.more:hover { text-decoration: underline; }
.caps-link { font-size: 14px; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; border-bottom: 1px solid var(--ink); padding-bottom: 3px; }

/* Header */
.site-header { background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--rule); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 20px; padding-bottom: 20px; }
.logo { text-decoration: none; color: var(--ink); font-family: var(--heading); font-size: 30px; line-height: 1; }
.logo img { display: none; }
.logo:hover { color: var(--ink); }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 36px; font-size: 15px; }
.nav a { text-decoration: none; padding: 10px 0; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 8px; }

/* Sections */
.section { padding: 88px 0; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 36px; }
.section-head > div { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.section-head--ruled { border-top: 1px solid var(--ink); padding-top: 22px; margin-bottom: 28px; }
.band { background: var(--wash); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.band--blue, .band--yellow { background: var(--wash); }
.page-head { padding-top: 80px; padding-bottom: 44px; display: flex; flex-direction: column; gap: 14px; }

/* Home hero: a gallery wall panel with the grid showing through */
.hero-panel { margin: 56px 0 0; padding: 96px 32px; border: 1px solid var(--rule); background: rgba(255, 255, 255, .55); display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.hero-panel .lede { margin: 0 auto; }
.hero-panel .btn-row { justify-content: center; padding-top: 8px; }

/* Photo frames + placeholders */
.frame { border: 1px solid var(--rule-strong); overflow: hidden; background: var(--wash); }
.frame--shadow { box-shadow: none; }
.frame img { width: 100%; height: 100%; object-fit: cover; }
.ph { display: flex; align-items: flex-end; padding: 16px; background-color: var(--wash); background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, .04) 0 10px, transparent 10px 20px); }
.ph span { background: #fff; font-family: var(--mono); font-size: 13px; padding: 5px 10px; }
.ratio-45 { aspect-ratio: 4 / 5; }
.ratio-11 { aspect-ratio: 1 / 1; }

/* Grids */
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* "FIG." cards (drafting-table treatment) */
.fig-card { margin: 0; background: #fff; border: 1px solid var(--rule-strong); padding: 12px; display: flex; flex-direction: column; gap: 12px; text-decoration: none; color: var(--ink); }
.fig-card:hover { border-color: var(--ink); color: var(--ink); }
.fig-card img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.fig-card .fig-label { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: .02em; }
.fig-card .fig-title { font-family: var(--heading); font-size: 26px; line-height: 1.1; }
.fig-card .fig-sub { font-size: 14px; color: var(--ink-soft); }
.fig-card figcaption, .fig-card .fig-text { display: flex; flex-direction: column; gap: 4px; }

/* Gallery (legacy class) */
figure { margin: 0; }
.quilt { display: flex; flex-direction: column; gap: 10px; }
.quilt figcaption strong { display: block; font-family: var(--heading); font-weight: 400; font-size: 24px; }

/* About */
.about { display: flex; flex-wrap: wrap; align-items: center; gap: 56px; }
.about__photo { flex: 0 1 300px; min-width: 200px; aspect-ratio: 4 / 5; border: 1px solid var(--rule-strong); overflow: hidden; }
.about__text { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.about__text p:not(.note):not(.lede) { max-width: 620px; }

/* Blog list */
.post-card { text-decoration: none; background: #fff; border: 1px solid var(--rule-strong); padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
.post-card:hover { border-color: var(--ink); color: var(--ink); }
.post-card strong { font-family: var(--heading); font-weight: 400; font-size: 28px; line-height: 1.1; }
.post-card .muted { font-size: 15px; }

/* Articles */
.article { max-width: 720px; margin: 0 auto; padding: 72px 24px 96px; }
.article header { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.article header .more { align-self: flex-start; }
.article p + p { margin-top: 1.1em; }
.article .body { background: #fff; border: 1px solid var(--rule); padding: 40px; font-size: 18px; }
.placeholder { background: var(--wash); border: 1px dashed var(--muted); padding: 12px 16px; font-size: 15px; }

/* Footer */
.site-footer { border-top: 1px solid var(--rule); background: #fff; color: var(--ink-soft); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding-top: 36px; padding-bottom: 36px; font-size: 14px; }
.site-footer .logo { font-size: 24px; }

/* Timeline */
.tl-jump { display: flex; flex-wrap: wrap; gap: 4px 18px; font-family: var(--mono); font-size: 14px; padding-top: 6px; }
.tl-jump a { text-decoration: none; padding: 6px 0; }
.tl-jump a:hover { text-decoration: underline; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 40px; position: relative; display: flex; flex-direction: column; gap: 28px; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 1px; background: var(--ink); }
.tl-year { position: relative; margin: 32px 0 -8px -40px; scroll-margin-top: 24px; }
.tl-year span { display: inline-block; background: #fff; border: 1px solid var(--ink); font-family: var(--mono); font-size: 14px; padding: 2px 8px; }
.tl-item { position: relative; display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 32px; align-items: center; background: #fff; border: 1px solid var(--rule-strong); padding: 12px; scroll-margin-top: 24px; }
.tl-item::before { content: ""; position: absolute; left: -33px; top: 50%; width: 9px; height: 9px; margin-top: -4px; background: #fff; border: 1px solid var(--ink); }
.tl-thumb { padding: 0; cursor: zoom-in; display: block; width: 100%; aspect-ratio: 4 / 3; border: 0; }
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.tl-thumb:hover img { transform: scale(1.03); }
.tl-text { display: flex; flex-direction: column; gap: 6px; padding-right: 12px; }
.tl-text h2 { font-size: clamp(28px, 3vw, 36px); }

/* Lightbox */
.lightbox { border: 1px solid var(--ink); padding: 0; max-width: min(1100px, 94vw); max-height: 94vh; background: #fff; color: var(--ink); overflow: auto; }
.lightbox::backdrop { background: rgba(22, 22, 22, .85); }
.lb-bar { position: sticky; top: 0; display: flex; justify-content: flex-end; padding: 8px; margin-bottom: -60px; z-index: 1; }
.lb-img { display: block; width: auto; height: auto; max-width: 100%; max-height: 74vh; margin: 0 auto; }
.lb-cap { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px 20px 20px; }
.lb-cap h2 { font-size: 30px; }
.lb-btn { width: 48px; height: 48px; border: 1px solid var(--ink); background: #fff; color: var(--ink); font-size: 18px; cursor: pointer; }
.lb-btn:hover { background: var(--ink); color: #fff; }

/* Blog post figures */
.article--wide { max-width: 880px; }
.article .lede { margin-top: 4px; }
.post-hero { display: block; width: 100%; margin-bottom: 40px; border: 1px solid var(--rule-strong); }
.article .body h2 { font-size: clamp(30px, 3.4vw, 38px); margin: 1.5em 0 .45em; }
.article .body h2:first-child { margin-top: 0; }
.post-fig { margin: 1.6em 0; }
.post-fig img { display: block; width: 100%; }
.post-fig figcaption { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); margin-top: 8px; line-height: 1.4; }
.post-fig--diagram svg { display: block; width: 100%; height: auto; }
.post-fig--narrow svg { max-width: 380px; margin: 0 auto; }
.post-fig--narrow figcaption { text-align: center; }
.koch-fig .k-lab { font: 600 16px var(--body); fill: var(--ink); }
.koch-fig .k-sub { font: 13px var(--mono); fill: var(--ink-soft); }
.koch-fig .k-on-dark { fill: #fff; }
.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 1.6em 0; }
.fig-row .post-fig { margin: 0; }
.fig-row .post-fig img { aspect-ratio: 4 / 3; object-fit: cover; }
.fig-row--hero { margin: 0 0 40px; }
.fig-row--hero .post-fig img { aspect-ratio: 3 / 4; }
.post-fig--narrow-img img { max-width: 360px; }
.post-fig--tall img { max-width: 440px; margin: 0 auto; }
.post-fig--tall figcaption { text-align: center; }
.article .sources { font-size: 14px; color: var(--muted); margin-top: 2em; }

/* Pentagon post */
.timeline-list { margin: 1em 0; padding-left: 1.2em; }
.timeline-list li { margin: .4em 0; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 24px 0 40px; }
.type-cell { margin: 0; background: #fff; border: 1px solid var(--rule-strong); padding: 8px; }
.type-cell img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.type-cell figcaption { display: flex; flex-direction: column; padding: 8px 2px 0; line-height: 1.3; }
.type-cell strong { font-family: var(--heading); font-weight: 400; font-size: 22px; }
.type-cell span { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.type-cell--new { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* Diagram colours (kept muted to sit with the photos) */
:root {
  --k-fill: #E8EDF5; --k-line: #161616; --k-a: #A9BBD6; --k-b: #C9D6C3;
  --p0: #EDEDEA; --p1: #A6A8AB; --p2: #55575A; --p-gap: #E9D9A6; --p-gap-line: #8A6A1F; --p-over: #2F4B7C;
  --pr-thick: #A9BBD6; --pr-thin: #2F4B7C;
  --h-a: #EADFC2; --h-b: #D3DCEA; --h-c: #C9D6C3;
  --t-light: #FAFAF8; --t-dark: #1F2F4E; --t-arrow: #2F4B7C;
}
.gw-bg { fill: #FAF8F2; } .gw-band, .gw-tooth, .gw-join { fill: #3B5BA9; } .gw-frame { stroke: var(--ink); stroke-width: 1.5; }
.gw-quilt { fill: none; stroke: #B9B2A0; stroke-width: 1.4; stroke-dasharray: 4 3; } .gw-quilt-ray { stroke: #D9D3C2; stroke-width: .8; }
.asa-bg { fill: #FAF8F2; } .asa-d, .asa-m, .asa-l { stroke-width: 3.2; stroke-linecap: round; }
.asa-d { stroke: #6B3F1D; } .asa-m { stroke: #9A6B3C; } .asa-l { stroke: #C9A36F; }

@media (max-width: 700px) {
  .tl-item { grid-template-columns: 1fr; gap: 14px; }
  .tl-text { padding: 0 4px 8px; }
  .lb-cap { gap: 10px; padding: 12px; }
}
@media (max-width: 600px) {
  .section { padding: 64px 0; }
  .hero-panel { padding: 64px 20px; margin-top: 32px; }
  .article .body { padding: 22px; }
  .nav { gap: 4px 24px; }
}
