/* ---------- Grundlagen ---------- */

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

:root {
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-border: #e0e0e0;
  --color-danger: #b00020;
  --focus-ring: 2px solid #1a1a1a;
}

body {
  background: #ffffff;
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

/* ============================================================
 * Öffentliche Galerie (index.html) — nur Bilder, kein Text
 * ============================================================ */

body.viewer {
  padding: 4px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 4px;
}

.gallery-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.gallery-tile:focus-visible {
  outline: var(--focus-ring);
  outline-offset: -2px;
}

.gallery-tile img,
.gallery-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover; /* zuschneiden statt verzerren */
  display: block;
}

/* Play-Symbol auf Video-Kacheln */
.gallery-tile.is-video::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.7rem 0 0.7rem 1.15rem;
  border-color: transparent transparent transparent #ffffff;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

@media (max-width: 40rem) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  }
}

/* ============================================================
 * Lightbox (öffentliche Galerie)
 * ============================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-image,
.lightbox-video {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  display: block;
}

.lightbox-image[hidden],
.lightbox-video[hidden] {
  display: none;
}

.lightbox-close,
.lightbox-nav {
  position: fixed;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  font-size: 2rem;
  line-height: 1;
  padding: 0.75rem;
  z-index: 101;
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.lightbox-close {
  top: 1rem;
  right: 1.25rem;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
}

.lightbox-prev {
  left: 0.75rem;
}

.lightbox-next {
  right: 0.75rem;
}

/* ============================================================
 * Bildverwaltung (admin.html) — nur lokal beim Betreiber
 * ============================================================ */

body.admin {
  max-width: 72rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.site-header {
  margin-bottom: 3rem;
}

h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.image-count {
  margin-top: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--color-text);
  background: #ffffff;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 2px;
}

.btn:hover:not(:disabled) {
  background: var(--color-text);
  color: #ffffff;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.btn-danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger);
  color: #ffffff;
}

/* ---------- Verbinden & Upload ---------- */

.connect-area {
  border: 1px solid var(--color-border);
  padding: 3rem 1.5rem;
  text-align: center;
  margin-bottom: 2rem;
}

.connect-area form {
  max-width: 24rem;
  margin: 0 auto;
  text-align: left;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
}

.field input {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: #ffffff;
  color: var(--color-text);
}

.field input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 1px;
}

.connect-area .upload-formats {
  margin-bottom: 1.5rem;
}

.upload-area {
  border: 1px dashed var(--color-border);
  padding: 3rem 1.5rem;
  text-align: center;
  margin-bottom: 2rem;
  transition: border-color 0.15s ease;
}

.upload-area.drag-over {
  border-color: var(--color-text);
}

.upload-hint {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.upload-formats {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

/* ---------- Status & leerer Zustand ---------- */

.status-message {
  color: var(--color-danger);
  font-size: 0.9rem;
  margin-top: 2rem;
}

.empty-state {
  color: var(--color-text-muted);
  text-align: center;
  padding: 3rem 0;
}

/* ---------- Werkzeugleiste (Sortierung) ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.toolbar select {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: #ffffff;
  color: var(--color-text);
  cursor: pointer;
}

.toolbar select:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 1px;
}

.drag-hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

/* Ziehbare Kacheln im Modus „Eigene Reihenfolge" */
.gallery-item.draggable {
  cursor: move;
}

.gallery-item.draggable .gallery-thumb {
  cursor: move;
}

.gallery-item.dragging {
  opacity: 0.4;
}

/* ---------- Bildliste in der Verwaltung ---------- */

.gallery {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 2rem;
}

.gallery-item {
  display: flex;
  flex-direction: column;
}

.gallery-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
}

.gallery-thumb img,
.gallery-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-thumb.is-video::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.6rem 0 0.6rem 1rem;
  border-color: transparent transparent transparent #ffffff;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.gallery-meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.gallery-name {
  font-weight: 500;
  word-break: break-all;
}

.gallery-details {
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.gallery-actions {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.link-button {
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  color: var(--color-text);
}

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

.link-button.delete {
  color: var(--color-danger);
}

.link-button.move {
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
  padding: 0.2rem 0.3rem;
}

.link-button:disabled {
  opacity: 0.25;
  cursor: default;
  text-decoration: none;
}

.link-button:disabled:hover {
  color: var(--color-text-muted);
}

/* ---------- Verwaltung ---------- */

.manage-area {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.manage-area p {
  margin-top: 1.25rem;
}

/* ---------- Responsive (Verwaltung) ---------- */

@media (max-width: 40rem) {
  body.admin {
    padding: 2rem 1rem 4rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 1.25rem;
  }

  .upload-area,
  .connect-area {
    padding: 2rem 1rem;
  }
}
