/**
 * Dynamic Page Blocks - Frontend Styles
 */

/* Container for blocks */
.dpb-blocks-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 2rem 0;
    width: 100%;
}

/* Individual block */
.dpb-block {
    flex: 1 1 calc(50% - 0.75rem); /* 2 columns by default */
    min-width: 280px;
    max-width: 100%;
    box-sizing: border-box;
}

/* Block inner wrapper */
.dpb-block-inner {
    height: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dpb-block-inner:hover {
    border-color: #0066cc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Block link */
.dpb-block-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.dpb-block-link:hover {
    text-decoration: none;
}

/* Text block */
.dpb-block-text {
    padding: 1.5rem;
    color: #333333;
    line-height: 1.6;
}

.dpb-block-text h1,
.dpb-block-text h2,
.dpb-block-text h3,
.dpb-block-text h4,
.dpb-block-text h5,
.dpb-block-text h6 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #0066cc;
}

.dpb-block-text p {
    margin: 0 0 1rem 0;
}

.dpb-block-text p:last-child {
    margin-bottom: 0;
}

.dpb-block-link:hover .dpb-block-text h1,
.dpb-block-link:hover .dpb-block-text h2,
.dpb-block-link:hover .dpb-block-text h3,
.dpb-block-link:hover .dpb-block-text h4,
.dpb-block-link:hover .dpb-block-text h5,
.dpb-block-link:hover .dpb-block-text h6 {
    text-decoration: underline;
}

/* Image block */
.dpb-block-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 400px;
}

/* Single block takes full width */
.dpb-blocks-container .dpb-block:only-child {
    flex: 1 1 100%;
    max-width: 100%;
}

/* Three or more blocks - 3 columns on large screens */
.dpb-blocks-container .dpb-block:first-child:nth-last-child(n+3),
.dpb-blocks-container .dpb-block:first-child:nth-last-child(n+3) ~ .dpb-block {
    flex: 1 1 calc(33.333% - 1rem);
}

/* Responsive adjustments */

/* Tablet - 2 columns */
@media screen and (max-width: 991px) {
    .dpb-blocks-container .dpb-block:first-child:nth-last-child(n+3),
    .dpb-blocks-container .dpb-block:first-child:nth-last-child(n+3) ~ .dpb-block {
        flex: 1 1 calc(50% - 0.75rem);
    }
}

/* Mobile - 1 column */
@media screen and (max-width: 767px) {
    .dpb-blocks-container {
        gap: 1rem;
        margin: 1.5rem 0;
    }

    .dpb-block {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .dpb-blocks-container .dpb-block:first-child:nth-last-child(n+3),
    .dpb-blocks-container .dpb-block:first-child:nth-last-child(n+3) ~ .dpb-block {
        flex: 1 1 100%;
    }

    .dpb-block-text {
        padding: 1rem;
    }

    .dpb-block-image {
        max-height: 250px;
    }
}

/* Animation on load */
@keyframes dpbFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dpb-block {
    animation: dpbFadeInUp 0.5s ease forwards;
}

/* Stagger animation for multiple blocks */
.dpb-block:nth-child(1) { animation-delay: 0.1s; }
.dpb-block:nth-child(2) { animation-delay: 0.2s; }
.dpb-block:nth-child(3) { animation-delay: 0.3s; }
.dpb-block:nth-child(4) { animation-delay: 0.4s; }
.dpb-block:nth-child(5) { animation-delay: 0.5s; }
.dpb-block:nth-child(6) { animation-delay: 0.6s; }

/* Accessibility */
.dpb-block-link:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

.dpb-block-link:focus .dpb-block-inner {
    border-color: #0066cc;
}

/* Print styles */
@media print {
    .dpb-blocks-container {
        display: block;
        page-break-inside: avoid;
    }

    .dpb-block {
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }

    .dpb-block-inner {
        border: 1px solid #000;
        box-shadow: none;
    }
}
