/**
 * Theme Name: Blocksy Child
 * Description: Blocksy Child theme
 * Author: Creative Themes
 * Template: blocksy
 * Text Domain: blocksy
 */

/* ========================================
   HEADER PROMOTION - Blocksy Customizer Integration
   Anti-AdBlocker: Verwende harmlose CSS-Klassennamen

   ⚠️ RECHTLICHER HINWEIS:
   Das "Werbung"-Label (.content-label) darf NIEMALS ausgeblendet werden!
   (§ 5a UWG, § 6 TMG - Kennzeichnungspflicht für Werbung)
   Bei Verstoß drohen Abmahnungen und Bußgelder bis € 500.000!
   ======================================== */

/* Styling für Promotion-Bereich im Header - Als normales Header Element */
header.site-header .stage-promotion-area,
.ct-header .ct-header-element.stage-promotion-area,
.ct-header-element.stage-promotion-area[data-id="ad-banner"],
.stage-promotion-area {
    /* Lass Blocksy die Positionierung handhaben - kein absolute! */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
}

.ct-header .stage-promotion-area .stage-featured-content {
    margin: 0 !important;
}

/* ⚠️ WICHTIG: .content-label NIEMALS ausblenden! (Rechtliche Kennzeichnungspflicht) */
/* Einheitliches Styling für "Werbung"-Label im Header (wie auf Rest der Seite) */
.ct-header .stage-promotion-area .content-label {
    /* Standard StageAds Label-Styling erzwingen */
    position: absolute !important;
    top: 100% !important;
    left: 20px !important;
    background: #3d3c3c !important;
    color: #ffffff !important;
    padding: 3px 6px !important;
    font-size: 9px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    font-weight: 500 !important;
    border-radius: 0 0 3px 3px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    backdrop-filter: blur(4px) !important;
    white-space: nowrap !important;
}

/* Responsive Anpassungen */
@media (max-width: 991px) {
    .ct-header .stage-promotion-area {
        justify-content: center;
        padding: 10px 0;
    }
}

@media (max-width: 768px) {
    .ct-header .stage-promotion-area .stage-featured-content {
        max-width: 468px;
    }
}

@media (max-width: 480px) {
    .ct-header .stage-promotion-area .stage-featured-content {
        max-width: 320px;
    }
}

/* ========================================
   DYNAMIC DATA HEADING RESET (Global)
   ======================================== */
/* Remove margin from ALL h1 headings in query loops */
article.wp-block-post h1.ct-dynamic-data {
    margin-top: 0 !important;
}

/* Remove margin from wrapper div containing h1 (grid layout) */
article.wp-block-post .wp-block-group.blockera-block:has(> h1.ct-dynamic-data) {
    margin-top: 0 !important;
}

/* Remove margin from columns containing h1 (featured layout) */
article.wp-block-post .wp-block-columns .wp-block-column:has(h1.ct-dynamic-data) {
    margin-top: 0 !important;
}

h2.ct-dynamic-data {
    margin-top: 0;
    margin-bottom: 0;
}

/* ========================================
   BETWEEN POSTS AD - Als eigenständige Card im Grid
   ======================================== */

/* Die Ad-Card verhält sich wie eine normale Post-Card */
article.between-posts-ad-card-item {
    /* Erbt Grid-Layout von Blocksy - KEINE feste Höhe! */
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--theme-palette-color-8, #fff);
    border-radius: var(--theme-border-radius, 3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    overflow: hidden;
    /* Grid soll die Höhe automatisch bestimmen */
    align-self: stretch;
    height: 100%;
}

/* Content-Bereich der Ad-Card */
.between-posts-ad-card-content {
    position: relative;
    padding: 40px 20px !important;
    text-align: center !important;
}

/* Container für das Label relativ positioniert */
.between-posts-ad-card-content .stage-featured-content {
    position: relative;
    display: inline-block;
}

/* Label-Positionierung für Between Posts Banner */
.between-posts-ad-card-content .content-label {
    /* Standard StageAds Label-Styling wie überall */
    position: absolute !important;
    top: 100% !important;
    left: 20px !important;
    background: #3d3c3c !important;
    color: #ffffff !important;
    padding: 3px 6px !important;
    font-size: 9px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    font-weight: 500 !important;
    border-radius: 0 0 3px 3px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    backdrop-filter: blur(4px) !important;
    white-space: nowrap !important;

}

/* Gilt für ALLE H2s, die dynamic-data sind */
h2.ct-dynamic-data {
    margin-top: 0;
    margin-bottom: 0;
}

/* ========================================
   POST FEATURED IMAGE - Margin Reset
   ======================================== */
:root .wp-block-post-featured-image {
    margin-bottom: 0;
    margin-block-end: 0;
}

/* ========================================
   BLOCKERA GROUP BLOCKS - Margin Reset
   ======================================== */
/* Erhöhte Spezifität um Blockera-Regeln zu überschreiben */
.wp-block-group.wp-block-group[class*="blockera-block-"].blockera-block,
.blockera-block.blockera-block[class*="blockera-block-"].wp-block-group {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* ========================================
   HEADINGS - Margin Reset
   ======================================== */
:root h1, :root h2, :root h3, :root h4, :root h5, :root h6 {
    margin-top: 0;
    margin-bottom: 0;
    margin-block-start: 0;
    margin-block-end: 0;
}

/* AUSNAHME: Überschriften IN ARTIKEL-CONTENT brauchen Margins! */
/* Höhere Spezifität als :root h2 durch :root Prefix */
:root .entry-content h1,
:root .entry-content h2,
:root .entry-content h3,
:root .entry-content h4,
:root .entry-content h5,
:root .entry-content h6,
:root .wp-block-post-content h1,
:root .wp-block-post-content h2,
:root .wp-block-post-content h3,
:root .wp-block-post-content h4,
:root .wp-block-post-content h5,
:root .wp-block-post-content h6,
:root article h1,
:root article h2,
:root article h3,
:root article h4,
:root article h5,
:root article h6,
:root .wp-block-heading {
    margin-top: 1em !important;
    margin-bottom: 0.5em !important;
}

/* Erste Überschrift im Content braucht kein margin-top */
:root .entry-content > h1:first-child,
:root .entry-content > h2:first-child,
:root .entry-content > h3:first-child,
:root .entry-content > h4:first-child,
:root .entry-content > h5:first-child,
:root .entry-content > h6:first-child,
:root .wp-block-post-content > h1:first-child,
:root .wp-block-post-content > h2:first-child,
:root .wp-block-post-content > h3:first-child,
:root .wp-block-post-content > h4:first-child,
:root .wp-block-post-content > h5:first-child,
:root .wp-block-post-content > h6:first-child,
:root article > h1:first-child,
:root article > h2:first-child,
:root article > h3:first-child,
:root article > h4:first-child,
:root article > h5:first-child,
:root article > h6:first-child,
:root .wp-block-heading:first-child {
    margin-top: 0 !important;
}

/* ========================================
   EVENTS WIDGET - Reset Margins
   ======================================== */
.events-widget-list > li {
    margin-bottom: 0;
}

.events-widget-item {
    gap: 12px;
}

.events-widget-date,
.events-widget-date time {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.field-veranstaltung_zu_location,
.field-datum {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* ========================================
   GALLERY ARCHIVE - Basic Grid (Style with Blockera)
   ======================================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.gallery-card {
    /* Basis-Struktur - Style mit Blockera */
}

.gallery-thumbnail {
    display: block;
}

.gallery-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   CUSTOM INLINE SEARCH FIELD - Header
   ======================================== */
.ct-header .custom-search-element {
    display: flex;
    align-items: center;
    height: 100%;
}

.ct-header .custom-search-form {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.ct-header .custom-search-element .custom-search-input {
    padding: 0 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 3px !important;
    min-width: 180px;
    max-width: 220px;
    font-size: 13px !important;
    line-height: 30px !important;
    background: #fff !important;
    color: #333 !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    height: 32px !important;
    max-height: 32px !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
    margin: 0 !important;
}

.ct-header .custom-search-element .custom-search-input:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    background: #fff !important;
}

.ct-header .custom-search-element .custom-search-input::placeholder {
    color: #999;
    line-height: 30px;
}

.ct-header .custom-search-element .custom-search-button,
.ct-header .custom-search-element button[type="submit"],
.custom-search-form .custom-search-button,
.custom-search-form button[type="submit"] {
    padding: 0 14px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    background: #dc2626 !important;
    color: #fff !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    border-radius: 3px !important;
    cursor: pointer;
    transition: background 0.3s ease;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    font-weight: 500;
    white-space: nowrap;
    box-sizing: border-box !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    margin: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.ct-header .custom-search-button:hover {
    background: #b91c1c;
}

.ct-header .custom-search-button span {
    display: inline-block;
    line-height: 1;
}

/* Responsive Anpassungen */
@media (max-width: 991px) {
    .ct-header .custom-search-input {
        min-width: 140px;
        max-width: 180px;
    }
}

@media (max-width: 768px) {
    .ct-header .custom-search-input {
        min-width: 120px;
        max-width: 150px;
        font-size: 12px;
        height: 30px;
    }

    .ct-header .custom-search-button {
        padding: 4px 12px;
        font-size: 12px;
        height: 30px;
    }
}

/* ========================================
   DACHZEILE FIELD - Margin Reset
   ======================================== */
.field-dachzeile,
p.field-dachzeile,
.wp-block-acf-field-blocks-acf-text.field-dachzeile,
p.wp-block-acf-field-blocks-acf-text.field-dachzeile {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
}

/* ========================================
   IMAGE CAPTIONS - Right Aligned (Copyright)
   ======================================== */

/* Äußeres Blocksy Figure - overflow visible für Caption */
.wp-block-post-featured-image {
    overflow: visible !important;
}

/* Figure Wrapper - transparent, stört nicht das äußere 16:9 Aspect Ratio */
.wp-post-thumbnail-figure {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
}

/* Bild im Figure - füllt den 16:9 Container */
.wp-post-thumbnail-figure img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

:root figcaption,
:root .wp-caption-text,
:root .wp-element-caption,
:root .wp-block-image figcaption,
:root .wp-block-gallery figcaption,
:root .wp-post-thumbnail-caption {
    display: block !important;
    text-align: right !important;
    font-size: 12px !important;
    color: #666 !important;
    font-style: italic !important;
    margin: 0 !important;
    padding: 0 0.25em 0 0 !important;
    white-space: nowrap !important;
    word-wrap: normal !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    overflow: visible !important;
    width: auto !important;
    max-width: none !important;
    text-indent: 0 !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
}

/* Links in Captions */
:root figcaption a,
:root .wp-caption-text a,
:root .wp-element-caption a,
:root .wp-post-thumbnail-caption a {
    color: #666 !important;
    text-decoration: underline !important;
    white-space: nowrap !important;
    display: inline !important;
}

:root figcaption a:hover,
:root .wp-caption-text a:hover,
:root .wp-element-caption a:hover,
:root .wp-post-thumbnail-caption a:hover {
    color: #333 !important;
}

/* ========================================
   MOBILE HEADER FIXES
   ======================================== */

/* Fix logo size on mobile devices */
@media (max-width: 999px) {
    .site-logo-container,
    .site-branding,
    [data-id="logo"] {
        max-height: 50px !important;
        display: flex !important;
        align-items: center !important;
    }

    .site-logo-container img,
    .site-branding img,
    .custom-logo {
        max-height: 50px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }
}

/* Make hamburger menu icon light/white */
@media (max-width: 999px) {
    .ct-header .ct-toggle-button,
    .mobile-menu-toggle,
    [data-toggle-panel],
    .ct-header-trigger {
        color: #ffffff !important;
    }

    .ct-header .ct-toggle-button svg,
    .mobile-menu-toggle svg,
    [data-toggle-panel] svg,
    .ct-header-trigger svg {
        fill: #ffffff !important;
        stroke: #ffffff !important;
    }

    /* Hamburger lines */
    .ct-header .ct-toggle-button span,
    .mobile-menu-toggle span {
        background-color: #ffffff !important;
    }
}

/* ========================================
   MOBILE MENU SEARCH FIELD
   ======================================== */
/* Search field in mobile off-canvas menu */
#offcanvas .custom-search-element,
.ct-panel .custom-search-element,
[data-behaviour*="panel"] .custom-search-element {
    width: 100%;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#offcanvas .custom-search-form,
.ct-panel .custom-search-form {
    width: 100%;
    flex-direction: column;
    gap: 10px;
}

#offcanvas .custom-search-input,
.ct-panel .custom-search-input {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    padding: 12px 15px !important;
    height: 44px !important;
    max-height: 44px !important;
    font-size: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

#offcanvas .custom-search-input::placeholder,
.ct-panel .custom-search-input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

#offcanvas .custom-search-input:focus,
.ct-panel .custom-search-input:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

#offcanvas .custom-search-button,
.ct-panel .custom-search-button {
    width: 100% !important;
    height: 44px !important;
    max-height: 44px !important;
    padding: 12px 20px !important;
    font-size: 16px !important;
}

/* ========================================
   FOOTER SPACING
   ======================================== */
footer.site-footer,
.ct-footer,
footer[data-id*="footer"] {
    margin-top: 50px;
}

/* ========================================
   SEARCH RESULTS - RESPONSIVE LAYOUT
   ======================================== */

/* Desktop: Bild links, Content rechts (Standard - funktioniert bereits) */

/* Mobile: Bild oben, Content unten */
@media (max-width: 768px) {
    /* Query Loop Post Template Row auf Mobile stacken */
    .search-results-content .wp-block-query .wp-block-post-template .wp-block-columns {
        flex-direction: column !important;
    }

    /* Beide Columns auf Mobile 100% Breite */
    .search-results-content .wp-block-query .wp-block-post-template .wp-block-column {
        flex-basis: 100% !important;
        width: 100% !important;
    }

    /* Bild-Column: Zentriert, kleinere Höhe */
    .search-results-content .wp-block-query .wp-block-post-template .wp-block-column:first-child {
        margin-bottom: 15px;
    }

    /* Optional: Bild auf Mobile etwas kleiner */
    .search-results-content .wp-block-post-featured-image img {
        max-height: 200px;
        object-fit: cover;
    }
}

/* ========================================
   SEARCH RESULTS - HIGHLIGHTED SNIPPETS
   ======================================== */

/* Highlight search terms in snippets (Google-style) */
mark,
.search-results-content mark,
.search-results mark,
.search-snippet-block mark {
    background-color: #ffeb3b !important;
    color: #000 !important;
    font-weight: 600 !important;
    padding: 2px 4px !important;
    border-radius: 2px !important;
}

/* ========================================
   SEARCH RESULTS - POST TYPE BADGES
   ======================================== */

/* Badge styling */
.search-result-badge {
    display: inline-block;
    margin-right: 12px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-radius: 4px;
    vertical-align: middle;
}

/* Gallery badge */
.badge-gallery {
    background: #8b0000;
    color: #ffffff;
    border: 2px solid #6b0000;
}

/* Optional: Different styling for gallery search results */
.post-type-foogallery {
    /* You can add custom styling for gallery results here */
}

/* ========================================
   SEARCH RESULTS - TRANSLATION ACCORDION
   ======================================== */

/* Translation toggle button */
.search-translation-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    background: transparent;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-translation-toggle:hover {
    background: #f8f8f8;
    border-color: #999;
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-translation-toggle .toggle-icon {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    transition: transform 0.25s ease;
}

.search-translation-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(45deg);
}

/* Translation content (collapsed by default) */
.search-translation-content {
    margin-top: 16px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e5e5e5;
    border-left: 4px solid #666;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-translation-content[hidden] {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Translation title */
.search-title-translation {
    margin: 0 0 14px 0;
    font-size: 1.3em;
    font-weight: 700;
    line-height: 1.3;
}

.search-title-translation a {
    text-decoration: none;
    color: #1a1a1a;
    transition: color 0.2s ease;
}

.search-title-translation a:hover {
    color: #0066cc;
}

/* Translation snippet */
.search-snippet-translation {
    font-size: 0.95em;
    line-height: 1.7;
    color: #444;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-translation-toggle {
        width: 100%;
        justify-content: center;
    }

    .search-translation-content {
        padding: 16px;
    }
}

/* StageAds: remove top margin from ad containers sitewide */
.stage-featured-content {
    margin-top: 0 !important;
    margin-block-start: 0 !important;
}
