/* ═══════════════════════════════════════════════════════════════════
   FOLIANT · a small library, properly kept
   Parchment ground, oxblood accents, Caslon for the words, Courier for
   the card catalogue. The signature is the shelf: every book is a
   cloth-bound spine row with gilt tooling and a foot label.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --paper: #F4ECDC;
  --paper-deep: #ECE1CA;
  --paper-lift: #FAF4E8;
  --paper-edge: #DCCDA9;
  --hairline: #D5C6A2;
  --ink: #2A2118;
  --ink-soft: #6E5F4B;
  --ink-faint: #98876C;
  --ox: #6E1F2A;
  --ox-deep: #521521;
  --ox-wash: #EBD9D2;
  --gilt: #9A7B2F;
  --gilt-bright: #B08D3A;
  --cloth-default: #4C4437;
  --display: "Libre Caslon Display", "Libre Caslon Text", Georgia, serif;
  --text: "Libre Caslon Text", Georgia, serif;
  --card: "Courier Prime", "Courier New", monospace;
  --shadow-spine: 0 1px 0 rgba(42, 33, 24, 0.14), 0 2px 6px rgba(42, 33, 24, 0.08);
  --shadow-lift: 0 3px 4px rgba(42, 33, 24, 0.14), 0 10px 22px rgba(42, 33, 24, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(140% 100% at 50% 0%, rgba(42, 33, 24, 0) 60%, rgba(42, 33, 24, 0.07) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; }

a { color: var(--ox); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ox-deep); }

:focus-visible { outline: 2px solid var(--ox); outline-offset: 2px; border-radius: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper); padding: 8px 14px; z-index: 60;
}
.skip:focus { left: 8px; top: 8px; }

/* ───────────────── masthead — the house title page ───────────────── */
.masthead {
  max-width: 1060px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(26px, 5vw, 52px) clamp(16px, 4vw, 40px) 0;
}
.mast-plate {
  text-align: center;
  border-top: 3px double var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: clamp(18px, 3.4vw, 30px) 8px clamp(14px, 2.6vw, 22px);
  position: relative;
}
.mast-plate::after {
  content: "";
  display: block;
  position: absolute; left: 0; right: 0; bottom: 3px;
  border-bottom: 1px solid var(--ink);
}
.mast-brand {
  font-family: var(--display);
  font-size: clamp(2.1rem, 6vw, 3.3rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-indent: 0.22em; /* balance the letterspaced last gap */
  color: var(--ink);
  text-decoration: none;
  display: block;
  line-height: 1.12;
}
.mast-brand:hover { color: var(--ox); }
.mast-motto {
  margin: 6px 0 0;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.98rem;
}
.mast-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--hairline);
}
.mast-nav > a {
  font-family: var(--text);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.mast-nav > a:hover { color: var(--ox); }
.mast-nav > a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ox); }
.badge {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--gilt);
  letter-spacing: 0;
}
.mast-spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 14px; }
.who-name {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

/* ───────────────── main column ───────────────── */
#main {
  flex: 1;
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(26px, 4.5vw, 54px) clamp(16px, 4vw, 40px) clamp(48px, 7vw, 90px);
}
.view[hidden] { display: none; }

.cap { max-width: 640px; margin: 0 0 clamp(24px, 4vw, 40px); }
.cap-eyebrow {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gilt);
  margin: 0 0 10px;
}
.cap-h {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.95rem, 4.4vw, 2.7rem);
  line-height: 1.12;
  margin: 0 0 12px;
  letter-spacing: 0.01em;
}
.cap-sub { margin: 0; color: var(--ink-soft); font-size: 1.02rem; }

.backlink {
  display: inline-block;
  font-family: var(--text);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  margin-bottom: clamp(20px, 3.4vw, 34px);
}
.backlink:hover { color: var(--ox); }

/* ───────────────── finder — chips + search ───────────────── */
.finder {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 28px;
  flex-wrap: wrap;
  margin-bottom: clamp(18px, 3vw, 26px);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font-family: var(--text);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}
.chips button b { font-family: var(--card); font-weight: 700; color: var(--gilt); margin-left: 4px; }
.chips button:hover { border-color: var(--ox); color: var(--ox); }
.chips button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.chips button[aria-pressed="true"] b { color: var(--gilt-bright); }
.find-field { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 210px; }
.find-field label {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.find-field input {
  font-family: var(--text);
  font-style: italic;
  font-size: 0.98rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink-soft);
  border-radius: 0;
  padding: 4px 2px;
}
.find-field input::placeholder { color: var(--ink-faint); }
.find-field input:focus-visible { outline: none; border-bottom: 2px solid var(--ox); }

/* ───────────────── the shelf — spine rows (the signature) ───────────────── */
.shelf { display: flex; flex-direction: column; gap: 10px; }
.spine {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 84px;
  background: var(--paper-lift);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-spine);
  overflow: hidden;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.spine:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); color: var(--ink); }
.spine:hover .spine-title { color: var(--ox); }
.spine-bind {
  flex: 0 0 58px;
  background: var(--cloth, var(--cloth-default));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spine-bind::before,
.spine-bind::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px;
  height: 2px;
  background: var(--gilt-bright);
  opacity: 0.85;
}
.spine-bind::before { top: 9px; }
.spine-bind::after { bottom: 9px; }
.spine-label {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(42, 33, 24, 0.35);
  border-radius: 1px;
  padding: 2px 5px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
.spine-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 12px clamp(14px, 2.6vw, 26px);
}
.spine-title {
  font-family: var(--text);
  font-weight: 700;
  font-size: clamp(1.02rem, 2vw, 1.22rem);
  line-height: 1.25;
  transition: color 120ms ease;
}
.spine-author { font-style: italic; color: var(--ink-soft); font-size: 0.92rem; }
.spine-tail {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  padding: 12px clamp(14px, 2.4vw, 24px);
  border-left: 1px solid var(--hairline);
}
.spine-cat {
  font-family: var(--text);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.spine-copies {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.spine-copies--out { color: var(--ox); }

/* ───────────────── one volume — the title page ───────────────── */
.titlepage { max-width: 700px; margin: 0 auto; text-align: center; }
.tp-eyebrow {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gilt);
  margin: 0 0 14px;
}
.tp-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.14;
  margin: 0 0 4px;
  letter-spacing: 0.005em;
}
.tp-orn {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px auto 14px;
  max-width: 320px;
  color: var(--gilt);
  font-size: 1.05rem;
  line-height: 1;
}
.tp-orn::before, .tp-orn::after { content: ""; flex: 1; border-top: 1px solid var(--hairline); }
.tp-author { font-style: italic; font-size: 1.12rem; margin: 0 0 6px; }
.tp-imprint {
  font-size: 0.86rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  margin: 0 0 clamp(22px, 4vw, 34px);
}
.tp-desc {
  text-align: left;
  max-width: 58ch;
  margin: 0 auto clamp(26px, 4.4vw, 38px);
  font-size: 1.04rem;
}
.dropcap {
  font-family: var(--display);
  float: left;
  font-size: 3.3em;
  line-height: 0.82;
  padding: 0.06em 0.12em 0 0;
  color: var(--ox);
}

/* the catalogue card in the pocket */
.cat-card {
  max-width: 460px;
  margin: 0 auto clamp(22px, 4vw, 32px);
  text-align: left;
  background: var(--paper-lift);
  border: 1px solid var(--ink-soft);
  border-radius: 2px;
  box-shadow: var(--shadow-spine);
  padding: 16px 18px 14px;
  position: relative;
}
.cat-card::before {
  content: "";
  position: absolute;
  left: 10px; right: 10px; top: 34px;
  border-top: 1px solid var(--ox-wash);
}
.cc-head {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ox);
  margin: 0 0 14px;
}
.cc-rows { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; }
.cc-rows dt {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  align-self: baseline;
}
.cc-rows dd {
  margin: 0;
  font-family: var(--card);
  font-size: 0.88rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cc-rows dd.cc-out { color: var(--ox); font-weight: 700; }

.tp-act { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tp-due { font-style: italic; color: var(--ink-soft); font-size: 0.94rem; }
.tp-note { margin: 0; font-style: italic; color: var(--ink-soft); max-width: 46ch; }
.tp-note--out { color: var(--ox); font-style: normal; font-weight: 700; }
.haveout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  background: var(--paper-deep);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  padding: 12px 18px;
  font-size: 0.98rem;
}
.haveout b { font-family: var(--card); font-size: 0.88rem; letter-spacing: 0.03em; }

/* ───────────────── my loans — slips & the ledger ───────────────── */
.loan-flight { display: flex; flex-direction: column; gap: 10px; }
.sub-head {
  font-family: var(--text);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 8px;
  margin: clamp(26px, 4.4vw, 40px) 0 14px;
}
.sub-head:first-child { margin-top: 0; }
.slip {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.4vw, 22px);
  background: var(--paper-lift);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  box-shadow: var(--shadow-spine);
  padding: 14px clamp(14px, 2.4vw, 20px);
  overflow: hidden;
  position: relative;
}
.slip::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 7px;
  background: var(--cloth, var(--cloth-default));
}
.slip-main { flex: 1 1 auto; min-width: 0; padding-left: 6px; }
.slip-title {
  font-family: var(--text);
  font-weight: 700;
  font-size: 1.06rem;
  line-height: 1.3;
  text-decoration: none;
  color: var(--ink);
}
.slip-title:hover { color: var(--ox); }
.slip-meta { margin: 3px 0 0; font-style: italic; color: var(--ink-soft); font-size: 0.88rem; }

/* the DATE DUE stamp */
.stamp {
  flex: 0 0 auto;
  text-align: center;
  font-family: var(--card);
  border: 2px solid var(--ink-soft);
  border-radius: 2px;
  color: var(--ink-soft);
  padding: 6px 12px 7px;
  min-width: 108px;
}
.stamp-cap {
  display: block;
  font-weight: 700;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.stamp-day {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  margin: 1px 0;
  color: var(--ink);
}
.stamp-note { display: block; font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; }
.stamp--soon { border-color: var(--gilt); color: var(--gilt); }
.stamp--soon .stamp-day { color: var(--gilt); }
.stamp--over { border-color: var(--ox); color: var(--ox); background: var(--ox-wash); }
.stamp--over .stamp-day { color: var(--ox); }

.ledger { margin-top: 6px; }
.ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 18px;
  flex-wrap: wrap;
  padding: 10px 2px;
  border-bottom: 1px solid var(--hairline);
}
.lr-title { font-weight: 700; font-size: 0.98rem; }
.lr-title a { color: var(--ink); text-decoration: none; }
.lr-title a:hover { color: var(--ox); }
.lr-dates { font-family: var(--card); font-size: 0.78rem; color: var(--ink-faint); letter-spacing: 0.03em; }

/* ───────────────── the desk (sign in) ───────────────── */
.desk { display: flex; justify-content: center; padding-top: clamp(4px, 1.6vw, 16px); }
.desk-card {
  width: 100%;
  max-width: 480px;
  background: var(--paper-lift);
  border: 1px solid var(--ink-soft);
  border-radius: 3px;
  box-shadow: var(--shadow-lift);
  padding: clamp(24px, 4.4vw, 38px) clamp(20px, 4vw, 36px) clamp(22px, 4vw, 32px);
  border-top: 4px solid var(--ox);
}
.desk-h {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  line-height: 1.15;
  margin: 0 0 10px;
}
.desk-lede { margin: 0 0 22px; color: var(--ink-soft); font-size: 0.98rem; }
.desk-alt { margin: 22px 0 0; font-style: italic; color: var(--ink-soft); }
.linklike {
  font: inherit;
  font-style: normal;
  font-weight: 700;
  color: var(--ox);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { color: var(--ox-deep); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field input {
  font-family: var(--text);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  padding: 9px 11px;
}
.field input:focus-visible { outline: 2px solid var(--ox); outline-offset: 0; border-color: var(--ox); }
.form-err {
  margin: 0 0 12px;
  color: var(--ox);
  font-size: 0.92rem;
  border-left: 3px solid var(--ox);
  padding-left: 10px;
}

.demo-slot {
  margin-top: 22px;
  border: 1px dashed var(--ink-faint);
  border-radius: 2px;
  padding: 14px 16px;
  background: var(--paper);
}
.ds-tag {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gilt);
  margin: 0 0 10px;
}
.ds-rows { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; }
.ds-rows dt {
  font-family: var(--card);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  align-self: baseline;
}
.ds-rows dd { margin: 0; font-family: var(--card); font-size: 0.86rem; overflow-wrap: anywhere; }

/* ───────────────── buttons ───────────────── */
.btn {
  display: inline-block;
  font-family: var(--text);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border-radius: 2px;
  padding: 11px 20px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.btn-primary { background: var(--ox); border: 1px solid var(--ox); color: var(--paper-lift); }
.btn-primary:hover { background: var(--ox-deep); border-color: var(--ox-deep); color: var(--paper-lift); }
.btn-ghost { background: transparent; border: 1px solid var(--ink-soft); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ox); color: var(--ox); }
.btn-sm { padding: 7px 13px; font-size: 0.66rem; }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ───────────────── states, empties, toast ───────────────── */
.state { margin: 8px 0 20px; }
.st-load {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
  animation: quietPulse 1.4s ease-in-out infinite;
}
@keyframes quietPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.st-err { margin: 0 0 10px; color: var(--ox); font-weight: 700; }
.st-err small { display: block; font-weight: 400; color: var(--ink-soft); margin-top: 2px; }

.empty {
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  background: var(--paper-deep);
  padding: clamp(22px, 4vw, 34px);
  text-align: center;
}
.empty strong { font-family: var(--display); font-weight: 400; font-size: 1.3rem; display: block; margin-bottom: 6px; }
.empty p { margin: 0 0 14px; color: var(--ink-soft); font-style: italic; }
.empty p:last-child { margin-bottom: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(92vw, 460px);
  background: var(--ink);
  color: var(--paper);
  border-left: 4px solid var(--gilt-bright);
  border-radius: 2px;
  box-shadow: var(--shadow-lift);
  padding: 12px 18px;
  font-size: 0.94rem;
}
.toast--err { background: var(--ox-deep); border-left-color: var(--paper); }

/* ───────────────── colophon ───────────────── */
.colophon {
  border-top: 3px double var(--ink);
  background: var(--paper-deep);
  padding: clamp(24px, 4vw, 40px) clamp(16px, 4vw, 40px) clamp(30px, 5vw, 48px);
  text-align: center;
}
.colo-brand {
  font-family: var(--display);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-transform: uppercase;
  font-size: 0.95rem;
  margin: 0 0 8px;
  color: var(--ink-soft);
}
.colo-line { margin: 0 auto; max-width: 56ch; font-style: italic; color: var(--ink-soft); font-size: 0.9rem; }

/* ───────────────── responsive ───────────────── */
@media (max-width: 720px) {
  .finder { flex-direction: column; align-items: stretch; }
  .find-field { min-width: 0; }
  .spine { min-height: 74px; }
  .spine-bind { flex-basis: 46px; }
  .spine-label { font-size: 0.6rem; padding: 2px 3px; letter-spacing: 0.04em; }
  .spine-tail { padding-right: 12px; }
  .spine-cat { display: none; }
  .slip { flex-wrap: wrap; }
  .slip-main { flex-basis: 100%; }
  .slip .btn { margin-left: auto; }
  .stamp { min-width: 96px; }
}

@media (max-width: 420px) {
  .mast-nav { gap: 4px 16px; }
  .who { gap: 10px; }
  .who-name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .spine-copies { font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spine, .btn, .chips button { transition: none; }
  .spine:hover { transform: none; }
  .st-load { animation: none; }
}
