/* Shared components (DESIGN.md §5). Each has a template in templates/components/. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-5);
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn--primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn--secondary { background: transparent; color: var(--text); border-color: var(--primary); }
.btn--danger { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.btn--small { min-height: var(--tap); padding: 0 var(--space-4); font-size: var(--text-sm); }
.btn:hover { text-decoration: underline; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Chips and filters ---------- */
.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1);
  margin: calc(-1 * var(--space-1));
  scrollbar-width: thin;
}
@media (min-width: 768px) { .chips { flex-wrap: wrap; overflow: visible; } }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex: none;
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip .icon { display: none; }
.chip[aria-pressed="true"] .icon { display: inline; }
/* Chips look 40px tall (DESIGN §5); this makes the tap area 44px (DESIGN §7). */
.chip, .suggestion-chip label { position: relative; }
.chip::after, .suggestion-chip label::after { content: ""; position: absolute; inset: -3px -1px; }

/* Suggestion chips: a real checkbox (kept focusable, visually hidden) and a chip-styled label. */
.suggestion-chips { border: 0; margin: 0; padding: 0; min-width: 0; }
.suggestion-chips legend { padding: 0; margin-bottom: var(--space-1); font-weight: 600; }
.suggestion-chips .hint { margin: 0 0 var(--space-2); }
.suggestion-chips__options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.suggestion-chip { position: relative; }
.suggestion-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.suggestion-chip label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}
.suggestion-chip__added { display: none; }
.suggestion-chip input:checked + label { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.suggestion-chip input:checked + label .suggestion-chip__add { display: none; }
.suggestion-chip input:checked + label .suggestion-chip__added { display: inline; }
.suggestion-chip input:focus-visible + label { outline: 3px solid var(--text); outline-offset: 2px; box-shadow: 0 0 0 6px var(--focus); }

/* ---------- Status badges: always icon + text ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3) 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; }
.badge--available { background: var(--badge-available-bg); color: var(--badge-available-fg); }
.badge--checked-out { background: var(--badge-checked-out-bg); color: var(--badge-checked-out-fg); }
.badge--unavailable { background: var(--badge-unavailable-bg); color: var(--badge-unavailable-fg); }
.badge--held { background: var(--badge-held-bg); color: var(--badge-held-fg); }
.badge--reserved { background: var(--badge-reserved-bg); color: var(--badge-reserved-fg); }
.badge--processing,
.badge--needs-details { background: var(--badge-processing-bg); color: var(--badge-processing-fg); }
.badge--returned { background: var(--badge-returned-bg); color: var(--badge-returned-fg); }
.badge--overdue, .badge--lost, .badge--error { background: var(--badge-error-bg); color: var(--badge-error-fg); }

/* ---------- Book cover frame (2:3) ---------- */
.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  box-shadow: var(--shadow-book);
  background: var(--header);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }

.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 14% 10% 10%;
  border: 1.5px solid var(--placeholder-border);
  border-radius: inherit;
  background: var(--header);
  color: var(--text);
  text-align: center;
}
.cover-placeholder__mark {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(2.5rem, 9vw, 4.5rem);
  line-height: 1;
}
.cover-placeholder__title {
  margin-top: auto;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(0.9rem, 2.4vw, 1.25rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.cover-placeholder__author {
  margin-top: var(--space-2);
  margin-bottom: auto;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Wishlist heart ---------- */
.heart {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.heart[aria-pressed="true"] { color: var(--heart); }
.heart[aria-pressed="true"] .icon { fill: currentColor; }

/* ---------- Book card and grid ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-8) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 640px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-8) var(--space-6); }
}
.book-card { display: flex; flex-direction: column; gap: var(--space-2); }
.book-card__cover { position: relative; margin-bottom: var(--space-2); }
.book-card__cover > a { display: block; color: inherit; text-decoration: none; }
.book-card__title { margin: 0; font-family: var(--font-sans); font-size: var(--text-body); font-weight: 700; line-height: 1.3; }
.book-card__title a { text-decoration: none; }
.book-card__title a:hover { text-decoration: underline; }
.book-card__author { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; margin-top: var(--space-4); }
.pagination a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---------- Cards and list rows ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
}
.list-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-row);
}

/* ---------- Form fields ---------- */
.field { display: grid; gap: var(--space-1); }
.field label { font-weight: 600; }
.field .hint { color: var(--text-muted); font-size: var(--text-sm); }
.input, .field input, .field select, .field textarea {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field textarea { min-height: 96px; resize: vertical; }
.field--invalid input { border-color: var(--danger); border-width: 2px; }
.field__error {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  margin: 0;
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 600;
}
.checkbox { display: flex; gap: var(--space-3); align-items: flex-start; }
.checkbox input { flex: none; width: 24px; height: 24px; margin-top: 2px; accent-color: var(--primary); }
/* Padding makes the label 44px to tap; the negative margin keeps the spacing as it was. */
.checkbox label { font-weight: 400; padding-block: 10px; margin-block: -10px; }
/* A group of checkboxes or radio buttons in a fieldset (components/checkbox_group.html). */
.checkbox-group { border: 0; margin-inline: 0; margin-bottom: 0; padding: 0; min-width: 0; }
.checkbox-group legend { padding: 0; margin-bottom: var(--space-2); font-weight: 600; }
.checkbox-group__options { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.checkbox-group__options--vertical { flex-direction: column; gap: 0; }
.checkbox-group .checkbox { align-items: center; min-height: var(--tap); }

/* An error for the whole form, e.g. "Too many attempts". */
.form-alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-input);
  background: var(--badge-error-bg);
  color: var(--badge-error-fg);
}
.form-alert svg { flex: none; margin-top: 3px; }
.form-alert p { margin: 0; }
.form-alert p + p { margin-top: var(--space-2); }
.form-alert a { color: inherit; font-weight: 600; }
.form-note { padding: var(--space-3) var(--space-4); border-radius: var(--radius-input); background: var(--header); }

/* ---------- Sign-up, login, logout and password pages ---------- */
.auth { max-width: 30rem; margin-inline: auto; }
.auth .card .btn { width: 100%; justify-content: center; }

/* ---------- Tables (staff) ---------- */
.table-wrap {
  /* Positioned, so visually hidden labels inside are clipped with the table, not the page. */
  position: relative;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-input);
  background: var(--primary);
  color: var(--on-primary);
}
.bulk-bar .btn--secondary { color: var(--on-primary); border-color: var(--on-primary); }

/* Inline rejection form (opens under its row). */
.inline-form { display: grid; gap: var(--space-3); padding: var(--space-4); background: var(--bg); border-radius: var(--radius-input); }

/* ---------- Offer card ---------- */
.offer-card { display: grid; grid-template-columns: 96px 1fr; gap: var(--space-4); align-items: start; }

/* ---------- Member barcode card: always black on white, in both themes ---------- */
.barcode-card {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  background: #FFFFFF;
  color: #000000;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  text-align: center;
}
.barcode-card__bars { width: 100%; max-width: 360px; min-height: 96px; background: #FFFFFF; }
.barcode-card__bars svg { width: 100%; height: auto; min-height: 96px; }
.barcode-card__code { font-family: var(--font-mono); font-weight: 500; font-size: 1.25rem; letter-spacing: 0.12em; color: #000000; }
.barcode-card__hint { margin: 0; font-size: var(--text-sm); color: #3B3B3B; }
.barcode-card .btn--secondary { color: #000000; border-color: #000000; }
.barcode-card:fullscreen { border: 0; border-radius: 0; align-content: center; }
.barcode-card:fullscreen .barcode-card__bars { max-width: 90vw; }

/* ---------- Scan desk ---------- */
.scan-input {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 72px;
  padding: 0 var(--space-5);
  background: #FFFFFF;
  color: #000000;
  border: 3px solid var(--primary);
  border-radius: var(--radius-card);
  box-shadow: 0 0 0 6px var(--focus);
}
.scan-input input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: #000000;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.625rem;
}
.scan-input input:focus { outline: none; box-shadow: none; } /* The whole box shows the focus ring. */
.scan-input:focus-within { outline: 3px solid var(--text); outline-offset: 3px; }

.feedback-banner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-card);
}
.feedback-banner__icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: currentColor;
}
.feedback-banner__icon .icon { color: var(--surface); }
.feedback-banner__headline { margin: 0; font-family: var(--font-sans); font-size: 1.625rem; font-weight: 700; }
.feedback-banner__detail { margin: 0; }
.feedback-banner--success { background: var(--badge-available-bg); color: var(--badge-available-fg); }
.feedback-banner--error { background: var(--badge-error-bg); color: var(--badge-error-fg); }

/* ---------- Messages after an action ---------- */
.messages { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }
.message {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-input);
  background: var(--header);
}
.message svg { flex: none; margin-top: 3px; }
.message--success { background: var(--badge-available-bg); color: var(--badge-available-fg); }
.message--error, .message--warning { background: var(--badge-error-bg); color: var(--badge-error-fg); }
