@font-face {
  font-family: "Newsreader";
  src: url("/static/fonts/newsreader-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Signalgelb: black and gold, after the Baden-Württemberg colours */
  --paper: #fffdf6;
  --surface: #ffffff;
  --field: #f6f2e4;
  --field-border: #d9d3bf;
  --ink: #1a1a17;
  --muted: #57544c;
  --rule: #e8e4d6;
  --band: #1a1a17;
  --band-ink: #fffdf6;
  --band-muted: #c8c4b6;
  --accent: #f2c230;
  --accent-hover: #e0b01f;
  --accent-ink: #1a1a17;

  /* Availability: text and tint pairs, each at least 5.5:1 */
  --ok: #1e6b3a;
  --ok-wash: #e3f1e6;
  --loan: #7a4e00;
  --loan-wash: #fcefc7;
  --none: #57544c;
  --none-wash: #eeebe0;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* One spacing scale: 4, 8, 12, 16, 24, 32, 48, 64 px */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* One type scale: 14, 16, 18, 22, 32 px */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.375rem;
  --text-xl: clamp(1.625rem, 1.2rem + 1.5vw, 2rem);

  --page: 65rem;
  --gutter: clamp(var(--space-4), 4vw, var(--space-6));
  --measure: 68ch;
  --radius-s: 4px;
  --radius: 12px;
  --radius-l: 16px;
  --control: 3rem;
  --control-l: 3.5rem;
  --hang-bullet: 1rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.25;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

@supports not (hanging-punctuation: first last) {
  .hang-start {
    text-indent: calc(-1 * var(--hang, 0.42em));
  }
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

:where(a, button, input, select, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ----------------------------------------------------------- layout ---- */

.site-header-inner,
.site-main,
.site-footer {
  width: min(100% - (2 * var(--gutter)), var(--page));
  margin-inline: auto;
}

.site-header {
  background: var(--band);
  color: var(--band-ink);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-5);
}

/* Pages with a search panel let it overlap the band. */
.site-header.has-panel .site-header-inner {
  padding-bottom: calc(var(--space-8) + var(--space-5));
}

.site-header :focus-visible {
  outline-color: var(--accent);
}

.site-title {
  color: var(--band-ink);
  font-family: var(--serif);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

.site-title:hover {
  text-decoration: underline;
}

.site-opac {
  color: var(--band-muted);
  font-size: var(--text-sm);
}

.site-opac:hover {
  color: var(--band-ink);
}

.site-main {
  padding-block: var(--space-7) var(--space-8);
}

.site-header.has-panel + .site-main {
  padding-top: 0;
}

.site-main:focus {
  outline: none;
}

h1 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-xl);
}

h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
}

.lede {
  max-width: var(--measure);
  margin: var(--space-6) 0 0;
  color: var(--muted);
  font-size: var(--text-md);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  padding-block: var(--space-5) var(--space-7);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--text-sm);
}

.site-footer p {
  margin: 0;
}

/* ---------------------------------------------------------- buttons ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control);
  padding: 0 var(--space-5);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: var(--accent-ink);
}

.button-secondary {
  border-color: var(--field-border);
  background: var(--surface);
}

.button-secondary:hover {
  border-color: var(--ink);
  background: var(--surface);
}

/* ----------------------------------------------------------- search ---- */

.search-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: calc(-1 * var(--space-8)) 0 var(--space-7);
  padding: var(--space-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-l);
  background: var(--surface);
}

.search-label {
  font-weight: 600;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.search-row input {
  flex: 999 1 18rem;
  min-width: 0;
  min-height: var(--control-l);
  padding: 0 var(--space-4);
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-md);
}

.search-row input:hover {
  border-color: var(--muted);
}

/* The field highlights its own edge instead of the offset outline. */
.search-row input:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  background: var(--surface);
}

.search-row .button {
  flex: 1 0 auto;
  min-height: var(--control-l);
  padding-inline: var(--space-6);
}

.search-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.search-fields legend {
  float: left;
  margin-right: var(--space-2);
  padding: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.search-fields label {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 var(--space-4);
  border-radius: 999px;
  background: var(--field);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

.search-fields label:hover {
  background: var(--rule);
}

.search-fields input:checked + label {
  background: var(--ink);
  color: var(--paper);
}

.search-fields input:focus-visible + label {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.suggestions:empty {
  display: none;
}

.suggestions-title {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
}

.suggestions-list {
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  list-style: none;
  overflow: hidden;
}

.progress {
  height: 2px;
  margin: calc(-1 * var(--space-6)) 0 var(--space-6);
  border-radius: 1px;
  background: transparent;
  transition: background-color 140ms ease;
}

.progress.htmx-request {
  background: var(--accent);
}

/* ----------------------------------------------------------- covers ---- */

/* The ekz image sits on top of a typographic cover drawn from the title. The
   art shows while the image loads, and stays when it is missing or fails.
   Sizes use container units so one design scales from thumbnail to record. */
.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-image[hidden] {
  display: none;
}

.cover-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 5cqi;
  overflow: hidden;
  padding: 10cqi 9cqi;
  background: var(--cover-bg);
  box-shadow: inset 0 0 0 1px rgb(26 26 23 / 0.08);
  color: var(--cover-ink);
}

.cover-art::after {
  content: "";
  position: absolute;
}

.cover-title,
.cover-author {
  position: relative;
  z-index: 1;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
}

.cover-title {
  font-family: var(--serif);
  font-size: 16cqi;
  font-weight: 600;
  line-height: 1.1;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.cover-author {
  font-size: 7.5cqi;
  line-height: 1.3;
  opacity: 0.85;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* Thumbnails keep the title; the author would be illegible. */
@container (max-width: 4.5rem) {
  .cover-author {
    display: none;
  }
}

.motif-band::after {
  inset: auto 0 10% 0;
  height: 18%;
  background: var(--cover-accent);
}

.motif-disc::after {
  right: -28%;
  bottom: -22%;
  width: 82%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--cover-accent);
}

.motif-rules::after {
  inset: auto 9cqi 10% 9cqi;
  height: 17cqi;
  background: repeating-linear-gradient(
    to bottom,
    var(--cover-accent) 0 3cqi,
    transparent 3cqi 7cqi
  );
}

.palette-ink {
  --cover-bg: #1a1a17;
  --cover-ink: #fffdf6;
  --cover-accent: #f2c230;
}

.palette-gold {
  --cover-bg: #f2c230;
  --cover-ink: #1a1a17;
  --cover-accent: #1a1a17;
}

.palette-oxblood {
  --cover-bg: #6e1f2b;
  --cover-ink: #fbefe6;
  --cover-accent: #e9a36b;
}

.palette-forest {
  --cover-bg: #1f4d3a;
  --cover-ink: #f4f0e0;
  --cover-accent: #d9b84a;
}

.palette-petrol {
  --cover-bg: #0f5960;
  --cover-ink: #eef6f4;
  --cover-accent: #f08b68;
}

.palette-ultramarine {
  --cover-bg: #26358c;
  --cover-ink: #f3f1ea;
  --cover-accent: #f2c230;
}

.palette-terracotta {
  --cover-bg: #b9532c;
  --cover-ink: #fff6ee;
  --cover-accent: #2a1a12;
}

.palette-paper {
  --cover-bg: #efe7d4;
  --cover-ink: #1a1a17;
  --cover-accent: #b8402c;
}

/* ---------------------------------------------------------- results ---- */

.results {
  scroll-margin-top: var(--space-4);
}

.results:focus {
  outline: none;
}

.results-status {
  border-bottom: 1px solid var(--rule);
}

.results-count {
  margin: 0;
  padding-bottom: var(--space-4);
  font-family: var(--serif);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.25;
}

.results-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hit {
  position: relative;
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: var(--space-5);
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--rule);
}

.hit-cover {
  position: relative;
  width: 4rem;
  height: 6rem;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--field);
  container-type: inline-size;
}

.hit-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.hit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.hit-title {
  flex: 1 1 20rem;
  min-width: 0;
  margin: 0;
  font-family: var(--serif);
  font-size: var(--text-lg);
  line-height: 1.3;
}

.hit-title a {
  text-decoration: none;
}

.hit-title a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* The title link covers the whole row. */
.hit-title a::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
}

.hit-subtitle {
  display: block;
  color: var(--muted);
  font-size: var(--text-md);
}

.hit-details {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0 var(--space-3);
  border-radius: 999px;
  background: var(--none-wash);
  color: var(--none);
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status.available {
  background: var(--ok-wash);
  color: var(--ok);
}

.status.on-loan {
  background: var(--loan-wash);
  color: var(--loan);
}

/* Suggestions reuse the hit row at a smaller scale: one line per field. */
.hit.compact {
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
}

.hit.compact:last-child {
  border-bottom: 0;
}

.hit.compact:hover,
.hit.compact:focus-within {
  background: var(--field);
}

.hit.compact .hit-cover {
  width: 2.5rem;
  height: 3.75rem;
}

.hit.compact .hit-body {
  gap: var(--space-1);
}

.hit.compact .hit-head {
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

.hit.compact .hit-title {
  display: -webkit-box;
  flex-basis: 12rem;
  overflow: hidden;
  font-size: var(--text-md);
  font-weight: 600;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.hit.compact .hit-details {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit.compact .status {
  min-height: 1.5rem;
}

.more-region {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.more-region .button {
  border-color: var(--field-border);
  background: var(--surface);
}

.more-region .button:hover {
  border-color: var(--ink);
}

.more-error:empty {
  display: none;
}

/* ----------------------------------------------------------- record ---- */

.record-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-7);
}

.record-head h1 {
  margin: 0;
}

.record-subtitle {
  margin: 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: var(--text-lg);
  line-height: 1.3;
}

.record-statement {
  margin: 0;
  color: var(--muted);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.record-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: var(--space-7);
  align-items: start;
}

.record-aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.record-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--field);
  container-type: inline-size;
}

.record-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  font-size: var(--text-sm);
}

.record-meta dt {
  margin-top: var(--space-4);
  color: var(--muted);
}

.record-meta dt:first-child {
  margin-top: 0;
}

.record-meta dd {
  margin: var(--space-1) 0 0;
  overflow-wrap: anywhere;
}

.record-main {
  min-width: 0;
}

.record-main > .record-section + .record-section {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--rule);
}

.record-description {
  max-width: var(--measure);
  margin: 0;
  white-space: pre-line;
}

.record-links {
  margin-block: 0;
  margin-inline-start: calc(-1 * var(--hang-bullet));
  padding-inline-start: var(--hang-bullet);
}

.availability-summary {
  margin: 0 0 var(--space-4);
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.copy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.copy-table .align-end {
  text-align: right;
}

.copy-table .nowrap {
  white-space: nowrap;
}

.copy-table th,
.copy-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.copy-table th:first-child,
.copy-table td:first-child {
  padding-left: 0;
}

.copy-table th:last-child,
.copy-table td:last-child {
  padding-right: 0;
}

.copy-table th {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.copy-table td .status {
  min-height: 1.5rem;
  padding-inline: var(--space-2);
  white-space: normal;
}

.copy-table tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------------------------------------------------------- notices ---- */

.notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  background: var(--field);
}

.notice p {
  margin: 0 0 var(--space-2);
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice a {
  font-weight: 600;
}

.results-status .notice {
  margin-bottom: var(--space-4);
}

/* -------------------------------------------------------- responsive ---- */

@media (max-width: 768px) {
  .record-layout {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .record-aside {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    align-items: start;
    gap: var(--space-4);
  }

  .copy-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .copy-table,
  .copy-table tbody,
  .copy-table tr,
  .copy-table td {
    display: block;
    width: 100%;
  }

  .copy-table tr {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--rule);
  }

  .copy-table tbody tr:last-child {
    border-bottom: 0;
  }

  .copy-table td {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: var(--space-3);
    padding: var(--space-1) 0;
    border: 0;
  }

  .copy-table td.align-end {
    text-align: left;
  }

  .copy-table td::before {
    content: attr(data-label);
    color: var(--muted);
  }

  .copy-table td .status {
    justify-self: start;
  }
}

@media (max-width: 480px) {
  .search-panel {
    padding: var(--space-4);
  }

  .hit {
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: var(--space-4);
  }

  .hit-cover {
    width: 3rem;
    height: 4.5rem;
  }

  .record-aside {
    grid-template-columns: 7rem minmax(0, 1fr);
  }

  .record-actions .button {
    width: 100%;
  }

  .record-links {
    margin-inline-start: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
