* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #f2f2f2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen[hidden] {
  display: none;
}

/* ---------- Eingabe / Fehler ---------- */

.input-card {
  max-width: 420px;
  width: 90%;
  text-align: center;
  padding: 32px;
  background: #161616;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.input-card h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.input-card p {
  color: #b5b5b5;
  margin: 0 0 24px;
}

#album-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#album-id-input {
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #3a3a3a;
  background: #0d0d0d;
  color: #fff;
}

#album-id-input:focus {
  outline: 2px solid #4a90e2;
}

button {
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 8px;
  border: none;
  background: #4a90e2;
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: #3a7bc8;
}

#error-back-button {
  margin-top: 8px;
}

.error-text {
  color: #ff6b6b;
  margin-top: 12px;
}

/* ---------- Ladebildschirm ---------- */

#screen-loading {
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #333;
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Diashow ---------- */

#screen-slideshow {
  padding: 0;
}

#slideshow-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.slide-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
}

.slide-img.visible {
  opacity: 1;
  z-index: 1;
}

.controls {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.55));
  opacity: 1;
  transition: opacity 0.4s ease;
  z-index: 2;
  /* Nur die Kopf-/Fußzeile sollen Klicks abfangen, damit z.B. Raster-Kacheln
     im durchsichtigen mittleren Bereich weiterhin klickbar bleiben. */
  pointer-events: none;
}

.controls.hidden {
  opacity: 0;
}

.controls-top,
.controls-bottom {
  pointer-events: auto;
}

.controls.hidden .controls-top,
.controls.hidden .controls-bottom {
  pointer-events: none;
}

.controls-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: #eee;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.controls-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.controls-bottom button,
.controls-bottom select {
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
}

.controls-bottom button:hover {
  background: rgba(50, 50, 50, 0.8);
}

.controls-bottom button.active {
  background: #4a90e2;
  border-color: #4a90e2;
}

.controls-bottom select {
  color: #fff;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

#btn-prev,
#btn-next {
  font-size: 1.4rem;
  line-height: 1;
  padding: 10px 18px;
}

#btn-play-pause {
  font-size: 0.9rem;
  padding: 10px 16px;
}

/* ---------- Raster-Ansicht: "justified" Bilderwand ---------- */

#screen-grid {
  padding: 0;
  position: relative;
}

.grid-wall {
  position: relative;
  width: 100%;
  height: 100%;
  /* Kein Padding: Die Kacheln sind absolut positioniert und würden ein
     Padding hier ohnehin ignorieren (Containing Block = Padding-Box). Randlos
     nutzt außerdem den verfügbaren Platz am besten aus. */
  background: #000;
  overflow-y: auto;
}

.grid-tile {
  position: absolute;
  overflow: hidden;
  border-radius: 4px;
  background: #111;
  cursor: pointer;
  /* Position/Größe werden von app.js (justified Zeilen-Layout) per Inline-
     Style gesetzt; die Transition lässt Änderungen weich einrasten statt
     hart zu springen, wenn sich eine Zeile durch einen Bildwechsel anpasst. */
  transition: left 0.6s ease, top 0.6s ease, width 0.6s ease, height 0.6s ease;
}

.grid-wall.no-anim .grid-tile {
  transition: none;
}

.grid-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Die Kachelgröße entspricht bereits dem Seitenverhältnis des Bilds
     (justified Layout) - "contain" ist hier nur ein Sicherheitsnetz gegen
     Rundungsfehler, in der Praxis füllt das Bild die Kachel vollständig,
     ohne Zuschnitt und ohne graue Ränder. */
  object-fit: contain;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
}

.grid-tile img.visible {
  opacity: 1;
  z-index: 1;
}
