/* Plain Binary website. Mobile-first. All colours/fonts/radii come from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.08; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

[hidden] { display: none !important; }
.sprite { display: none; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--radius-sm); text-decoration: none; }
.skip-link:focus { top: 12px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.mono { font-family: var(--font-mono); font-weight: 500; font-size: 13px; letter-spacing: .02em; color: var(--body); }

/* Mono label with marker square, as on the carousels: "■ SOURCE LIBRARY" */
.label {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
}
.square { width: 10px; height: 10px; background: var(--marker); flex: none; }

/* Marker highlight behind a key word */
mark {
  background: var(--marker); color: var(--on-marker);
  padding: 0 .08em; margin: 0 -.02em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 20px;
  border-radius: var(--radius-sm); border: 1px solid var(--ink);
  font-weight: 600; font-size: 16px; line-height: 1.2; text-decoration: none;
  cursor: pointer; transition: background-color .15s ease, color .15s ease;
}
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: #33332f; }
.btn-line { background: var(--paper); color: var(--ink); }
.btn-line:hover { background: var(--wash); }
.btn[disabled] { opacity: .55; cursor: progress; }

.text-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
  padding: 0; border: 0; background: none; cursor: pointer;
  font-family: var(--font-mono); font-weight: 500; font-size: 13px; color: var(--body);
  text-decoration: none;
}
.text-btn .icon { width: 16px; height: 16px; }
.text-btn:hover { color: var(--ink); }
.text-btn.copied { color: var(--ink); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--rule); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand img { width: 136px; height: auto; }
.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; cursor: pointer;
}
.menu-toggle .icon { width: 24px; height: 24px; }
.site-nav {
  display: none; position: absolute; left: 0; right: 0; top: 64px;
  flex-direction: column; padding: 8px 20px 20px; background: var(--paper); border-bottom: 1px solid var(--rule);
}
.site-nav.open { display: flex; }
.site-nav a { padding: 12px 0; font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--rule); }
.site-nav a:last-child { border-bottom: 0; }
.nav-ig { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-weight: 500 !important; font-size: 14px; }

/* Hero */
.hero { padding: 56px 0 64px; border-bottom: 1px solid var(--rule); }
.hero h1 { margin-top: 24px; font-size: clamp(44px, 12.5vw, 104px); letter-spacing: -0.045em; line-height: 1; max-width: 11ch; }
.lede { margin-top: 24px; max-width: 34ch; font-size: 19px; line-height: 1.55; color: var(--body); }
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; }

/* Sections */
.section { padding: 64px 0; border-bottom: 1px solid var(--rule); }
.section-head { margin-bottom: 32px; }
.section h2 { margin-top: 16px; font-size: clamp(30px, 7.5vw, 48px); letter-spacing: -0.035em; max-width: 20ch; }
.section-intro { margin-top: 16px; max-width: 56ch; color: var(--body); }

/* Library tools */
.library { background: var(--wash); }
.tools { display: grid; grid-template-columns: 1fr; gap: 10px; }
.search, .select {
  display: flex; align-items: center; min-height: 50px;
  background: var(--paper); border: 1px solid var(--ghost); border-radius: var(--radius-sm);
}
.search:focus-within, .select:focus-within { border-color: var(--ink); }
.search { gap: 10px; padding: 0 14px; color: var(--body); }
.search input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: none; font-size: 16px; color: var(--ink); }
.search input::placeholder { color: var(--label); }
.select select {
  width: 100%; height: 48px; padding: 0 40px 0 14px; border: 0; outline: 0; background: transparent; font-size: 16px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231A1A1A' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.result-count { margin: 18px 0 8px; min-height: 1.5em; }

/* Library results */
.series-block { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm); margin-top: 16px; }
.series-top { padding: 22px 20px 18px; border-bottom: 1px solid var(--rule); }
.series-top h3 { margin-top: 10px; font-size: 24px; letter-spacing: -0.035em; }
.series-top h3 a { text-decoration: none; }
.series-top h3 a:hover { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 4px; text-underline-offset: 4px; }
.series-top p { margin-top: 8px; color: var(--body); font-size: 16px; max-width: 64ch; }
.series-actions { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 10px; }

.post { padding: 22px 20px; border-top: 1px solid var(--rule); }
.post:first-of-type { border-top: 0; }
.post-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.post-meta .part { color: var(--ink); font-weight: 600; }
.post h4 { margin: 8px 0 0; font-size: 20px; line-height: 1.25; letter-spacing: -0.02em; font-weight: 700; }
.post h4 a { text-decoration: none; }
.post h4 a:hover { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 4px; text-underline-offset: 4px; }
.post-desc { margin-top: 6px; color: var(--body); font-size: 16px; max-width: 68ch; }
.post-sources { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.post-sources li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; font-size: 15px; line-height: 1.45; }
.post-sources .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--label); }
.post-sources a { text-decoration: none; }
.post-sources a:hover .src-title { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.src-org { font-weight: 600; }
.src-title { color: var(--body); }
.post-actions { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; }

.empty { padding: 32px 20px; background: var(--paper); border: 1px dashed var(--ghost); border-radius: var(--radius-sm); color: var(--body); }
.loading { padding: 24px 0; }

/* About */
.about-grid { display: grid; gap: 28px; }
.about-body > p { font-size: 19px; color: var(--body); max-width: 56ch; }
.principles { list-style: none; padding: 0; margin: 28px 0 0; border-top: 1px solid var(--rule); }
.principles li { padding: 16px 0 16px 22px; border-bottom: 1px solid var(--rule); color: var(--body); position: relative; }
.principles li::before { content: ""; position: absolute; left: 0; top: 25px; width: 10px; height: 10px; background: var(--marker); }
.principles strong { color: var(--ink); }

/* Contact */
.contact { background: var(--wash); }
.contact-grid { display: grid; gap: 32px; }
.form-panel { background: var(--paper); border: 1px solid var(--rule); border-top: 3px solid var(--ink); border-radius: var(--radius-sm); padding: 24px 20px; }
.form-status { display: grid; gap: 6px; }
.form-status span { color: var(--body); }
.form-status a { font-weight: 600; text-decoration-color: var(--marker); text-decoration-thickness: 3px; text-underline-offset: 3px; }
#contact-form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.optional { font-weight: 400; color: var(--body); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 11px 13px; font-size: 16px;
  background: var(--paper); border: 1px solid #C9C9C3; border-radius: var(--radius-sm);
}
.field select { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231A1A1A' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.field textarea { resize: vertical; min-height: 140px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.field [aria-invalid="true"] { border-color: #B42318; }
.field-error { font-size: 14px; color: #B42318; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.turnstile { min-height: 65px; }
.form-response { font-weight: 600; min-height: 1.6em; }
.form-response.ok { color: var(--ink); }
.form-response.ok::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--marker); margin-right: 10px; }
.form-response.err { color: #B42318; padding: 12px 14px; background: #FEF3F2; border-left: 3px solid #B42318; font-weight: 500; font-size: 15px; }
.form-response:empty { display: none; }

/* Sending state: form dims, overlay with binary "progress" */
.form-panel { position: relative; scroll-margin-top: 88px; }
#contact-form { transition: opacity .25s ease, filter .25s ease; }
.form-panel.is-sending #contact-form { opacity: .18; filter: blur(1.5px); pointer-events: none; user-select: none; }
.sending { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: center; padding: 20px; }
.sending-inner {
  margin-top: min(18vh, 140px);
  display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: 26px 28px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(26,26,26,.06);
  animation: rise .25s ease both;
}
.sending-title { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.bits { display: flex; gap: 5px; margin-bottom: 4px; }
.bits span {
  display: grid; place-items: center; width: 22px; height: 28px;
  font-family: var(--font-mono); font-weight: 600; font-size: 14px;
  color: var(--ink); background: var(--wash); border-radius: 2px;
  animation: bit 1.6s ease-in-out infinite;
}
.bits span:nth-child(2) { animation-delay: .1s; } .bits span:nth-child(3) { animation-delay: .2s; }
.bits span:nth-child(4) { animation-delay: .3s; } .bits span:nth-child(5) { animation-delay: .4s; }
.bits span:nth-child(6) { animation-delay: .5s; } .bits span:nth-child(7) { animation-delay: .6s; }
.bits span:nth-child(8) { animation-delay: .7s; }
@keyframes bit {
  0%, 60%, 100% { background: var(--wash); transform: translateY(0); }
  25% { background: var(--marker); transform: translateY(-4px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Sent state */
.sent { display: grid; gap: 14px; animation: rise .35s ease both; outline: none; }
.sent-mark {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px;
  background: var(--marker); color: var(--on-marker); border-radius: 50%;
  animation: pop .45s cubic-bezier(.2,1.4,.4,1) both .1s;
}
.sent-mark .icon { width: 28px; height: 28px; stroke-width: 2.4; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sent-title { font-size: clamp(28px, 7vw, 36px); letter-spacing: -0.035em; line-height: 1.1; }
.sent-body { color: var(--body); max-width: 44ch; }
.sent-body strong { color: var(--ink); overflow-wrap: anywhere; }
.sent-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 0; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.sent-summary dt { font-family: var(--font-mono); font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--body); }
.sent-summary dd { margin: 4px 0 0; font-weight: 600; font-size: 15px; }
.sent-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
@media (min-width: 600px) { .sent-actions { flex-direction: row; flex-wrap: wrap; } }

/* Detail (series and post pages) */
.detail { padding: 32px 0 72px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 13px; color: var(--body); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.detail h1 { margin-top: 28px; font-size: clamp(36px, 10vw, 72px); letter-spacing: -0.045em; line-height: 1.02; max-width: 16ch; }
.detail .label { margin-top: 28px; }
.detail .lede { max-width: 58ch; font-size: 19px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin: 28px 0 0; padding: 18px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts dt { font-family: var(--font-mono); font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--body); }
.facts dd { margin: 4px 0 0; font-size: 15px; font-weight: 600; }
.facts dd a { text-decoration-color: var(--marker); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-top: 14px; }
.detail h2 { margin-top: 56px; font-size: 28px; letter-spacing: -0.035em; }
.detail h2 + .mono { margin-top: 6px; }

.refs { list-style: none; counter-reset: ref; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--ink); }
.ref { counter-increment: ref; display: grid; grid-template-columns: 34px 1fr; gap: 0 8px; padding: 22px 0; border-bottom: 1px solid var(--rule); }
.ref::before { content: counter(ref, decimal-leading-zero); font-family: var(--font-mono); font-weight: 600; font-size: 13px; padding-top: 3px; }
.ref-org { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.ref-org strong { font-size: 15px; }
.ref-title { display: inline; margin-top: 6px; font-size: 19px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.ref-title:hover { background: var(--marker); }
.ref-title .icon { display: inline-block; width: 16px; height: 16px; vertical-align: -2px; margin-left: 2px; }
.ref-body { min-width: 0; }
.ref-body > p { margin-top: 8px; color: var(--body); font-size: 16px; max-width: 68ch; }
.ref-host { overflow-wrap: anywhere; }

.notes { margin-top: 20px; padding: 18px 20px; background: var(--wash); border-left: 3px solid var(--marker); }
.notes li { color: var(--body); }
.notes ul { margin: 8px 0 0; padding-left: 18px; }

.parts { list-style: none; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--ink); }
.parts li { border-bottom: 1px solid var(--rule); }
.parts a { display: grid; grid-template-columns: 64px 1fr 20px; gap: 4px 8px; align-items: start; padding: 18px 0; text-decoration: none; }
.parts a:hover .part-title { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 4px; text-underline-offset: 4px; }
.parts .mono { padding-top: 3px; }
.part-title { font-weight: 700; font-size: 18px; line-height: 1.3; letter-spacing: -0.015em; }
.part-desc { grid-column: 2; color: var(--body); font-size: 15px; }
.parts .icon { margin-top: 3px; color: var(--body); }
.parts [aria-current="page"] { background: var(--wash); margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.pager { display: grid; gap: 12px; margin-top: 32px; }
.pager a { display: grid; gap: 2px; padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius-sm); text-decoration: none; }
.pager a:hover { border-color: var(--ink); }
.pager strong { font-size: 17px; }
.not-found { padding: 24px 0; }

/* Footer */
.site-footer { padding: 44px 0 36px; }
.footer-grid { display: grid; gap: 24px; }
.footer-brand img { width: 136px; height: auto; }
.footer-brand p { margin-top: 10px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.footer-nav a { font-weight: 600; text-decoration: none; padding: 6px 0; }
.footer-nav a:hover { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.privacy { max-width: 70ch; font-size: 14px; color: var(--body); }
.privacy strong { color: var(--ink); }
.copyright { font-size: 12px; }

/* ≥ 600px */
@media (min-width: 600px) {
  .wrap { padding: 0 32px; }
  .actions { flex-direction: row; flex-wrap: wrap; }
  .tools { grid-template-columns: 1fr 200px 200px; }
  .series-top, .post { padding-left: 28px; padding-right: 28px; }
  .facts { grid-template-columns: repeat(4, auto); justify-content: start; gap: 16px 48px; }
  .pager { grid-template-columns: 1fr 1fr; }
  .pager .next { text-align: right; grid-column: 2; }
  .form-panel { padding: 32px; }
}

/* ≥ 900px */
@media (min-width: 900px) {
  body { font-size: 18px; }
  .header-inner { height: 76px; }
  .brand img { width: 160px; }
  .menu-toggle { display: none; }
  .site-nav { display: flex; position: static; flex-direction: row; align-items: center; gap: 32px; padding: 0; border: 0; }
  .site-nav a { padding: 6px 0; border: 0; font-size: 15px; }
  .site-nav a:not(.nav-ig):hover { text-decoration: underline; text-decoration-color: var(--marker); text-decoration-thickness: 3px; text-underline-offset: 6px; }
  .nav-ig { padding: 8px 14px !important; border: 1px solid var(--ghost) !important; border-radius: var(--radius-sm); }
  .nav-ig:hover { border-color: var(--ink) !important; }
  .hero { padding: 112px 0 104px; }
  .lede { font-size: 21px; }
  .section { padding: 104px 0; }
  .section-head { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; align-items: end; margin-bottom: 40px; }
  .section-head .label { grid-column: 1 / -1; }
  .section-head .section-intro { margin: 0; }
  .post { display: grid; grid-template-columns: 1fr 1.05fr; gap: 0 48px; padding: 28px; }
  .post-main { grid-column: 1; }
  .post-sources { grid-column: 2; grid-row: 1 / span 2; margin-top: 4px; }
  .about-grid, .contact-grid { grid-template-columns: 1fr 1fr; gap: 64px; align-items: start; }
  .detail { padding: 48px 0 112px; }
  .detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 72px; align-items: start; }
  .detail-aside { position: sticky; top: 104px; }
  .detail-aside h2 { margin-top: 56px; }
  .footer-grid { grid-template-columns: 1fr auto; align-items: start; }
  .privacy { grid-column: 1; }
  .copyright { grid-column: 2; text-align: right; align-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
@media print {
  .site-header, .site-footer, .tools, .post-actions, .detail-actions, .contact { display: none !important; }
}
