/* ═══════════════════════════════════════════════════════════════
   BEATEN BY POCKET CHANGE — the duty roster.

   The book is a lexicon: a four-thousand-year-old demon learning
   the country that retired his name, one word a chapter, on a
   contract, at a primary school in Chongqing. So the page is his
   paperwork — mono, hairline, square, flat. 黑身白手, black body
   white hands: the whole page is two inks. The one colour in the
   building is vermilion, and in the book it arrives in three forms
   that turn out to be the same form: the red paper of the charm,
   the red scarves at the gate, and a ten-year-old's red pen writing
   the character 祟 back onto the duty roster. The seal on this page
   is that red pen.

   House pattern: this page carries the colour; the prose does not.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bb-bg: #f4f3f0;
  --bb-panel: #eceae5;
  --bb-ink: #17181a;
  --bb-soft: #55575a;
  --bb-faint: #8b8d90;
  --bb-rule: #d9d7d2;
  --bb-chi: #b03a2b;        /* the red pen — 朱 */
  --bb-chi-ink: #96301f;
  --bb-night: #1c1d1f;      /* the corridor at the fourth watch */
  --bb-night-ink: #f4f3f0;
}

html[data-theme="dark"] {
  --bb-bg: #141518;
  --bb-panel: #1b1d21;
  --bb-ink: #e8e7e4;
  --bb-soft: #a5a7ab;
  --bb-faint: #6f7175;
  --bb-rule: #33353a;
  --bb-chi: #d05a48;
  --bb-chi-ink: #dd7060;
  --bb-night: #e8e7e4;      /* the band inverts with the theme */
  --bb-night-ink: #141518;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bb-bg);
  color: var(--bb-ink);
  font-family: "Inter", "Noto Serif SC", sans-serif;
  line-height: 1.65;
}

.bb-wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 clamp(1.1rem, 5vw, 2rem);
}

/* ── the red pen's mark ──────────────────────────────────────────── */

.bb-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  background: var(--bb-chi);
  color: #f4f3f0;
  font-family: "Noto Serif SC", serif;
  font-size: 1.2rem;
  line-height: 1;
}

/* ── nav ─────────────────────────────────────────────────────────── */

.bb-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--bb-rule);
}

.bb-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--bb-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
}

.bb-nav__name { letter-spacing: -.01em; }

.bb-nav__links {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.bb-nav__links a {
  color: var(--bb-soft);
  text-decoration: none;
  font-size: .84rem;
}

.bb-nav__links a:hover { color: var(--bb-chi-ink); }

/* ── hero ────────────────────────────────────────────────────────── */

.bb-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: center;
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 5.5rem) clamp(1.1rem, 5vw, 2rem) 3.2rem;
}

.bb-hero__text { min-width: 0; }

.bb-eyebrow {
  margin: 0 0 .8rem;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--bb-chi-ink);
}

.bb-title {
  margin: 0 0 1.1rem;
  font-size: clamp(2rem, 5.6vw, 3.2rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.bb-lede {
  margin: 0 0 1rem;
  max-width: 46ch;
  font-size: 1.02rem;
  color: var(--bb-soft);
}

.bb-meta {
  margin: 0 0 1.8rem;
  font-size: .82rem;
  color: var(--bb-faint);
}

.bb-meta__sep { margin: 0 .5rem; }

.bb-take {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.bb-btn {
  display: inline-flex;
  align-items: baseline;
  gap: .1rem;
  padding: .62rem 1.05rem;
  border: 1px solid var(--bb-ink);
  background: transparent;
  color: var(--bb-ink);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.bb-btn:hover {
  border-color: var(--bb-chi);
  color: var(--bb-chi-ink);
}

/* the inverted CTA — the machine's own style: black block, white word */
.bb-btn--primary {
  background: var(--bb-ink);
  color: var(--bb-bg);
}

.bb-btn--primary:hover {
  background: var(--bb-chi);
  border-color: var(--bb-chi);
  color: #f4f3f0;
}

.bb-plate { margin: 0; }

.bb-plate img {
  display: block;
  width: 15rem;
  max-width: 38vw;
  height: auto;
  border: 1px solid var(--bb-rule);
}

/* ── the punch ───────────────────────────────────────────────────── */

.bb-punch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 46rem;
  margin: 0 auto;
  border: 1px solid var(--bb-night);
  background: var(--bb-night);
  color: var(--bb-night-ink);
  font-variant-numeric: tabular-nums;
}

.bb-punch__cell {
  display: grid;
  gap: .1rem;
  justify-items: center;
  padding: .9rem .5rem;
  border-left: 1px solid color-mix(in srgb, var(--bb-night-ink) 22%, transparent);
}

.bb-punch__cell:first-child { border-left: 0; }

.bb-punch__t {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.bb-punch__k {
  font-size: .64rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .55;
}

/* ── sections ────────────────────────────────────────────────────── */

.bb-section {
  padding: clamp(2.6rem, 7vw, 4.2rem) 0;
}

.bb-section--alt {
  border-top: 1px solid var(--bb-rule);
  background: var(--bb-panel);
}

.bb-head { margin-bottom: 2rem; }

.bb-head__run {
  margin: 0 0 .5rem;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--bb-chi-ink);
}

.bb-head__title {
  margin: 0 0 .6rem;
  font-size: clamp(1.3rem, 3.4vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -.02em;
}

.bb-head__sub {
  margin: 0;
  max-width: 52ch;
  font-size: .95rem;
  color: var(--bb-soft);
}

/* ── the lexicon ─────────────────────────────────────────────────── */

/* the vocabulary spine: fourteen words, one strip */
.bb-words {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .9rem;
  margin: 0 0 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--bb-rule);
  background: var(--bb-panel);
  font-family: "Noto Serif SC", serif;
  font-size: 1.05rem;
  letter-spacing: .06em;
}

.bb-word { white-space: nowrap; }

.bb-word:nth-child(3n) { color: var(--bb-chi-ink); }

.bb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--bb-rule);
}

.entry { border-bottom: 1px solid var(--bb-rule); }

.entry__link {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: baseline;
  padding: .72rem .3rem;
  text-decoration: none;
  color: var(--bb-ink);
}

.entry__link:hover { background: var(--bb-panel); }

.entry__no {
  font-size: .72rem;
  font-weight: 500;
  color: var(--bb-chi-ink);
  font-variant-numeric: tabular-nums;
}

.entry__title {
  font-size: .98rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.entry__open {
  grid-column: 2 / 3;
  font-size: .86rem;
  color: var(--bb-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry__words {
  grid-column: 3 / 4;
  grid-row: 1 / 3;
  align-self: center;
  font-size: .72rem;
  color: var(--bb-faint);
  font-variant-numeric: tabular-nums;
}

/* ── provenance ──────────────────────────────────────────────────── */

.bb-quote {
  max-width: 34rem;
  margin: 0 auto 2.2rem;
  padding: 1.6rem clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--bb-rule);
  border-left: 4px solid var(--bb-chi);
  background: var(--bb-bg);
  text-align: center;
}

html[data-theme="dark"] .bb-quote { background: var(--bb-bg); }

.bb-quote__zh {
  margin: 0 0 .5rem;
  font-family: "Noto Serif SC", serif;
  font-size: 1.5rem;
  letter-spacing: .1em;
}

.bb-quote__py {
  margin: 0 0 .6rem;
  font-size: .8rem;
  color: var(--bb-faint);
}

.bb-quote__en {
  margin: 0 0 .8rem;
  font-size: 1.02rem;
  font-style: italic;
}

.bb-quote__attr {
  margin: 0;
  font-size: .76rem;
  color: var(--bb-soft);
}

.bb-prose { max-width: 44rem; margin: 0 auto; }

.bb-prose > p { margin: 0 0 1.2rem; font-size: 1rem; }

.bb-note {
  margin: 1.4rem 0 0;
  padding: 1rem 1.2rem;
  border-left: 2px solid var(--bb-rule);
  font-size: .9rem;
  color: var(--bb-soft);
}

/* ── footer ──────────────────────────────────────────────────────── */

.bb-foot {
  margin-top: 2.4rem;
  border-top: 1px solid var(--bb-rule);
}

.bb-foot__inner {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  padding-top: 2.4rem;
  padding-bottom: 2rem;
}

.bb-foot__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 600;
  font-size: .95rem;
}

.bb-foot__tag {
  margin: .7rem 0 0;
  font-size: .8rem;
  color: var(--bb-faint);
}

.bb-foot__col h4 {
  margin: 0 0 .6rem;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--bb-faint);
}

.bb-foot__col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .35rem;
}

.bb-foot__col a {
  color: var(--bb-soft);
  text-decoration: none;
  font-size: .86rem;
}

.bb-foot__col a:hover { color: var(--bb-chi-ink); }

.bb-foot__bottom {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 clamp(1.1rem, 5vw, 2rem) 2rem;
  font-size: .76rem;
  color: var(--bb-faint);
}

/* ── small screens ───────────────────────────────────────────────── */

@media (max-width: 700px) {
  .bb-hero { grid-template-columns: 1fr; }
  .bb-plate { order: -1; }
  .bb-plate img { width: 11rem; max-width: 45vw; }
  .bb-punch { grid-template-columns: 1fr; }
  .bb-punch__cell {
    border-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--bb-night-ink) 22%, transparent);
  }
  .bb-punch__cell:first-child { border-top: 0; }
  .bb-foot__inner { grid-template-columns: 1fr; gap: 1.6rem; }
}
