/* --------------------------------------------------------------------------
   Community library. Mobile first, because both audiences are on a phone:
   the public browsing at home, the librarian standing at a stall.
   -------------------------------------------------------------------------- */

:root {
  --ink: #241f1a;
  --ink-soft: #5b5148;
  --paper: #fbf7f0;
  --card: #ffffff;
  --line: #e2d8c9;
  --accent: #7a4a2b;
  --accent-soft: #f0e4d8;
  --green: #2f6b46;
  --green-soft: #e3f0e7;
  --amber: #8a5a12;
  --amber-soft: #fbeed6;
  --red: #8c2f28;
  --red-soft: #f8e2e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(36, 31, 26, .07), 0 6px 18px rgba(36, 31, 26, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece5db;
    --ink-soft: #a89c8d;
    --paper: #17140f;
    --card: #211d17;
    --line: #38312a;
    --accent: #d99b6a;
    --accent-soft: #33261c;
    --green: #7ec295;
    --green-soft: #1c2f22;
    --amber: #e0b46a;
    --amber-soft: #33271476;
    --red: #e89a91;
    --red-soft: #331d1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 ui-serif, Georgia, "Iowan Old Style", Palatino, serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 62rem; margin: 0 auto; padding: 0 1rem; }

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
p { margin: 0 0 1rem; }
.quiet { color: var(--ink-soft); font-size: .875rem; }

/* Header ------------------------------------------------------------------ */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.site-header.is-admin { background: var(--accent-soft); }
.header-inner {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: baseline; justify-content: space-between;
  padding-top: .7rem; padding-bottom: .7rem;
}
.brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--ink); }
.site-nav { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .9rem; }
.site-nav a { text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

.site-notice {
  border-bottom: 1px solid var(--line);
  font-size: .875rem;
  padding: .55rem 0;
}
.site-notice p { margin: 0; }

.event-strip {
  background: var(--accent); color: #fff; font-size: .875rem;
  padding: .45rem 0;
}
.event-strip a { color: #fff; }

main { padding: 1.5rem 1rem 3rem; }

/* Catalogue --------------------------------------------------------------- */

.toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem;
  align-items: center; margin-bottom: 1.25rem;
}
.toolbar input[type="search"] { flex: 1 1 14rem; }
.filters { display: flex; gap: .35rem; }
.filters a {
  text-decoration: none; font-size: .85rem; padding: .35rem .7rem;
  border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft);
  background: var(--card);
}
.filters a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
}
.book-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.book-card a.cover-link { display: block; text-decoration: none; color: inherit; }
.cover {
  aspect-ratio: 2 / 3; width: 100%; object-fit: cover; display: block;
  background: var(--accent-soft);
}
.cover-fallback {
  aspect-ratio: 2 / 3; display: flex; align-items: center; justify-content: center;
  padding: .75rem; text-align: center; background: var(--accent-soft);
  color: var(--accent); font-size: .8rem; font-weight: 600;
}
.book-card .meta { padding: .6rem .7rem .75rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.book-card .t { font-weight: 600; font-size: .95rem; line-height: 1.25; }
.book-card .a { font-size: .82rem; color: var(--ink-soft); }

/* Status pills ------------------------------------------------------------ */

.pill {
  display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  padding: .16rem .5rem; border-radius: 999px; text-transform: uppercase;
  font-family: ui-sans-serif, system-ui, sans-serif; width: fit-content;
}
.pill-available { background: var(--green-soft); color: var(--green); }
.pill-reserved  { background: var(--amber-soft); color: var(--amber); }
.pill-onloan    { background: var(--red-soft);   color: var(--red); }

/* Book page --------------------------------------------------------------- */

.book-detail { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) {
  .book-detail { grid-template-columns: 15rem 1fr; }
}
.book-detail .cover, .book-detail .cover-fallback {
  border-radius: var(--radius); border: 1px solid var(--line);
}
.curator-note {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  padding: .85rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1rem 0;
}
.curator-note h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; }
.curator-note p:last-child { margin-bottom: 0; }

/* Forms ------------------------------------------------------------------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1.1rem;
}
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-size: .82rem; color: var(--ink-soft); margin: .2rem 0 0; }
input[type="text"], input[type="tel"], input[type="email"], input[type="search"],
input[type="password"], input[type="date"], input[type="number"], textarea, select {
  width: 100%; padding: .6rem .7rem; font: inherit; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; font-size: 1rem;
  padding: .6rem 1.1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--card); color: var(--accent); }
.btn-danger { background: var(--card); color: var(--red); border-color: var(--red); }
.btn-small { font-size: .85rem; padding: .35rem .7rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Due date at check-out ---------------------------------------------------
   Folded away by default: with a queue of people at a stall, handing a book
   over has to stay one tap, and the automatic date is readable without
   opening anything. */

.due-pick { margin: 0 0 .5rem; font-size: .85rem; }
.due-pick > summary {
  cursor: pointer; color: var(--accent); padding: .25rem 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.due-pick[open] {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: .6rem .7rem; margin-bottom: .7rem;
}
.due-pick[open] > summary { margin-bottom: .6rem; }
.due-pick .field { margin-bottom: .6rem; }
.due-pick .field:last-child { margin-bottom: 0; }
.due-pick label { font-size: .82rem; }

/* Content notes -----------------------------------------------------------
   A shelf like this one has to be able to say what is in a book without
   whispering it. Distinct from the curator's note, and never red: this is
   information, not a warning siren. */

.subtitle { color: var(--ink-soft); font-size: 1.05rem; margin: -.4rem 0 .3rem; }

.content-note {
  background: var(--amber-soft); border: 1px solid var(--amber);
  border-radius: var(--radius); padding: .9rem 1rem; margin: 1.1rem 0;
}
.content-note h3 { margin: 0 0 .35rem; font-size: .95rem; color: var(--amber); }
.content-note p { margin: 0 0 .5rem; }
.content-note p:last-child { margin-bottom: 0; }

/* Deliberately not amber: the three state pills already own that, and this
   is not a state. */
.pill-reference { background: var(--accent-soft); color: var(--accent); }

.content-flag {
  font-size: .78rem; color: var(--amber); text-decoration: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.content-flag::before { content: "\2022\00a0"; }

/* Honeypot: hidden from people, tempting to bots. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Flash messages ---------------------------------------------------------- */

.flash {
  padding: .7rem .9rem; border-radius: 8px; margin: 1rem 0 0;
  border: 1px solid var(--line); background: var(--card);
}
.flash-error   { background: var(--red-soft);   border-color: var(--red);   color: var(--red); }
.flash-success { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.flash-warn    { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }

/* Queue position ---------------------------------------------------------- */

.position-badge {
  display: flex; align-items: center; gap: .9rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.position-badge .n {
  font-size: 2.2rem; font-weight: 700; color: var(--accent); line-height: 1;
  min-width: 2.4rem; text-align: center;
}
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft); color: var(--accent); padding: .1rem .4rem;
  border-radius: 5px; font-weight: 700; letter-spacing: .04em;
}

/* Lists / tables ---------------------------------------------------------- */

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
  justify-content: space-between;
  padding: .8rem 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .who { font-weight: 600; }
.row .what { color: var(--ink-soft); font-size: .9rem; }
.row .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.row.done { opacity: .5; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
     font-family: ui-sans-serif, system-ui, sans-serif; }

.empty { color: var(--ink-soft); font-style: italic; padding: 1rem 0; }

.tick { color: var(--green); font-weight: 700; }

/* Spicy Sites credit ------------------------------------------------------
   Self-contained on purpose: this block plus src/views/powered-by.js is the
   whole badge, so it lifts into another site unchanged. The only hooks into
   this stylesheet are the colour variables below, which every site of ours
   defines. */

.powered-by { margin: 3rem 0 1.5rem; }
.powered-by .wrap { display: flex; justify-content: flex-end; }

.powered-by a {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .15rem;
  color: var(--ink-soft);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .78rem; letter-spacing: .01em;
  text-decoration: none;
  opacity: .7;
  transition: opacity .15s ease, color .15s ease;
}

.powered-by a:hover,
.powered-by a:focus-visible { opacity: 1; color: var(--accent); }

.powered-by strong { font-weight: 600; }

.powered-by-logo { height: 5rem; width: auto; flex: none; display: block; }

/* Print: the run sheet is the offline mode ------------------------------- */

.print-only { display: none; }

@media print {
  .print-only { display: block; }
  :root { --paper: #fff; --card: #fff; --ink: #000; --ink-soft: #333; --line: #999; }
  .site-header, .site-notice, .event-strip, .powered-by,
  .no-print, .actions, .btn { display: none !important; }
  body { font-size: 11pt; }
  main { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  h2 { break-after: avoid; margin-top: 1.2rem; }
  .row, tr { break-inside: avoid; }
  .card { border: 0; box-shadow: none; padding: 0; }
  /* Tick boxes so a paper run sheet can be worked through with a pen. */
  .row::before, .runsheet tbody tr td:first-child::before {
    content: "☐  "; font-size: 1.1em;
  }
}
