/*
 * catalog.css — Korpus-Uebersichtsseite (docs/index.html)
 * Geladen nach tokens.css + base.css.
 *
 * Designziel: ruhiges, konsistentes Tabellen-Bild. Eine Body-Schrift fuer alle
 * Zellen, Monospace nur fuer Identifier (Doc-ID, Stream-Labels). Header sitzt im
 * gleichen Surface wie der Body, nur durch eine Linie getrennt. Filter-Bar mit
 * einheitlicher 32px-Hoehe ueber alle Eingaben + Reset-Button.
 */

.catalog-body {
  background: var(--h-bg);
  color: var(--h-text);
  min-height: 100vh;
}

/* (Site-Header/Footer + Header-Disclaimer stehen in base.css.) */

/* ============================================================
   Wrap
   ============================================================ */
.catalog {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--h-space-lg) var(--h-space-xl) var(--h-space-2xl);
}

/* ============================================================
   Filter-Bar: eine kompakte Reihe, alles 32px hoch
   Search nimmt 1fr, Dropdowns sind auto-breit (>= 130px),
   Reset rechts. base.css hat `.input { width: 100% }` -- daher
   muessen wir hier explizit width: auto setzen, sonst stapeln
   die Selects vertikal.
   ============================================================ */
.filter-bar {
  margin-bottom: var(--h-space-md);
  /* Sticky am oberen Viewport-Rand: Filter bleibt erreichbar, wenn die Seite scrollt.
     Loest den frueheren doppelten Scroll (Tabellen-overflow + Seiten-Scroll). */
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: var(--h-space-sm);
  background: var(--h-bg);
}
.filter-bar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.filter-bar__search {
  flex: 1 1 240px;
  min-width: 200px;
  display: flex;
}
.filter-bar__search .input {
  flex: 1 1 auto;
  width: 100%;
  padding: 0 12px;
}
.filter-bar__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Einheitliche 32-px-Hoehe + Reset des base.css `width: 100%` fuer alle Filter-Items. */
.filter-bar .input,
.filter-bar .btn {
  height: 32px;
  padding: 0 10px;
  font-size: var(--h-sm);
  line-height: 1;
  border-radius: var(--h-radius);
  box-sizing: border-box;
}
.filter-bar__group .input,
.filter-bar__group .btn {
  width: auto;
  flex: 0 0 auto;
}
.filter-bar__group select.input {
  min-width: 130px;
  padding-right: 22px;  /* Platz fuer den nativen Caret-Pfeil */
}

/* Treffer-Zaehler: rechtsbuendig in der Filterzeile, dezent. */
.filter-bar__count {
  margin-left: auto;
  font-size: var(--h-sm);
  color: var(--h-text-muted);
  white-space: nowrap;
}

#filter-reset.btn--ghost {
  border: 1px solid var(--h-border-emphasis);
  background: transparent;
  color: var(--h-text-secondary);
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
}
#filter-reset.btn--ghost:hover {
  color: var(--h-text);
  border-color: var(--h-text-muted);
}

/* ============================================================
   Status-Legende (Workflow-Ampel, sichtbar statt nur Tooltip)
   ============================================================ */
.status-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--h-space-md);
  margin: var(--h-space-sm) 0;
  font-size: var(--h-sm);
  color: var(--h-text-secondary);
}
.status-legend__title {
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text-muted);
}
.status-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================
   Doc-Tabelle
   ============================================================ */
.doc-table {
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius-lg);
  overflow: hidden;
}

/* Gemeinsames Spalten-Raster fuer Head + Row. */
.doc-table__head,
.doc-table__row {
  display: grid;
  grid-template-columns:
    48px                 /* thumb */
    minmax(220px, 3fr)   /* title */
    minmax(120px, 1.4fr) /* author */
    64px                 /* date */
    80px                 /* lang  -- Platz fuer "SPRACHE" + Sort-Pfeil */
    96px                 /* type -- lesbares Label ("Zweispaltig") statt Code */
    minmax(110px, 1fr)   /* form */
    64px                 /* pages */
    100px;               /* workflow (vertikale Ampel + Labels) */
  column-gap: var(--h-space-md);
  align-items: center;
}

/* Head: gleiche Flaeche wie Body, nur Trennstrich. */
.doc-table__head {
  padding: 10px var(--h-space-lg);
  border-bottom: 1px solid var(--h-border);
  font-family: var(--h-font-heading);
  font-size: var(--h-xs);
  font-weight: 500;
  letter-spacing: var(--h-tracking-caps);
  text-transform: uppercase;
  color: var(--h-text-muted);
  background: var(--h-surface);
}

.doc-table__body {
  /* Kein eigener Scroll mehr -- die Tabelle waechst natuerlich und die Seite scrollt
     als Ganzes. Die Filter-Bar bleibt via position:sticky im Blick. */
}

.doc-table__row {
  padding: 10px var(--h-space-lg);
  border-bottom: 1px solid var(--h-border);
  text-decoration: none;
  color: var(--h-text);
  transition: background var(--h-transition-fast);
  /* Eine Body-Schrift, sofern Zelle nicht ueberschreibt. */
  font-family: var(--h-font-body);
  font-size: var(--h-sm);
  line-height: 1.3;
}
.doc-table__row:last-child { border-bottom: none; }
.doc-table__row:hover { background: var(--h-bg-alt); }

.doc-table__empty {
  padding: var(--h-space-2xl);
  text-align: center;
  font-style: italic;
  color: var(--h-text-muted);
}

/* ============================================================
   Sortierbare Spaltenheader (Affordance bei Ruhezustand)
   ============================================================ */
.col-sort {
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  user-select: none;
  /* Wichtig: KEIN overflow:hidden/ellipsis hier, sonst verschwindet der Sortier-Pfeil. */
}
.col-sort::after {
  content: '\2195';          /* up-down arrow, Ruhezustand */
  font-size: 10px;
  color: var(--h-text-muted);
  opacity: 0.4;
  transition: opacity var(--h-transition-fast), color var(--h-transition-fast);
  flex: 0 0 auto;
}
.col-sort:hover { color: var(--h-text); }
.col-sort:hover::after { opacity: 0.8; }
.col-sort[aria-sort="ascending"]  { color: var(--h-ziegelrot); }
.col-sort[aria-sort="descending"] { color: var(--h-ziegelrot); }
.col-sort[aria-sort="ascending"]::after  { content: '\2191'; color: var(--h-ziegelrot); opacity: 1; }
.col-sort[aria-sort="descending"]::after { content: '\2193'; color: var(--h-ziegelrot); opacity: 1; }

/* Numerische Spalten: Header rechts ausrichten -- Pfeil dann nach dem Text rechts. */
.doc-table__head .col-pages.col-sort,
.doc-table__head .col-date.col-sort  { justify-content: flex-end; text-align: right; }

/* ============================================================
   Spalten-Inhalt
   ============================================================ */
.col-thumb {
  width: 48px;
  height: 64px;
  background: var(--h-bg-alt);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.col-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.col-thumb__placeholder {
  font-family: var(--h-font-mono);
  font-size: var(--h-xs);
  color: var(--h-text-muted);
}
.doc-table__head .col-thumb {
  background: transparent;
  border: none;
  height: auto;
}

/* Titel: in Datenzeilen 2-stoeckig (ID/Name). Im Header bleibt der Sort-Button inline. */
.doc-table__row .col-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.col-title__id {
  font-family: var(--h-font-mono);
  font-size: var(--h-xs);
  color: var(--h-text-muted);
  letter-spacing: 0.02em;
}
.col-title__name {
  font-family: var(--h-font-body);
  font-size: var(--h-base);
  color: var(--h-ziegelrot);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-table__row:hover .col-title__name { text-decoration: underline; }

/* Datenzellen: gleiche Body-Schrift, kein italic, nur Ton-Variation. */
.doc-table__row .col-author,
.doc-table__row .col-date,
.doc-table__row .col-lang,
.doc-table__row .col-type,
.doc-table__row .col-form,
.doc-table__row .col-pages {
  color: var(--h-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-table__row .col-lang,
.doc-table__row .col-type { color: var(--h-text-muted); }

/* Numerische Spalten: tabular-nums + rechtsbuendig. */
.doc-table__row .col-date,
.doc-table__row .col-pages {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Workflow-Spalte: vertikale Ampel mit OCR/Layout/TEI-XML Labels
   ============================================================ */
.col-workflow {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.col-workflow__row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.col-workflow__dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
  border: 1px solid var(--h-border-emphasis);
  cursor: help;
}
.col-workflow__label {
  font-family: var(--h-font-mono);
  font-size: var(--h-xs);
  color: var(--h-text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
/* Ampel-Semantik (E77, drei Stufen): die Pipeline ERZEUGT OCR/Layout/TEI deterministisch
   fuer alle 285 Docs, der Default-Status ist also nicht "nichts da", sondern "vorhanden,
   unverifiziert".
   neutral/grau = Pipeline-Output da, noch nicht angefasst (unverifiziert),
   gelb = in Bearbeitung (in_arbeit),
   gruen = menschlich verifiziert (verifiziert).
   rot bleibt reserviert fuer einen spaeteren expliziten "Problem"/"fehlt"-Status. */
.col-workflow__dot--unverifiziert { background: var(--h-text-muted); }
.col-workflow__dot--ausstehend    { background: transparent; box-shadow: inset 0 0 0 1px var(--h-text-muted); }
.col-workflow__dot--in_arbeit     { background: var(--h-ocker); }
.col-workflow__dot--verifiziert   { background: var(--h-olivgruen); }

/* Header: Workflow-Label nur als statisches Wort, nicht klickbar. */
.doc-table__head .col-workflow {
  display: block;
  text-align: left;
}

/* ============================================================
   Responsive: ab 1000px Tabelle, darunter Karten-Liste
   ============================================================ */
@media (max-width: 1000px) {
  .doc-table__head { display: none; }
  .doc-table__row {
    grid-template-columns: 48px 1fr auto;
    grid-template-areas:
      "thumb title    workflow"
      "thumb author   workflow"
      "thumb meta     workflow";
    row-gap: 4px;
    padding: var(--h-space-md) var(--h-space-lg);
  }
  .col-thumb    { grid-area: thumb; align-self: start; }
  .col-title    { grid-area: title; }
  .col-author   { grid-area: author; }
  .col-workflow { grid-area: workflow; align-self: center; }
  .col-date,
  .col-lang,
  .col-type,
  .col-form,
  .col-pages { display: none; }
}
