/* CSL Downloads – helles, ruhiges Design nach Apple-Vorbild, Farben von csl.ch */

:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --text: #2b2b2b;
  --text-soft: #6e6e73;
  --line: #e5e5ea;
  --ink: #2b2b2b;
  --ink-hover: #000000;
  --error: #c0392b;
  --radius: 12px;
  --control-radius: 8px;
  --primary: #3a3a3c;
  --secondary: #f2f2f5;
  --secondary-hover: #e6e6ea;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.topbar, .hero, .content, .footer {
  max-width: 800px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* Kopfzeile mit Logo */

.topbar {
  display: flex;
  align-items: center;
  height: 88px;
}

.topbar__logo { display: inline-flex; line-height: 0; }

.topbar__logo img { width: 150px; height: auto; }

/* Titelbereich */

.hero { padding: 24px 24px 8px; }

.hero__title {
  margin: 0;
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
  word-break: break-word;
}

.hero__linkname {
  margin: 6px 0 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  word-break: break-word;
}

.hero__linkname:empty { display: none; }

.hero__subtitle {
  margin: 12px 0 0;
  font-size: 17px;
  color: var(--text-soft);
}

.hero__date {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-soft);
  opacity: 0.85;
}

.hero__date:empty { display: none; }

/* Skeleton-Loader */

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}

.hero__skeleton { display: none; }

.hero--loading .hero__skeleton { display: block; }

.hero--loading .hero__title,
.hero--loading .hero__linkname,
.hero--loading .hero__subtitle,
.hero--loading .hero__date { display: none; }

.folder--skeleton .folder__summary { cursor: default; }

.folder--skeleton .folder__summary::before { visibility: hidden; }

.skeleton-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.skeleton-row + .skeleton-row { border-top: 1px solid var(--line); }

.skeleton-row__text { display: flex; flex-direction: column; gap: 8px; flex: 1; }

.skeleton-row__actions { display: flex; gap: 8px; }

/* Inhalt */

.content { padding-top: 32px; padding-bottom: 64px; }

.status {
  margin: 0 0 24px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-soft);
}

.status[hidden] { display: none; }

.status--error { color: var(--error); }

.folder {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.folder__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.folder__summary::-webkit-details-marker { display: none; }

.folder__summary::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 1.5px solid var(--text-soft);
  border-bottom: 1.5px solid var(--text-soft);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.folder[open] .folder__summary::before { transform: rotate(45deg); }

.folder__name { flex: 1; word-break: break-word; }

.folder__count {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-soft);
  white-space: nowrap;
}

.folder__empty { margin: 0; padding: 0 22px 20px; color: var(--text-soft); }

.files {
  list-style: none;
  margin: 0;
  padding: 0 22px;
  border-top: 1px solid var(--line);
}

.file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}

.file + .file { border-top: 1px solid var(--line); }

.file__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.file__name { font-weight: 500; word-break: break-word; }

.file__meta { font-size: 14px; color: var(--text-soft); }

.file__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Buttons – wie in der App: Radius 8, Primär dunkelgrau, Sekundär hellgrau */

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--control-radius);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.button svg { width: 13px; height: 13px; flex-shrink: 0; }

.button:hover { filter: brightness(1.12); }

.button:active { transform: scale(0.98); }

.button:disabled { opacity: 0.45; cursor: default; }

.button--secondary {
  background: var(--secondary);
  color: var(--ink);
  font-weight: 500;
}

.button--secondary:hover { filter: none; background: var(--secondary-hover); }

.button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.button--disabled { opacity: 0.35; pointer-events: none; cursor: default; }

/* Fusszeile */

.footer {
  padding-top: 24px;
  padding-bottom: 48px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-soft);
}

.footer p { margin: 0; }

.footer a { color: var(--text-soft); text-decoration: none; }

.footer a:hover { color: var(--ink); text-decoration: underline; }

/* Schmale Bildschirme */

@media (max-width: 560px) {
  .topbar { height: 72px; }
  .topbar__logo img { width: 120px; }
  .file { flex-direction: column; align-items: stretch; }
  .file__actions { justify-content: flex-start; }
  .folder__summary { padding: 16px 18px; font-size: 17px; }
  .files { padding: 0 18px; }
}


/* Vorschau (Vollbild auf der Seite) */

body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.viewer[hidden] { display: none; }

.viewer__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: env(safe-area-inset-top) 12px 0 8px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.viewer__back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px 8px 6px;
  border: 0;
  border-radius: var(--control-radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.viewer__back:hover { background: rgba(0, 0, 0, 0.05); }

.viewer__heading { flex: 1; min-width: 0; }

.viewer__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer__tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.viewer__zoom, .viewer__nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--control-radius);
  background: rgba(0, 0, 0, 0.05);
}

.viewer__zoom[hidden] { display: none; }

.viewer__zoom-label, .viewer__counter {
  min-width: 48px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.viewer__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}

.viewer__icon:hover { background: rgba(0, 0, 0, 0.07); }

.viewer__icon:disabled { opacity: 0.3; cursor: default; }

.viewer__body {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viewer__image, .viewer__video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 56px - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: auto;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  background: #fff;
}

.viewer__audio { width: min(100%, 480px); margin-top: 8px; }

.viewer__audio-name { margin: 24px 0 8px; font-weight: 500; }

.viewer__text {
  width: min(100%, 860px);
  margin: 0;
  padding: 20px 24px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  font: 14px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.viewer__message { margin: 32px 0 16px; color: var(--text-soft); }

/* PDF: Körper scrollt in beide Richtungen, Seiten-Container so breit wie die breiteste Seite */
.viewer__body--pdf {
  display: block;
  padding: 0;
  text-align: center;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}

.viewer__body--pdf .viewer__skeleton { margin: 16px auto; }

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  transform-origin: 0 0;
}

.pdf-page {
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.pdf-page canvas { display: block; }

/* Übersicht füllt die Seite und wird per CSS mitskaliert; das Detail liegt scharf darüber */
.pdf-page__base { position: absolute; inset: 0; width: 100%; height: 100%; }

.pdf-page__detail { position: absolute; }

.viewer__zoom-label { cursor: pointer; }

@media (max-width: 640px) {
  .viewer__back span { display: none; }
  .viewer__subtitle, .viewer__counter, .viewer__zoom-label { display: none; }
  .viewer__title { font-size: 15px; }
}


/* Skeleton in der Vorschau */

.viewer__skeleton {
  width: min(100%, 860px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.viewer__skeleton .skeleton { width: 100%; }

.pdf-page--pending {
  background: color-mix(in srgb, var(--text) 4%, #fff);
}

.pdf-page--pending::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

.pdf-page { position: relative; overflow: hidden; }


/* Datenschutz und Impressum */

.legal {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  color: var(--text);
}

.legal h1 {
  margin: 8px 0 12px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.legal h1 + .legal h1, .legal #impressum { margin-top: 48px; }

.legal h2 {
  margin: 28px 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.legal p {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.55;
  max-width: 68ch;
}

.legal__lead { color: var(--text-soft); }

.legal a { color: inherit; }
