/* ============================================================
   Veranstaltungs-Plakat: Einblendung beim Aufruf der Startseite
   Vorderseite = Plakat (images/plakat-wuenschestadt-2026-*.webp/jpg),
   Klick wendet die Karte, Rückseite = Postkartentext + Astronaut.
   Wird von plakat-popup.js aufgebaut. Termin und Texte stehen dort.
   ============================================================ */

html.plakat-open,
html.plakat-open body {
    overflow: hidden;
}

.plakat[hidden] {
    display: none;
}

.plakat {
    position: fixed;
    inset: 0;
    z-index: 3000; /* über Header (100), Viewer (1000) und Info-Popup (2000) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 16px 16px; /* oben Platz für den Schließen-Knopf, auch wenn die Karte die volle Breite nutzt */
    animation: plakatFade 0.3s ease-out;
}

@keyframes plakatFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.plakat__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 8, 20, 0.9);
    cursor: pointer;
}

/* Weichzeichner nur auf dem Desktop: über dem animierten Sternenhimmel kostet er
   auf schwachen Handys zu viel Leistung, dort bleibt die dunkle Abdeckung. */
@media (min-width: 901px) {
    .plakat__backdrop {
        background: rgba(0, 8, 20, 0.72);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
}

.plakat__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(79, 172, 254, 0.5);
    background: rgba(0, 8, 20, 0.75);
    color: #cfe6ff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.plakat__close:hover,
.plakat__close:focus-visible {
    background: rgba(79, 172, 254, 0.25);
    color: #ffffff;
    transform: rotate(90deg);
    outline: none;
}

.plakat__close:focus-visible {
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.6);
}

.plakat__scene {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    animation: plakatIn 0.45s ease-out;
}

@keyframes plakatIn {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Kartenmaß: Plakat-Seitenverhältnis 0.7073 (Breite/Höhe). Höhe begrenzt durch den Bildschirm
   abzüglich Platz für Schließen-Knopf und Hinweis, Breite durch 92 % der Fensterbreite. */
.plakat__card {
    --pw: min(92vw, calc((100vh - 130px) * 0.7073));
    --pw: min(92vw, calc((100dvh - 130px) * 0.7073));
    width: var(--pw);
    height: calc(var(--pw) / 0.7073);
    perspective: 1800px;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.plakat__card:focus-visible .plakat__inner {
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.8);
}

.plakat__inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    transform-style: preserve-3d;
    transition: transform 0.85s cubic-bezier(0.4, 0.1, 0.2, 1);
}

.plakat__card.is-flipped .plakat__inner {
    transform: rotateY(180deg);
}

/* Kurzes Anwinkeln nach dem Öffnen: zeigt, dass sich die Karte wenden lässt */
.plakat__card.is-peek .plakat__inner {
    animation: plakatPeek 1.2s ease-in-out;
}

@keyframes plakatPeek {
    0% { transform: rotateY(0); }
    45% { transform: rotateY(-22deg); }
    100% { transform: rotateY(0); }
}

.plakat__face {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.65),
        0 0 44px rgba(79, 172, 254, 0.28);
}

/* Die abgewandte Seite bekommt keine Zeigerereignisse: Browser treffen beim Hit-Test sonst die
   unsichtbare Rückseite der Vorderseite, und Knöpfe oder Scrollen auf der Rückseite gehen ins Leere */
.plakat__card.is-flipped .plakat__front,
.plakat__card:not(.is-flipped) .plakat__back {
    pointer-events: none;
}

.plakat__front {
    background: #0d0709;
}

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

/* Rückseite: weiße Postkarte */
.plakat__back {
    transform: rotateY(180deg);
    background: #ffffff;
    color: #1d1d1f;
}

.plakat__back-scroll {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: clamp(16px, calc(var(--pw) * 0.05), 30px) clamp(16px, calc(var(--pw) * 0.05), 30px) clamp(16px, calc(var(--pw) * 0.045), 26px);
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(12px, calc(var(--pw) * 0.029), 16.5px);
    line-height: 1.45;
    text-align: left;
    cursor: pointer;
}

.plakat__text {
    flex: none;
}

/* Astronaut sitzt wie die Briefmarke auf der Postkarte oben rechts im Rahmen */
.plakat__stamp {
    float: right;
    width: 36%;
    max-width: 230px;
    margin: 0 0 10px 14px;
    padding: 4px;
    border: 1px solid #1d1d1f;
    background: #fff;
}

.plakat__stamp picture,
.plakat__astro {
    display: block;
    width: 100%;
    height: auto;
}

/* Auslauf am unteren Rand, nur wenn der Text länger ist als die Karte (Klasse setzt das Skript) */
.plakat__back.is-scroll::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 38px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #ffffff);
    pointer-events: none;
}

.plakat__quote {
    margin: 0 0 0.9em;
    font-weight: 600;
    font-size: 1.28em;
    line-height: 1.3;
    letter-spacing: 0.1px;
}

.plakat__lead {
    margin: 1.1em 0 0.25em;
    font-weight: 600;
}

.plakat__lead:first-of-type {
    margin-top: 0.4em;
}

.plakat__back-scroll p {
    margin: 0 0 0.75em;
}

.plakat__back-scroll strong {
    font-weight: 600;
}

.plakat__ti {
    color: #2f80ed;
    font-weight: 600;
}

/* Fußzeile: Termin links, Sprachumschalter rechts. Steht unten auf der Karte; ist der Text
   länger als die Karte, rückt sie einfach ans Ende */
.plakat__foot {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    flex-wrap: wrap;
    margin-top: auto; /* Fußzeile bleibt unten, wenn der Text kürzer ist als die Karte */
    padding-top: 0.9em;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}

.plakat__when {
    margin: 0 !important;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8em;
    letter-spacing: 0.6px;
    color: #333;
}

.plakat__text {
    padding-bottom: 1em;
}

/* Sprachknöpfe oben rechts auf der Rückseite, damit sie ohne Scrollen zu sehen sind */
.plakat__lang {
    flex: none;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin: 0 0 0.6em;
}

.plakat__lang-btn {
    min-width: 34px;
    padding: 4px 8px;
    border: 1px solid rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    background: transparent;
    color: #333;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72em;
    letter-spacing: 0.8px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.plakat__lang-btn:hover,
.plakat__lang-btn:focus-visible {
    border-color: #2f80ed;
    color: #2f80ed;
    outline: none;
}

.plakat__lang-btn[aria-pressed="true"] {
    background: #1d1d1f;
    border-color: #1d1d1f;
    color: #fff;
}

/* Hinweis unter der Karte */
.plakat__hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(79, 172, 254, 0.5);
    background: rgba(0, 8, 20, 0.7);
    color: #cfe6ff;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.plakat__hint:hover,
.plakat__hint:focus-visible {
    background: rgba(79, 172, 254, 0.22);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(79, 172, 254, 0.45);
    outline: none;
}

.plakat__hint svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
    animation: plakatHintPulse 2.4s ease-in-out infinite;
}

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

/* Sehr niedrige Fenster (Handy quer): Hinweis weg, Karte nutzt die Höhe */
@media (max-height: 520px) {
    .plakat {
        padding: 8px 12px;
    }
    .plakat__card {
        --pw: min(92vw, calc((100vh - 24px) * 0.7073));
        --pw: min(92vw, calc((100dvh - 24px) * 0.7073));
    }
    .plakat__hint {
        display: none;
    }
    .plakat__close {
        top: 8px;
        right: 8px;
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 640px) and (min-height: 521px) {
    .plakat {
        padding: 56px 12px 12px;
    }
    .plakat__close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    .plakat__hint {
        font-size: 10px;
        padding: 7px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .plakat,
    .plakat__scene,
    .plakat__card.is-peek .plakat__inner,
    .plakat__hint svg {
        animation: none;
    }
    .plakat__inner {
        transition-duration: 0.2s;
    }
}
