/* ==========================================================================
   HerzFotos Galerie & Login - Haupt-Style (css/galerie.css)
   ========================================================================= */
:root {
  --cream: #f7f2e9;
  --paper: #fffdf8;
  --ink: #514c45;
  --muted: #777066;
  --olive: #737762;
  --olive2: #5e624f;
  --sand: #e4d5c5;
  --rose: #dbc4b1;
  --line: rgba(81,76,69,.14);
  --shadow: 0 24px 70px rgba(67,59,48,.13);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "DM Sans", Arial, sans-serif;
  line-height: 1.7;
  overflow-x: clip;
  min-height: 100vh;
  position: relative;
}

/* FIX: Perfekte vertikale und horizontale Zentrierung der Login-Box */
body.login-view,
body.login-body {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100vh;
  padding: 20px;
}

body.gallery-view {
  display: block;
  padding: var(--hf-header-height, 72px) 0 120px 0; /* Optimiert auf die Header-Höhe */
}

body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .05;
  background-image: url("../images/papier.jpg");
  background-size: 600px;
  mix-blend-mode: multiply;
  z-index: -1;
}

body:after {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: var(--rose);
  filter: blur(80px);
  opacity: .2;
  right: -100px;
  top: -100px;
  z-index: -1;
}

.gallery-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(67,59,48,.04);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
}

.logo {
  font: 600 32px/1 "Caveat", cursive;
  color: #62574d;
  text-decoration: none;
}

.logo span {
  color: var(--olive);
}

.logout-btn {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
  background: transparent;
}

.logout-btn:hover {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--muted);
}

.gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px;
}

/* FIX: Willkommensbox klebt nun sauber unter dem Header beim Scrollen */
.welcome-box {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 30px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 40px;
  text-align: center;
  position: sticky;
  top: calc(var(--hf-header-height, 72px) + 8px);
  z-index: 990;
}

.welcome-box h2 {
  font: 600 36px/1.2 "Caveat", cursive;
  color: #675b50;
  margin-bottom: 6px;
}

.welcome-box h2 span {
  color: var(--olive);
}

.welcome-box p {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 12px;
}

.welcome-box.limit-warning {
    background: #fffbeb !important;
    border: 1px solid #fde68a !important;
    box-shadow: 0 4px 15px rgba(217, 119, 6, 0.1);
}

.limit-hint {
  display: inline-block;
  font-size: 13px;
  background: var(--cream);
  padding: 4px 14px;
  border-radius: 999px;
  color: var(--ink);
  border: 1px solid rgba(81,76,69,.08);
}

/* ==========================================================================
   Login Box
   ========================================================================= */
.login-box {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: clamp(30px, 6vw, 50px);
  border-radius: 30px;
  width: min(460px, 100%);
  box-shadow: var(--shadow);
  transform: rotate(-1deg);
  transition: transform 0.3s ease;
  animation: boxReveal 0.6s ease forwards;
  position: relative;
}

@keyframes boxReveal {
  from { opacity: 0; transform: translateY(20px) rotate(0deg); }
  to { opacity: 1; transform: translateY(0) rotate(-1deg); }
}

.login-box:before {
  content: "♡";
  position: absolute;
  right: 30px;
  top: -25px;
  font: 55px "Caveat", cursive;
  color: #8a7565;
}

.login-box h2 {
  font: 600 32px/1.1 "Caveat", cursive;
  color: #675b50;
  margin-bottom: 12px;
  text-align: center;
}

.login-box p {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 25px;
  text-align: center;
}

form {
  display: flex;
  flex-direction: column;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 7px;
  color: var(--muted);
}

input[type="password"],
input[type="text"] {
  width: 100%;
  border: 1px solid #cfc5b7;
  background: #fffdfa;
  border-radius: 13px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  outline: none;
  margin-bottom: 20px;
  transition: all 0.25s ease;
}

input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(115, 119, 98, .12);
}

.submit-btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--olive);
  color: white;
  box-shadow: 0 12px 28px rgba(94,98,79,.25);
  transition: .25s;
}

.submit-btn:hover {
  transform: translateY(-3px);
  background: var(--olive2);
}

/* ==========================================================================
   Bilder-Grid & Karten-Struktur
   ========================================================================= */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(67,59,48,.05);
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.img-wrapper {
  position: relative;
  aspect-ratio: 3 / 2;
  background: #fdfcf7;
  overflow: hidden;
  border-radius: 17px 17px 0 0;
}

.img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.filename-box {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--paper);
  border-top: 1px solid rgba(81,76,69,.05);
  border-radius: 0 0 17px 17px;
}

.checkbox-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: var(--olive);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 15;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.hidden-checkbox {
  display: none !important;
}

.card.selected {
  border-color: var(--olive);
  box-shadow: 0 12px 40px rgba(115, 119, 98, 0.2);
}

.card.selected .checkbox-overlay {
  opacity: 1;
  transform: scale(1);
}

.card:hover:not(.selected) .checkbox-overlay {
  opacity: 0.4;
  transform: scale(0.9);
  background: var(--muted);
}

/* ==========================================================================
   FIX: Proportionales, flackerfreies Global-Vorschau-Popup
   ========================================================================= */
#global-preview-tooltip {
  position: fixed;
  display: none;
  z-index: 10000;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 15px;
  box-shadow: 0 30px 70px rgba(67,59,48,0.3);
  pointer-events: none;
  width: 400px;
  max-width: 90vw;
  transition: opacity 0.15s ease-out;
}

#tooltip-title {
  font: 600 20px/1.2 "Caveat", cursive;
  color: #675b50;
  margin-bottom: 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#tooltip-img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  border-radius: 12px;
  display: block;
  background: var(--cream);
}

/* ==========================================================================
   Auswahl-Panel unten
   ========================================================================= */
.selection-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 25px;
  box-shadow: var(--shadow);
  max-width: 600px;
  margin: 40px auto 0 auto;
  text-align: center;
}

.selection-panel label {
  display: block;
  font-weight: 700;
  margin: 20px 0 10px 0;
  text-align: left;
  color: var(--muted);
}

.selection-panel textarea {
  width: 100%;
  height: 100px;
  border: 1px solid #cfc5b7;
  background: #fffdfa;
  border-radius: 13px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  resize: vertical;
  margin-bottom: 25px;
  transition: all 0.25s ease;
}

.selection-panel textarea:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(115, 119, 98, .12);
}

/* ==========================================================================
   Responsive Ansichten & Touch-Optimierung
   ========================================================================= */
@media(max-width: 650px) {
  body.gallery-view {
    padding-top: 80px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
  }
  .gallery-header {
    padding: 12px 20px;
  }
  #global-preview-tooltip {
    display: none !important; /* Komplett aus auf Mobilgeräten */
  }
}

/* Confirmation and payment share one dialog, also available on a later visit. */
[hidden] { display: none !important; }
.hf-payment-open { margin: 12px 0 0; padding: 10px 20px; border: 1px solid var(--olive); border-radius: 999px; background: var(--olive); color: #fff; font: 600 14px/1.5 "DM Sans", Arial, sans-serif; cursor: pointer; min-height: 44px; }
.hf-payment-open:hover { background: var(--olive2); }
.hf-selection-thanks { position: fixed; inset: 0; margin: auto; width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 28px 32px; border: 1px solid var(--sand); border-radius: 24px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); text-align: center; font: 15px/1.6 "DM Sans", Arial, sans-serif; overflow-y: auto; overscroll-behavior: contain; }
.hf-selection-thanks::backdrop, .hf-checkout-backdrop { background: rgba(35,31,25,.5); }
.hf-checkout-backdrop { position: fixed; inset: 0; z-index: 1090; }
.hf-selection-thanks.hf-checkout-active { z-index: 1100; }
.hf-thanks-heart { color: var(--olive); font-size: 40px; line-height: 1; margin: 2px 0 10px; }
#hf-thanks-title:focus { outline: none; }
.hf-selection-thanks h2 { font: normal 29px/1.2 Georgia, serif; margin: 0 12px 16px; color: #675b50; }
.hf-selection-thanks p { margin: 10px 0; }
.hf-selection-thanks button { font-family: inherit; cursor: pointer; }
.hf-selection-thanks .hf-thanks-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 28px; border-radius: 50%; }
.hf-selection-thanks .hf-thanks-return { padding: 11px 24px; min-height: 44px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--cream); font-size: 14px; }
.hf-payment-open:focus-visible, .hf-selection-thanks button:focus-visible { outline: 3px solid #b78b51; outline-offset: 3px; }
.hf-selection-thanks button:disabled { opacity: .55; cursor: wait; }
.hf-payment-panel { text-align: left; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 20px 0 16px; padding: 18px 0; }
.hf-payment-panel h3 { font-size: 17px; }
.hf-payment-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hf-payment-total strong { font-size: 28px; color: #514c45; }
.hf-payment-total span { font-size: 13px; color: var(--muted); }
#hf-paypal-checkout { position: relative; z-index: 0; min-width: 0; width: 100%; }
.hf-payment-panel .hf-payment-note { font-size: 12px; color: var(--muted); }
#hf-paypal-message { font-size: 14px; overflow-wrap: anywhere; }
#hf-paypal-message:empty { display: none; }
.hf-payment-retry { min-height: 44px; background: var(--cream); color: var(--ink); padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; }
.hf-bank-transfer { background: var(--cream); border-radius: 12px; padding: 14px 16px; margin-top: 16px; }
.hf-bank-transfer h4 { font-size: 14px; }
.hf-bank-transfer p { font-size: 13px; margin-bottom: 0; }
.hf-payment-success { color: var(--olive2); }
.hf-thanks-signature { color: var(--muted); font-size: 13px; }
@media (max-width: 650px) {
  body.gallery-view { padding-top: var(--hf-header-height, 72px); }
  .welcome-box { padding: 16px; margin-bottom: 24px; border-radius: 16px; }
  .welcome-box h2 { font-size: 26px; }
  .welcome-box p { font-size: 13px; margin-bottom: 8px; }
  .limit-hint { font-size: 12px; padding: 4px 8px; }
  .hf-selection-thanks { padding: 24px 18px; }
  .hf-selection-thanks h2 { font-size: 25px; }
}
