/* St Martin's parish library: volunteer pages. Phone first.
   Colours and fonts follow the parish website. */
:root {
  --blue: #003366;
  --blue-dark: #00264d;
  --gold: #D4AF37;
  --burgundy: #800020;
  --red: #9F1D35;
  --ink: #3E2723;
  --muted: #6b5c57;
  --green: #2E6B3F;
  --line: #e4e0d6;
  --tint: #eef3f8;
  --focus: rgba(0, 51, 102, 0.25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
}
a { color: var(--blue); }
h1, h2 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; color: var(--burgundy); }
h1 { font-size: 1.95rem; line-height: 1.15; margin: 0.35rem 0 0.75rem; }
h2 { font-size: 1.45rem; line-height: 1.2; margin: 1.75rem 0 0.4rem; }
p { margin: 0.5rem 0; }
.lead { color: var(--muted); margin-top: -0.35rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue); color: #fff;
  border-bottom: 3px solid var(--gold);
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  max-width: 46rem; margin: 0 auto; padding: 0.55rem 1rem 0.15rem;
}
.brand {
  font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 700; font-size: 1.5rem;
  color: #fff; text-decoration: none;
}
.whoami { font-size: 0.85rem; color: rgba(255, 255, 255, 0.82); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.tabs { display: flex; max-width: 46rem; margin: 0 auto; padding: 0 0.4rem; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  flex: 1 0 auto; text-align: center; white-space: nowrap;
  color: rgba(255, 255, 255, 0.85); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  padding: 0.5rem 0.55rem 0.6rem;
}
.tabs a.is-active { color: #fff; box-shadow: inset 0 -4px 0 #fff; }
.late-count {
  display: inline-block; min-width: 1.35em; padding: 0 0.3em; margin-left: 0.1rem;
  border-radius: 3px; background: var(--red); color: #fff;
  font-size: 0.75rem; line-height: 1.35em; text-align: center; vertical-align: 1px;
}

/* ---------- Page ---------- */
.page { max-width: 46rem; margin: 0 auto; padding: 0.75rem 1rem 7rem; }
body.narrow .page { max-width: 26rem; padding-top: 1.75rem; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1rem; margin: 1rem 0; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
input[type=text], input[type=search], input[type=email], input[type=tel], input[type=password],
input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 46px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid #a8a29a; border-radius: 6px;
  padding: 0.6rem 0.75rem;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }
.hint { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); }
.field-error { margin: 0.3rem 0 0; color: var(--red); font-size: 0.9rem; font-weight: 600; }
.check { display: flex; gap: 0.6rem; align-items: center; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--blue); margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.45rem 1rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--blue); background: #fff;
  border: 1px solid var(--blue); border-radius: 6px;
}
.btn:hover { background: var(--tint); }
.btn-primary { color: #fff; background: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #fbeff1; }
.btn-quiet { border-color: transparent; background: transparent; text-decoration: underline; padding-left: 0.4rem; padding-right: 0.4rem; }
.btn-quiet:hover { background: transparent; }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0.3rem 0.85rem; font-size: 0.95rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-icon { width: 48px; padding: 0; flex: 0 0 auto; }
.btn svg { width: 22px; height: 22px; }

/* ---------- Notices ---------- */
.notice { margin: 0.75rem 0; padding: 0.7rem 0.9rem; border-radius: 6px; border: 1px solid var(--line); border-left-width: 4px; background: #fff; }
.notice-ok { border-left-color: var(--green); }
.notice-error { border-left-color: var(--red); }
.notice-info { border-left-color: var(--blue); }
.notice-warn { border-left-color: var(--gold); }
.notice p { margin: 0.25rem 0; }
.notice .actions { margin-top: 0.6rem; }

/* ---------- Search ---------- */
.searchbar { display: flex; gap: 0.5rem; margin: 0.25rem 0 0.5rem; }
.searchbar input { flex: 1; }
.stats { display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; color: var(--muted); font-size: 0.9rem; margin: 0 0 0.5rem; }
.stats strong { color: var(--ink); }

/* ---------- Lists of books, loans, people ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 0.85rem;
  padding: 0.85rem 0; border-bottom: 1px solid var(--line);
}
.item.no-cover { grid-template-columns: minmax(0, 1fr); }
.item > .cover { grid-row: 1 / span 4; }
.cover { display: block; width: 48px; height: 72px; object-fit: cover; border-radius: 3px; background: var(--tint); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.cover-blank {
  display: flex; align-items: center; justify-content: center;
  background: var(--blue); color: var(--gold);
  font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.6rem; font-weight: 700;
}
.cover-lg { width: 96px; height: 144px; font-size: 3rem; }
.item-title { margin: 0; font-weight: 700; line-height: 1.3; }
.item-title a { color: inherit; text-decoration: none; }
.item-title a:hover { text-decoration: underline; }
.item-sub { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.92rem; }
.copy { font-weight: 400; color: var(--muted); white-space: nowrap; }
.status { display: flex; gap: 0.45rem; align-items: baseline; margin: 0.25rem 0 0; font-size: 0.92rem; }
.status::before { content: ''; flex: 0 0 auto; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: currentColor; }
.status-in { color: var(--green); }
.status-out { color: var(--ink); }
.status-late { color: var(--red); font-weight: 600; }
.item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.55rem; }
.item.is-done { opacity: 0.55; }
.contact { display: block; margin-top: 0.15rem; font-size: 0.92rem; }
.contact a { font-weight: 600; }
.contact-none { color: var(--muted); }
.empty { color: var(--muted); padding: 1.25rem 0; }
.count { color: var(--muted); font-family: 'Open Sans', sans-serif; font-weight: 400; font-size: 1rem; }

/* ---------- Lending sheet ---------- */
dialog.sheet {
  width: 100%; max-width: 32rem; max-height: 94vh; padding: 0; border: 0;
  margin: auto auto 0; border-radius: 12px 12px 0 0;
  color: var(--ink); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
}
dialog.sheet::backdrop { background: rgba(0, 20, 40, 0.5); }
@media (min-width: 40rem) { dialog.sheet { margin: auto; border-radius: 12px; } }
.sheet-inner { padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.sheet h2 { margin: 0.15rem 0 0.2rem; }
.sheet-book { margin: 0 0 0.75rem; color: var(--muted); }
.choices { list-style: none; margin: 0.4rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.choices li + li { border-top: 1px solid var(--line); }
.choice {
  display: block; width: 100%; min-height: 48px; padding: 0.6rem 0.8rem;
  text-align: left; font: inherit; color: var(--ink); background: #fff; border: 0; cursor: pointer;
}
.choice:hover, .choice:focus { background: var(--tint); outline: none; }
.choice small { display: block; color: var(--muted); font-size: 0.85rem; }
.choice-new { color: var(--blue); font-weight: 600; }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.55rem 0.4rem 0.55rem 0.8rem; border: 2px solid var(--blue); border-radius: 6px; }
.picked small { display: block; color: var(--muted); }
.newperson { display: grid; gap: 0.75rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: 6px; }
.sheet #lend-submit { margin-top: 1.1rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%); width: calc(100% - 2rem); max-width: 30rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 0.9rem; border-radius: 8px;
  color: #fff; background: var(--blue-dark); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--red); }
.toast-undo {
  flex: 0 0 auto; min-height: 40px; padding: 0.3rem 0.9rem;
  font: inherit; font-weight: 700; color: var(--gold); background: transparent;
  border: 1px solid var(--gold); border-radius: 6px; cursor: pointer;
}

/* ---------- Barcode scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 100; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute; left: 8%; right: 8%; top: 36%; height: 20%;
  border: 3px solid var(--gold); border-radius: 8px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.4); pointer-events: none;
}
.scanner-qr .scanner-frame { left: 50%; right: auto; top: 50%; width: min(70vw, 70vh); height: min(70vw, 70vh); transform: translate(-50%, -50%); }
.scanner-book .scanner-frame { left: 50%; right: auto; top: 50%; width: min(78vw, 70vh); height: min(56vw, 50vh); transform: translate(-50%, -50%); }
.scanner-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(1rem + env(safe-area-inset-top)) 1rem 1rem; text-align: center; font-weight: 600; text-shadow: 0 1px 3px #000; }
.scanner-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
.scanner .btn { min-width: 9rem; }

/* ---------- Menus and misc ---------- */
.menu { list-style: none; margin: 0.5rem 0 1.5rem; padding: 0; border-top: 1px solid var(--line); }
.menu li { border-bottom: 1px solid var(--line); }
.menu a, .menu button {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; width: 100%;
  padding: 0.9rem 0.2rem; font: inherit; font-weight: 600; color: var(--ink);
  text-decoration: none; text-align: left; background: none; border: 0; cursor: pointer;
}
.menu small { display: block; font-weight: 400; color: var(--muted); }
.menu a::after { content: '›'; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.book-head { display: flex; gap: 1rem; align-items: flex-start; margin: 0.5rem 0 1rem; }
.book-head h1 { margin-top: 0; }
.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.history { font-size: 0.92rem; }
.history li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.spaced { margin-top: 1rem; }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 600; color: var(--blue); border: 1px solid var(--blue); border-radius: 4px; padding: 0 0.35rem; margin-left: 0.3rem; vertical-align: 1px; }
.tag-muted { color: var(--muted); border-color: var(--line); }
.found { display: flex; gap: 0.85rem; align-items: flex-start; }
.temp-password { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.02em; }

/* ---------- Sign-in codes ---------- */
.code-panel { text-align: center; }
.qr-box { display: flex; justify-content: center; margin: 0.5rem 0; }
.qr { width: min(64vw, 240px); height: auto; image-rendering: pixelated; }
.code-big { margin: 0.25rem 0 0.5rem; font-size: 1.9rem; font-weight: 700; letter-spacing: 0.12em; color: var(--blue); }
.code-panel .small { text-align: left; }
.admin-login { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.admin-login summary { cursor: pointer; color: var(--blue); font-weight: 600; padding: 0.6rem 0; }

/* ---------- Stickers and borrowing by themselves ---------- */
.filter { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.75rem 0; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.filter a { font-weight: 600; text-decoration: none; padding: 0.3rem 0; }
.filter a.is-active { color: var(--burgundy); box-shadow: inset 0 -3px 0 var(--burgundy); }
.pick-list li { border-bottom: 1px solid var(--line); }
.pick-list .check { align-items: flex-start; padding: 0.6rem 0; }
.pick-list .check input { margin-top: 0.15rem; flex: 0 0 auto; }
.pick-list small { display: block; color: var(--muted); font-size: 0.85rem; }
.sticker-code { font-weight: 700; letter-spacing: 0.08em; color: var(--blue); }
.tag-self { color: var(--green); border-color: var(--green); }
