/* THC Library — uses the child theme's palette tokens (same fallbacks as the Field Tools).
   The child theme may restyle any .thc-lib* class. */

.thc-lib {
  --thc-lib-canvas: var(--wp--preset--color--base, #f7f1e4);
  --thc-lib-raised: var(--wp--preset--color--accent-5, #fcf8ef);
  --thc-lib-muted: var(--wp--preset--color--accent-4, #ece4d9);
  --thc-lib-border: var(--wp--preset--color--accent-6, #d9d0bc);
  --thc-lib-text: var(--wp--preset--color--contrast, #332d25);
  --thc-lib-leaf: var(--wp--preset--color--accent-1, #5e7d53);
  --thc-lib-deep: var(--wp--preset--color--accent-3, #3f5c3b);
  --thc-lib-sage: var(--wp--preset--color--accent-2, #a8b79a);
  --thc-lib-stroke: var(--wp--preset--color--control-stroke, #8a7f66);
  --thc-lib-gold: #b8912a;
  --thc-lib-radius: 12px;
  color: var(--thc-lib-text);
  margin-block: var(--wp--preset--spacing--md, 1rem) 0;
}
.thc-lib *, .thc-lib *::before, .thc-lib *::after { box-sizing: border-box; }
.thc-lib__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.thc-lib__lead { margin: 0 0 var(--wp--preset--spacing--lg, 1.5rem); font-size: var(--wp--preset--font-size--large, 1.2rem); max-width: 60ch; }
.thc-lib__h2 { font-size: 1.35rem; margin: 0 0 .25rem; color: var(--thc-lib-deep); }
.thc-lib__hint { margin: 0 0 .9rem; color: var(--thc-lib-deep); }

/* ---------- layout ---------- */
.thc-lib__layout { display: grid; grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.thc-lib__filters { position: sticky; top: 1rem; background: var(--thc-lib-raised); border: 1px solid var(--thc-lib-border); border-radius: var(--thc-lib-radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 1rem; }
.thc-lib__main { min-width: 0; }
.thc-lib__status { margin: 0 0 1rem; font-size: .95rem; color: var(--thc-lib-deep); }

/* ---------- filters ---------- */
.thc-lib__group { border: 0; padding: 0; margin: 0; min-width: 0; }
.thc-lib__group legend, .thc-lib__label { font-size: .85rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--thc-lib-deep); margin-bottom: .35rem; display: block; padding: 0; }
.thc-lib__check { display: flex; align-items: center; gap: .45rem; padding: .18rem 0; cursor: pointer; font-size: .97rem; }
.thc-lib__check input { accent-color: var(--thc-lib-leaf); width: 1.05rem; height: 1.05rem; margin: 0; flex: none; }
.thc-lib__check span { flex: 1 1 auto; }
.thc-lib__check small { color: var(--thc-lib-stroke); font-variant-numeric: tabular-nums; }
.thc-lib__check.is-zero { opacity: .5; }
.thc-lib input[type="search"], .thc-lib input[type="text"], .thc-lib input[type="url"], .thc-lib input[type="email"], .thc-lib select, .thc-lib textarea {
  font: inherit; color: inherit; background: var(--thc-lib-canvas); border: 1px solid var(--thc-lib-stroke); border-radius: 10px; padding: .55em .8em; width: 100%; min-width: 0;
}
.thc-lib input:focus-visible, .thc-lib select:focus-visible, .thc-lib textarea:focus-visible, .thc-lib button:focus-visible, .thc-lib a:focus-visible { outline: 2px solid var(--thc-lib-leaf); outline-offset: 2px; }
.thc-lib__btn { font: inherit; font-weight: 600; border: 1px solid var(--thc-lib-leaf); background: var(--thc-lib-leaf); color: #fff; border-radius: 999px; padding: .55em 1.2em; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.2; }
.thc-lib__btn:hover { background: var(--thc-lib-deep); border-color: var(--thc-lib-deep); color: #fff; }
.thc-lib__btn--ghost { background: transparent; color: var(--thc-lib-deep); }
.thc-lib__btn--ghost:hover { background: var(--thc-lib-muted); color: var(--thc-lib-deep); }
.thc-lib__btn--sm { padding: .38em .9em; font-size: .9rem; }
.thc-lib__link { font-size: .9rem; color: var(--thc-lib-deep); text-decoration: underline; text-underline-offset: .15em; margin-right: .2rem; }

/* ---------- start-here strip ---------- */
.thc-lib__start { margin: 0 0 1.5rem; padding: 1rem 1.1rem; background: var(--thc-lib-muted); border-radius: var(--thc-lib-radius); }
.thc-lib__strip { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: .3rem; scroll-snap-type: x proximity; }
.thc-lib__strip a { flex: 0 0 auto; width: 8.5rem; scroll-snap-align: start; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .35rem; }
.thc-lib__strip img, .thc-lib__strip .thc-lib__nocover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--thc-lib-border); background: var(--thc-lib-raised); }
.thc-lib__strip strong { font-size: .88rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thc-lib__strip span { font-size: .8rem; color: var(--thc-lib-deep); }

/* ---------- grid + cards ---------- */
.thc-lib__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.thc-lib__card { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: .9rem; background: var(--thc-lib-raised); border: 1px solid var(--thc-lib-border); border-radius: var(--thc-lib-radius); padding: .9rem; }
.thc-lib__card.is-featured { border-color: var(--thc-lib-gold); box-shadow: inset 0 0 0 1px var(--thc-lib-gold); }
.thc-lib__card[hidden] { display: none; }
.thc-lib__cover { display: block; width: 6rem; }
.thc-lib__cover img { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--thc-lib-border); background: var(--thc-lib-canvas); display: block; }
.thc-lib__nocover { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 2 / 3; border-radius: 6px; border: 1px dashed var(--thc-lib-stroke); background: var(--thc-lib-canvas); color: var(--thc-lib-stroke); font-size: 2rem; font-weight: 700; }
.thc-lib__nocover--fallback { display: none; }
.thc-lib__cover.is-nocover .thc-lib__nocover--fallback { display: flex; }
.thc-lib__body { min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.thc-lib__pick { align-self: flex-start; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #6b5210; background: #f3e4b3; border-radius: 999px; padding: .15em .6em; }
.thc-lib__title { font-size: 1.08rem; line-height: 1.3; margin: 0; }
.thc-lib__title a { color: var(--thc-lib-deep); text-decoration: none; }
.thc-lib__title a:hover { text-decoration: underline; }
.thc-lib__sub { margin: 0; font-size: .92rem; color: var(--thc-lib-deep); font-style: italic; }
.thc-lib__authors { margin: 0; font-size: .95rem; }
.thc-lib__meta { margin: 0; font-size: .85rem; color: var(--thc-lib-stroke); }
.thc-lib__oop { color: #8a4b2a; font-weight: 600; }
.thc-lib__tags { margin: .1rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.thc-lib__tag { font-size: .75rem; background: var(--thc-lib-muted); color: var(--thc-lib-deep); border-radius: 999px; padding: .12em .6em; }
.thc-lib__tag--region { background: #e6ecdf; }
.thc-lib__blurb { margin: .2rem 0 0; font-size: .95rem; }
.thc-lib__note { margin: .3rem 0 0; padding: .5rem .8rem; border-left: 3px solid var(--thc-lib-gold); background: var(--thc-lib-canvas); font-size: .93rem; font-style: italic; }
.thc-lib__notelabel { font-style: normal; font-weight: 700; color: #6b5210; margin-right: .3rem; }
.thc-lib__by { margin: 0; font-size: .82rem; color: var(--thc-lib-stroke); }
.thc-lib__links { margin: .4rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.thc-lib__empty { padding: 2rem 1rem; text-align: center; background: var(--thc-lib-muted); border-radius: var(--thc-lib-radius); }

/* ---------- suggestion form ---------- */
.thc-lib__suggest { margin-top: 2.5rem; padding: 1.2rem 1.3rem; background: var(--thc-lib-raised); border: 1px solid var(--thc-lib-border); border-radius: var(--thc-lib-radius); }
.thc-lib__form { display: flex; flex-direction: column; gap: .8rem; }
.thc-lib__frow { display: flex; flex-wrap: wrap; gap: .8rem; }
.thc-lib__field { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 12rem; min-width: 0; }
.thc-lib__field--wide { flex: 2 1 18rem; }
.thc-lib__field > span { font-size: .88rem; font-weight: 600; color: var(--thc-lib-deep); }
.thc-lib__field em { font-weight: 400; color: var(--thc-lib-stroke); }
.thc-lib__hp { position: absolute; left: -9999px; top: -9999px; }
.thc-lib__factions { margin: 0; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.thc-lib__fmsg { font-size: .95rem; }
.thc-lib__fmsg.is-ok { color: var(--thc-lib-deep); font-weight: 600; }
.thc-lib__fmsg.is-err { color: #8a2f1f; }

/* ---------- single book ---------- */
.thc-lib__back { margin: 0 0 1rem; }
.thc-lib__single { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.3rem; margin-bottom: 1.5rem; }
.thc-lib__cover--lg { width: 11rem; }
.thc-lib__single .thc-lib__title { font-size: 1.4rem; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .thc-lib__layout { grid-template-columns: 1fr; }
  .thc-lib__filters { position: static; }
  .thc-lib__filters details summary { cursor: pointer; font-weight: 700; color: var(--thc-lib-deep); }
  .thc-lib__filters--collapsible .thc-lib__group, .thc-lib__filters--collapsible [data-lib-clear] { display: none; }
  .thc-lib__filters--collapsible.is-open .thc-lib__group, .thc-lib__filters--collapsible.is-open [data-lib-clear] { display: block; }
  .thc-lib__toggle { font: inherit; font-weight: 700; background: none; border: 1px solid var(--thc-lib-border); border-radius: 999px; padding: .45em 1em; color: var(--thc-lib-deep); cursor: pointer; }
  .thc-lib__card { grid-template-columns: 4.6rem minmax(0, 1fr); padding: .75rem; }
  .thc-lib__cover { width: 4.6rem; }
  .thc-lib__single { grid-template-columns: 1fr; }
  .thc-lib__cover--lg { width: 8rem; }
}
@media (prefers-reduced-motion: no-preference) { .thc-lib__strip { scroll-behavior: smooth; } }
@media print { .thc-lib__filters, .thc-lib__suggest, .thc-lib__links { display: none !important; } .thc-lib__card { break-inside: avoid; } }
