/* HentaiFox Local Library — design system.
   Reuses the tokens and visual language of the existing skeleton
   (ink / paper / acid palette, Fraunces + Inter rhythm) but ships no demo
   classes and no external font request, so the site works fully offline. */

:root {
  --ink: #0b0e12;
  --ink-2: #141a21;
  --ink-3: #1d2630;
  --paper: #f4eee3;
  --paper-2: #fbf7ef;
  --muted: #aab3bd;
  --muted-2: #6f7a86;
  --line: rgba(244, 238, 227, 0.14);
  --line-strong: rgba(244, 238, 227, 0.28);
  --acid: #d9ff4f;
  --coral: #ff5d5d;
  --gold: #e8b86d;
  --radius: 16px;
  --radius-sm: 9px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wrap: 1280px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--acid); }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid var(--acid); outline-offset: 3px; }
::selection { background: var(--acid); color: var(--ink); }

.wrap { width: min(100% - 40px, var(--wrap)); margin-inline: auto; }
.eyebrow {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted-2); margin: 0 0 10px;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15;
  margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(30px, 4vw, 52px); }
h2 { font-size: clamp(22px, 2.4vw, 32px); }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 14, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 22px;
  min-height: 62px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700;
  letter-spacing: .02em; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--acid), var(--gold));
  display: grid; place-items: center; color: var(--ink); font-size: 14px;
  font-family: var(--serif); font-weight: 700;
}
.brand small { display: block; font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted-2); font-weight: 500; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  padding: 7px 11px; border-radius: 999px; font-size: 14px; color: var(--muted);
  border: 1px solid transparent;
}
.nav a:hover { color: var(--paper); border-color: var(--line); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--acid); }

/* ---------- hero ---------- */
.hero { padding: 54px 0 26px; border-bottom: 1px solid var(--line); }
.hero p.lead { font-size: clamp(16px, 1.6vw, 19px); color: var(--muted);
  max-width: 62ch; }
.stats { display: flex; gap: 26px; flex-wrap: wrap; margin: 26px 0 6px; }
.stat .n { font-family: var(--serif); font-size: 30px; color: var(--paper); }
.stat .k { font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted-2); }

/* ---------- sections ---------- */
.section { padding: 38px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.link-more { font-size: 14px; color: var(--muted); }
.link-more:hover { color: var(--acid); }

/* ---------- cards ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}
.card {
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .16s ease, border-color .16s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.card .thumb { position: relative; aspect-ratio: 3 / 4; background: var(--ink-3);
  overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .placeholder {
  width: 100%; height: 100%; display: grid; place-content: center; gap: 6px;
  text-align: center; padding: 12px;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(217,255,79,.10), transparent 60%),
    repeating-linear-gradient(135deg, #161d25 0 12px, #131a21 12px 24px);
}
.card .placeholder .pid { font-family: var(--serif); font-size: 22px;
  color: rgba(244,238,227,.55); }
.card .placeholder .pnote { font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted-2); }
.card .body { padding: 11px 12px 13px; display: flex; flex-direction: column;
  gap: 6px; flex: 1; }
.card .title { font-size: 13.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; }
.card .meta { margin-top: auto; font-size: 11px; color: var(--muted-2);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { color: var(--acid); border-color: rgba(217,255,79,.4); }
.badge.warn { color: var(--gold); border-color: rgba(232,184,109,.4); }
.badge.off { color: var(--muted-2); }

/* ---------- filters / chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.chip {
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: transparent;
}
.chip:hover { color: var(--paper); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--acid); color: var(--ink);
  border-color: var(--acid); font-weight: 600; }
.field {
  display: flex; align-items: center; gap: 8px; background: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  min-width: 260px; flex: 1;
}
.field input {
  background: transparent; border: 0; color: var(--paper); width: 100%;
  outline: none;
}
.field input::placeholder { color: var(--muted-2); }

/* ---------- breadcrumbs ---------- */
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px;
  color: var(--muted-2); padding: 22px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs span.sep { opacity: .5; }

/* ---------- gallery detail ---------- */
.gallery-layout { display: grid; grid-template-columns: 320px 1fr; gap: 34px;
  padding: 26px 0 40px; align-items: start; }
.cover-box { position: sticky; top: 84px; }
.cover-box .frame {
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--ink-3);
}
.cover-box .placeholder { aspect-ratio: 3 / 4; }
.gallery-head h1 { margin-bottom: .3em; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px;
  margin: 18px 0 24px; font-size: 14px; }
.meta-list dt { color: var(--muted-2); }
.meta-list dd { margin: 0; color: var(--paper); }
.taglist { display: flex; gap: 7px; flex-wrap: wrap; }
.taglist a {
  font-size: 12.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.taglist a:hover { color: var(--ink); background: var(--acid); border-color: var(--acid); }
.notice {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 16px 18px; color: var(--muted); background: rgba(255,255,255,.015);
  font-size: 14px;
}
.notice strong { color: var(--paper); }

/* pages strip */
.pages-strip { display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); margin-top: 14px; }
.page-thumb {
  position: relative; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--ink-3); aspect-ratio: 3 / 4;
  padding: 0; cursor: zoom-in;
}
.page-thumb img { width: 100%; height: 100%; object-fit: cover; }
.page-thumb .no {
  position: absolute; left: 6px; bottom: 6px; font-size: 10px;
  background: rgba(11,14,18,.75); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 999px;
}
.page-thumb.pending { cursor: default; display: grid; place-content: center;
  color: var(--muted-2); font-size: 11px; text-align: center; padding: 6px;
}

/* ---------- pagination ---------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center;
  margin: 34px 0 10px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--line); font-size: 13.5px;
  color: var(--muted); padding: 0 10px;
}
.pagination a:hover { border-color: var(--line-strong); color: var(--paper); }
.pagination .current { background: var(--acid); color: var(--ink);
  border-color: var(--acid); font-weight: 700; }
.pagination .disabled { opacity: .35; }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 90; display: none;
  background: rgba(6, 8, 11, 0.96); padding: 24px; overflow: hidden;
}
/* minmax(0,1fr) + min-height:0 stop the middle row from growing to the
   image's intrinsic height, which used to clip tall pages. */
.viewer.open { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; font-size: 13px; color: var(--muted); }
/* The stage scrolls: a tall page is never clipped, it is read by scrolling. */
.viewer-stage { display: block; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.viewer-stage img { display: block; margin: 0 auto; width: auto; max-width: 100%;
  height: auto; border-radius: 6px; }
.viewer-nav { display: flex; justify-content: center; gap: 10px; }
.btn {
  background: var(--ink-2); color: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 16px; cursor: pointer;
}
.btn:hover { border-color: var(--acid); color: var(--acid); }
.btn[disabled] { opacity: .35; cursor: default; }

/* ---------- misc ---------- */
.empty { padding: 60px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); }
.list-simple { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); }
.list-simple a { display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 13.5px; color: var(--muted); }
.list-simple a:hover { color: var(--paper); border-color: var(--line-strong); }
.list-simple .n { color: var(--muted-2); }
.site-footer { border-top: 1px solid var(--line); margin-top: 40px;
  padding: 28px 0 60px; color: var(--muted-2); font-size: 12.5px; }
.site-footer .wrap { display: flex; gap: 18px; justify-content: space-between;
  flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 860px) {
  .gallery-layout { grid-template-columns: 1fr; }
  .cover-box { position: static; max-width: 320px; }
}
@media (max-width: 620px) {
  .wrap { width: min(100% - 26px, var(--wrap)); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .nav { width: 100%; margin-left: 0; gap: 2px; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .gallery-pager { grid-template-columns: 1fr; }
  .stats { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* gallery prev/next */
.gallery-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.pager-link { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pager-link .k { font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted-2); }
.pager-link .t { font-size: 13.5px; color: var(--paper); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.pager-link.next { text-align: right; }
.pager-link.disabled { opacity: .35; }

/* ---------- continuous reader ---------- */
.reader-section { margin-top: 34px; }
.reader { display: grid; gap: 14px; max-width: 900px; margin: 14px auto 0; }
.reader-page {
  display: block; width: 100%; padding: 0; border: 0; background: none;
  cursor: zoom-in; border-radius: 10px; text-align: center;
}
.reader-page img {
  display: block; width: 100%; height: auto; max-width: 100%;
  border-radius: 10px; border: 1px solid var(--line);
}
.reader-page:hover img, .reader-page:focus-visible img { border-color: var(--line-strong); }

/* ---------- taxonomy cards ---------- */
.taxon-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  margin-top: 18px;
}
.taxon-card {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  min-height: 74px; padding: 14px 16px; background: var(--ink-2);
  border: 1px solid var(--line); border-radius: 12px;
  transition: transform .14s ease, border-color .14s ease;
}
.taxon-card:hover { transform: translateY(-2px); border-color: var(--acid); }
.taxon-name { font-size: 14.5px; font-weight: 600; color: var(--paper); }
.taxon-count { font-size: 12px; color: var(--muted-2); }

/* ---------- hero quick links ---------- */
.quicklinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

@media (max-width: 620px) {
  .taxon-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .taxon-card { min-height: 66px; padding: 12px; }
  .reader { gap: 10px; }
}

/* ---------- home browse-by ---------- */
.browse-by { margin-top: 46px; padding-top: 30px; border-top: 1px solid var(--line); }
.browse-group { margin-top: 22px; }
.browse-group h3 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted-2); margin-bottom: 10px; font-weight: 600;
}
.taxon-grid.compact { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); margin-top: 0; }
.taxon-grid.compact .taxon-card { min-height: 62px; padding: 10px 12px; }
.taxon-grid.compact .taxon-name { font-size: 13.5px; }

/* ---------- footer links ---------- */
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 6px; }
.footer-links a { color: var(--muted); font-size: 12.5px; }
.footer-links a:hover { color: var(--acid); }

@media (max-width: 620px) {
  .taxon-grid.compact { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}
