/* The app's own styles (dark-factory #812, #1078). Three stylesheets, in this order: the platform's theme.css with
   the --theme-* custom properties (light and dark), the utilities .container .prose .stack .cluster .card and the app
   shell's classes (.app-*, .skip-link); brand.css, the project's brand, which the platform writes; then this file.
   Style here, never there: a rule here wins over the theme's.

   Bibliothek Lerchwil, the lending desk. Every colour, space, radius and type size is a --theme-* token; a tint is
   mixed from two tokens where the theme has no step between them. */

/* An element the script hides stays hidden, whatever display its class sets. */
[hidden] {
  display: none !important;
}

/* The demo notice above the header: the platform's voice, so the neutral surfaces and no brand colour. */
.demo-banner {
  padding: var(--theme-space-3xs) var(--theme-space-s);
  font-size: var(--theme-size-step--1);
  color: var(--theme-text-secondary);
  text-align: center;
  background: var(--theme-surface-sunken);
  border-block-end: 1px solid var(--theme-border-subtle);
}

.demo-banner p {
  margin: 0;
}

.demo-banner a,
.demo-banner a:hover,
.demo-banner a:focus-visible {
  color: var(--theme-text-primary);
}

/* The logo in the header's slot and the type of the shell: an old-style serif, set a little larger to read well. */
.brand-mark {
  display: block;
  inline-size: 100%;
  block-size: 100%;
}

.brand-mark-ground {
  fill: var(--theme-accent-base);
}

.brand-mark-page {
  fill: var(--theme-accent-contrast);
}

.brand-mark-fold {
  fill: none;
  stroke: var(--theme-accent-base);
  stroke-width: 1.5;
}

.brand-mark-ribbon {
  fill: var(--theme-highlight-base);
}

body {
  line-height: 1.6;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.footer-note {
  margin-inline-start: auto;
}

/* The hero: the promise, the search, and a shelf with one book leaning where another was taken out. */
.hero {
  display: grid;
  gap: var(--theme-space-m);
  align-items: end;
  padding-block: var(--theme-space-l) 0;
  border-block-end: 2px solid var(--theme-text-primary);
}

.hero-copy {
  padding-block-end: var(--theme-space-l);
}

.hero h1 {
  max-inline-size: 12ch;
  margin-block-end: var(--theme-space-s);
  font-size: var(--theme-size-step-5);
  font-weight: 400;
  font-style: italic;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero-lead {
  max-inline-size: 44ch;
  margin-block-end: var(--theme-space-m);
  font-size: var(--theme-size-step-1);
  color: var(--theme-text-secondary);
}

.search-form {
  display: grid;
  gap: var(--theme-space-xs);
  align-items: end;
  max-inline-size: calc(var(--theme-space-3xl) * 5);
}

@media (min-width: 40em) {
  .search-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

.shelf-art {
  display: block;
  inline-size: 100%;
  max-block-size: calc(var(--theme-space-3xl) * 2);
}

.spine-a {
  fill: var(--theme-accent-base);
}

.spine-b {
  fill: color-mix(in srgb, var(--theme-accent-base) 45%, var(--theme-surface-raised));
}

.spine-c {
  fill: color-mix(in srgb, var(--theme-text-primary) 82%, var(--theme-accent-base));
}

.spine-d {
  fill: var(--theme-highlight-base);
}

.spine-e {
  fill: color-mix(in srgb, var(--theme-text-muted) 60%, var(--theme-surface-raised));
}

.spine-band {
  fill: var(--theme-surface-raised);
  opacity: 0.9;
}

.spine-band-gold {
  fill: var(--theme-highlight-base);
  opacity: 1;
}

.shelf-board {
  fill: var(--theme-text-primary);
}

@media (min-width: 60em) {
  .hero {
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    padding-block-start: var(--theme-space-xl);
  }

  .hero h1 {
    font-size: var(--theme-size-step-6);
  }

  .shelf-art {
    max-block-size: none;
  }
}

/* Form parts every page shares: a field with its label, hint and error, the pills of a choice, a check box. */
.field {
  min-inline-size: 0;
}

.field label,
fieldset legend {
  margin-block-end: var(--theme-space-3xs);
  font-size: var(--theme-size-step--1);
  font-weight: 600;
  color: var(--theme-text-secondary);
}

.field-hint {
  margin: var(--theme-space-3xs) 0 0;
  font-size: var(--theme-size-step--1);
  color: var(--theme-text-muted);
}

.field-error {
  margin: var(--theme-space-3xs) 0 0;
  font-size: var(--theme-size-step--1);
  font-weight: 600;
  color: var(--theme-state-danger);
}

[aria-invalid='true'] {
  border-color: var(--theme-state-danger);
  outline: 1px solid var(--theme-state-danger);
}

fieldset {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset legend {
  padding: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-2xs);
}

.chip {
  position: relative;
  display: inline-flex;
  margin: 0;
  color: var(--theme-text-primary);
  cursor: pointer;
}

.chip input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.chip > span {
  display: inline-flex;
  gap: var(--theme-space-2xs);
  align-items: center;
  min-block-size: var(--theme-control-min);
  padding: var(--theme-space-2xs) var(--theme-space-s);
  border-block-end: 2px solid var(--theme-border-subtle);
}

.chip:hover > span {
  border-color: var(--theme-accent-base);
}

.chip input:checked + span {
  font-weight: 600;
  color: var(--theme-accent-base);
  border-color: var(--theme-accent-base);
}

.chip input:checked + span::before {
  inline-size: var(--theme-space-2xs);
  block-size: var(--theme-space-2xs);
  content: '';
  background: currentColor;
  transform: rotate(45deg);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--theme-accent-base);
  outline-offset: 2px;
}

.chip-count {
  font-size: var(--theme-size-step--1);
  font-variant-numeric: tabular-nums;
  color: var(--theme-text-muted);
}

.check {
  display: inline-flex;
  gap: var(--theme-space-2xs);
  align-items: center;
  min-block-size: var(--theme-control-min);
  margin: 0;
  color: var(--theme-text-primary);
  cursor: pointer;
}

.check input {
  inline-size: var(--theme-space-m);
  block-size: var(--theme-space-m);
  margin: 0;
  accent-color: var(--theme-accent-base);
}

.button-link,
.button-link:hover,
.button-link:focus-visible {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--theme-control-min);
  padding: var(--theme-space-2xs) var(--theme-space-s);
  font-weight: 600;
  color: var(--theme-accent-contrast);
  text-decoration: none;
  background: var(--theme-accent-base);
  border-radius: var(--theme-radius-m);
}

.button-link:hover,
.button-link:focus-visible {
  background: var(--theme-accent-strong);
}

button {
  font-weight: 600;
}

/* The catalogue: its head, its tools, then the covers. */
.catalogue {
  margin-block-start: var(--theme-space-xl);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-3xs) var(--theme-space-m);
  align-items: baseline;
  justify-content: space-between;
  margin-block-end: var(--theme-space-s);
}

.section-head h2 {
  margin: 0;
}

.section-count {
  margin: 0;
  color: var(--theme-text-secondary);
}

.tools {
  display: grid;
  gap: var(--theme-space-s);
  margin-block-end: var(--theme-space-l);
}

.tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-s) var(--theme-space-l);
  align-items: center;
  justify-content: space-between;
}

.field-inline {
  display: flex;
  gap: var(--theme-space-xs);
  align-items: center;
}

.field-inline label {
  flex: none;
  margin: 0;
}

.books {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--theme-space-l) var(--theme-space-s);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 36em) {
  .books {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--theme-space-m);
  }
}

@media (min-width: 48em) {
  .books {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 64em) {
  .books {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .books .cover-title {
    font-size: var(--theme-size-step-1);
  }
}

.book p {
  margin: 0;
}

.book-link {
  display: block;
  margin-block-end: var(--theme-space-xs);
  text-decoration: none;
  border-radius: var(--theme-radius-s);
  transition: transform 150ms ease-out;
}

.book-link:hover {
  transform: translateY(calc(var(--theme-space-3xs) * -1));
}

.book-link:focus-visible {
  outline-offset: var(--theme-space-3xs);
}

/* A cover: cloth in the section's colour, a ruled frame, the author above the title, the shelf mark on its label. */
.cover {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--theme-space-2xs);
  aspect-ratio: 2 / 3;
  padding: var(--theme-space-s) var(--theme-space-xs) var(--theme-space-xs) var(--theme-space-s);
  overflow: hidden;
  color: var(--theme-accent-contrast);
  background: var(--theme-accent-base);
  border-radius: var(--theme-radius-s);
}

/* The hinge of the binding, a darker strip along the spine side. */
.cover::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: var(--theme-space-2xs);
  content: '';
  background: currentColor;
  opacity: 0.22;
}

.cover-author {
  font-size: var(--theme-size-step--2);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.cover-title {
  margin: 0;
  padding-block-start: var(--theme-space-2xs);
  font-size: var(--theme-size-step-0);
  font-weight: 600;
  font-style: italic;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  border-block-start: 1px solid currentColor;
}

/* The tooled frame of a cloth binding, a hair inside the edge. */
.cover::after {
  position: absolute;
  inset: var(--theme-space-3xs);
  inset-inline-start: var(--theme-space-xs);
  content: '';
  border: 1px solid currentColor;
  border-radius: var(--theme-radius-s);
  opacity: 0.35;
  pointer-events: none;
}

.cover-foot {
  display: flex;
  gap: var(--theme-space-2xs);
  align-items: baseline;
  justify-content: space-between;
  margin-block-start: auto;
}

.cover-year {
  font-size: var(--theme-size-step--2);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.cover-mark {
  padding: 0 var(--theme-space-2xs);
  font-family: var(--theme-font-mono);
  font-size: var(--theme-size-step--2);
  line-height: 1.6;
  color: var(--theme-text-primary);
  background: var(--theme-surface-raised);
  border: 1px solid var(--theme-border-strong);
  border-radius: var(--theme-radius-s);
}

.cover-crime {
  color: var(--theme-surface-raised);
  background: color-mix(in srgb, var(--theme-text-primary) 88%, var(--theme-accent-base));
}

.cover-nature {
  color: var(--theme-text-primary);
  background: color-mix(in srgb, var(--theme-accent-base) 24%, var(--theme-surface-raised));
}

.cover-children {
  color: var(--theme-text-primary);
  background: color-mix(in srgb, var(--theme-highlight-base) 38%, var(--theme-surface-raised));
}

.cover-local-history {
  color: var(--theme-text-primary);
  background: var(--theme-surface-sunken);
  border: 1px solid var(--theme-border-strong);
}

.shelf-state {
  font-weight: 600;
}

.shelf-state::before {
  display: inline-block;
  inline-size: var(--theme-space-2xs);
  block-size: var(--theme-space-2xs);
  margin-inline-end: var(--theme-space-2xs);
  vertical-align: 0.1em;
  content: '';
  border: 2px solid currentColor;
  border-radius: var(--theme-radius-full);
}

.is-on-shelf {
  color: var(--theme-state-success);
}

.is-on-shelf::before {
  background: currentColor;
}

.is-out {
  color: var(--theme-text-secondary);
}

.book-meta,
.loan-meta {
  font-size: var(--theme-size-step--1);
  color: var(--theme-text-muted);
}

[aria-busy='true'] {
  opacity: 0.55;
  transition: opacity 120ms ease-out;
}

/* One title: the cover, the text, and the loan beside them. */
.back {
  margin: 0;
}

.back a {
  display: inline-flex;
  align-items: center;
  min-block-size: var(--theme-control-min);
}

.book-page {
  display: grid;
  gap: var(--theme-space-l);
  align-items: start;
}

.book-cover {
  max-inline-size: calc(var(--theme-space-3xl) * 2);
}

.book-cover .cover {
  padding: var(--theme-space-m) var(--theme-space-s) var(--theme-space-s) var(--theme-space-m);
}

.book-cover .cover-author {
  font-size: var(--theme-size-step--1);
}

.book-cover .cover-title {
  font-size: var(--theme-size-step-2);
}

.book-cover .cover-mark {
  font-size: var(--theme-size-step--1);
}

@media (min-width: 40em) {
  .book-page {
    grid-template-columns: calc(var(--theme-space-3xl) * 2) minmax(0, 1fr);
  }

  .lend {
    grid-column: 1 / -1;
  }
}

@media (min-width: 64em) {
  .book-page {
    grid-template-columns: calc(var(--theme-space-3xl) * 2) minmax(0, 1fr) calc(var(--theme-space-3xl) * 3);
    gap: var(--theme-space-xl);
  }

  .lend {
    grid-column: auto;
  }
}

.book-section {
  margin: 0 0 var(--theme-space-3xs);
  font-weight: 600;
  color: var(--theme-accent-base);
}

.book-text h1 {
  margin-block-end: var(--theme-space-2xs);
  font-size: var(--theme-size-step-5);
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
}

.book-author {
  font-size: var(--theme-size-step-1);
  color: var(--theme-text-secondary);
}

.book-blurb {
  font-size: var(--theme-size-step-1);
}

.facts {
  margin: var(--theme-space-m) 0 0;
}

.facts div {
  display: flex;
  gap: var(--theme-space-s);
  align-items: baseline;
  justify-content: space-between;
  padding-block: var(--theme-space-2xs);
  border-block-start: 1px solid var(--theme-border-subtle);
}

.facts dt {
  flex: none;
  color: var(--theme-text-secondary);
}

.facts dd {
  margin: 0;
  text-align: end;
}

.lend-form,
.slip {
  display: grid;
  gap: var(--theme-space-s);
  padding: var(--theme-space-m);
  background: var(--theme-surface-raised);
  border: 1px solid var(--theme-border-subtle);
  border-radius: var(--theme-radius-l);
}

.lend-form h2,
.slip h2 {
  margin: 0;
  font-size: var(--theme-size-step-2);
}

.lend-form p,
.slip p {
  margin: 0;
}

.due-list {
  margin: 0;
  padding: 0;
  color: var(--theme-text-secondary);
  list-style: none;
}

.due-list:empty {
  display: none;
}

.form-status {
  align-items: flex-start;
  padding: var(--theme-space-s);
  text-align: start;
}

.slip {
  border-color: var(--theme-state-success);
}

.slip .facts {
  margin: 0;
}

.slip-state {
  font-weight: 600;
  color: var(--theme-state-success);
}

.slip-state::before {
  content: '✓ ';
}

/* The date stamp: the library's ink, a little off the line as a hand sets it. */
.stamp {
  display: inline-flex;
  flex-direction: column;
  justify-self: start;
  margin: 0;
  padding: var(--theme-space-3xs) var(--theme-space-xs);
  font-family: var(--theme-font-mono);
  font-size: var(--theme-size-step-0);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: var(--theme-accent-base);
  white-space: nowrap;
  border: 2px solid currentColor;
  border-radius: var(--theme-radius-s);
  transform: rotate(-2deg);
}

.stamp-label {
  font-family: var(--theme-font-sans);
  font-size: var(--theme-size-step--2);
  font-weight: 600;
}

.stamp-large {
  padding: var(--theme-space-2xs) var(--theme-space-s);
  font-size: var(--theme-size-step-3);
}

.stamp-large .stamp-label {
  font-size: var(--theme-size-step--1);
}

/* The desk's list of loans. */
.page-head h1 {
  margin-block-end: var(--theme-space-2xs);
  font-size: var(--theme-size-step-5);
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
}

.page-lead {
  max-inline-size: 62ch;
  font-size: var(--theme-size-step-1);
  color: var(--theme-text-secondary);
}

.tally {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--theme-space-s);
  margin: var(--theme-space-m) 0;
  padding-block: var(--theme-space-s);
  border-block: 1px solid var(--theme-border-subtle);
}

.tally div {
  display: flex;
  flex-direction: column-reverse;
}

.tally div + div {
  padding-inline-start: var(--theme-space-s);
  border-inline-start: 1px solid var(--theme-border-subtle);
}

.tally dt {
  font-size: var(--theme-size-step--1);
  color: var(--theme-text-secondary);
}

.tally dd {
  margin: 0;
  font-size: var(--theme-size-step-5);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.tally-overdue dd {
  color: var(--theme-state-danger);
}

.notice {
  margin: var(--theme-space-s) 0 0;
  padding: var(--theme-space-xs) var(--theme-space-s);
  font-weight: 600;
  color: var(--theme-state-success);
  background: var(--theme-surface-raised);
  border-inline-start: 4px solid var(--theme-state-success);
}

.loans {
  margin: var(--theme-space-m) 0 0;
  padding: 0;
  list-style: none;
  border-block-start: 2px solid var(--theme-text-primary);
}

.loan {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--theme-space-xs) var(--theme-space-m);
  align-items: center;
  padding: var(--theme-space-s) var(--theme-space-3xs);
  border-block-end: 1px solid var(--theme-border-subtle);
}

.loan p,
.loan-title {
  margin: 0;
}

.loan-title {
  font-size: var(--theme-size-step-1);
  font-style: italic;
}

.loan-title a {
  color: var(--theme-text-primary);
  text-decoration-color: var(--theme-border-strong);
}

.loan-title a:hover {
  color: var(--theme-accent-base);
}

.loan-state,
.loan-action {
  grid-column: 2;
}

.loan-action:empty {
  display: none;
}

.loan-overdue .stamp {
  color: var(--theme-state-danger);
}

.loan-returned .stamp {
  color: var(--theme-text-muted);
  border-style: dashed;
}

.status {
  font-weight: 600;
}

.status-overdue {
  color: var(--theme-state-danger);
}

.status-overdue::before {
  content: '! ';
}

.status-due-soon {
  color: var(--theme-state-warning);
}

.status-returned {
  color: var(--theme-text-muted);
}

.status-returned::before {
  content: '✓ ';
}

@media (min-width: 52em) {
  .loan {
    grid-template-columns: calc(var(--theme-space-3xl) * 1.25) minmax(0, 1fr) calc(var(--theme-space-3xl) * 1.5) calc(var(--theme-space-3xl) * 1.25);
  }

  .loan-state,
  .loan-action {
    grid-column: auto;
  }

  .loan-action {
    justify-self: end;
  }

  .loan-action:empty {
    display: block;
  }
}

/* The visit page. */
.visit {
  display: grid;
  gap: var(--theme-space-m);
  margin-block-start: var(--theme-space-m);
}

@media (min-width: 60em) {
  .visit {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }

  .rules,
  .steps-section {
    grid-column: 1 / -1;
  }
}

.visit h2 {
  font-size: var(--theme-size-step-2);
}

.visit address {
  margin-block-end: var(--theme-space-s);
  font-style: normal;
  font-weight: 600;
}

.visit .facts div {
  display: block;
}

.visit .facts dt {
  font-size: var(--theme-size-step--1);
  font-weight: 600;
}

.visit .facts dd {
  text-align: start;
}

.table-scroll {
  overflow-x: auto;
}

.table-scroll th[scope='row'] {
  font-weight: 400;
  color: var(--theme-text-primary);
}

.rules,
.steps-section {
  padding-block-start: var(--theme-space-m);
}

.rule-list {
  display: grid;
  gap: var(--theme-space-m);
  margin: 0;
}

@media (min-width: 40em) {
  .rule-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64em) {
  .rule-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.rule-list div {
  padding-block-start: var(--theme-space-xs);
  border-block-start: 2px solid var(--theme-highlight-base);
}

.rule-list dt {
  font-size: var(--theme-size-step-2);
  font-style: italic;
  line-height: 1.2;
}

.rule-list dd {
  margin: var(--theme-space-2xs) 0 0;
  color: var(--theme-text-secondary);
}

.steps {
  display: grid;
  gap: var(--theme-space-m);
  margin: 0 0 var(--theme-space-m);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

@media (min-width: 48em) {
  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.steps li {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--theme-space-xs);
  counter-increment: step;
}

.steps li::before {
  grid-row: span 2;
  font-size: var(--theme-size-step-3);
  font-style: italic;
  line-height: 1.1;
  color: var(--theme-accent-base);
  content: counter(step) '.';
}

.steps h3 {
  margin-block-end: var(--theme-space-3xs);
  font-size: var(--theme-size-step-1);
}

.steps p {
  margin: 0;
  color: var(--theme-text-secondary);
}

@media (prefers-reduced-motion: reduce) {
  .book-link,
  [aria-busy='true'] {
    transition: none;
  }

  .book-link:hover {
    transform: none;
  }
}
