/**
 * Weiße Nacht Toolkit – Frontend-Styles
 * Markenfarben zentral als CSS-Variablen – hier anpassen, gilt überall.
 * @version 1.0.0
 */

.wn-scope {
    --wn-primary: #5a4ca7;
    --wn-primary-dark: #534582;
    --wn-primary-light: #6e5fab;
    --wn-text: #2c3e50;
    --wn-text-soft: #556677;
    --wn-surface: #ffffff;
    --wn-border: #e0e0e0;
    --wn-radius: 14px;
    --wn-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
    --wn-shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.12);
}

body.wn-no-scroll {
    overflow: hidden;
}

/* =====================================================================
 * Teilnehmer-Grid
 * ===================================================================== */
.wn-grid-wrap {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.wn-grid {
    display: grid;
    gap: 22px;
    width: 100%;
}

.wn-item {
    /* Button-Reset */
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    color: inherit;

    background: var(--wn-surface);
    border: 1px solid var(--wn-border);
    border-radius: var(--wn-radius);
    box-shadow: var(--wn-shadow);
    aspect-ratio: 1;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.wn-item:hover,
.wn-item:focus-visible {
    transform: translateY(-5px);
    box-shadow: var(--wn-shadow-hover);
    border-color: var(--wn-primary);
    outline: none;
}

.wn-item-logo {
    width: 85%;
    height: 85%;
    object-fit: contain;
    transition: transform 0.25s ease;
}

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

.wn-item-name {
    font-weight: 600;
    color: var(--wn-text);
    word-break: break-word;
    line-height: 1.3;
    font-size: 15px;
}

/* =====================================================================
 * Popup
 * ===================================================================== */
.wn-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    background: linear-gradient(135deg, rgba(22, 18, 40, 0.9), rgba(45, 38, 70, 0.95));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.wn-popup.is-open {
    display: flex;
    animation: wnFadeIn 0.3s ease-out;
}

.wn-popup.is-closing .wn-popup-content {
    animation: wnZoomOut 0.25s ease-in forwards;
}

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

.wn-popup-content {
    background: var(--wn-surface);
    border-radius: 22px;
    padding: 40px 44px;
    max-width: 620px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    animation: wnZoomIn 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
}

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

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

.wn-popup-close {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #666;
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.25s ease;
    z-index: 2;
}

.wn-popup-close:hover,
.wn-popup-close:focus-visible {
    background: rgba(0, 0, 0, 0.12);
    color: var(--wn-text);
    transform: rotate(90deg);
    outline: none;
}

.wn-popup-logo {
    max-width: 190px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto 18px;
    display: block;
}

h3.wn-popup-title,
.wn-popup-title {
    font-size: 21px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    color: var(--wn-text);
    margin: 0 0 14px !important;
    line-height: 1.4 !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.wn-popup-desc {
    font-size: 16px;
    line-height: 1.7;
    color: var(--wn-text-soft);
    margin-bottom: 26px;
    text-align: left;
}

.wn-button {
    display: inline-block;
    background: linear-gradient(145deg, var(--wn-primary-light), var(--wn-primary-dark));
    color: #ffffff !important;
    padding: 13px 34px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-decoration: none !important;
    box-shadow: 0 5px 15px rgba(90, 76, 167, 0.3);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.wn-button:hover,
.wn-button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(90, 76, 167, 0.4);
    outline: none;
}

/* Navigation */
.wn-popup-nav {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: var(--wn-text);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease, background-color 0.25s ease, opacity 0.25s ease;
    z-index: 1;
}

.wn-popup-nav:hover,
.wn-popup-nav:focus-visible {
    background: #ffffff;
    transform: translateY(-50%) scale(1.08);
    outline: none;
}

.wn-prev { left: 36px; }
.wn-next { right: 36px; }

.wn-popup-nav.is-hidden {
    opacity: 0;
    pointer-events: none;
}

/* =====================================================================
 * Programm-Timetable
 * ===================================================================== */
.wn-timetable {
    max-width: 760px;
    margin: 0 auto;
    padding: 10px 0;
    position: relative;
}

/* durchgehende Linie */
.wn-timetable::before {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 86px;
    width: 2px;
    background: linear-gradient(to bottom, var(--wn-primary-light), var(--wn-primary-dark));
    opacity: 0.35;
}

.wn-slot {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 44px;
    position: relative;
    padding: 14px 0;
}

/* Verhindert, dass lange Inhalte das Grid über den Viewport hinausdrücken */
.wn-slot > * {
    min-width: 0;
}

/* Punkt auf der Linie */
.wn-slot::before {
    content: "";
    position: absolute;
    left: 80px;
    top: 28px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--wn-primary);
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 2px var(--wn-primary), 0 2px 8px rgba(90, 76, 167, 0.35);
    z-index: 1;
}

.wn-slot-time {
    text-align: right;
    padding-top: 22px;
}

.wn-slot-start {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--wn-primary);
    line-height: 1.1;
}

.wn-slot-end {
    display: block;
    font-size: 13px;
    color: var(--wn-text-soft);
    margin-top: 2px;
}

.wn-slot-card {
    background: var(--wn-surface);
    border: 1px solid var(--wn-border);
    border-radius: var(--wn-radius);
    box-shadow: var(--wn-shadow);
    padding: 20px 24px;
    display: flex;
    gap: 18px;
    align-items: flex-start;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.wn-slot-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--wn-shadow-hover);
    border-color: var(--wn-primary);
}

.wn-slot-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

.wn-slot-body {
    min-width: 0; /* Flex-Kind darf schrumpfen, statt überzulaufen */
}

/* !important: setzt sich gegen globale Überschriften-Größen
   aus dem Page Builder (Breakdance) durch */
h3.wn-slot-title,
.wn-slot-title {
    font-size: 17px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    color: var(--wn-text);
    margin: 0 0 6px !important;
    line-height: 1.35 !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.wn-slot-ort {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--wn-primary);
    margin: 0 0 8px;
}

.wn-icon {
    flex-shrink: 0;
}

.wn-slot-desc {
    font-size: 15px;
    line-height: 1.65;
    color: var(--wn-text-soft);
    overflow-wrap: anywhere;
}

.wn-slot-desc p:last-child {
    margin-bottom: 0;
}

/* =====================================================================
 * Responsive
 * ===================================================================== */
@media (max-width: 800px) {
    .wn-popup-nav {
        width: 42px;
        height: 42px;
        font-size: 19px;
    }
    .wn-prev { left: 10px; }
    .wn-next { right: 10px; }
}

@media (max-width: 767px) {
    .wn-grid {
        gap: 14px;
    }

    .wn-popup-content {
        padding: 32px 22px;
    }

    h3.wn-popup-title,
    .wn-popup-title {
        font-size: 18px !important;
    }

    h3.wn-slot-title,
    .wn-slot-title {
        font-size: 16px !important;
    }

    /* Timetable: Zeit über die Karte, Linie nach links */
    .wn-timetable::before {
        left: 8px;
    }

    .wn-slot {
        grid-template-columns: 1fr;
        gap: 6px;
        padding-left: 32px;
    }

    .wn-slot::before {
        left: 2px;
        top: 6px;
    }

    .wn-slot-time {
        text-align: left;
        padding-top: 0;
        display: flex;
        align-items: baseline;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .wn-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }

    .wn-popup-content {
        padding-left: 50px;
        padding-right: 50px;
    }

    .wn-prev { left: 4px; }
    .wn-next { right: 4px; }
}

/* =====================================================================
 * Interaktive Eventkarte
 * ===================================================================== */
.wn-map {
    --wn-cat-teilnehmer: #5a4ca7;
    --wn-cat-gastro: #1f9e5a;
    --wn-cat-musik: #7d2150;
    --wn-cat-kids: #e6007e;

    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* [wn_karte breite="voll"]: nutzt die komplette Breite des Containers */
.wn-map--full {
    max-width: none;
}

.wn-map.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 100001;
    max-width: none;
    background: #f4f3f7;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
}

.wn-map.is-fullscreen .wn-map-viewport {
    flex: 1;
    aspect-ratio: auto !important;
    max-height: none;
}

.wn-map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.wn-map-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Mobil: Filter als horizontal wischbare Reihe statt Umbruch */
@media (max-width: 767px) {
    .wn-map-toolbar {
        flex-wrap: nowrap;
        align-items: center;
    }

    .wn-map-filters {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;          /* Firefox */
        padding: 2px;
        margin: -2px;                   /* Platz für Fokus-Ringe */
        mask-image: linear-gradient(to right, #000 92%, transparent); /* dezenter Hinweis: da geht's weiter */
        -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
    }

    .wn-map-filters::-webkit-scrollbar {
        display: none;                  /* Chrome/Safari */
    }

    .wn-filter {
        flex: 0 0 auto;
        font-size: 12px;
        padding: 7px 12px;
        white-space: nowrap;
    }

    .wn-map-controls {
        flex: 0 0 auto;
    }

    .wn-map-btn {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
}

.wn-filter {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: 50px;
    border: 1px solid var(--wn-border);
    background: var(--wn-surface);
    color: var(--wn-text-soft);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.wn-filter.is-active {
    background: var(--wn-primary);
    border-color: var(--wn-primary);
    color: #fff;
}

.wn-filter--gastro.is-active { background: var(--wn-cat-gastro); border-color: var(--wn-cat-gastro); }
.wn-filter--musik.is-active  { background: var(--wn-cat-musik);  border-color: var(--wn-cat-musik); }
.wn-filter--kids.is-active   { background: var(--wn-cat-kids);   border-color: var(--wn-cat-kids); }

.wn-map-controls {
    display: flex;
    gap: 6px;
}

.wn-map-btn {
    appearance: none;
    -webkit-appearance: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--wn-border);
    background: var(--wn-surface);
    color: var(--wn-text);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--wn-shadow);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.wn-map-btn:hover,
.wn-map-btn:focus-visible {
    border-color: var(--wn-primary);
    transform: translateY(-1px);
    outline: none;
}

.wn-map-viewport {
    position: relative;
    width: 100%;
    max-height: 78vh;
    overflow: hidden;
    border-radius: var(--wn-radius);
    border: 1px solid var(--wn-border);
    background: #eceaf2;
    touch-action: none;       /* Pinch/Pan übernimmt das Skript */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.wn-map-viewport:active {
    cursor: grabbing;
}

.wn-map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transform-origin: 0 0;
    will-change: transform;
}

.wn-map-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

/* Marker */
.wn-marker {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: var(--wn-cat-teilnehmer);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s ease;
}

/* Auf Touch-Geräten kleinere Punkte (liegen oft dicht beieinander),
   die Tap-Fläche bleibt über ein unsichtbares Polster groß genug */
@media (max-width: 767px) {
    .wn-marker {
        width: 14px;
        height: 14px;
        border-width: 2px;
    }
}

.wn-marker::after {
    content: "";
    position: absolute;
    inset: -10px; /* unsichtbare, größere Tap-Fläche */
}

.wn-marker[data-cat="gastro"] { background: var(--wn-cat-gastro); }
.wn-marker[data-cat="musik"]  { background: var(--wn-cat-musik); }
.wn-marker[data-cat="kids"]   { background: var(--wn-cat-kids); }

.wn-marker.is-active {
    box-shadow: 0 0 0 4px rgba(90, 76, 167, 0.35), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.wn-marker.is-filtered {
    opacity: 0;
    pointer-events: none;
}

.wn-marker:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Infokarte (Bottom Sheet im Kartenbereich) */
.wn-map-card {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background: var(--wn-surface);
    border-radius: var(--wn-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    padding: 18px 48px 18px 20px;
    z-index: 5;
    animation: wnCardUp 0.25s ease-out;
}

@keyframes wnCardUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) {
    .wn-map-card {
        left: auto;
        right: 16px;
        top: 16px;
        bottom: auto;
        width: 320px;
    }
}

.wn-card-close {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #666;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wn-card-close:hover {
    background: rgba(0, 0, 0, 0.12);
    color: var(--wn-text);
}

.wn-card-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #fff;
    background: var(--wn-cat-teilnehmer);
    border-radius: 50px;
    padding: 3px 10px;
    margin-bottom: 8px;
}

.wn-badge--gastro { background: var(--wn-cat-gastro); }
.wn-badge--musik  { background: var(--wn-cat-musik); }
.wn-badge--kids   { background: var(--wn-cat-kids); }

.wn-card-title {
    display: block;
    font-size: 16px !important;
    font-weight: 600;
    color: var(--wn-text);
    line-height: 1.35 !important;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.wn-card-meta {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--wn-primary);
    margin-bottom: 6px;
}

.wn-card-text {
    display: block;
    font-size: 14px;
    line-height: 1.55;
    color: var(--wn-text-soft);
    margin-bottom: 10px;
}

.wn-button--small {
    padding: 9px 22px;
    font-size: 12px;
}

.wn-map-hint {
    font-size: 12px;
    color: var(--wn-text-soft);
    text-align: center;
    margin: 8px 0 0;
}

.wn-map.is-fullscreen .wn-map-hint {
    display: none;
}

/* Weniger Animation für Nutzer, die das wünschen (Barrierefreiheit) */
@media (prefers-reduced-motion: reduce) {
    .wn-scope *,
    .wn-popup,
    .wn-popup-content {
        animation: none !important;
        transition: none !important;
    }
}
