/**
 * PostHub Feed – Frontend-Styles v2.2
 *
 * Alles via CSS Custom Properties überschreibbar.
 * Layouts: Slideshow (horizontal multi-slide) + Karten-Grid.
 * Features: Lightbox mit Galerie, Flat-Style, Dark Mode, Responsive.
 */

/* ─── Custom Properties ───────────────────────────────────────── */
:root {
    --posthub-grid-gap: 1.5rem;
    --posthub-slide-gap: 1rem;
    --posthub-card-bg: #ffffff;
    --posthub-card-radius: 8px;
    --posthub-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --posthub-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --posthub-text-color: #333333;
    --posthub-date-color: #888888;
    --posthub-accent-color: #0073aa;
    --posthub-font-size: 0.9375rem;
    --posthub-date-font-size: 0.8125rem;
    --posthub-title-font-size: 1.125rem;
    --posthub-transition: 0.3s ease;
    --posthub-nav-size: 40px;
    --posthub-dot-size: 10px;
    --posthub-btn-bg: #0073aa;
    --posthub-btn-color: #ffffff;
    --posthub-btn-radius: 6px;
    --posthub-lightbox-bg: rgba(0, 0, 0, 0.92);
}

/* ═══════════════════════════════════════════════════════════════════
 * SHARED
 * ═══════════════════════════════════════════════════════════════════ */

.posthub-feed-wrapper {
    position: relative;
    width: 100%;
}

/* ─── Text «...mehr» Toggle ───────────────────────────────────── */
.posthub-ellipsis {
    white-space: nowrap;
}

.posthub-more-toggle {
    background: none;
    border: none;
    color: var(--posthub-accent-color);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
    margin-left: 0.25em;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.posthub-more-toggle:hover {
    text-decoration: none;
}

/* Error / Empty */
.posthub-feed-error,
.posthub-feed-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--posthub-date-color);
    font-style: italic;
}

.posthub-feed-error {
    background: #fff3f3;
    border: 1px solid #e0b0b0;
    border-radius: var(--posthub-card-radius);
    color: #a33;
}

/* ═══════════════════════════════════════════════════════════════════
 * SLIDESHOW (Horizontal Multi-Slide)
 * ═══════════════════════════════════════════════════════════════════ */

.posthub-slideshow-wrapper {
    margin: 0 auto;
    position: relative;
}

.posthub-slideshow-viewport {
    overflow: hidden;
    border-radius: var(--posthub-card-radius);
}

.posthub-slideshow-track {
    display: flex;
    gap: var(--posthub-slide-gap);
    transition: transform 0.4s ease;
}

/* Slides: horizontal layout */
.posthub-slide {
    display: flex;
    flex-direction: column;
    flex: 0 0 100%;
    max-width: 100%;
    min-width: 0;
}

/* Card-style slides */
.posthub-slideshow-wrapper:not(.posthub-style-flat) .posthub-slide {
    background: var(--posthub-card-bg);
    border-radius: var(--posthub-card-radius);
    box-shadow: var(--posthub-card-shadow);
    overflow: hidden;
}

.posthub-slide-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    background: #f0f0f0;
}

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

.posthub-slide-content {
    padding: 1rem 1.25rem 1.25rem;
}

.posthub-slide-title {
    font-size: var(--posthub-title-font-size);
    font-weight: 600;
    margin: 0 0 0.5rem;
    line-height: 1.3;
    color: var(--posthub-text-color);
}

.posthub-slide-text {
    font-size: var(--posthub-font-size);
    color: var(--posthub-text-color);
    line-height: 1.5;
    margin: 0 0 0.75rem;
    word-break: break-word;
}

.posthub-slide-date {
    font-size: var(--posthub-date-font-size);
    color: var(--posthub-date-color);
    display: block;
}

/* Navigation Arrows */
.posthub-slideshow-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-100%);
    width: var(--posthub-nav-size);
    height: var(--posthub-nav-size);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background var(--posthub-transition), opacity var(--posthub-transition);
    z-index: 2;
    color: var(--posthub-text-color);
    padding: 0;
}

.posthub-slideshow-nav:hover {
    background: #ffffff;
}

.posthub-nav-prev { left: 12px; }
.posthub-nav-next { right: 12px; }

/* Dots */
.posthub-slideshow-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 1rem;
}

.posthub-dot {
    width: var(--posthub-dot-size);
    height: var(--posthub-dot-size);
    border-radius: 50%;
    border: none;
    background: #d0d0d0;
    cursor: pointer;
    padding: 0;
    transition: background var(--posthub-transition), transform var(--posthub-transition);
}

.posthub-dot.is-active {
    background: var(--posthub-accent-color);
    transform: scale(1.3);
}

.posthub-dot:hover {
    background: var(--posthub-accent-color);
}

/* ═══════════════════════════════════════════════════════════════════
 * KARTEN-GRID
 * ═══════════════════════════════════════════════════════════════════ */

.posthub-cards-grid {
    display: grid;
    gap: var(--posthub-grid-gap);
    list-style: none;
    margin: 0;
    padding: 0;
}

.posthub-cards-grid.posthub-cols-1 { grid-template-columns: 1fr; }
.posthub-cards-grid.posthub-cols-2 { grid-template-columns: repeat(2, 1fr); }
.posthub-cards-grid.posthub-cols-3 { grid-template-columns: repeat(3, 1fr); }
.posthub-cards-grid.posthub-cols-4 { grid-template-columns: repeat(4, 1fr); }
.posthub-cards-grid.posthub-cols-5 { grid-template-columns: repeat(5, 1fr); }
.posthub-cards-grid.posthub-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Card */
.posthub-card {
    background: var(--posthub-card-bg);
    border-radius: var(--posthub-card-radius);
    box-shadow: var(--posthub-card-shadow);
    overflow: hidden;
    transition: box-shadow var(--posthub-transition), transform var(--posthub-transition);
    display: flex;
    flex-direction: column;
}

.posthub-card:hover {
    box-shadow: var(--posthub-card-shadow-hover);
    transform: translateY(-2px);
}

/* Hidden cards (für «Mehr laden») */
.posthub-card-hidden {
    display: none;
}

/* Reveal-Animation */
.posthub-card-reveal {
    animation: posthubCardReveal 0.4s ease forwards;
}

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

/* Card Image */
.posthub-card-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    background: #f0f0f0;
}

.posthub-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--posthub-transition);
}

.posthub-card:hover .posthub-card-image img {
    transform: scale(1.03);
}

/* Card Content */
.posthub-card-content {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.posthub-card-title {
    font-size: var(--posthub-title-font-size);
    font-weight: 600;
    margin: 0 0 0.5rem;
    line-height: 1.3;
    color: var(--posthub-text-color);
}

.posthub-card-text {
    font-size: var(--posthub-font-size);
    color: var(--posthub-text-color);
    line-height: 1.5;
    margin: 0 0 0.75rem;
    flex: 1;
    word-break: break-word;
}

.posthub-card-date {
    font-size: var(--posthub-date-font-size);
    color: var(--posthub-date-color);
    margin-top: auto;
    display: block;
}

/* «Mehr laden»-Button */
.posthub-load-more-wrap {
    text-align: center;
    margin-top: var(--posthub-grid-gap);
}

.posthub-load-more-btn {
    background: var(--posthub-btn-bg);
    color: var(--posthub-btn-color);
    border: none;
    border-radius: var(--posthub-btn-radius);
    padding: 0.75em 2em;
    font-size: var(--posthub-font-size);
    font-family: inherit;
    cursor: pointer;
    transition: background var(--posthub-transition), transform var(--posthub-transition);
}

.posthub-load-more-btn:hover {
    background: color-mix(in srgb, var(--posthub-btn-bg) 85%, black);
    transform: translateY(-1px);
}

.posthub-load-more-btn:active {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════════════════
 * FLAT STYLE (kein Karten-Design)
 * ═══════════════════════════════════════════════════════════════════ */

/* Cards – flat */
.posthub-cards-wrapper.posthub-style-flat .posthub-card {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.posthub-cards-wrapper.posthub-style-flat .posthub-card:hover {
    box-shadow: none;
    transform: none;
}

.posthub-cards-wrapper.posthub-style-flat .posthub-card-image {
    border-radius: var(--posthub-card-radius);
}

.posthub-cards-wrapper.posthub-style-flat .posthub-card-content {
    padding: 0.625rem 0 0;
}

/* Slideshow – flat */
.posthub-slideshow-wrapper.posthub-style-flat .posthub-slide {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.posthub-slideshow-wrapper.posthub-style-flat .posthub-slide-image {
    border-radius: var(--posthub-card-radius);
}

.posthub-slideshow-wrapper.posthub-style-flat .posthub-slide-content {
    padding: 0.625rem 0 0;
}

/* ═══════════════════════════════════════════════════════════════════
 * RESPONSIVE
 * ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .posthub-cards-grid.posthub-cols-5,
    .posthub-cards-grid.posthub-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
    .posthub-cards-grid.posthub-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .posthub-cards-grid.posthub-cols-3,
    .posthub-cards-grid.posthub-cols-4,
    .posthub-cards-grid.posthub-cols-5,
    .posthub-cards-grid.posthub-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .posthub-slideshow-wrapper .posthub-nav-prev { left: 8px; }
    .posthub-slideshow-wrapper .posthub-nav-next { right: 45px; }
}

@media (max-width: 480px) {
    .posthub-cards-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
 * LIGHTBOX TRIGGER
 * ═══════════════════════════════════════════════════════════════════ */

.posthub-lightbox-trigger {
    cursor: zoom-in;
}

.posthub-lightbox-trigger::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background var(--posthub-transition);
    pointer-events: none;
    z-index: 1;
}

.posthub-lightbox-trigger:hover::after {
    background: rgba(0, 0, 0, 0.08);
}

/* ═══════════════════════════════════════════════════════════════════
 * LIGHTBOX OVERLAY mit Galerie-Navigation
 * ═══════════════════════════════════════════════════════════════════ */

body.posthub-lightbox-open {
    overflow: hidden;
}

.posthub-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: posthubLightboxIn 0.25s ease;
}

.posthub-lightbox[hidden] {
    display: none;
}

.posthub-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: var(--posthub-lightbox-bg);
}

.posthub-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.posthub-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    cursor: default;
    animation: posthubLightboxZoomIn 0.3s ease;
}

.posthub-lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
    backdrop-filter: blur(4px);
}

.posthub-lightbox-close:hover,
.posthub-lightbox-close:focus-visible {
    background: rgba(255, 255, 255, 0.3);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Lightbox Gallery Navigation */
.posthub-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
    backdrop-filter: blur(4px);
}

.posthub-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.posthub-lightbox-nav[hidden] {
    display: none;
}

.posthub-lightbox-prev { left: 1rem; }
.posthub-lightbox-next { right: 1rem; }

.posthub-lightbox-counter {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.3em 1em;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.posthub-lightbox-counter[hidden] {
    display: none;
}

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

@keyframes posthubLightboxZoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════
 * AUTO-LINKED URLs
 * ═══════════════════════════════════════════════════════════════════ */

.posthub-slide-text a,
.posthub-card-text a {
    color: var(--posthub-accent-color);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.posthub-slide-text a:hover,
.posthub-card-text a:hover {
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════
 * DARK MODE
 * ═══════════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    :root {
        --posthub-card-bg: #1e1e1e;
        --posthub-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        --posthub-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.5);
        --posthub-text-color: #e0e0e0;
        --posthub-date-color: #999999;
        --posthub-accent-color: #4dabf5;
        --posthub-btn-bg: #4dabf5;
        --posthub-btn-color: #111111;
        --posthub-lightbox-bg: rgba(0, 0, 0, 0.96);
    }

    .posthub-slide-image,
    .posthub-card-image {
        background: #2a2a2a;
    }

    .posthub-feed-error {
        background: #2a1515;
        border-color: #5a2020;
        color: #e88;
    }

    .posthub-slideshow-nav {
        background: rgba(40, 40, 40, 0.9);
        color: #e0e0e0;
    }

    .posthub-slideshow-nav:hover {
        background: rgba(60, 60, 60, 1);
    }

    .posthub-dot {
        background: #555555;
    }
}
