/* ---------------------------------------------------------------------------
   Die Galerie der Gaeste.

   Aufbau und Bausteine wie in der Verwaltung (assets/backend.css): eine
   Kopfleiste, die beim Blaettern stehen bleibt, Karten mit weichem Verlauf
   und runden Ecken, Buttons mit fester Bedeutung - gefuellt fuer die
   Hauptaktion, umrandet fuer alles daneben - und dieselben Reiter.

   Die Farben kommen nicht von hier, sondern aus dem Theme der Galerie
   (galerie_gestaltung.php). Es setzt die Variablen '--seite', '--flaeche',
   '--akzent' usw. in einem <style>-Block der Seite; hier steht nur, welche
   Flaeche welche Rolle hat. So sieht jede Galerie aus wie die Verwaltung,
   traegt aber die Farben ihrer Feier.
   ------------------------------------------------------------------------ */

:root {
    --radius: 16px;
    --radius-klein: 11px;
    --rand: 1.1rem;
    --breite: 1320px;
    --schatten: 0 12px 30px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--schrift);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--seite);
}
/* Ohne Hintergrundbild ein sehr weicher Lichtpunkt in der Akzentfarbe -
   wie in der Verwaltung. Mit Bild liegt das Bild darueber (body::before). */
body.ohne-bild {
    background-image: radial-gradient(1100px 620px at 12% -12%, var(--akzent-weich), transparent 60%);
    background-attachment: fixed;
}

a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

/* --- Buttons --------------------------------------------------------------
   Eine Bedeutung je Aussehen: Gefuellt in der Akzentfarbe ist die
   Hauptaktion - in der Galerie der Download aller Aufnahmen. Alles andere
   ist umrandet. */
.knopf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-klein);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.knopf:hover { text-decoration: none; }
.knopf:active { transform: translateY(1px); }
.knopf svg { width: 18px; height: 18px; flex: none; }
.knopf-haupt { background: var(--akzent); color: var(--akzent-text); }
.knopf-haupt:hover { background: var(--akzent-dunkel); color: var(--akzent-text); }
.knopf-rand { background: transparent; border-color: var(--rahmen); color: var(--text); }
.knopf-rand:hover { background: var(--flaeche-2-grund); border-color: var(--akzent); color: var(--text); }

/* --- Kopfleiste ----------------------------------------------------------- */
.galerie-kopf {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--flaeche-kopf, var(--flaeche-grund));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--rahmen-leise);
    padding: calc(0.6rem + env(safe-area-inset-top)) var(--rand) 0.6rem;
}
.galerie-kopf-innen {
    max-width: var(--breite);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
}
.galerie-marke { display: inline-flex; align-items: center; min-height: 44px; margin-right: auto; }
.galerie-logo { display: block; width: auto; height: 46px; max-width: min(62vw, 300px); object-fit: contain; }
.galerie-aktionen { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; min-width: 0; }
.kopf-link-button { max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.kopf-info-button .info-zeichen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35em;
    height: 1.35em;
    border-radius: 50%;
    background: var(--akzent);
    color: var(--akzent-text);
    font-family: Georgia, serif;
    font-style: italic;
    font-weight: 700;
}

/* Der Sprachumschalter als Pille wie in der Verwaltung. */
.sprachwahl {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--rahmen-leise);
    border-radius: 999px;
    background: var(--flaeche-2-grund);
}
.sprachwahl a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 0.75rem;
    border-radius: 999px;
    color: var(--text-leise);
    font-size: 0.85rem;
    font-weight: 700;
}
.sprachwahl a:hover { color: var(--text); text-decoration: none; }
.sprachwahl a.active { background: var(--akzent); color: var(--akzent-text); }

/* --- Inhalt --------------------------------------------------------------- */
.galerie-inhalt {
    flex: 1;
    width: 100%;
    max-width: var(--breite);
    margin: 0 auto;
    padding: 1.4rem var(--rand) 0;
}

.karte {
    background: linear-gradient(180deg, var(--flaeche-2-grund), var(--flaeche-grund));
    border: 1px solid var(--rahmen-leise);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.1rem;
    box-shadow: var(--schatten);
}
.karte > h2:first-child { margin-top: 0; }
.karte-titel { margin: 0 0 0.8rem; font-size: 1.05rem; }

/* Der Hinweistext als Karte. Er wird nicht uebersetzt, nur formatiert. */
.readme-notice { line-height: 1.6; font-size: 0.95rem; overflow-wrap: anywhere; }
.raw-hidden-notice { color: var(--text-leise); font-size: 0.9rem; }

/* Zum Aufklappen: das Plus im Kreis wie bei den Karten der Verwaltung. */
details.readme-klappbar > summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 32px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
details.readme-klappbar > summary::-webkit-details-marker { display: none; }
details.readme-klappbar > summary::before {
    content: '+';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    flex: none;
    border-radius: 50%;
    background: var(--akzent-weich);
    color: var(--akzent);
    font-weight: 700;
}
details.readme-klappbar[open] > summary::before { content: '\2212'; }
details.readme-klappbar[open] > summary { margin-bottom: 0.8rem; }

/* Eigene Dateien zum Download. */
.galerie-dateien-reihe { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.galerie-datei {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    max-width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--rahmen);
    border-radius: var(--radius-klein);
    background: var(--flaeche-grund);
    color: var(--text);
}
.galerie-datei:hover, .galerie-datei:focus-visible { border-color: var(--akzent); text-decoration: none; }
.galerie-datei svg { width: 22px; height: 22px; flex: none; color: var(--akzent); }
.galerie-datei-text { display: flex; flex-direction: column; min-width: 0; }
.galerie-datei-name { font-weight: 700; overflow-wrap: anywhere; }
.galerie-datei-info { font-size: 0.8rem; color: var(--text-leise); }

/* --- Reiter nach Art der Aufnahme - wie die Reiter der Verwaltung -------- */
.galerie-reiter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.4rem 0 1.1rem;
    box-shadow: inset 0 -1px 0 var(--rahmen-leise);
}
.galerie-reiter[hidden] { display: none; }
.galerie-reiter button {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 46px;
    padding: 0 1rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--text-leise);
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.galerie-reiter button:hover { color: var(--text); }
.galerie-reiter button[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--akzent); }
.galerie-reiter .anzahl { font-size: 0.75rem; font-weight: 700; color: var(--text-leise); }

/* --- Das Raster ----------------------------------------------------------
   Masonry ohne Zuschneiden: Das Skript der Seite liest Zeilenhoehe und
   Abstand von hier und setzt je Kachel die Zahl der Zeilen. */
.gallery.pswp-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    grid-auto-rows: 8px;
    gap: 12px;
    align-items: start;
    padding-bottom: 1rem;
}
/* Ohne Kacheln kein Raster: Die 8px-Zeilen gaeben dem Hinweis nur eine
   Zeile Hoehe. */
.gallery.pswp-gallery.gallery-leer { display: block; }
a.gallery-link {
    display: block;
    position: relative;
    overflow: hidden;
    line-height: 0;
    border: 1px solid var(--rahmen-leise);
    border-radius: var(--radius-klein);
    background: var(--flaeche);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
a.gallery-link:hover { border-color: var(--akzent); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25); }
a.gallery-link[hidden], h2.gallery-folder-heading[hidden] { display: none; }
a.gallery-link img,
a.gallery-link video {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    /* Einen Rahmen weiter innen, sonst steht zwischen Rahmen und Bild ein
       feiner Spalt. Safari verliert beim Vergroessern sonst die Ecke. */
    border-radius: calc(var(--radius-klein) - 1px);
    transition: transform 0.3s ease;
}
a.gallery-link:hover img,
a.gallery-link:hover video { transform: scale(1.03); }
h2.gallery-folder-heading {
    grid-column: 1 / -1;
    grid-row-end: span 5;
    align-self: end;
    margin: 0.6rem 0 0;
    padding-bottom: 0.4rem;
    font-size: 1.1rem;
    line-height: normal;
    border-bottom: 1px solid var(--rahmen-leise);
}
.no-images, .gallery .error {
    margin: 0;
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--text-leise);
    background: linear-gradient(180deg, var(--flaeche-2-grund), var(--flaeche-grund));
    border: 1px solid var(--rahmen-leise);
    border-radius: var(--radius);
}

/* Der Lichtkasten bleibt dunkel, gleich welches Theme gewaehlt ist: Ein
   Bild wird vor dunklem Grund betrachtet, nicht vor hellem. */
.pswp img { max-width: none; object-fit: contain; }
.pswp__bg { background-color: rgba(0, 0, 0, 0.9); }
.pswp__button { cursor: pointer; }
.pswp__button--close svg path, .pswp__button--download svg path, .pswp__button--share svg path,
.pswp__button--arrow--prev svg path, .pswp__button--arrow--next svg path { fill: var(--akzent) !important; transition: fill 0.3s ease; }
.pswp__button--download svg path[fill="none"], .pswp__button--share svg path[fill="none"] { fill: none !important; }
.pswp__button--close:hover svg path, .pswp__button--download:hover svg path, .pswp__button--share:hover svg path,
.pswp__button--arrow--prev:hover svg path, .pswp__button--arrow--next:hover svg path { fill: #ffffff !important; }
.pswp__button--download:hover svg path[fill="none"], .pswp__button--share:hover svg path[fill="none"] { fill: none !important; }

/* --- Anmeldung ------------------------------------------------------------
   Eine schmale Karte in der Mitte, wie die Anmeldung der Verwaltung. */
.anmeldung {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem var(--rand);
}
.anmeldung-karte { width: 100%; max-width: 440px; margin: 0; padding: 1.75rem 1.5rem; text-align: center; }
.anmeldung-karte .galerie-logo { height: 64px; max-width: 100%; margin: 0 auto 1.2rem; }
.anmeldung-karte h1 { margin: 0 0 0.4rem; font-size: 1.45rem; }
.anmeldung-karte p.hinweis { margin: 0 0 1.2rem; color: var(--text-leise); }
.anmeldung-karte form { text-align: left; }
.anmeldung-karte label { display: block; margin: 0 0 0.4rem; font-weight: 600; }
.anmeldung-karte input[type="text"] {
    width: 100%;
    min-height: 48px;
    padding: 0.72rem 0.9rem;
    border: 1px solid var(--eingabe-rahmen);
    border-radius: var(--radius-klein);
    background: var(--eingabe-grund);
    color: var(--text);
    font: inherit;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
}
.anmeldung-karte input[type="text"]:focus { outline: none; border-color: var(--akzent); box-shadow: 0 0 0 3px var(--akzent-weich); }
.anmeldung-karte .knopf { width: 100%; margin-top: 0.9rem; min-height: 48px; }
.anmeldung-fehler {
    margin: 0.9rem 0 0;
    padding: 0.7rem 0.9rem;
    border: 1px solid rgba(248, 113, 113, 0.55);
    border-radius: var(--radius-klein);
    background: rgba(248, 113, 113, 0.12);
    color: var(--text);
    font-weight: 600;
}

/* Die Testcodes im Demo-Betrieb. */
.demo-hinweis {
    margin: 0 0 1.1rem;
    padding: 0.8rem 1rem;
    text-align: left;
    border: 1px dashed var(--akzent);
    border-radius: var(--radius-klein);
    background: var(--akzent-weich);
    font-size: 0.9rem;
}
.demo-hinweis p { margin: 0 0 6px; }
.demo-hinweis ul { margin: 0; padding-left: 18px; }
.demo-hinweis li { margin-bottom: 3px; }
.demo-hinweis code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; }

/* --- Fusszeile ------------------------------------------------------------ */
.galerie-fuss {
    margin-top: 2rem;
    padding: 1.2rem var(--rand) calc(1.2rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--rahmen-leise);
    text-align: center;
    color: var(--text-leise);
    font-size: 0.8rem;
}
.galerie-fuss p { margin: 0.4rem 0 0; }

/* --- Telefon -------------------------------------------------------------- */
@media (max-width: 640px) {
    .galerie-logo { height: 38px; }
    .galerie-aktionen { width: 100%; justify-content: flex-start; }
    .galerie-aktionen .knopf { min-height: 40px; padding: 0.45rem 0.8rem; font-size: 0.92rem; }
    .galerie-aktionen .download-button { order: -1; flex: 1 1 100%; }
    .kopf-info-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .galerie-inhalt { padding-top: 1rem; }
    .karte { padding: 1rem; border-radius: 14px; }
    .galerie-datei { flex: 1 1 100%; }
    .gallery.pswp-gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
    /* Wie in der Verwaltung: Reiter als Schaltflaechen, die umbrechen. */
    .galerie-reiter { gap: 0.45rem; box-shadow: none; }
    .galerie-reiter button {
        min-height: 40px;
        padding: 0 0.9rem;
        border: 1px solid var(--rahmen);
        border-radius: 999px;
        font-size: 0.92rem;
    }
    .galerie-reiter button[aria-pressed="true"] { border-color: var(--akzent); background: var(--akzent-weich); }
}

/* --- Gaeste-Upload ---------------------------------------------------------- */
.gast-upload-dialog .rechtstext-inhalt p { margin: 0 0 0.9rem; }
.gast-upload-wahl { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; margin: 0 0 1rem; cursor: pointer; }
.gast-upload-wahl input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.gast-upload-wahl input[type="file"]:focus-visible + .knopf { outline: 2px solid var(--akzent); outline-offset: 2px; }
.gast-upload-auswahl { color: var(--text-leise); font-size: 0.88rem; }
.gast-upload-zustimmung { color: var(--text-leise); font-size: 0.82rem; }
.gast-upload-senden { width: 100%; }
.gast-upload-fortschritt { height: 8px; margin-top: 1rem; border-radius: 999px; background: var(--flaeche-2); overflow: hidden; }
.gast-upload-fortschritt span { display: block; height: 100%; width: 0; background: var(--akzent); transition: width 0.2s ease; }
.gast-upload-status { margin: 0.8rem 0 0 !important; font-weight: 600; }
.gast-upload-status.ist-fehler { color: #f87171; }
.galerie-meldung { font-weight: 600; }
.galerie-meldung.ist-fehler { border-color: rgba(248, 113, 113, 0.55); }
