@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --parchment: #f5e6c8;
  --parchment-dark: #e8d4a8;
  --brown: #3d2b1f;
  --brown-light: #6b4c3b;
  --green: #4a7c59;
  --green-dark: #2d5a3f;
  --green-light: #7ab68a;
  --brown-accent: #8a5a35;
  --brown-accent-dark: #6b4526;
  --gold: #c9a84c;
  --gold-light: #e8cc6e;
  --red-warm: #9b4d3a;
  --shadow: rgba(61, 43, 31, 0.3);
}

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

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--brown);
  color: var(--brown);
  min-height: 100vh;
  overflow: hidden;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(61, 43, 31, 0.3), rgba(61, 43, 31, 0.3)),
    url('assets/bg-fotobox.webp') center / cover,
    linear-gradient(170deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  overflow-y: auto;
}

#screen-gallery,
#screen-result {
  background:
    linear-gradient(rgba(61, 43, 31, 0.3), rgba(61, 43, 31, 0.3)),
    url('assets/bg-gallery.webp') center / cover,
    linear-gradient(170deg, var(--parchment) 0%, var(--parchment-dark) 100%);
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.content {
  text-align: center;
  padding: 2rem;
  max-width: 900px;
  width: 100%;
}

/* Auf den einfachen Text-Screens Inhalt auf die Breite des gemalten Rahmens begrenzen,
   damit nichts über den Goldrahmen des Hintergrundbilds hinausläuft. Ergebnis-Screen
   bleibt bei 900px (braucht die Breite für den Vorher/Nachher-Vergleich nebeneinander). */
#screen-welcome .content,
#screen-processing .content,
#screen-error .content {
  max-width: 600px;
}

h1 {
  font-family: 'Cinzel', serif;
  font-size: 2.55rem;
  color: var(--brown);
  margin-bottom: 0.5rem;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(245, 230, 200, 0.4);
}

.title-accent {
  color: var(--brown-accent);
  font-size: 2.975rem;
  display: block;
}

h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.7rem;
  color: var(--brown);
  margin-bottom: 1rem;
  text-shadow: 0 1px 2px rgba(245, 230, 200, 0.4);
}

.subtitle {
  font-size: 1.7rem;
  color: var(--brown-light);
  margin-bottom: 2.5rem;
  font-style: italic;
  text-shadow: 0 1px 2px rgba(245, 230, 200, 0.4);
}

/* Buttons */

.btn-primary {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  padding: 1rem 3rem;
  background: var(--brown-accent);
  color: var(--parchment);
  border: 2px solid var(--brown-accent-dark);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px var(--shadow);
  margin: 0.5rem;
}

.btn-primary:hover {
  background: var(--brown-accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow);
}

.btn-secondary {
  font-family: 'Lora', serif;
  font-size: 1.2rem;
  padding: 0.8rem 2.2rem;
  background: rgba(245, 230, 200, 0.35);
  color: var(--brown-light);
  border: 1px solid var(--brown-light);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s;
  margin: 0.5rem;
  backdrop-filter: blur(3px);
}

.btn-secondary:hover {
  background: var(--brown);
  color: var(--parchment);
}

.btn-settings {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  background: rgba(61, 43, 31, 0.15);
  color: var(--brown-light);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s;
}

.btn-settings:hover {
  background: rgba(61, 43, 31, 0.35);
  color: var(--brown);
}

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

.settings-overlay.hidden {
  display: none;
}

.settings-panel {
  background: var(--parchment);
  border-radius: 15px;
  border: 3px solid var(--brown);
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.settings-panel h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  margin: 1rem 0 0.8rem;
  color: var(--brown-light);
}

.camera-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  text-align: left;
  font-size: 1.3rem;
}

.camera-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.email-form {
  margin-top: 1rem;
}

.email-form p {
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}

.email-form input[type="email"] {
  font-family: 'Lora', serif;
  font-size: 1.4rem;
  padding: 0.6rem 1rem;
  border-radius: 25px;
  border: 1px solid var(--brown-light);
  margin-right: 0.5rem;
  max-width: 220px;
}

.email-msg {
  margin-top: 0.5rem;
  font-style: italic;
  color: var(--brown-light);
  min-height: 1.2em;
}

.btn-back {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  font-family: 'Lora', serif;
  font-size: 1.3rem;
  padding: 0.6rem 1.4rem;
  background: rgba(61, 43, 31, 0.75);
  color: var(--parchment);
  border: 1px solid rgba(201, 168, 76, 0.6);
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  transition: all 0.3s;
  z-index: 10;
}

.btn-back:hover {
  background: rgba(61, 43, 31, 0.9);
  border-color: var(--gold-light);
}

/* Camera */

.camera-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  overflow: hidden;
  border: none;
  background: #000;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-controls {
  margin-top: 2rem;
}

/* Kamera/Vorschau mittig auf dem Bildschirm positionieren, unabhängig vom Hintergrundbild.
   Quadratischer Ausschnitt (1:1); das Hintergrundbild wird darauf abgestimmt. */
#screen-camera .camera-container,
#screen-preview .preview-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 55vh;
  height: auto;
  aspect-ratio: 1 / 1;
  max-width: none;
  border: none;
  border-radius: 0;
}

#screen-camera .camera-controls,
#screen-preview .camera-controls {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0;
}

/* Preview */

.preview-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  overflow: hidden;
  border: none;
  background: #000;
}

.preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.privacy-hint {
  position: fixed;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 480px;
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--brown-light);
  text-shadow: 0 1px 2px rgba(245, 230, 200, 0.4);
}

.btn-capture {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--red-warm);
  border: 5px solid var(--parchment);
  cursor: pointer;
  position: relative;
  box-shadow: 0 0 0 4px var(--brown), 0 5px 20px var(--shadow);
  transition: transform 0.15s;
}

.btn-capture:hover {
  transform: scale(1.1);
}

.btn-capture:active {
  transform: scale(0.95);
}

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

/* Countdown */

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 8rem;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  z-index: 5;
  animation: countPulse 1s ease-in-out infinite;
}

.countdown.hidden {
  display: none;
}

@keyframes countPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Processing */

.processing-animation {
  margin-bottom: 2rem;
}

.ring-spinner {
  width: 100px;
  height: 100px;
  margin: 0 auto;
  border: 5px solid var(--parchment-dark);
  border-top-color: var(--gold);
  border-right-color: var(--green);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

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

.fun-fact {
  font-style: italic;
  color: var(--brown-light);
  font-size: 1.4rem;
  margin-top: 1.5rem;
  transition: opacity 0.3s;
  min-height: 2em;
  text-shadow: 0 1px 2px rgba(245, 230, 200, 0.4);
}

/* Ergebnis-Screen: zweispaltig, Foto links, QR-Code/Buttons rechts */
#screen-result .content {
  max-width: 1700px;
}

.result-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.result-columns {
  display: flex;
  gap: 3rem;
  align-items: center;
  text-align: left;
  width: 100%;
}

.result-photo-col {
  flex: 2;
}

.result-info-col {
  flex: 1;
  text-align: center;
}

/* Framed photo — geteilt zwischen Ergebnis-Screen und Galerie-Kacheln.
   Holzrahmen-Overlay (assets/frame.webp, 3278×2672px) liegt über dem Foto;
   das Foto wird auf das transparente Sichtfenster des Rahmens zugeschnitten
   (Insets: links/rechts 10.28%, oben/unten 13.59% der Rahmen-Gesamtgröße). */
.framed-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 3278 / 2672;
  overflow: hidden;
  cursor: pointer;
}

.framed-photo-image {
  position: absolute;
  top: 13.59%;
  left: 10.28%;
  width: 79.44%;
  height: 72.82%;
  object-fit: cover;
  display: block;
}

.framed-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('assets/frame.webp') center / cover no-repeat;
  pointer-events: none;
}

.qr-section {
  margin: 1.5rem 0;
}

.qr-section p {
  margin-bottom: 0.8rem;
  color: var(--brown-light);
  font-size: 1.4rem;
}

#qr-canvas {
  border-radius: 10px;
  box-shadow: 0 4px 15px var(--shadow);
}

.result-actions {
  margin-top: 1.5rem;
}

/* Gallery */

#screen-gallery .content {
  max-width: 1300px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.2rem;
  margin: 1.5rem 0;
}

.gallery-hint {
  color: var(--brown-light);
  font-style: italic;
  font-size: 1.4rem;
  margin-bottom: 1rem;
  text-shadow: 0 1px 2px rgba(245, 230, 200, 0.4);
}

.gallery-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  transition: transform 0.3s;
}

.gallery-item:hover {
  transform: scale(1.05);
}

/* Lightbox */

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

.lightbox-overlay.hidden {
  display: none;
}

.lightbox-image {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-frame.framed {
  position: relative;
  width: min(90vw, 1100px);
  aspect-ratio: 3278 / 2672;
  overflow: hidden;
}

.lightbox-frame.framed::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('assets/frame.webp') center / cover no-repeat;
  pointer-events: none;
}

.lightbox-frame.framed .lightbox-image {
  position: absolute;
  top: 13.59%;
  left: 10.28%;
  width: 79.44%;
  height: 72.82%;
  max-width: none;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}

.btn-delete {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  font-size: 1.4rem;
  background: var(--red-warm);
  color: var(--parchment);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s;
}

.btn-delete:hover {
  background: var(--brown-accent-dark);
}

.btn-delete.hidden {
  display: none;
}


/* Responsive */

@media (max-width: 900px) {
  .result-columns {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 600px) {
  h1 { font-size: 1.7rem; }
  .title-accent { font-size: 2.125rem; }
  h2 { font-size: 1.275rem; }
  .result-arrow { display: none; }
  .result-compare { flex-direction: column; }
  .result-card { max-width: 100%; min-width: unset; }
}
