/*
 Theme Name:   GeneratePress Child
 Theme URI:    https://generatepress.com
 Description:  Default GeneratePress child theme
 Author:       Tom Usborne
 Author URI:   https://tomusborne.com
 Template:     generatepress
 Version:      0.1
*/


/* ==================================================
   FLIP-CARD – ÄUSSERER CONTAINER
   ================================================== */

.flip-card {
    position: relative;
    width: 100%;
    aspect-ratio: 12 / 5;

    perspective: 1200px;
    cursor: pointer;

    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}


/* Sichtbarer Tastaturfokus */
.flip-card:focus-visible {
    outline: 3px solid #51483e;
    outline-offset: 4px;
    border-radius: 12px;
}


/* ==================================================
   DREHBARER KARTENKÖRPER
   ================================================== */

.flip-card-inner {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;

    transition: transform 0.65s cubic-bezier(0.2, 0.7, 0.2, 1);
    will-change: transform;
}


/* Drehung durch JavaScript auf Touch-Geräten */
.flip-card.is-flipped .flip-card-inner {
    transform: rotateY(180deg);
}


/* Hover-Drehung nur auf Geräten mit Maus */
@media (hover: hover) and (pointer: fine) {

    .flip-card:hover .flip-card-inner {
        transform: rotateY(180deg);
    }
}


/* ==================================================
   GEMEINSAME KARTENSEITEN
   ================================================== */

.flip-card-front,
.flip-card-back {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    margin: 0;
    overflow: hidden;
    box-sizing: border-box;

    border-radius: 12px;

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}


/* ==================================================
   VORDERSEITE
   ================================================== */

.flip-card-front {
    padding: 0;
    transform: rotateY(0deg) translateZ(1px);
}


/* GenerateBlocks-Bildcontainer vollständig ausfüllen */
.flip-card-front figure,
.flip-card-front .gb-block-image {
    display: block;

    width: 100%;
    height: 100%;

    margin: 0;
}


/* Bild vollständig innerhalb der Karte darstellen */
.flip-card-front img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
}


/* ==================================================
   KLEINE DREH-LASCHE AUF DER VORDERSEITE
   ::before bleibt für die Bedienung reserviert.
   ::after wird weiter unten für die Bildbeschriftung verwendet.
   ================================================== */

.flip-card-front::before {
    content: "↻";

    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;

    display: grid;
    place-items: center;

    width: 30px;
    height: 30px;
    padding: 0;
    box-sizing: border-box;

    color: #ffffff;
    background: rgba(45, 41, 36, 0.88);

    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.24);

    font-family: Oxygen, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    text-align: center;

    pointer-events: none;

    transition:
        background-color 0.25s ease,
        transform 0.25s ease;
}


/* Hervorhebung der kleinen Lasche bei Maus-Hover */
@media (hover: hover) and (pointer: fine) {

    .flip-card:hover .flip-card-front::before {
        background: #51483e;
        transform: scale(1.05);
    }
}


/* ==================================================
   RÜCKSEITE
   ================================================== */

.flip-card-back {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 12px;
    padding: 42px 30px 30px;
    overflow-y: auto;

    color: #29251f;
    background: #f1ece4;
    text-align: center;

    transform: rotateY(180deg) translateZ(1px);
}


/* Standardabstände entfernen */
.flip-card-back h1,
.flip-card-back h2,
.flip-card-back h3,
.flip-card-back h4,
.flip-card-back p {
    margin: 0;
}


/* Optionaler Button */
.flip-card-back .gb-button,
.flip-card-back .wp-block-button__link {
    margin-top: 8px;
}


/* ==================================================
   KLEINE ZURÜCK-LASCHE AUF DER RÜCKSEITE
   ================================================== */

.flip-card-back::after {
    content: "↶";

    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;

    display: flex;
    align-items: flex-start;
    justify-content: flex-start;

    width: 32px;
    height: 32px;

    padding: 3px 0 0 4px;
    box-sizing: border-box;

    color: #ffffff;
    background: #2d2924;

    font-size: 13px;
    font-weight: 700;
    line-height: 1;

    clip-path: polygon(
        0 0,
        100% 0,
        0 100%
    );

    pointer-events: none;

    transition: background-color 0.25s ease;
}


/* Hervorhebung der kleinen Zurück-Lasche */
@media (hover: hover) and (pointer: fine) {

    .flip-card:hover .flip-card-back::after {
        background: #51483e;
    }
}


/* ==================================================
   TABLET UND SMARTPHONE
   ================================================== */

@media (max-width: 768px) {

    .flip-card {
        aspect-ratio: 4 / 3;
    }

    .flip-card-back {
        gap: 10px;
        padding: 38px 20px 20px;
    }


    /* Kleine Dreh-Lasche auf der Vorderseite */
    .flip-card-front::before {
        top: 7px;
        right: 7px;

        width: 28px;
        height: 28px;

        font-size: 16px;
    }


    /* Sehr kleine Zurück-Lasche */
    .flip-card-back::after {
        content: "↶";

        width: 28px;
        height: 28px;

        padding: 3px 0 0 4px;

        font-size: 11px;
    }
}


/* ==================================================
   KLEINE SMARTPHONES
   ================================================== */

@media (max-width: 480px) {

    .flip-card-back {
        gap: 8px;
        padding: 34px 18px 18px;
    }

    .flip-card-back h2,
    .flip-card-back h3 {
        font-size: 22px;
    }

    .flip-card-back p {
        font-size: 15px;
        line-height: 1.5;
    }

    .flip-card-back::after {
        width: 26px;
        height: 26px;

        padding: 2px 0 0 3px;

        font-size: 10px;
    }
}


/* ==================================================
   REDUZIERTE BEWEGUNGEN
   ================================================== */

@media (prefers-reduced-motion: reduce) {

    .flip-card-inner,
    .flip-card-front::before,
    .flip-card-back::after {
        transition: none;
    }
}

/* =========================================================
   KONTAKTFORMULAR – FERIENWOHNUNG AM HERRENTEICH
   Kompakte Darstellung für Contact Form 7
   ========================================================= */

/* Formular-Grundstruktur */
.herrenteich-anfrageformular {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    width: 100%;
    max-width: 680px;
    margin: 0;
    padding: 0;
}

/* Von WordPress und Contact Form 7 erzeugte Abstände entfernen */
.herrenteich-anfrageformular p,
.herrenteich-anfrageformular > p,
.herrenteich-anfrageformular label,
.herrenteich-anfrageformular .wpcf7-form-control-wrap,
.herrenteich-anfrageformular .wpcf7-list-item {
    margin: 0 !important;
}

/* Überflüssige Zeilenumbrüche vermeiden */
.herrenteich-anfrageformular > br {
    display: none;
}

/* Einzelne Formularzeilen */
.herrenteich-anfrageformular > p {
    padding: 0;
}

/* Beschriftungen */
.herrenteich-anfrageformular label {
    display: block;
    color: var(--contrast, #222222);
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
}

/* Abstand zwischen Beschriftung und Eingabefeld */
.herrenteich-anfrageformular .wpcf7-form-control-wrap {
    display: block;
    margin-top: 5px !important;
}

/* Textfelder, Datumsfelder und Textarea */
.herrenteich-anfrageformular input[type="text"],
.herrenteich-anfrageformular input[type="email"],
.herrenteich-anfrageformular input[type="date"],
.herrenteich-anfrageformular input[type="tel"],
.herrenteich-anfrageformular input[type="number"],
.herrenteich-anfrageformular select,
.herrenteich-anfrageformular textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 9px 13px;
    border: 1px solid #c8c8c8;
    border-radius: 7px;
    background-color: #f7f9fb;
    color: var(--contrast, #222222);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    box-sizing: border-box;
    box-shadow: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

/* Kompakte Höhe der normalen Felder */
.herrenteich-anfrageformular input[type="text"],
.herrenteich-anfrageformular input[type="email"],
.herrenteich-anfrageformular input[type="date"],
.herrenteich-anfrageformular input[type="tel"],
.herrenteich-anfrageformular input[type="number"],
.herrenteich-anfrageformular select {
    height: 44px;
    min-height: 44px;
}

/* Datumsfelder */
.herrenteich-anfrageformular input[type="date"] {
    cursor: pointer;
}

/* Nachrichtenfeld verkürzen */
.herrenteich-anfrageformular textarea {
    height: 125px;
    min-height: 125px;
    max-height: 260px;
    resize: vertical;
}

/* Platzhalter */
.herrenteich-anfrageformular input::placeholder,
.herrenteich-anfrageformular textarea::placeholder {
    color: #747474;
    opacity: 1;
}

/* Fokus */
.herrenteich-anfrageformular input:focus,
.herrenteich-anfrageformular select:focus,
.herrenteich-anfrageformular textarea:focus {
    outline: none;
    border-color: var(--accent, #b8aa7c);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px color-mix(
        in srgb,
        var(--accent, #b8aa7c) 20%,
        transparent
    );
}

/* Anreise und Abreise nebeneinander */
.herrenteich-anfrageformular .anfrage-zeitraum {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 0 !important;
    padding: 0;
}

/* Datumsbereich vollständig kompakt halten */
.herrenteich-anfrageformular .anfrage-zeitraum p,
.herrenteich-anfrageformular .anfrage-zeitraum label,
.herrenteich-anfrageformular .anfrage-zeitraum .wpcf7-form-control-wrap {
    margin-bottom: 0 !important;
}

/* Validierungsmeldungen direkt unter dem Feld */
.herrenteich-anfrageformular .wpcf7-not-valid-tip {
    display: block;
    margin: 3px 0 0 !important;
    color: #c32018;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
}

/* Fehlerhafte Felder */
.herrenteich-anfrageformular .wpcf7-not-valid {
    border-color: #c32018;
}

/* Datenschutzbereich */
.herrenteich-anfrageformular .wpcf7-acceptance {
    display: block;
    margin: 0 !important;
}

/* Checkbox und Datenschutztext */
.herrenteich-anfrageformular .wpcf7-acceptance label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.45;
    cursor: pointer;
}

/* Checkbox */
.herrenteich-anfrageformular input[type="checkbox"] {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    margin: 2px 0 0 !important;
    accent-color: var(--accent, #b8aa7c);
    cursor: pointer;
}

/* Datenschutztext */
.herrenteich-anfrageformular .wpcf7-list-item-label {
    display: inline;
}

/* Absende-Button */
.herrenteich-anfrageformular input[type="submit"],
.herrenteich-anfrageformular button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 44px;
    margin: 0;
    padding: 10px 22px;
    border: 1px solid var(--accent, #b8aa7c);
    border-radius: 7px;
    background-color: var(--accent, #b8aa7c);
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    box-shadow: none;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

/* Button Hover */
.herrenteich-anfrageformular input[type="submit"]:hover,
.herrenteich-anfrageformular button[type="submit"]:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* Button Fokus */
.herrenteich-anfrageformular input[type="submit"]:focus-visible,
.herrenteich-anfrageformular button[type="submit"]:focus-visible {
    outline: 3px solid color-mix(
        in srgb,
        var(--accent, #b8aa7c) 35%,
        transparent
    );
    outline-offset: 2px;
}

/* Button während des Sendens */
.herrenteich-anfrageformular input[type="submit"]:disabled,
.herrenteich-anfrageformular button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

/* Ladeanimation */
.herrenteich-anfrageformular .wpcf7-spinner {
    margin: 0 0 0 8px;
    vertical-align: middle;
}

/* Allgemeine Rückmeldung unter dem Formular */
.wpcf7 form .wpcf7-response-output {
    max-width: 680px;
    margin: 12px 0 0 !important;
    padding: 9px 13px;
    border-width: 1px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1.45;
}

/* Erfolgreiche Übermittlung */
.wpcf7 form.sent .wpcf7-response-output {
    border-color: var(--accent, #b8aa7c);
    background-color: color-mix(
        in srgb,
        var(--accent, #b8aa7c) 12%,
        #ffffff
    );
}

/* Fehlerhafte Übermittlung */
.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output,
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output {
    border-color: #c32018;
    background-color: #fff6f5;
}

/* =========================================================
   TABLET UND SMARTPHONE
   ========================================================= */

@media (max-width: 768px) {

    .herrenteich-anfrageformular {
        max-width: 100%;
        gap: 13px;
    }

    .herrenteich-anfrageformular .anfrage-zeitraum {
        gap: 14px;
    }

    .herrenteich-anfrageformular textarea {
        height: 115px;
        min-height: 115px;
    }
}

@media (max-width: 580px) {

    /* Datumsfelder untereinander */
    .herrenteich-anfrageformular .anfrage-zeitraum {
        grid-template-columns: 1fr;
        gap: 13px;
    }

    .herrenteich-anfrageformular textarea {
        height: 110px;
        min-height: 110px;
    }

    .herrenteich-anfrageformular input[type="submit"],
    .herrenteich-anfrageformular button[type="submit"] {
        width: 100%;
    }
}

/* ==========================================================
   GALERIEN – FERIENWOHNUNG AM HERRENTEICH
   Ergänzung für den optimierten GenerateBlocks-Seitencode
   ========================================================== */

/* Beide Wohnungen werden untereinander dargestellt. */
.fewo-gallery-list {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 70px !important;
}

/* Grundaufbau der beiden Wohnungsgalerien. */
.apartment-gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: auto repeat(4, clamp(155px, 14vw, 185px));
    gap: 14px;
    width: 100%;
}

.apartment-gallery > h4 {
    grid-column: 1 / -1;
    margin: 0 0 8px;
    padding: 0;
    text-align: center;
}

/* Karten in den CSS-Grids füllen ihre jeweilige Rasterfläche vollständig. */
.apartment-gallery .gallery-card,
.excursion-gallery .excursion-card {
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    aspect-ratio: auto !important;
    align-self: stretch;
}

.apartment-gallery .flip-card-inner,
.apartment-gallery .flip-card-front,
.apartment-gallery .flip-card-back,
.excursion-gallery .flip-card-inner,
.excursion-gallery .flip-card-front,
.excursion-gallery .flip-card-back {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 10px;
}

.apartment-gallery .flip-card-front img,
.excursion-gallery .flip-card-front img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: cover !important;
    border-radius: 10px !important;
}

/* ----------------------------------------------------------
   Appartement 1
   ---------------------------------------------------------- */
.apartment-gallery--1 .gallery-card--living {
    grid-column: 1 / 3;
    grid-row: 2 / 4;
}

.apartment-gallery--1 .gallery-card--bedroom {
    grid-column: 3 / 4;
    grid-row: 2 / 4;
}

.apartment-gallery--1 .gallery-card--entrance {
    grid-column: 4 / 5;
    grid-row: 2 / 4;
}

.apartment-gallery--1 .gallery-card--bath {
    grid-column: 1 / 3;
    grid-row: 4 / 6;
}

.apartment-gallery--1 .gallery-card--dining {
    grid-column: 3 / 4;
    grid-row: 4 / 6;
}

.apartment-gallery--1 .gallery-card--kids {
    grid-column: 4 / 5;
    grid-row: 4 / 6;
}

/* ----------------------------------------------------------
   Appartement 2
   ---------------------------------------------------------- */
.apartment-gallery--2 .gallery-card--living {
    grid-column: 1 / 3;
    grid-row: 2 / 4;
}

.apartment-gallery--2 .gallery-card--bedroom {
    grid-column: 3 / 5;
    grid-row: 2 / 3;
}

.apartment-gallery--2 .gallery-card--bath {
    grid-column: 3 / 5;
    grid-row: 3 / 4;
}

.apartment-gallery--2 .gallery-card--entrance {
    grid-column: 1 / 2;
    grid-row: 4 / 6;
}

.apartment-gallery--2 .gallery-card--kitchen {
    grid-column: 2 / 5;
    grid-row: 4 / 6;
}

/* ----------------------------------------------------------
   Urlaub in Schneeberg – 9 Flip-Cards
   Desktop: 3 × 3, Tablet: 2 Spalten, Mobil: 1 Spalte
   ---------------------------------------------------------- */
.excursion-gallery {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-flow: row;
    grid-auto-rows: clamp(235px, 22vw, 310px);
    gap: 14px !important;
    width: 100%;
    padding: 25px 0 !important;
}

/*
 * Alle neun Karten laufen in der natürlichen HTML-Reihenfolge.
 * Alte feste Magazin-Positionen werden damit vollständig aufgehoben.
 */
.excursion-gallery .excursion-card {
    grid-column: auto !important;
    grid-row: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    aspect-ratio: auto !important;
    align-self: stretch;
}

/* Einheitliche Kartenhöhen und saubere Bildausschnitte */
.excursion-gallery .flip-card-inner,
.excursion-gallery .flip-card-front,
.excursion-gallery .flip-card-back {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 10px;
}

.excursion-gallery .flip-card-front img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: cover !important;
    border-radius: 10px !important;
}

/* Motivbezogene Bildausschnitte */
.excursion-gallery .excursion-card--church .flip-card-front img {
    object-position: center 42%;
}

.excursion-gallery .excursion-card--pochwerk .flip-card-front img,
.excursion-gallery .excursion-card--museum .flip-card-front img,
.excursion-gallery .excursion-card--bergstreittag .flip-card-front img,
.excursion-gallery .excursion-card--lichtelfest .flip-card-front img,
.excursion-gallery .excursion-card--fundora .flip-card-front img,
.excursion-gallery .excursion-card--actinion .flip-card-front img,
.excursion-gallery .excursion-card--zoo .flip-card-front img,
.excursion-gallery .excursion-card--planetarium .flip-card-front img {
    object-position: center center;
}

/* ----------------------------------------------------------
   Beschriftungen auf den Bildvorderseiten
   ---------------------------------------------------------- */
.gallery-card .flip-card-front::after,
.excursion-card .flip-card-front::after {
    position: absolute;
    top: auto;
    right: auto;
    bottom: 10px;
    left: 10px;
    z-index: 4;

    display: block;
    width: auto;
    height: auto;
    max-width: min(78%, 420px);
    margin: 0;
    padding: 6px 9px;

    border: 0;
    border-left: 3px solid var(--accent, #b8aa7c);
    border-radius: 0 7px 7px 0;

    background: rgba(0, 0, 0, 0.68);
    color: #ffffff;
    box-shadow: none;

    font-family: Oxygen, sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.01em;
    text-align: left;
    text-transform: none;
    white-space: normal;
    overflow-wrap: anywhere;
    writing-mode: horizontal-tb;

    clip-path: none;
    transform: none;
    transform-origin: initial;

    pointer-events: none;
    box-sizing: border-box;
}

.gallery-card--living .flip-card-front::after {
    content: "Wohnbereich";
}

.gallery-card--bedroom .flip-card-front::after {
    content: "Schlafzimmer";
}

.gallery-card--bath .flip-card-front::after {
    content: "Bad";
}

.gallery-card--entrance .flip-card-front::after {
    content: "Eingangsbereich";
}

.gallery-card--dining .flip-card-front::after {
    content: "Essbereich";
}

.gallery-card--kids .flip-card-front::after {
    content: "Kinderzimmer";
}

.gallery-card--kitchen .flip-card-front::after {
    content: "Küche & Essbereich";
}

.excursion-card--church .flip-card-front::after {
    content: "St.-Wolfgang-Kirche";
}

.excursion-card--pochwerk .flip-card-front::after {
    content: "Siebenschlehener Pochwerk";
}

.excursion-card--museum .flip-card-front::after {
    content: "Museum für Bergmännische Volkskunst";
}

.excursion-card--bergstreittag .flip-card-front::after {
    content: "Schneeberger Bergstreittag";
}

.excursion-card--lichtelfest .flip-card-front::after {
    content: "Lichtelfest";
}

.excursion-card--fundora .flip-card-front::after {
    content: "Fundora";
}

.excursion-card--actinion .flip-card-front::after {
    content: "ACTINON";
}

.excursion-card--zoo .flip-card-front::after {
    content: "Zoo der Minis";
}

.excursion-card--planetarium .flip-card-front::after {
    content: "Zeiss-Planetarium Schneeberg";
}

/* ----------------------------------------------------------
   Rückseiten innerhalb der Galerien
   ---------------------------------------------------------- */
.apartment-gallery .flip-card-back,
.excursion-gallery .flip-card-back {
    align-items: flex-start;
    justify-content: flex-start;

    padding: 42px 22px 20px;

    text-align: left;
    overflow-x: hidden;
    overflow-y: auto;
}

.apartment-gallery .flip-card-back > *,
.excursion-gallery .flip-card-back > * {
    position: relative;
    z-index: 1;

    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.apartment-gallery .flip-card-back p,
.excursion-gallery .flip-card-back p {
    font-size: clamp(12px, 1vw, 15px);
    line-height: 1.45;
    overflow-wrap: anywhere;
}


/* ----------------------------------------------------------
   Tablet
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
    .fewo-gallery-list {
        gap: 55px !important;
    }

    .apartment-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto;
        grid-auto-rows: 270px;
        gap: 14px;
    }

    .apartment-gallery .gallery-card {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    .apartment-gallery--1 .gallery-card--living,
    .apartment-gallery--1 .gallery-card--kids,
    .apartment-gallery--2 .gallery-card--living {
        grid-column: 1 / -1 !important;
    }

    .excursion-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        grid-auto-flow: row;
        grid-auto-rows: 250px;
        gap: 14px !important;
    }

    .excursion-gallery .excursion-card {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    /*
     * Bei neun Karten bleibt die letzte Karte allein.
     * Das Planetarium nutzt deshalb auf Tablet die volle Breite.
     */
    .excursion-gallery .excursion-card--planetarium {
        grid-column: 1 / -1 !important;
        min-height: 270px;
    }
}

/* ----------------------------------------------------------
   Smartphone – kompaktes Magazin-/Mosaik-Layout
   ---------------------------------------------------------- */
@media (max-width: 767px) {

    .fewo-gallery-list {
        gap: 48px !important;
    }

    /*
     * Beide Wohnungsgalerien bleiben auf Smartphones zweispaltig.
     * Wichtige Motive erhalten die volle Breite, Detailaufnahmen
     * werden paarweise angeordnet.
     */
    .apartment-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        grid-template-rows: auto !important;
        grid-auto-rows: clamp(112px, 32vw, 145px) !important;
        gap: 10px !important;
    }

    .apartment-gallery > h4 {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        margin: 0 0 4px !important;
        padding: 0 6px !important;
        line-height: 1.3;
    }

    .apartment-gallery--1 {
        grid-template-rows:
            auto
            repeat(8, clamp(112px, 32vw, 145px)) !important;
        grid-auto-rows: clamp(112px, 32vw, 145px) !important;
    }

    .apartment-gallery .gallery-card {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;

        border: 1px solid rgba(45, 41, 36, 0.08);
        border-radius: 12px;
        box-shadow: 0 7px 20px rgba(45, 41, 36, 0.14);

        grid-column: auto !important;
        grid-row: auto !important;
        overflow: visible;
    }

    /*
     * Appartement 1 erhält feste Zeilen.
     * Das verhindert Leerflächen, obwohl das Bad im HTML vor dem
     * Eingangsbereich steht.
     */
    .apartment-gallery--1 .gallery-card--living {
        grid-column: 1 / -1 !important;
        grid-row: 2 / 4 !important;
    }

    .apartment-gallery--1 .gallery-card--bedroom {
        grid-column: 1 / 2 !important;
        grid-row: 4 / 6 !important;
    }

    .apartment-gallery--1 .gallery-card--entrance {
        grid-column: 2 / 3 !important;
        grid-row: 4 / 6 !important;
    }

    .apartment-gallery--1 .gallery-card--bath {
        grid-column: 1 / -1 !important;
        grid-row: 6 / 8 !important;
    }

    .apartment-gallery--1 .gallery-card--dining {
        grid-column: 1 / 2 !important;
        grid-row: 8 / 10 !important;
    }

    .apartment-gallery--1 .gallery-card--kids {
        grid-column: 2 / 3 !important;
        grid-row: 8 / 10 !important;
    }

    /* Appartement 2: Wohnbereich und Küche groß, Details kompakt dazwischen. */
    .apartment-gallery--2 .gallery-card--living {
        grid-column: 1 / -1 !important;
        grid-row: auto / span 2 !important;
    }

    .apartment-gallery--2 .gallery-card--bedroom {
        grid-column: 1 / 2 !important;
        grid-row: auto / span 2 !important;
    }

    .apartment-gallery--2 .gallery-card--bath {
        grid-column: 2 / 3 !important;
        grid-row: auto / span 2 !important;
    }

    /*
     * Der Eingangsbereich von Appartement 2 ist ein eher hochformatiges Motiv.
     * Zwei Rasterzeilen verhindern den zu starken vertikalen Beschnitt.
     */
    .apartment-gallery--2 .gallery-card--entrance {
        grid-column: 1 / -1 !important;
        grid-row: auto / span 2 !important;
    }

    .apartment-gallery--2 .gallery-card--kitchen {
        grid-column: 1 / -1 !important;
        grid-row: auto / span 2 !important;
    }

    /*
     * Schneeberg-Galerie auf Smartphones:
     * neun Karten untereinander, damit Bilder und Rückseitentexte
     * zuverlässig lesbar und vollständig bedienbar bleiben.
     */
    .excursion-gallery {
        grid-template-columns: 1fr !important;
        grid-template-rows: none !important;
        grid-auto-flow: row;
        grid-auto-rows: auto !important;
        align-items: start;
        gap: 12px !important;
        padding: 18px 0 24px !important;
    }

    .excursion-gallery .excursion-card,
    .excursion-gallery .excursion-card--church,
    .excursion-gallery .excursion-card--pochwerk,
    .excursion-gallery .excursion-card--museum,
    .excursion-gallery .excursion-card--bergstreittag,
    .excursion-gallery .excursion-card--lichtelfest,
    .excursion-gallery .excursion-card--fundora,
    .excursion-gallery .excursion-card--actinion,
    .excursion-gallery .excursion-card--zoo,
    .excursion-gallery .excursion-card--planetarium {
        grid-column: 1 !important;
        grid-row: auto !important;
        width: 100% !important;
        height: clamp(220px, 62vw, 300px) !important;
        min-height: 0 !important;
        margin: 0 !important;

        border: 1px solid rgba(45, 41, 36, 0.08);
        border-radius: 12px;
        box-shadow: 0 7px 20px rgba(45, 41, 36, 0.14);
        overflow: hidden;
    }

    /*
     * Das hochformatige Kirchenmotiv erhält mehr Höhe.
     * Durch automatische Rasterzeilen wächst die Zeile mit und
     * die nachfolgende Karte kann nicht mehr überlappen.
     */
    .excursion-gallery .excursion-card--church {
        height: clamp(340px, 108vw, 500px) !important;
    }

    .excursion-gallery .excursion-card--planetarium {
        height: clamp(240px, 70vw, 330px) !important;
    }

    /*
     * Die vorhandenen GenerateBlocks-Höhen der Bilder dürfen das
     * neue Raster nicht aufsprengen.
     */
    .apartment-gallery .flip-card-inner,
    .apartment-gallery .flip-card-front,
    .apartment-gallery .flip-card-back,
    .excursion-gallery .flip-card-inner,
    .excursion-gallery .flip-card-front,
    .excursion-gallery .flip-card-back {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        border-radius: 12px;
    }

    .apartment-gallery .flip-card-front img,
    .excursion-gallery .flip-card-front img {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        object-fit: cover !important;
        border-radius: 12px !important;
    }

    /* Motivbezogene Bildausschnitte für das schmale Smartphone-Raster. */
    .apartment-gallery--1 .gallery-card--bedroom img {
        object-position: 48% center !important;
    }

    .apartment-gallery--2 .gallery-card--bedroom img {
        object-position: center center !important;
    }

    /*
     * Der Eingangsbereich von Appartement 1 wird im schmalen Hochformat
     * nach rechts verschoben. So bleiben Flur, Garderobe und Raumtiefe
     * sichtbar und die helle Wand dominiert den Ausschnitt nicht.
     */
    .apartment-gallery--1 .gallery-card--entrance img {
        object-position: 72% center !important;
    }

    .apartment-gallery--2 .gallery-card--entrance img {
        object-position: center 46% !important;
    }

    .apartment-gallery--2 .gallery-card--kitchen img {
        object-position: center 56% !important;
    }

    .excursion-gallery .excursion-card--church img {
        object-position: center center !important;
    }

    .excursion-gallery .excursion-card--museum img,
    .excursion-gallery .excursion-card--pochwerk img {
        object-position: center center !important;
    }

    /* Rückseiten bleiben auch in den kleineren Rasterkarten bedienbar. */
    .apartment-gallery .flip-card-back,
    .excursion-gallery .flip-card-back {
        padding: 36px 13px 13px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    .apartment-gallery .flip-card-back p,
    .excursion-gallery .flip-card-back p {
        margin: 0 0 0.55em;
        font-size: 11px;
        line-height: 1.36;
    }

    .apartment-gallery .flip-card-back p:last-child,
    .excursion-gallery .flip-card-back p:last-child {
        margin-bottom: 0;
    }

    /* Kompakte Beschriftungen lassen mehr vom Bild sichtbar. */
    .gallery-card .flip-card-front::after,
    .excursion-card .flip-card-front::after {
        top: auto;
        right: auto;
        bottom: 7px;
        left: 7px;

        max-width: calc(100% - 48px);
        padding: 5px 7px;

        border-left-width: 2px;
        border-radius: 0 6px 6px 0;

        font-size: 10px;
        line-height: 1.2;

        clip-path: none;
        transform: none;
    }

    .flip-card-front::before {
        top: 7px;
        right: 7px;

        width: 27px;
        height: 27px;

        border-radius: 7px;
        font-size: 15px;
    }

    .flip-card-back::after {
        width: 27px;
        height: 27px;
        padding: 3px 0 0 4px;
        font-size: 10px;
    }
}


/* ----------------------------------------------------------
   Sehr schmale Smartphones
   ---------------------------------------------------------- */
@media (max-width: 359px) {

    /*
     * Unterhalb von 360 px wird zugunsten der Lesbarkeit wieder
     * einspaltig dargestellt. Die unterschiedliche Bildhöhe bleibt
     * erhalten, sodass die Galerie weiterhin abwechslungsreich wirkt.
     */
    .apartment-gallery,
    .excursion-gallery {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        grid-auto-rows: auto !important;
    }

    .apartment-gallery > h4,
    .apartment-gallery .gallery-card,
    .excursion-gallery .excursion-card {
        grid-column: 1 !important;
        grid-row: auto !important;
    }

    .apartment-gallery .gallery-card {
        height: 230px !important;
    }

    .apartment-gallery .gallery-card--living,
    .apartment-gallery .gallery-card--bath,
    .apartment-gallery .gallery-card--kitchen {
        height: 270px !important;
    }

    .excursion-gallery .excursion-card {
        height: 190px !important;
    }

    .excursion-gallery .excursion-card--church {
        height: 320px !important;
    }

    .excursion-gallery .excursion-card--planetarium {
        height: 230px !important;
    }
}
