/* Freystadt in alten Ansichten — "Warmes Archiv"
   Statische Postkarten-Galerie, keine Abhängigkeiten. */

:root {
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style",
           "Hoefler Text", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --paper:       #f2e8d2;   /* Seitenhintergrund */
  --paper-card:  #fbf6e9;   /* Kartenfläche */
  --paper-inset: #efe4cc;   /* Bildbett hinter den Scans */
  --ink:         #3a3123;   /* Haupttext (dunkles Sepia) */
  --ink-soft:    #6d5f47;   /* gedämpfter Text */
  --ink-faint:   #97876a;   /* Labels/Hinweise */
  --line:        #d8c9a8;   /* Ränder */
  --line-soft:   #e6dabf;
  --accent:      #8c4a2f;   /* Siegellack-Rotbraun, sparsam */
  --tag-bg:      #e9ddc0;
  --tag-ink:     #6a5636;

  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(58,45,20,.08), 0 6px 18px rgba(58,45,20,.10);
  --shadow-lift: 0 4px 10px rgba(58,45,20,.14), 0 14px 34px rgba(58,45,20,.16);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(242,232,210,.92);
  backdrop-filter: saturate(120%) blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 12px 20px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
}
.topbar__brand {
  font-family: var(--serif);
  font-size: 20px; letter-spacing: .2px; color: var(--ink);
}
.topbar__brand a { color: inherit; }
.topbar__brand a:hover { text-decoration: none; color: var(--accent); }
.topbar__count { font-size: 13px; color: var(--ink-faint); white-space: nowrap; }

/* ---------- Hero / Titelseite ---------- */
.hero {
  max-width: var(--maxw); margin: 0 auto;
  padding: 46px 20px 26px;
  text-align: center;
}
.hero__kicker {
  font-size: 12px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--accent); margin: 0 0 14px;
}
.hero__title {
  font-family: var(--serif);
  font-weight: 500; font-size: clamp(30px, 5vw, 50px);
  line-height: 1.08; margin: 0 0 16px; color: var(--ink);
}
.hero__lead {
  max-width: 640px; margin: 0 auto;
  font-size: 17px; color: var(--ink-soft);
}
.hero__rule {
  width: 74px; height: 2px; margin: 26px auto 0;
  background: var(--accent); opacity: .55;
}

/* ---------- Werkzeugleiste ---------- */
.toolbar {
  max-width: var(--maxw); margin: 0 auto;
  padding: 6px 20px 0;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.search {
  position: relative; width: 100%; max-width: 460px;
}
.search input {
  width: 100%; height: 44px;
  padding: 0 40px 0 42px;
  font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(140,74,47,.14);
}
.search__icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 17px; line-height: 1;
}
.search__clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer;
  color: var(--ink-faint); font-size: 20px; line-height: 1;
  width: 28px; height: 28px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
}
.search__clear:hover { background: var(--line-soft); color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  font-family: var(--sans); font-size: 13.5px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--paper-card); color: var(--ink-soft);
  border: 1px solid var(--line); cursor: pointer;
  transition: all .13s;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent); color: #fbf3e6; border-color: var(--accent);
}
.chip .chip__n { opacity: .7; font-size: 12px; margin-left: 4px; }

.result-note {
  max-width: var(--maxw); margin: 20px auto 0; padding: 0 20px;
  font-size: 13px; color: var(--ink-faint); text-align: center;
}

/* ---------- Galerie-Raster ---------- */
.grid {
  max-width: var(--maxw); margin: 18px auto 70px; padding: 0 20px;
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  display: flex; flex-direction: column;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform .16s ease, box-shadow .16s ease;
  text-align: left;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card__frame {
  background: var(--paper-inset);
  aspect-ratio: 3 / 2;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.card__frame img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain;
  box-shadow: 0 1px 4px rgba(58,45,20,.22);
}
.card__body { padding: 12px 14px 15px; display: flex; flex-direction: column; gap: 6px; }
.card__title {
  font-family: var(--serif); font-size: 16.5px; line-height: 1.25; color: var(--ink);
}
.card__meta { font-size: 12.5px; color: var(--ink-faint); }

.empty {
  max-width: 520px; margin: 60px auto; padding: 0 20px; text-align: center;
  color: var(--ink-soft);
}

/* ---------- Detail / Blätter-Ansicht ---------- */
.viewer { max-width: var(--maxw); margin: 0 auto; padding: 18px 20px 80px; }
.viewer__back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink-soft); margin-bottom: 18px;
}
.viewer__back:hover { color: var(--accent); text-decoration: none; }

.viewer__grid {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 38px; align-items: start;
}

.stage { position: sticky; top: 84px; }
.stage__frame {
  background: var(--paper-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; justify-content: center;
  min-height: 320px;
}
.stage__frame img {
  max-width: 100%; max-height: 68vh; width: auto; height: auto;
  object-fit: contain; cursor: zoom-in;
  box-shadow: var(--shadow-card);
  transition: opacity .18s ease;
}
.stage__frame.is-flipping img { opacity: 0; }

.stage__controls {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
}
.btn {
  font-family: var(--sans); font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px;
  background: var(--paper-card); color: var(--ink);
  border: 1px solid var(--line); cursor: pointer;
  transition: all .13s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--primary { background: var(--accent); color: #fbf3e6; border-color: var(--accent); }
.btn--primary:hover { color: #fff; filter: brightness(1.06); }
.btn--icon { padding: 9px 11px; }
.btn__side {
  margin-left: auto; font-size: 12px; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 6px;
}

/* Info-Spalte */
.info__eyebrow {
  font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 4px;
}
.info__title {
  font-family: var(--serif); font-weight: 500;
  font-size: 26px; line-height: 1.18; color: var(--ink); margin: 0 0 18px;
}
.facts { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.facts th, .facts td {
  text-align: left; vertical-align: top;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-weight: 400;
}
.facts th {
  width: 34%; color: var(--ink-faint); font-size: 13px; padding-right: 12px;
  white-space: nowrap;
}
.facts td { font-size: 14.5px; color: var(--ink); }

.note {
  margin-top: 20px; background: var(--paper-card);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px 16px;
}
.note__label {
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 7px;
}
.note__body {
  font-family: var(--serif); font-size: 15px; line-height: 1.6; color: var(--ink-soft);
  white-space: pre-wrap;
}
.note--plain .note__body { font-family: var(--sans); font-size: 14px; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.tag {
  font-size: 12.5px; padding: 4px 12px; border-radius: 999px;
  background: var(--tag-bg); color: var(--tag-ink);
}

/* Blätter-Navigation */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line);
}
.pager__count { font-size: 13.5px; color: var(--ink-soft); text-align: center; }
.pager__count strong { color: var(--ink); font-weight: 500; }
.pager__hint { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.pager .btn[disabled] { opacity: .4; cursor: default; pointer-events: none; }

/* ---------- Lightbox / Zoom ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(30,22,12,.9);
  display: none; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out; overflow: auto;
}
.lightbox.is-open { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%; margin: auto;
  box-shadow: 0 10px 50px rgba(0,0,0,.5);
}
.lightbox.is-actual { cursor: grab; }
.lightbox.is-actual img { max-width: none; max-height: none; }
.lightbox__close {
  position: fixed; top: 16px; right: 20px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.3);
  color: #f4ead6; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox__close:hover { background: rgba(0,0,0,.55); }

/* ---------- Fußzeile ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 26px 20px; text-align: center;
  font-size: 13px; color: var(--ink-faint);
}

/* ---------- Responsiv ---------- */
@media (max-width: 820px) {
  .viewer__grid { grid-template-columns: 1fr; gap: 24px; }
  .stage { position: static; }
  .stage__frame img { max-height: 56vh; }
}
@media (max-width: 480px) {
  .hero { padding-top: 30px; }
  .grid { gap: 18px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Reduzierte Bewegung */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto; }
}
