/* ═══════════════════════════════════════════════════════════════
   ZHEN AI — the catalog page
   Built on SUYĀ (素雅).

   This page is a shelf, not an essay. It has one job: show every
   volume, at any count, and get out of the way.

   House rule: the page stays in ink (黑). Colour belongs to the
   covers — each volume's own pigment from the Five Colours — so
   one accent is on the page at a time, and the page contributes
   none of its own.

   Editorial copy about individual figures lives on the book pages,
   not here. See content/daoji.md.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Masthead ───────────────────────────────────────────────
   The wordmark on its own full-width line, then a two-column standfirst:
   what the shelf is on the left, how the books are made on the right.

   The headline used to share a row with the body column, which left a wide
   dead gap beside a short word. Giving it the full width fixes that without
   anything having to fill the space. */

.masthead {
  padding: clamp(3rem, 8vw, 5.5rem) 0 clamp(2.4rem, 5vw, 3.6rem);
}

/* Sized up, and set on a rule. The wordmark is a short word on a 1120px
   line, so the white space after it is unavoidable — what it needed was a
   terminus, not something to fill it with. The rule closes the line and the
   larger face gives it enough weight to hold the width. */
.masthead-h {
  font-family: var(--f-disp);
  font-weight: 500;
  font-size: clamp(2.7rem, 6.4vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -.022em;
  margin: 0;
  padding-bottom: clamp(1.1rem, 2.4vw, 1.6rem);
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: baseline;
  gap: .75rem;
  flex-wrap: wrap;
}
.masthead-h em {
  font-family: var(--f-zh);
  font-style: normal;
  font-size: .38em;
  color: var(--ink-3);
  letter-spacing: .1em;
}

.masthead-in {
  margin-top: clamp(2rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
  gap: clamp(1.8rem, 4vw, 3rem) clamp(2.5rem, 6vw, 5rem);
  align-items: start;
}
@media (max-width: 860px) {
  .masthead-in { grid-template-columns: 1fr; gap: 1.6rem; }
}

/* both columns run to the same measure, so neither reads as a short line
   stranded beside a long one */
.masthead-p,
.masthead-aside p {
  font-size: 1rem;
  line-height: 1.74;
  color: var(--ink-2);
  margin: 0;
  max-width: 42ch;
}
.masthead-p { font-size: clamp(1.02rem, 1.5vw, 1.12rem); }

.masthead-aside p + p { margin-top: 1.4rem; }

/* Who wrote the books is a footnote to the books, not a headline — so it sits
   below a hairline, one size down and one shade quieter. */
.masthead-note {
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: .91rem !important;
  color: var(--ink-3) !important;
}
.masthead-note b {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--f-zh);
  font-size: 1.1em;
  letter-spacing: .04em;
}
.masthead-note i { font-style: italic; }

/* ─── The shelf ────────────────────────────────────────────── */

.shelf { padding-bottom: clamp(3rem, 7vw, 5rem); }

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: .85rem;
  margin-bottom: clamp(1.6rem, 3.5vw, 2.4rem);
  border-bottom: 1px solid var(--line);
}
.shelf-head h2 {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}
.shelf-count {
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* The shelf itself. Flex with a fixed card width rather than a
   stretching grid: covers stay the same size at any count, and
   left-align, so two volumes read as a shelf with room to grow
   rather than as a broken layout. */
.wall {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.6rem, 3vw, 2.4rem) clamp(1rem, 2.2vw, 1.8rem);
  align-items: flex-start;
}
.wall-note {
  color: var(--ink-3);
  font-size: .95rem;
  padding: 2rem 0;
}

/* ─── A volume ─────────────────────────────────────────────── */

.vol {
  --d: var(--t-hei);
  --d-on: var(--t-hei-on);
  width: clamp(9.5rem, 21vw, 12.5rem);
  display: flex;
  flex-direction: column;
}
.vol[data-accent="chi"]   { --d: var(--t-zhu);   --d-on: var(--t-zhu-on); }
.vol[data-accent="huang"] { --d: var(--t-huang); --d-on: var(--t-huang-on); }
.vol[data-accent="qing"]  { --d: var(--t-qing);  --d-on: var(--t-qing-on); }
.vol[data-accent="bai"]   { --d: var(--t-bai);   --d-on: var(--t-bai-on); }
.vol[data-accent="hei"]   { --d: var(--t-hei);   --d-on: var(--t-hei-on); }

/* the cover is the whole hit target */
.vol-cover {
  display: block;
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform .5s cubic-bezier(.2,.7,.3,1), border-color .35s ease;
}
.vol-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 0 var(--d);
  transition: box-shadow .4s ease;
  pointer-events: none;
}
.vol-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .8s cubic-bezier(.2,.7,.3,1);
}
/* The hover ring. Mixed rather than raw, for the same reason as the line above:
   a near-black accent on a near-black page would mean the hover simply does
   not happen.

   50% is the most pigment that still clears 3:1 against the page in both
   themes (3.21 light / 4.04 dark) — a non-text UI edge needs 3:1, and 60%
   measured 2.48 light, which is why it is 50. */
.vol {
  --d-visible: color-mix(in srgb, var(--d) 50%, var(--ink));
}
.vol:hover .vol-cover { transform: translateY(-4px); border-color: var(--d-visible); }
.vol:hover .vol-cover::after { box-shadow: inset 0 0 0 3px var(--d-visible); }
.vol:hover .vol-cover img { transform: scale(1.03); }

/* an unillustrated volume still looks composed */
.vol-cover.is-empty {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(135deg,
      transparent 0 11px, color-mix(in srgb, var(--line) 55%, transparent) 11px 12px),
    var(--paper-2);
}
.vol-cover.is-empty::before {
  content: attr(data-empty);
  font-family: var(--f-zh);
  font-size: 3rem;
  color: var(--line-2);
}

.vol-seal {
  position: absolute;
  left: .7rem; bottom: .7rem;
  width: 2.05rem; height: 2.05rem;
  display: grid; place-items: center;
  background: var(--d);
  color: var(--d-on);
  font-family: var(--f-zh);
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 3px;
  transform: rotate(-3deg);
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.55);
}

/* Metadata — three quiet lines, nothing more */
.vol-meta { padding-top: .85rem; }

/* The source figure. This was `color: var(--d)` — the accent used as body
   text — which is a misuse of the Five Colours: they are accent *fills*,
   with --a-on for text sitting on them, not text colours on paper.
   Measured against suya's own paper, the raw accents gave:

     accent    light      dark
     chi       4.67 ok    4.37 marginal
     huang     2.82 FAIL  8.92 ok
     qing      6.81 ok    4.44 marginal
     bai       1.07 FAIL 14.84 ok
     hei      13.53 ok    1.08 FAIL

   Three of four volumes failed or marginalised in one theme, and both unused
   accents failed in one. --ink-2 is the theme's own second ink: 6.43:1 light
   and 7.74:1 dark, for every accent. The volume's colour still walks the page
   — it is on the seal, which uses --d-on and stays legible for all five. */
.vol-after {
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 .3rem;
}
.vol-title {
  font-family: var(--f-disp);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.22;
  letter-spacing: -.01em;
  margin: 0 0 .35rem;
  text-wrap: balance;
}
.vol-title a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--d), var(--d));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size .4s cubic-bezier(.2,.7,.3,1);
}
.vol:hover .vol-title a { background-size: 100% 1px; }
.vol-sub {
  font-size: .78rem;
  line-height: 1.5;
  color: var(--ink-3);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* ─── Footer ───────────────────────────────────────────────── */

.zfoot {
  padding: clamp(2.5rem, 6vw, 4rem) 0 3rem;
  border-top: 1px solid var(--line);
}
.zfoot-in { display: flex; flex-wrap: wrap; gap: .5rem 2rem; align-items: baseline; }
.zfoot-brand {
  font-family: var(--f-disp);
  font-size: 1rem;
  color: var(--ink);
  margin: 0;
}
.zfoot-tag {
  font-size: .86rem;
  color: var(--ink-3);
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .vol-cover, .vol-cover img, .vol-title a { transition: none; }
}


/* ─── hiding a filtered-out card ───────────────────────────────
   The `hidden` attribute is only styled by the browser's user-agent
   stylesheet, and author rules beat that. Since .vol sets `display: flex`,
   `card.hidden = true` set the attribute and changed nothing — the filter
   ran correctly and the shelf never moved. This puts the semantic back. */

[hidden] { display: none !important; }

/* ─── series, on the card ──────────────────────────────────────
   The badge carries the number so a run is legible at a glance; the line
   below names it, and only appears when the book's own title differs from
   the series — otherwise Book One says its name twice. */

.vol-badge {
  position: absolute;
  right: .45rem; top: .45rem;
  min-width: 1.35rem; height: 1.35rem;
  padding: 0 .3rem;
  display: grid; place-items: center;
  background: var(--d);
  color: var(--d-on);
  font-size: .68rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 2px;
  box-shadow: 0 4px 12px -6px rgba(0, 0, 0, .6);
}

.vol-series {
  font-size: .7rem;
  letter-spacing: .06em;
  color: var(--ink-3);
  margin: .35rem 0 0;
}

/* ─── the facet bar ────────────────────────────────────────────── */

.facets {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.8rem;
  margin: 0 0 clamp(1.6rem, 3.5vw, 2.4rem);
  padding-bottom: clamp(1rem, 2.4vw, 1.4rem);
  border-bottom: 1px solid var(--line);
}
.facets__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}
.facets__label {
  font-size: .62rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: .35rem;
}

.chip {
  font: inherit;
  font-size: .78rem;
  line-height: 1;
  padding: .38rem .6rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip--all { font-weight: 500; }
.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.chip__n {
  font-size: .62rem;
  opacity: .55;
  font-variant-numeric: tabular-nums;
}
.chip.is-on .chip__n { opacity: .75; }

@media (prefers-reduced-motion: reduce) { .chip { transition: none; } }
