/* ═══════════════════════════════════════════════════════════════════
   GUARDIANS · THE BOUND BESTIARY (bestiary.css)
   The field naturalist's journal: rougher paper, colder grey, sketch-
   ghosts under the veil. Left page = the full roster in one sweep,
   banded by tier. Right page = the illuminated field plate: portrait
   sealed to the paper with true wax. portal.css is LAW; toolbar dress
   comes from compendium.css; the book skeleton is the Grimoire's
   sibling — same shelf, different beast.
   ═══════════════════════════════════════════════════════════════════ */

html:not(.bestiary-on) .bb-scriptorium,
html:not(.bestiary-on) #bb-book { display: none; }
html.bestiary-on #bb-fallback { display: none; }

/* Title zone: the strapped journal beside its name */
.bb-titlezone {
  display: flex; align-items: center; justify-content: center; gap: clamp(18px, 3vw, 40px);
  flex-wrap: wrap; max-width: 1100px; margin: 0 auto 22px; text-align: left;
}
.bb-titlezone img {
  width: clamp(150px, 19vw, 235px); height: auto;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 22px rgba(183, 154, 224, 0.12));
}
.bb-titlezone h2 {
  font-family: var(--f-arc); font-weight: 400; margin: 0;
  font-size: clamp(1.9rem, 4.4vw, 3rem); letter-spacing: 0.06em; color: #f0eaf8;
  text-shadow: 0 0 34px rgba(183, 154, 224, 0.35);
}
.bb-titlezone .bb-sub {
  margin: 6px 0 0; font-family: var(--f-arc); font-style: italic;
  color: #ab9fc4; font-size: 1.02rem;
}

/* Scriptorium bar (field desk) */
.bb-scriptorium { max-width: 1100px; margin: 0 auto 8px; }
.bb-scriptorium .toolbar { margin-bottom: 8px; }
.bb-meta { display: flex; align-items: center; gap: 14px; }
.bb-meta #count { flex: 1 1 auto; margin: 0; }
.bb-scriptorium .export-options { flex: 0 0 auto; justify-content: flex-end; }
.bb-scriptorium .export-options button { padding: 9px 16px; font-size: 0.7rem; }
#bb-status { max-width: 1100px; margin: 0 auto 10px; }
#bb-status:empty { display: none; }

/* ── The journal, spread on the page ── */
#bb-book {
  position: relative; max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr;
  min-height: clamp(560px, 76vh, 860px);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.75), 0 0 60px rgba(183, 154, 224, 0.1);
}
#bb-book::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 64px;
  transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(38, 32, 24, 0.34) 45%, rgba(18, 15, 10, 0.5) 50%, rgba(38, 32, 24, 0.34) 55%, transparent);
}
.bb-page { overflow-y: auto; padding: clamp(22px, 3.4vw, 46px); color: var(--ink); }
/* the journal's paper is colder and rougher than the Grimoire's — a
   lighter veil (~76%) lets the anatomical ghosts breathe through */
.bb-page.bb-index {
  background:
    linear-gradient(rgba(226, 220, 205, 0.76), rgba(226, 220, 205, 0.76)),
    url("../images/bestiary/page-index.webp") center / cover;
}
.bb-page.bb-entrypage {
  background:
    linear-gradient(rgba(229, 223, 207, 0.78), rgba(229, 223, 207, 0.78)),
    url("../images/bestiary/page-entry.webp") center / cover;
  position: relative;
}

/* ── Left page: the roster, banded by tier ── */
.bb-head { font-family: var(--f-arc); font-size: 1.4rem; text-align: center; margin: 0 0 14px; color: var(--ink); }
.bb-band {
  display: flex; align-items: baseline; gap: 10px; margin: 16px 0 4px;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: #6d4a1f;
}
.bb-band::after { content: ""; flex: 1 1 auto; border-top: 1px solid rgba(109, 74, 31, 0.35); }
.bb-band .ct {
  font-size: 0.72rem; letter-spacing: 0.04em; color: var(--ink-soft);
  border: 1px solid rgba(74, 61, 44, 0.4); border-radius: 999px; padding: 0 8px;
}
.bb-roster { display: grid; gap: 2px; }
.bb-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; cursor: pointer; background: none; border: none;
  font-family: var(--f-arc); font-size: 1rem; color: var(--ink);
  padding: 6px 4px; border-bottom: 1px dotted rgba(74, 61, 44, 0.3);
}
.bb-row:hover { background: rgba(138, 109, 59, 0.1); }
.bb-row.open { background: rgba(138, 109, 59, 0.16); font-weight: 700; }
.bb-row .th {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; border: 1px solid rgba(74, 61, 44, 0.45);
  filter: sepia(0.25) contrast(0.96);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.bb-row:hover .th { filter: none; }
.bb-row .nm {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bb-row .mn { flex: 0 0 auto; font-size: 0.74rem; color: #6d4a1f; font-style: italic; }
.bb-row .sz { flex: 0 0 auto; font-size: 0.7rem; color: var(--ink-soft); letter-spacing: 0.06em; }
.bb-none { font-family: var(--f-arc); font-style: italic; color: var(--ink-soft); padding: 12px 4px; }
.bb-listtop { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.bb-ribbon {
  flex: 0 0 auto; cursor: pointer; font-family: var(--f-ui); font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--parch); background: #4a3d2c; border: none; border-radius: 6px;
  padding: 9px 14px; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}
.bb-ribbon:hover { background: #5d4d38; }

/* ── Right page: frontispiece ── */
.bb-front { text-align: center; padding-top: clamp(20px, 5vh, 60px); }
.bb-front-k { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.3em; text-transform: uppercase; color: #8a6d3b; }
.bb-front h3 { font-family: var(--f-arc); font-weight: 400; font-size: clamp(1.8rem, 3.4vw, 2.6rem); margin: 8px 0; color: var(--ink); }
.bb-front-n { font-family: var(--f-arc); font-style: italic; color: var(--ink-soft); }
.bb-front-t { font-family: var(--f-arc); font-style: italic; color: var(--ink-soft); margin-top: 26px; line-height: 1.7; }
.bb-front-logo { display: block; margin: 30px auto 0; width: clamp(240px, 24vw, 330px); height: auto; }

/* ── Right page: the field plate ── */
/* the portrait, mounted like a specimen plate and sealed with wax */
.bb-mount {
  float: right; position: relative; width: min(46%, 300px);
  margin: 6px 0 14px 18px; transform: rotate(1.4deg);
}
.bb-mount img.portrait {
  display: block; width: 100%; height: auto; cursor: zoom-in;
  border: 7px solid rgba(250, 246, 234, 0.9);
  outline: 1px solid rgba(74, 61, 44, 0.4);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  filter: sepia(0.12) contrast(0.98);
}
.bb-stamp {
  position: absolute; left: -26px; bottom: -24px; width: 104px; height: 100px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 24px; box-sizing: border-box; transform: rotate(-9deg);
  background: url("../images/bestiary/wax-seal.webp") center / contain no-repeat;
  font-size: 0.56rem; font-weight: 700; letter-spacing: 0.1em; line-height: 1.2;
  text-transform: uppercase; color: rgba(255, 226, 210, 0.95);
  text-shadow: 0 1px 2px rgba(60, 6, 8, 0.9), 0 0 6px rgba(60, 6, 8, 0.6);
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}
.bb-name { font-family: var(--f-arc); font-weight: 400; font-size: clamp(1.6rem, 2.6vw, 2.3rem); margin: 0 0 2px; color: var(--ink); }
.bb-name .cap { float: left; font-size: 2.35em; line-height: 0.82; padding: 4px 10px 0 0; color: #5d3f14; }
.bb-kind { clear: none; font-family: var(--f-arc); font-style: italic; font-size: 0.98rem; color: var(--ink-soft); margin: 0 0 12px; }
.bb-temper { font-family: var(--f-arc); font-style: italic; font-size: 0.98rem; line-height: 1.65; color: var(--ink); margin: 0 0 12px; }
.bb-appear { font-family: var(--f-arc); font-size: 1.02rem; line-height: 1.7; color: var(--ink); margin: 0 0 12px; }
.bb-blurb { font-family: var(--f-arc); font-style: italic; font-size: 0.93rem; line-height: 1.6; color: var(--ink-soft); margin: 0 0 14px; }

/* vitals ledger */
.bb-mech { clear: left; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.bb-mech span {
  font-size: 0.8rem; color: var(--ink);
  border: 1px solid rgba(74, 61, 44, 0.45); border-radius: 999px; padding: 3px 12px;
  background: rgba(255, 255, 255, 0.28);
}
.bb-mech b { color: #5d3f14; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.66rem; margin-right: 4px; }

/* the seven attributes, a measuring strip */
.bb-attrs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; }
.bb-attrs span {
  flex: 1 1 0; min-width: 44px; text-align: center; padding: 4px 2px;
  border: 1px solid rgba(74, 61, 44, 0.35); border-radius: 6px;
  background: rgba(255, 255, 255, 0.22); font-size: 0.92rem; color: var(--ink);
}
.bb-attrs b {
  display: block; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: #6d4a1f;
}

/* section heads + margin blocks */
.bb-h {
  clear: both; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.24em;
  text-transform: uppercase; color: #6d4a1f; margin: 18px 0 8px;
  display: flex; align-items: center; gap: 10px;
}
.bb-h::after { content: ""; flex: 1 1 auto; border-top: 1px solid rgba(109, 74, 31, 0.3); }
.bb-margin { font-size: 0.9rem; line-height: 1.55; color: var(--ink-soft); border-left: 3px solid rgba(138, 109, 59, 0.5); padding-left: 12px; margin: 0 0 10px; }
.bb-margin b { color: #5d3f14; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.68rem; }
.bb-margin .src { font-style: italic; font-size: 0.78rem; color: var(--ink-soft); }
.bb-also { font-family: var(--f-arc); font-style: italic; font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 10px; }

/* marks & wards chips */
.bb-chips { margin: 0 0 6px; }
.bb-chips .lb {
  display: inline-block; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: #6d4a1f; margin: 0 8px 6px 0;
}
.bb-chips span.c {
  display: inline-block; margin: 0 6px 6px 0; padding: 2px 12px;
  font-size: 0.74rem; color: #5d3f14; border: 1px solid rgba(93, 63, 20, 0.5);
  border-radius: 999px; background: rgba(255, 255, 255, 0.25);
}
.bb-chips.res span.c { border-color: rgba(70, 50, 93, 0.55); color: #46325d; }
.bb-chips.weak span.c { border-color: rgba(140, 45, 30, 0.55); color: #7a2a18; }
.bb-tags span {
  display: inline-block; margin: 0 6px 6px 0; padding: 2px 12px;
  font-size: 0.74rem; color: #5d3f14; border: 1px solid rgba(93, 63, 20, 0.5);
  border-radius: 999px; background: rgba(255, 255, 255, 0.25);
}
.bb-prov { font-family: var(--f-arc); font-style: italic; font-size: 0.8rem; color: var(--ink-soft); border-top: 1px solid rgba(74, 61, 44, 0.3); padding-top: 8px; margin-top: 16px; }

/* The page turn */
@keyframes bb-turn {
  0%   { opacity: 0.25; transform: perspective(1200px) rotateY(-14deg); }
  100% { opacity: 1;    transform: perspective(1200px) rotateY(0deg); }
}
.bb-page.turning #bb-entry-host, .bb-page.turning .bb-front { animation: bb-turn 0.45s ease-out; transform-origin: left center; }
#bb-back { display: none; }

/* One page at a time on small screens */
@media (max-width: 760px) {
  #bb-book { grid-template-columns: 1fr; min-height: min(820px, 92vh); }
  .bb-page.bb-entrypage { display: none; }
  #bb-book.entry-open .bb-index { display: none; }
  #bb-book.entry-open .bb-entrypage { display: block; }
  .bb-mount { float: none; width: min(100%, 340px); margin: 10px auto 26px; }
  #bb-back {
    display: inline-block; position: sticky; bottom: 0; margin-top: 18px; cursor: pointer;
    font-family: var(--f-ui); font-size: 0.78rem; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--parch); background: #4a3d2c; border: none; border-radius: 6px;
    padding: 12px 20px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

/* No-JS chain (also the print truth) */
#bb-fallback { max-width: 940px; margin: 0 auto; }
.fb-tier {
  border: 1px solid rgba(183, 154, 224, 0.22); border-radius: 10px;
  background: rgba(16, 13, 30, 0.72); margin: 0 0 12px; padding: 0 18px;
}
.fb-tier summary { cursor: pointer; padding: 14px 0; font-weight: 700; color: #f0eaf8; }
.fb-tier summary .count { font-size: 0.75rem; color: var(--arc-hi); border: 1px solid var(--arc-line); border-radius: 999px; padding: 1px 9px; margin-left: 8px; }
.fb-beast { border-top: 1px solid rgba(183, 154, 224, 0.12); padding: 12px 0; overflow: hidden; }
.fb-beast h4 { margin: 0 0 4px; color: #ffe3ae; }
.fb-beast h4 em { font-weight: 400; font-size: 0.8rem; color: #9d92b8; margin-left: 8px; }
.fb-beast img { float: left; width: 76px; height: 76px; object-fit: cover; border-radius: 8px; margin: 2px 14px 6px 0; border: 1px solid rgba(183, 154, 224, 0.25); }
.fb-beast p { margin: 0 0 6px; font-family: var(--f-arc); line-height: 1.55; color: #c9bfdd; }
.fb-mech { font-size: 0.82rem; color: #ab9fc4 !important; }
.fb-blurb { font-style: italic; color: #9d92b8 !important; }

@media (prefers-reduced-motion: reduce) {
  .bb-page.turning #bb-entry-host, .bb-page.turning .bb-front { animation: none; }
}
@media print {
  .bb-scriptorium, #bb-book, .bb-titlezone img { display: none !important; }
  #bb-fallback { display: block !important; }
}
