/* Saxdorf Bildarchiv – schlicht, warm, viel Platz für die Bilder */

:root {
  --bg: #f7f5f0;
  --paper: #ffffff;
  --ink: #2b2a26;
  --muted: #7a776d;
  --line: #e3dfd4;
  --accent: #4f6b3a;      /* Blattgrün */
  --accent-soft: #e6ecdf;
  --internal: #8a5a2b;    /* Erdbraun für „nur intern“ */
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
code { font-size: 0.85em; }
code.path { word-break: break-all; color: var(--muted); }

/* --- Kopfzeile --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.5rem; background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--ink); font-size: 1.15rem; font-family: Georgia, "Times New Roman", serif; }
.brand-mark { color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 0.9rem; margin-left: 0.3rem; }
.userbar { display: flex; gap: 1rem; align-items: center; color: var(--muted); font-size: 0.9rem; }
.userbar form { margin: 0; }
.linkbutton { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* --- Layout --- */
.layout { display: grid; grid-template-columns: 270px 1fr; gap: 1.5rem; padding: 1.5rem; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }

/* --- Facetten --- */
.facets { position: sticky; top: 4.2rem; align-self: start; max-height: calc(100vh - 5rem); overflow-y: auto; padding-right: 0.3rem; }
.search input {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; background: var(--paper); margin-bottom: 1rem;
}
.facet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.8rem; margin-bottom: 0.6rem; }
.facet summary, .facet h3 { font-weight: 600; cursor: pointer; font-size: 0.95rem; margin: 0; }
.facet.internal summary { color: var(--internal); }
.badge { font-size: 0.7rem; font-weight: 500; border: 1px solid currentColor; border-radius: 3px; padding: 0 0.3rem; margin-left: 0.3rem; }
.reset { float: right; color: var(--muted); font-weight: 400; }
.options { list-style: none; margin: 0.4rem 0 0; padding: 0; max-height: 18rem; overflow-y: auto; }
.options li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.1rem 0; font-size: 0.92rem; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.crumbs { margin: 0.4rem 0 0; font-size: 0.9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0 0; }
.chip {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 0.85rem;
}
.chip.active { background: var(--accent); color: #fff; }
.chip.internal { background: #f3e9dd; color: var(--internal); }

/* --- Ergebnisse: Masonry über CSS-Spalten --- */
.summary { margin: 0 0 1rem; color: var(--muted); }
.summary strong { color: var(--ink); }
.grid { columns: 4 250px; column-gap: 0.8rem; }
.tile {
  display: block; break-inside: avoid; margin-bottom: 0.8rem; position: relative;
  border-radius: var(--radius); overflow: hidden; background: var(--line);
}
.tile img { display: block; width: 100%; height: auto; transition: transform 0.3s; }
.tile:hover img { transform: scale(1.03); }
.tile-caption {
  position: absolute; inset: auto 0 0 0; padding: 1.5rem 0.6rem 0.4rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.65)); color: #fff; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.2s;
}
.tile:hover .tile-caption { opacity: 1; }
.tile-caption em { display: block; font-style: normal; opacity: 0.85; font-size: 0.78rem; }

.pager { display: flex; justify-content: center; gap: 1.5rem; margin: 2rem 0; color: var(--muted); }

/* --- Detail --- */
.detail { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.back { margin: 0 0 1rem; }
.hero { margin: 0; text-align: center; }
.hero img { max-width: 100%; max-height: 80vh; border-radius: var(--radius); box-shadow: 0 4px 24px rgba(0,0,0,0.12); }
.hero figcaption { font-family: Georgia, serif; font-size: 1.15rem; margin: 1rem auto 0; max-width: 60ch; }
.meta { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 2rem; margin-top: 2rem; }
@media (max-width: 800px) { .meta { grid-template-columns: 1fr; } }
.meta dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; margin: 0; font-size: 0.92rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; align-content: flex-start; margin: 0; }

.strip { margin-top: 2.5rem; }
.strip h2 { font-family: Georgia, serif; font-weight: 400; font-size: 1.3rem; }
.strip-row { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.5rem; }
.strip-row a { flex: 0 0 auto; position: relative; }
.strip-row img { height: 150px; border-radius: var(--radius); display: block; }
.strip-row span { position: absolute; left: 0.4rem; bottom: 0.3rem; color: #fff; font-size: 0.8rem; text-shadow: 0 1px 3px #000; }

/* --- Login --- */
.login { max-width: 360px; margin: 4rem auto; background: var(--paper); padding: 2rem; border-radius: var(--radius); border: 1px solid var(--line); }
.login h1 { font-family: Georgia, serif; font-weight: 400; margin-top: 0; }
.login label { display: block; margin: 0.8rem 0; font-size: 0.9rem; color: var(--muted); }
.login input { display: block; width: 100%; padding: 0.5rem; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; margin-top: 0.2rem; }
.login button { margin-top: 1rem; padding: 0.55rem 1.2rem; background: var(--accent); color: #fff; border: 0; border-radius: var(--radius); font: inherit; cursor: pointer; }
.error { color: #a33; }

/* --- Suchschlitz oben mit Vorschlägen --- */
.topsearch { position: relative; flex: 1; max-width: 560px; margin: 0 1.5rem; }
.topsearch input {
  width: 100%; padding: 0.5rem 0.9rem; border: 1px solid var(--line); border-radius: 999px;
  font: inherit; background: var(--bg);
}
.topsearch input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--paper); }
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  list-style: none; margin: 0; padding: 0.3rem 0; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.suggest a { display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: baseline; padding: 0.35rem 0.9rem; color: var(--ink); }
.suggest a:hover { text-decoration: none; }
.suggest li.active a { background: var(--accent-soft); }
.suggest .label { font-weight: 600; }
.suggest .context { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .context.internal { color: var(--internal); }
.suggest .count { justify-self: end; }
.suggest .kind-caption, .suggest .kind-all { border-top: 1px solid var(--line); }
.suggest .kind-caption .label, .suggest .kind-all .label { font-weight: 400; color: var(--accent); }
@media (max-width: 800px) { .topbar { flex-wrap: wrap; gap: 0.5rem; } .topsearch { order: 3; flex-basis: 100%; margin: 0; max-width: none; } }

/* --- Merken (Fähnchen) --- */
.marklist-link { color: var(--ink); }
.marklist-link.active { color: var(--accent); font-weight: 600; }
.mark-count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 0.45rem; font-size: 0.8rem; }
.mark-toggle {
  position: absolute; top: 0.4rem; right: 0.4rem; width: 2rem; height: 2rem; border-radius: 50%;
  border: 0; background: rgba(0,0,0,0.35); color: #fff; font-size: 1rem; cursor: pointer;
  opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.tile:hover .mark-toggle, .mark-toggle:focus-visible, .mark-toggle.on { opacity: 1; }
.mark-toggle.on { background: #d9a400; color: #fff; }
.mark-toggle.inline {
  position: static; width: auto; height: auto; opacity: 1; border-radius: 999px;
  padding: 0.2rem 0.8rem; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 0.9rem;
}
.mark-toggle.inline.on { background: #d9a400; color: #fff; }
.back { display: flex; justify-content: space-between; align-items: center; }
.hint { color: var(--muted); font-size: 0.85rem; margin-left: 0.4rem; }
.marklist-actions { margin: -0.5rem 0 1rem; }
.tile-link { display: block; }
.alertbar { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #a33; color: #fff; padding: 0.5rem 1rem; border-radius: var(--radius); z-index: 100; }

/* --- Betrachter --- */
body.viewer-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 50; background: #111; color: #eee; display: grid; grid-template-rows: 1fr auto auto; }
.viewer[hidden] { display: none; }
.viewer-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.viewer-nav, .viewer-close {
  position: absolute; border: 0; background: rgba(255,255,255,0.08); color: #fff; cursor: pointer;
  font-size: 2.5rem; line-height: 1; border-radius: 50%; width: 3.2rem; height: 3.2rem;
}
.viewer-nav:hover, .viewer-close:hover { background: rgba(255,255,255,0.2); }
.viewer-nav:disabled { opacity: 0.2; cursor: default; }
.viewer-nav.prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.viewer-nav.next { right: 1rem; top: 50%; transform: translateY(-50%); }
.viewer-close { top: 1rem; right: 1rem; font-size: 2rem; }
.viewer-bar { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 1.2rem; background: #1b1b1b; }
.viewer-info { flex: 1; min-width: 0; }
.viewer-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-meta { color: #aaa; font-size: 0.85rem; }
.viewer-detail { color: #cfe0bf; }
.viewer-strip { display: flex; gap: 4px; overflow-x: auto; padding: 6px; background: #0b0b0b; scrollbar-color: #444 #0b0b0b; }
.strip-thumb { flex: 0 0 auto; padding: 0; border: 2px solid transparent; background: none; cursor: pointer; border-radius: 4px; position: relative; opacity: 0.6; }
.strip-thumb img { height: 64px; display: block; border-radius: 2px; }
.strip-thumb.current { border-color: #fff; opacity: 1; }
.strip-thumb:hover { opacity: 1; }
.strip-thumb.marked::after { content: "⚑"; position: absolute; top: 2px; right: 4px; color: #ffcc33; font-size: 0.8rem; text-shadow: 0 1px 2px #000; }
