/* ══════════════════════════════════════════════════════════════════════════
   blog.css: blog hub + single-post viewer
   Built on the CSS variables defined in css/styles.css (--bg, --primary, …).
   ══════════════════════════════════════════════════════════════════════════ */

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

html, body {
  min-height: 100%;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }

/* ── Top bar ──────────────────────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  height: var(--nav-h);
  padding: 0 1.25rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.tb-brand { font-size: 0.85rem; color: var(--text-soft); white-space: nowrap; }
.tb-brand .dim { color: var(--text-muted); }
.tb-brand .cur { color: var(--primary); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tb-spacer { flex: 1; }

.tb-btn {
  font-family: var(--font-mono); font-size: 0.78rem;
  background: none; color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tb-btn:hover { color: var(--primary); border-color: var(--primary); }
.tb-back { color: var(--text-soft); font-size: 0.82rem; }
.tb-back:hover { color: var(--primary); }

/* ── Page shell ───────────────────────────────────────────────────────────── */
.wrap { max-width: 1040px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }

.page-head { margin-bottom: 2rem; }
.page-head h1 {
  font-size: 1.9rem; font-weight: 700; letter-spacing: -0.5px;
  color: var(--text);
}
.page-head h1 .accent { color: var(--primary); }
.page-head p { margin-top: 0.5rem; color: var(--text-soft); font-size: 0.9rem; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border); }
.tab {
  font-family: var(--font-mono); font-size: 0.85rem;
  background: none; border: none; cursor: pointer;
  color: var(--text-soft);
  padding: 0.6rem 0.9rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.panel { display: none; }
.panel.active { display: block; }

/* ── Post cards ───────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.card {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow); }
.card-cover { aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg-alt); }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.card:hover .card-cover img { transform: scale(1.05); }
.card-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.55rem; flex: 1; }
.card-date { font-size: 0.72rem; color: var(--text-muted); }
.card-title { font-size: 1.05rem; font-weight: 600; color: var(--text); line-height: 1.35; }
.card-excerpt { font-size: 0.83rem; color: var(--text-soft); line-height: 1.55; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-size: 0.68rem; color: var(--accent);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.12rem 0.55rem;
}
.tag::before { content: "#"; opacity: 0.6; }

/* ── Photo grid ───────────────────────────────────────────────────────────── */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.photo {
  position: relative; cursor: zoom-in;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-alt);
  aspect-ratio: 1 / 1;
}
.photo img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.photo:hover img { transform: scale(1.06); }
.photo-cap {
  position: absolute; inset: auto 0 0 0;
  padding: 0.6rem 0.7rem 0.5rem;
  font-size: 0.74rem; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  opacity: 0; transition: opacity 0.2s;
}
.photo:hover .photo-cap { opacity: 1; }

/* ── Lightbox ─────────────────────────────────────────────────────────────── */
#lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: none; place-items: center;
  background: rgba(0,0,0,0.9);
  padding: 2rem; cursor: zoom-out;
}
#lightbox.open { display: grid; }
#lightbox img { max-width: 100%; max-height: 82vh; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
#lightbox .lb-cap { color: #ddd; font-size: 0.85rem; margin-top: 1rem; text-align: center; }
#lightbox .lb-close { position: absolute; top: 1.2rem; right: 1.4rem; font-size: 1.4rem; color: #fff; background: none; border: none; cursor: pointer; }

/* ── PDF cards ────────────────────────────────────────────────────────────── */
/* PDF covers are first-page previews, anchored to the top so the header shows. */
.card-cover-pdf { aspect-ratio: 4 / 3; background: var(--bg-alt); }
.card-cover-pdf img { object-fit: cover; object-position: top center; }

/* ── PDF viewer ───────────────────────────────────────────────────────────── */
#pdfviewer {
  position: fixed; inset: 0; z-index: 250;
  display: none; place-items: center;
  background: rgba(0,0,0,0.9);
  padding: 1.5rem;
}
#pdfviewer.open { display: grid; }
.pv-panel {
  display: flex; flex-direction: column;
  width: 100%; max-width: 1100px; height: 92vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.pv-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.pv-title {
  font-size: 0.85rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 48%;
}
.pv-count { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.pv-spacer { flex: 1; }
.pv-bar .tb-btn { text-decoration: none; }
.pv-close { line-height: 1; }

.pv-body { position: relative; flex: 1; min-height: 0; background: #3a3d42; }
/* E-reader stage: one page at a time, centered and fit-to-view */
.pv-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.pv-stage canvas {
  max-width: 100%; max-height: 100%;
  background: #fff;
  box-shadow: 0 6px 28px rgba(0,0,0,0.5);
  border-radius: 2px;
}
.pv-stage.loading canvas { visibility: hidden; }
.pv-stage.loading::after {
  content: '…'; color: #cfd3d8; font-size: 1.6rem; letter-spacing: 0.15em;
}

/* Floating prev/next page arrows */
.pv-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.6rem; line-height: 1;
  color: #fff; background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.25);
  cursor: pointer; z-index: 5;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.pv-nav:hover { background: var(--primary); color: #000; }
.pv-nav:active { transform: translateY(-50%) scale(0.92); }
.pv-nav.disabled { opacity: 0.25; pointer-events: none; }
.pv-prev { left: 0.8rem; }
.pv-next { right: 0.8rem; }

/* ── Empty / loading state ────────────────────────────────────────────────── */
.state { color: var(--text-muted); font-size: 0.85rem; padding: 2rem 0; }

/* ── Single post (prose) ──────────────────────────────────────────────────── */
.post-wrap { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
.post-meta { color: var(--text-muted); font-size: 0.78rem; margin-bottom: 0.4rem; }
.post-cover { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); margin: 1.5rem 0; }

.prose { font-family: var(--font-sans); font-size: 1rem; line-height: 1.75; color: var(--text); }
.prose h1, .prose h2, .prose h3 { font-family: var(--font-mono); color: var(--text); line-height: 1.3; margin: 2rem 0 0.8rem; }
.prose h1 { font-size: 1.8rem; }
.prose h2 { font-size: 1.35rem; }
.prose h2::before { content: "## "; color: var(--primary); }
.prose h3 { font-size: 1.1rem; }
.prose h3::before { content: "### "; color: var(--accent); }
.prose p { margin: 0.9rem 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose a:hover { color: var(--primary); }
.prose ul, .prose ol { margin: 0.9rem 0 0.9rem 1.4rem; }
.prose li { margin: 0.35rem 0; }
.prose img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); margin: 1.2rem 0; }
.prose blockquote { border-left: 3px solid var(--primary); padding-left: 1rem; margin: 1.2rem 0; color: var(--text-soft); font-style: italic; }
.prose code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-alt); padding: 0.12em 0.4em; border-radius: var(--radius-sm); color: var(--accent); }
.prose pre { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; overflow-x: auto; margin: 1.2rem 0; }
.prose pre code { background: none; padding: 0; color: var(--text); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Inline post PDF (e-reader) ───────────────────────────────────────────── */
.post-pdf { margin: 1.8rem 0; }
.reader {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-alt);
  display: flex; flex-direction: column;
}
.reader-top {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.reader-spacer { flex: 1; }
.reader-btn {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text-soft); text-decoration: none;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.7rem; cursor: pointer; white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.reader-btn:hover { color: var(--primary); border-color: var(--primary); }
.reader-stage {
  height: 78vh;
  background: #3a3d42;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
  overflow: auto;
}
/* Fullscreen: fill the screen and scroll the (full-width) page */
.reader:fullscreen { width: 100%; height: 100%; border: 0; border-radius: 0; background: #23262b; }
.reader:fullscreen .reader-stage { height: auto; flex: 1; align-items: flex-start; }
.reader:fullscreen .reader-stage canvas { max-height: none; }
.reader-stage canvas {
  max-width: 100%; max-height: 100%;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  border-radius: 2px;
}
.reader-bar {
  display: flex; align-items: center; justify-content: center; gap: 1.5rem;
  padding: 0.6rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.reader-count { font-size: 0.8rem; color: var(--text-soft); min-width: 4rem; text-align: center; }
.reader-nav {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.4rem; line-height: 1;
  background: none; color: var(--text-soft);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}
.reader-nav:hover { color: var(--primary); border-color: var(--primary); }
.reader-nav:active { transform: scale(0.92); }
.reader-nav.disabled { opacity: 0.3; pointer-events: none; }
.pdf-fallback { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-size: 0.9rem; }

@media (max-width: 640px) {
  .reader-stage { height: 62vh; }
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tb-brand { font-size: 0.75rem; }
  .page-head h1 { font-size: 1.5rem; }
  #pdfviewer { padding: 0; }
  .pv-panel { height: 100%; max-width: none; border: 0; border-radius: 0; }
  .pv-title { font-size: 0.78rem; max-width: 34%; }
  .pv-bar { gap: 0.4rem; }
  .pv-bar .tb-btn { padding: 0.3rem 0.5rem; font-size: 0.72rem; white-space: nowrap; }
  .pv-nav { width: 38px; height: 38px; font-size: 1.3rem; }
}

/* ── Kontakt-Footer unter jedem Beitrag ─────────────────────────────────── */
/* Das globale `footer`-Styling zentriert und polstert; hier links ausgerichtet
   wie der restliche Beitrag. */
.post-contact {
  text-align: left;
  margin-top: 3rem;
  padding: 2rem 0 0;
  border-top: 1px solid var(--border);
}
/* Im schmalen Beitragslayout passen drei Spalten nicht ohne hässliche
   Wortumbrüche; die Karten dürfen früher umbrechen. */
.post-contact .contact-grid { grid-template-columns: repeat(auto-fit, minmax(265px, 1fr)); }
.post-contact .contact-card span { word-break: normal; overflow-wrap: anywhere; }
.post-contact-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  color: var(--primary);
  margin: 0 0 0.4rem;
}
.post-contact-lead {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin: 0 0 1.2rem;
}
