/* ---------- Design-Tokens ---------- */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #eeece7;
  --text: #16171a;
  --text-2: #5d6068;
  --line: rgb(22 23 26 / 0.09);
  --accent: #b5762a;
  --accent-soft: rgb(181 118 42 / 0.12);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 30px rgb(0 0 0 / 0.06);
  --topbar-bg: rgb(246 245 242 / 0.72);
  --radius: 14px;
  --gap: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0f; --surface: #15171c; --surface-2: #1d2027; --text: #eceae6; --text-2: #9a9ca3;
    --line: rgb(255 255 255 / 0.08); --accent: #e8b86b; --accent-soft: rgb(232 184 107 / 0.14);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 40px rgb(0 0 0 / 0.35); --topbar-bg: rgb(11 12 15 / 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0f; --surface: #15171c; --surface-2: #1d2027; --text: #eceae6; --text-2: #9a9ca3;
  --line: rgb(255 255 255 / 0.08); --accent: #e8b86b; --accent-soft: rgb(232 184 107 / 0.14);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 40px rgb(0 0 0 / 0.35); --topbar-bg: rgb(11 12 15 / 0.7);
  color-scheme: dark;
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
body.no-scroll { overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer;
  font-weight: 500; font-size: 14px; transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn-primary:hover { background: var(--text); opacity: 0.88; }
.btn-icon { width: 40px; padding: 0; justify-content: center; background: transparent; border-color: transparent; }
.btn-icon:hover { background: var(--accent-soft); }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--topbar-bg); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; font-size: 16px; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 200deg, var(--accent), #6f8fb3, #8fb38a, var(--accent)); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
#theme-toggle svg { display: none; }
:root:not([data-theme]) #theme-toggle .i-auto,
:root[data-theme="light"] #theme-toggle .i-light,
:root[data-theme="dark"] #theme-toggle .i-dark { display: block; }

/* ---------- Layout ---------- */
#view { outline: none; padding: 0 16px 80px; max-width: 1680px; margin: 0 auto; }
.view-enter { animation: fade-up 0.45s var(--ease) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { padding: clamp(40px, 9vw, 110px) 0 clamp(28px, 5vw, 56px); }
.hero h1, .album-head h1 {
  margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; line-height: 1.05;
  font-size: clamp(38px, 7vw, 76px);
}
.hero p { margin: 14px 0 0; color: var(--text-2); font-size: clamp(16px, 2vw, 19px); max-width: 46ch; }
.hero-stats { margin-top: 22px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 13px; font-weight: 500; }

/* ---------- Albenübersicht ---------- */
.albums { display: grid; gap: clamp(14px, 2vw, 24px); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.album-card { position: relative; display: block; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); aspect-ratio: 4 / 3; isolation: isolate; }
.album-card img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.9s var(--ease), opacity 0.5s; }
.album-card:hover img { transform: scale(1.045); }
.album-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgb(0 0 0 / 0.62), rgb(0 0 0 / 0) 55%); z-index: 1; }
.album-card-body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 18px 20px; color: #fff; }
.album-card h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 24px; letter-spacing: -0.01em; line-height: 1.15; }
.album-card-meta { margin-top: 4px; font-size: 13px; opacity: 0.82; }

.year-group + .year-group { margin-top: clamp(40px, 6vw, 72px); }
.year-heading { display: flex; align-items: baseline; gap: 14px; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-family: var(--font-display); font-weight: 500; font-size: clamp(26px, 3.4vw, 36px); letter-spacing: -0.01em; }
.year-heading small { font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }

/* ---------- Albumansicht ---------- */
.album-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; padding: clamp(28px, 6vw, 70px) 0 clamp(20px, 3vw, 32px); }
.album-head h1 { font-size: clamp(32px, 5.5vw, 60px); }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 14px; margin-bottom: 14px; }
.back:hover { color: var(--text); }
.back svg { width: 16px; height: 16px; }
.album-sub { margin-top: 10px; color: var(--text-2); }
.album-desc { margin: 10px 0 0; max-width: 60ch; color: var(--text-2); }

.justified { position: relative; }
.album-actions { display: flex; align-items: center; gap: 8px; }
.view-toggle { display: none; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); }
.view-toggle .btn-icon { width: 34px; height: 34px; }
.view-toggle .btn-icon svg { width: 18px; height: 18px; }
.view-toggle [aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
@media (max-width: 700px) {
  .view-toggle { display: inline-flex; }
  /* Pinch auf dem Raster steuert die Ansicht statt den Seiten-Zoom. */
  .justified { touch-action: pan-y; }
  .justified.full { margin-inline: -16px; --gap: 4px; }
  .justified.full .tile { border-radius: 0; cursor: zoom-in; }
  .justified.full .tile::after { display: none; }
}
.justified .row { display: flex; gap: var(--gap); margin-bottom: var(--gap); }
.tile { position: relative; display: block; overflow: hidden; border-radius: 6px; cursor: zoom-in; background: var(--surface-2); flex: none; }
.tile img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.tile img.loaded, .album-card img.loaded { opacity: 1; }
.album-card img { opacity: 0; }
.tile:hover img { transform: scale(1.03); }
.tile::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px var(--line); border-radius: inherit; pointer-events: none; }

.empty { text-align: center; padding: 18vh 0; color: var(--text-2); }
.empty h2 { color: var(--text); font-family: var(--font-display); font-weight: 500; font-size: 30px; margin: 0 0 8px; }
.empty code { background: var(--surface-2); padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #08090b; color: #f2f1ee; display: grid; animation: fade 0.25s var(--ease); }
.lightbox[hidden], .show[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.lb-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 64px 16px; touch-action: pan-y pinch-zoom; overflow: hidden; }
.lb-img { max-width: 100%; max-height: calc(100dvh - 128px); object-fit: contain; border-radius: 4px; box-shadow: 0 30px 80px rgb(0 0 0 / 0.5); transition: opacity 0.3s var(--ease), transform 0.35s var(--ease); user-select: none; -webkit-user-drag: none; }
.lb-img.is-loading { opacity: 0.25; }
.lb-bar { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; z-index: 2; }
.lb-top { top: 0; background: linear-gradient(rgb(0 0 0 / 0.45), transparent); }
.lb-counter { font-size: 13px; opacity: 0.75; padding-left: 6px; font-variant-numeric: tabular-nums; }
.lb-tools { display: flex; gap: 2px; }
.lightbox .btn-icon:hover, .show .btn-icon:hover { background: rgb(255 255 255 / 0.12); }
.lb-nav { position: absolute; top: 50%; translate: 0 -50%; z-index: 2; width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgb(255 255 255 / 0.08); color: #fff; cursor: pointer; backdrop-filter: blur(8px); transition: background 0.2s, opacity 0.2s; }
.lb-nav:hover { background: rgb(255 255 255 / 0.18); }
.lb-nav:disabled { opacity: 0; pointer-events: none; }
.lb-prev { left: 16px; } .lb-next { right: 16px; }
.lb-info { position: absolute; right: 16px; bottom: 16px; z-index: 2; max-width: min(360px, calc(100% - 32px)); padding: 16px 18px; border-radius: var(--radius); background: rgb(20 21 25 / 0.78); backdrop-filter: blur(16px); font-size: 13px; line-height: 1.6; opacity: 0; translate: 0 8px; pointer-events: none; transition: opacity 0.25s, translate 0.25s var(--ease); }
.lightbox.show-info .lb-info { opacity: 1; translate: 0 0; pointer-events: auto; }
.lb-info .cap { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.lb-info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; }
.lb-info dt { opacity: 0.55; } .lb-info dd { margin: 0; }
@media (max-width: 640px) { .lb-nav { display: none; } .lb-stage { padding: 56px 0; } .lb-img { border-radius: 0; max-height: calc(100dvh - 112px); } }

/* ---------- Diashow / Fotodisplay ---------- */
.show { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; overflow: hidden; cursor: none; }
.show.ui-visible { cursor: default; }
.show-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 1.6s ease; }
.show-layer.active { opacity: 1; }
.show-layer .bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(40px) brightness(0.45) saturate(1.2); }
.show-layer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.show-layer.kenburns img { animation: kenburns var(--kb-duration, 10s) linear both; }
@keyframes kenburns { from { transform: scale(1) translate(0, 0); } to { transform: scale(var(--kb-scale, 1.06)) translate(var(--kb-x, 0), var(--kb-y, 0)); } }
.show-overlay { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 28px max(28px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left)); background: linear-gradient(transparent 65%, rgb(0 0 0 / 0.5)); pointer-events: none; }
.show-meta { text-shadow: 0 1px 12px rgb(0 0 0 / 0.5); }
.show-clock { font-family: var(--font-display); font-size: clamp(36px, 6vw, 72px); font-weight: 500; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.show-caption { margin-top: 8px; font-size: clamp(14px, 1.6vw, 18px); opacity: 0.85; transition: opacity 0.6s; }
.show-controls { display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px; background: rgb(20 21 25 / 0.6); backdrop-filter: blur(16px); opacity: 0; translate: 0 10px; transition: opacity 0.3s, translate 0.3s var(--ease); pointer-events: none; }
.show.ui-visible .show-controls { opacity: 1; translate: 0 0; pointer-events: auto; }
.show-toggle .i-play, .show.paused .show-toggle .i-pause { display: none; }
.show.paused .show-toggle .i-play { display: block; }
.show-shuffle[aria-pressed="false"] { opacity: 0.45; }
.show-select select { height: 36px; padding: 0 10px; border-radius: 999px; border: 0; background: rgb(255 255 255 / 0.1); color: #fff; cursor: pointer; }
.show-select option { color: #000; }
@media (max-width: 640px) { .show-overlay { flex-direction: column; align-items: stretch; } .show-controls { justify-content: center; flex-wrap: wrap; border-radius: 20px; } }

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