/**
 * ALO Posts Block Element Styles
 */

.alo-postsblock {
    font-family: 'Rubik', sans-serif;
    margin-bottom: 20px;
    border: none !important;
}

/* --------------------------------------------------------------------------
 * Heading Section (reuses Heading element styles)
 * -------------------------------------------------------------------------- */

.alo-postsblock__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-radius: 8px;
    background-color: var(--alo-postsblock-heading-bg, #f5f5f5);
    border: none;
    border-right: var(--alo-postsblock-heading-border-width, 15px) solid var(--alo-postsblock-heading-border-color, #0080ce);
    box-sizing: border-box;
    gap: 16px;
    transition: background-color 0.2s ease;
    margin-bottom: 20px !important;
}

.alo-postsblock__heading:hover {
    background-color: color-mix(in oklch, var(--alo-postsblock-heading-bg, #f5f5f5), black 5%);
}

.alo-postsblock__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--alo-postsblock-icon-size, 35px);
    line-height: 1;
}

.alo-postsblock__icon i {
    color: var(--alo-postsblock-icon-color, #0080ce);
}

.alo-postsblock__heading-content {
    flex: 1;
}

.alo-postsblock__heading-title-link {
    color: inherit !important;
    text-decoration: none !important;
    transition: opacity 0.2s ease;
    display: inline-block;
}

.alo-postsblock__heading-title-link:hover {
    opacity: 0.8;
    text-decoration: none !important;
}

.alo-postsblock__heading-title {
    margin: 0;
    font-weight: 600;
    line-height: 1.5;
    color: var(--alo-postsblock-heading-title-color, #0080ce);
    font-size: var(--alo-postsblock-heading-title-size, 18px);
}

/* RTL support for heading */
.rtl .alo-postsblock__heading {
    direction: rtl;
    border-right: none;
    border-left: var(--alo-postsblock-heading-border-width, 15px) solid var(--alo-postsblock-heading-border-color, #0080ce);
}

/* --------------------------------------------------------------------------
 * Posts Grid
 * -------------------------------------------------------------------------- */

.alo-postsblock__posts-grid {
    display: grid;
    gap: 20px;
}

/* Column layouts */
.alo-postsblock--columns-1 .alo-postsblock__posts-grid {
    grid-template-columns: 1fr;
}

.alo-postsblock--columns-2 .alo-postsblock__posts-grid {
    grid-template-columns: repeat(2, 1fr);
}

.alo-postsblock--columns-3 .alo-postsblock__posts-grid {
    grid-template-columns: repeat(3, 1fr);
}

.alo-postsblock--columns-4 .alo-postsblock__posts-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* --------------------------------------------------------------------------
 * Post Item - With Thumbnail
 * -------------------------------------------------------------------------- */

.alo-postsblock--with-thumbnail .alo-postsblock__post-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alo-postsblock__post-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-radius: 8px;
    background-color: #f5f5f5;
}

.alo-postsblock__post-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    transition: transform 0.3s ease;
}

.alo-postsblock__post-thumbnail:hover .alo-postsblock__post-image {
    transform: scale(1.05);
}

.alo-postsblock__post-content {
    flex: 1;
}

.alo-postsblock__post-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    color: #383838;
    transition: color 0.2s ease;
}

.alo-postsblock__post-title a {
    color: inherit;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.alo-postsblock--with-thumbnail .alo-postsblock__post-item:hover .alo-postsblock__post-title,
.alo-postsblock--with-thumbnail .alo-postsblock__post-item:hover .alo-postsblock__post-title a {
    color: var(--alo-postsblock-heading-border-color, #0080ce);
}

.alo-postsblock__post-excerpt {
    margin: 8px 0 0 0;
    font-size: 14px;
    line-height: 1.6;
    color: #888888;
}

/* --------------------------------------------------------------------------
 * Post Item - Title Only
 * -------------------------------------------------------------------------- */

.alo-postsblock--title-only .alo-postsblock__post-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

/* LTR: border on right */
.alo-postsblock--title-only .alo-postsblock__post-item:not(.rtl) {
    border-right: 3px solid rgba(0, 0, 0, 0.11);
}

/* RTL: border on right (which is the starting side in RTL) */
.rtl .alo-postsblock--title-only .alo-postsblock__post-item {
    border-right: 3px solid rgba(0, 0, 0, 0.11);
}

.alo-postsblock--title-only .alo-postsblock__post-item:hover {
    background-color: color-mix(in oklch, #ffffff, black 2%);
    border-right-color: var(--alo-postsblock-heading-border-color, #0080ce);
}

.alo-postsblock__post-vertical-bar {
    display: none;
}

.alo-postsblock--title-only .alo-postsblock__post-content {
    flex: 1;
}

.alo-postsblock--title-only .alo-postsblock__post-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    color: #383838;
    transition: color 0.2s ease;
}

.alo-postsblock--title-only .alo-postsblock__post-title a {
    color: inherit;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.alo-postsblock--title-only .alo-postsblock__post-item:hover .alo-postsblock__post-title,
.alo-postsblock--title-only .alo-postsblock__post-item:hover .alo-postsblock__post-title a {
    color: var(--alo-postsblock-heading-border-color, #0080ce);
}

.alo-postsblock--title-only .alo-postsblock__post-excerpt {
    margin: 8px 0 0 0;
    font-size: 14px;
    line-height: 1.6;
    color: #888888;
}

/* RTL support for title-only */
.rtl .alo-postsblock--title-only .alo-postsblock__post-item {
    direction: rtl;
}

.rtl .alo-postsblock--title-only .alo-postsblock__post-vertical-bar {
    margin-right: 0;
    margin-left: 12px;
}

/* --------------------------------------------------------------------------
 * Pagination
 * -------------------------------------------------------------------------- */

.alo-postsblock__pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.alo-postsblock__pagination-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background-color: #2563eb;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Rubik', sans-serif;
}

.alo-postsblock__pagination-btn:hover:not(:disabled) {
    background-color: color-mix(in oklch, #2563eb, black 15%);
    transform: scale(1.03);
}

.alo-postsblock__pagination-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.alo-postsblock__pagination-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

.alo-postsblock__pagination-label {
    font-size: 15px;
    color: #383838;
    font-weight: 500;
}

.alo-postsblock__load-more-btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* RTL support for pagination */
.rtl .alo-postsblock__pagination {
    direction: rtl;
}

/* --------------------------------------------------------------------------
 * No Posts Message
 * -------------------------------------------------------------------------- */

.alo-postsblock__no-posts {
    text-align: center;
    padding: 20px;
    color: #888888;
    font-size: 15px;
}

/* --------------------------------------------------------------------------
 * Loading State
 * -------------------------------------------------------------------------- */

.alo-postsblock__loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.alo-postsblock__loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: alo-postsblock-spin 0.8s linear infinite;
}

@keyframes alo-postsblock-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --------------------------------------------------------------------------
 * Theme Override - High Specificity
 * -------------------------------------------------------------------------- */

body .alo-postsblock__heading {
    border: none !important;
    border-right: var(--alo-postsblock-heading-border-width, 15px) solid var(--alo-postsblock-heading-border-color, #0080ce) !important;
}

.rtl body .alo-postsblock__heading {
    border-right: none !important;
    border-left: var(--alo-postsblock-heading-border-width, 15px) solid var(--alo-postsblock-heading-border-color, #0080ce) !important;
}

body .alo-postsblock__pagination-btn {
    border: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

/* --------------------------------------------------------------------------
 * Reduced Motion
 * -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .alo-postsblock__heading {
        transition: none;
    }

    .alo-postsblock__heading:hover {
        background-color: var(--alo-postsblock-heading-bg, #f5f5f5);
    }

    .alo-postsblock__post-image {
        transition: none;
    }

    .alo-postsblock__post-thumbnail:hover .alo-postsblock__post-image {
        transform: none;
    }

    .alo-postsblock__post-title {
        transition: none;
    }

    .alo-postsblock__post-vertical-bar {
        transition: none;
    }

    .alo-postsblock__pagination-btn {
        transition: none;
    }

    .alo-postsblock__pagination-btn:hover:not(:disabled) {
        transform: none;
        background-color: #2563eb;
    }

    .alo-postsblock__pagination-btn:active:not(:disabled) {
        transform: none;
    }
}

/* --------------------------------------------------------------------------
 * Mobile Responsive
 * -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .alo-postsblock--columns-2 .alo-postsblock__posts-grid,
    .alo-postsblock--columns-3 .alo-postsblock__posts-grid,
    .alo-postsblock--columns-4 .alo-postsblock__posts-grid {
        grid-template-columns: 1fr;
    }

    .alo-postsblock__heading {
        padding: 15px 12px;
    }

    .alo-postsblock__pagination {
        flex-direction: column;
        gap: 12px;
    }

    .alo-postsblock__pagination-btn {
        width: 100%;
    }
}
