/* ACC Grid — grid.css */

/* ── CSS Variables (set via inline style on .acc-grid-wrap) ── */
:root {
    --g-primary: #11B2BA;
    --g-secondary: #F79C85;
    --g-text: #111827;
    --g-bg: #ffffff;
    --g-radius: 16px;
    --g-gap: 20px;
    --g-transition: 250ms;
    --g-cols-desk: 3;
    --g-cols-tab: 2;
    --g-cols-mob: 1;
}

/* ── Container ───────────────────────────────────────────────── */
.acc-archive-main {
    padding: 40px 0;
    min-height: 60vh;
}

.acc-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.acc-archive-header {
    margin-bottom: 32px;
    text-align: center;
}

.acc-archive-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--g-primary);
    margin: 0;
}

/* ── Filter Bar ──────────────────────────────────────────────── */
.acc-filter-bar {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 28px;
    direction: rtl;
    /* يجب أن يكون relative + z-index لتظهر فوق الكرود */
    position: relative;
    z-index: 50;
}

.acc-filter-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    /* نسمح بالتفاف العناصر إذا ضاقت الشاشة حتى لا تتداخل */
    flex-wrap: wrap;
}

.acc-filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 120px;
    min-width: 100px;
}

/* Keyword field */
.acc-kw-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1.2 1 140px;
    min-width: 110px;
}

.acc-filter-label {
    font-size: .75rem;
    font-weight: 700;
    color: #6b7280;
    letter-spacing: .03em;
    white-space: nowrap;
}

/* ── Keyword Search ───────────────────────────────────────────── */
.acc-kw-wrap {
    position: relative;
}

.acc-keyword-input {
    width: 100%;
    box-sizing: border-box;
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0 10px 0 34px;
    /* مسافة للأيقونة يسار */
    font-size: .88rem;
    direction: rtl;
    color: #111827;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}

.acc-keyword-input:focus {
    outline: none;
    border-color: var(--g-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--g-primary) 18%, transparent);
}

.acc-kw-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .85rem;
    color: #9ca3af;
    pointer-events: none;
    line-height: 1;
}

/* ── Custom Searchable Dropdown ──────────────────────────────── */
.acc-custom-select {
    position: relative;
}

.acs-trigger {
    width: 100%;
    box-sizing: border-box;
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: pointer;
    font-size: .88rem;
    direction: rtl;
    text-align: right;
    transition: border-color .2s, box-shadow .2s;
    gap: 6px;
}

.acs-trigger:hover {
    border-color: var(--g-primary);
}

.acs-trigger.open {
    border-color: var(--g-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--g-primary) 18%, transparent);
}

.acs-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #374151;
}

.acs-arrow {
    color: #9ca3af;
    flex-shrink: 0;
    font-size: .75rem;
    transition: transform .2s;
}

.acs-trigger.open .acs-arrow {
    transform: rotate(180deg);
}

/* Dropdown panel */
.acs-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .13);
    z-index: 9999;
    /* فوق كل شيء بما فيها الكرود */
    overflow: hidden;
    direction: rtl;
}

.acs-dropdown[hidden] {
    display: none !important;
}

.acs-search-wrap {
    padding: 8px;
    border-bottom: 1px solid #f3f4f6;
}

.acs-search {
    width: 100%;
    box-sizing: border-box;
    height: 34px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0 10px;
    font-size: .85rem;
    direction: rtl;
    transition: border-color .2s;
}

.acs-search:focus {
    outline: none;
    border-color: var(--g-primary);
}

.acs-options {
    list-style: none;
    margin: 0;
    padding: 4px;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}

.acs-option {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .88rem;
    color: #374151;
    transition: background .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acs-option:hover {
    background: #e8f9fa;
    color: var(--g-primary);
}

.acs-option.acs-selected {
    background: #e8f9fa;
    color: var(--g-primary);
    font-weight: 700;
}

.acs-option[hidden] {
    display: none !important;
}

/* ── Filter actions ──────────────────────────────────────────── */
.acc-filter-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 0;
    flex-shrink: 0;
}

.acc-btn-reset {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: .82rem;
    color: #6b7280;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    height: 40px;
}

.acc-btn-reset:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

.acc-result-count {
    font-size: .82rem;
    color: #9ca3af;
    white-space: nowrap;
}

/* On mobile: allow wrap */
@media (max-width: 640px) {
    .acc-filter-row {
        flex-wrap: wrap;
    }

    .acc-filter-field,
    .acc-kw-field {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }

    .acc-filter-actions {
        width: 100%;
        justify-content: flex-end;
    }
}


/* ── Loading ─────────────────────────────────────────────────── */
.acc-loader {
    display: none;
    /* مخفي افتراضياً */
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .65);
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--g-radius);
    backdrop-filter: blur(2px);
}

/* يظهر فقط عند التحميل */
.acc-is-loading {
    position: relative;
}

.acc-is-loading .acc-loader {
    display: flex;
}

.acc-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--g-primary);
    border-radius: 50%;
    animation: acc-spin .7s linear infinite;
}

@keyframes acc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Grid Layout ─────────────────────────────────────────────── */
.acc-grid {
    display: grid;
    gap: var(--g-gap);
    grid-template-columns: repeat(var(--g-cols-desk), 1fr);
}

.acc-grid.layout-list {
    grid-template-columns: 1fr;
}

@media (max-width: 1024px) {
    .acc-grid {
        grid-template-columns: repeat(var(--g-cols-tab), 1fr);
    }
}

@media (max-width: 640px) {
    .acc-grid {
        grid-template-columns: repeat(var(--g-cols-mob), 1fr);
    }
}

/* ── Card ────────────────────────────────────────────────────── */
.acc-card {
    background: var(--g-bg);
    border-radius: var(--g-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    content-visibility: auto;
    contain-intrinsic-size: 0 320px;
    transition: transform var(--g-transition) ease, box-shadow var(--g-transition) ease;
}

/* Shadows */
.shadow-soft .acc-card {
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

.shadow-strong .acc-card {
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
}

.shadow-glow .acc-card {
    box-shadow: 0 0 20px color-mix(in srgb, var(--g-primary) 30%, transparent);
}

.shadow-none .acc-card {
    box-shadow: none;
    border: 1px solid #e5e7eb;
}

/* Card hover effects */
.acc-card.card-hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
}

.acc-card.card-hover-scale:hover {
    transform: scale(1.02);
}

.acc-card.card-hover-glow:hover {
    box-shadow: 0 0 30px color-mix(in srgb, var(--g-primary) 45%, transparent);
}

.acc-card.card-hover-border:hover {
    outline: 2px solid var(--g-primary);
}

/* ── Card Image ──────────────────────────────────────────────── */
.acc-card-img-wrap {
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
}

.acc-card-img-link {
    display: block;
    width: 100%;
    height: 100%;
}

.acc-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Books: contain image so cover isn't cropped ────────────── */
[data-post-type="books"] .acc-card-img-wrap {
    background: #f8f8f4;
    /* warm off-white behind book covers */
}

[data-post-type="books"] .acc-card-img {
    object-fit: contain;
    padding: 6px;
}

/* Image hover effects */
.acc-card.img-hover-zoom .acc-card-img {
    transition: transform var(--g-transition) ease;
}

.acc-card.img-hover-zoom:hover .acc-card-img {
    transform: scale(1.07);
}

.acc-card.img-hover-fade:hover .acc-card-img {
    opacity: .8;
}

.acc-card.img-hover-gray:hover .acc-card-img {
    filter: grayscale(60%);
}

.acc-img-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .55) 0%, transparent 60%);
    pointer-events: none;
}

.acc-no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 3rem;
    background: #f3f4f6;
    color: #d1d5db;
}

/* ── Card Overlay (title over image) ─────────────────────────── */
.acc-card.title-pos-over {
    position: relative;
}

.acc-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, .75), transparent);
    z-index: 2;
}

.acc-card.title-pos-over .acc-card-overlay .acc-card-title {
    color: #fff;
    margin: 0;
    font-size: 1rem;
}

/* ── Card Body ───────────────────────────────────────────────── */
.acc-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    text-align: var(--text-align, right);
    direction: rtl;
}

.acc-card-meta {
    font-size: .78rem;
    color: #9ca3af;
    font-weight: 500;
}

.acc-card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--g-text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.acc-card-title a {
    color: inherit;
    text-decoration: none;
}

.acc-card-title a:hover {
    color: var(--g-primary);
}

[data-title-size="lg"] .acc-card-title {
    font-size: 1.2rem;
}

[data-title-size="sm"] .acc-card-title {
    font-size: .88rem;
}

.acc-card-excerpt {
    font-size: .85rem;
    color: #6b7280;
    line-height: 1.6;
}

.acc-card-footer {
    margin-top: auto;
    padding-top: 8px;
}

/* ── Badge ───────────────────────────────────────────────────── */
.acc-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--g-primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    line-height: 1.4;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.acc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .2s;
    cursor: pointer;
}

.acc-btn-solid {
    background: var(--g-primary);
    color: #fff;
    border: 2px solid var(--g-primary);
}

.acc-btn-solid:hover {
    filter: brightness(1.12);
}

.acc-btn-outline {
    background: transparent;
    color: var(--g-primary);
    border: 2px solid var(--g-primary);
}

.acc-btn-outline:hover {
    background: var(--g-primary);
    color: #fff;
}

.acc-btn-link {
    background: none;
    border: none;
    color: var(--g-primary);
    padding: 0;
}

.acc-btn-link:hover {
    text-decoration: underline;
}

/* ── Empty state ─────────────────────────────────────────────── */
.acc-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
    font-size: 1rem;
}

/* ── Sentinel & Load more ────────────────────────────────────── */
.acc-sentinel {
    height: 1px;
}

.acc-loadmore-wrap {
    text-align: center;
    margin: 32px 0;
}

.acc-btn-loadmore {
    background: var(--g-primary);
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter .2s;
}

.acc-btn-loadmore:hover {
    filter: brightness(1.1);
}

/* ── Numbers Pagination ──────────────────────────────────────── */
.acc-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 32px 0;
    direction: rtl;
}

.acc-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: .9rem;
    color: #374151;
    text-decoration: none;
    transition: all .2s;
}

.acc-pagination .page-numbers:hover {
    border-color: var(--g-primary);
    color: var(--g-primary);
}

.acc-pagination .page-numbers.current {
    background: var(--g-primary);
    color: #fff;
    border-color: var(--g-primary);
    font-weight: 700;
}

.acc-pagination .page-numbers.dots {
    border: none;
    pointer-events: none;
}

/* loadmore-wrap is hidden by default, JS will un-hide it */
.acc-loadmore-wrap[hidden] {
    display: none !important;
}


/* ── Dark style override ─────────────────────────────────────── */
.style-dark {
    background: #0f0f1a;
}

.style-dark .acc-filter-bar {
    background: #1a1a2e;
    border-color: #2a2a4a;
}

.style-dark .acc-filter-label {
    color: #a5b4fc;
}

.style-dark .acc-select {
    background-color: #1e1e3a;
    border-color: #3a3a5a;
    color: #e5e7eb;
}

.style-dark .acc-archive-title {
    color: #818cf8;
}

/* ── Glass style ─────────────────────────────────────────────── */
.style-glass .acc-card {
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, .3);
}

/* ── No section ──────────────────────────────────────────────── */
.acc-no-section {
    padding: 60px;
    text-align: center;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    color: #6b7280;
}

/* ══════════════════════════════════════════════════════════════
   HOMEPAGE SECTION PREVIEW  [acc_section_preview]
   Primary: #11B2BA
   ══════════════════════════════════════════════════════════════ */

/* Outer wrapper for all sections on homepage */
.acc-sections-homepage {
    direction: rtl;
    padding: 0;
}

/* Each section block */
.acc-preview-section {
    margin-bottom: 56px;
}

/* ── Section Header (title + view-all link) ─────────────────── */
.acc-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    direction: rtl;
}

.acc-preview-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: #0e9aa1;
    margin: 0;
    position: relative;
    padding-right: 16px;
    letter-spacing: -.01em;
}

.acc-preview-title::before {
    content: '';
    position: absolute;
    right: 0;
    top: 8%;
    height: 84%;
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(to bottom, #11B2BA, #0e9aa1);
}

.acc-preview-more-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .88rem;
    font-weight: 700;
    color: #11B2BA;
    text-decoration: none;
    border: 2px solid #11B2BA;
    padding: 7px 20px;
    border-radius: 100px;
    white-space: nowrap;
    transition: all .25s ease;
    flex-shrink: 0;
    background: rgba(17, 178, 186, .04);
}

.acc-preview-more-link:hover {
    background: #11B2BA;
    color: #fff;
    box-shadow: 0 4px 16px rgba(17, 178, 186, .3);
    transform: translateY(-1px);
}

.acc-preview-arrow {
    font-size: 1rem;
    display: inline-block;
    transition: transform .25s;
}

.acc-preview-more-link:hover .acc-preview-arrow {
    transform: translateX(-4px);
}

/* ── Scroll Container (arrows + track) ──────────────────────── */
.acc-scroll-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
}

/* ── Arrow Buttons ──────────────────────────────────────────── */
.acc-scroll-arrow {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    background: #fff;
    color: #11B2BA;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .25s ease;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    padding: 0;
    position: relative;
}

.acc-scroll-arrow:hover {
    background: #11B2BA;
    color: #fff;
    border-color: #11B2BA;
    box-shadow: 0 4px 16px rgba(17, 178, 186, .35);
    transform: scale(1.08);
}

.acc-scroll-arrow:active {
    transform: scale(.95);
}

.acc-scroll-arrow:disabled,
.acc-scroll-arrow.acc-arrow-hidden {
    opacity: .25;
    pointer-events: none;
}

.acc-scroll-prev {
    margin-left: -4px;
    margin-right: 10px;
}

.acc-scroll-next {
    margin-right: -4px;
    margin-left: 10px;
}

/* ── Horizontal Scroll Track (layout="scroll") ──────────────── */
.acc-preview-scroll-track {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    /* Snap effect on mobile */
    scroll-behavior: smooth;

    /* Hide scrollbar completely — arrows handle navigation */
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    min-width: 0;
}

.acc-preview-scroll-track::-webkit-scrollbar {
    display: none;
}

.acc-preview-scroll-inner {
    display: grid;
    grid-auto-flow: column;
    /* 100% refers exactly to the visible track width */
    grid-auto-columns: calc((100% - calc(var(--preview-cols, 4) - 1) * var(--g-gap, 20px)) / var(--preview-cols, 4));
    gap: var(--g-gap, 20px);
    padding: 12px 0;
    width: 100%;
}

/* Each card inside the scroll row gets a fixed width via grid-auto-columns */
.acc-preview-scroll-inner>.acc-card {
    min-width: 0;
    width: 100%;
    /* fill the grid cell */
    scroll-snap-align: start;
    /* Align snap to start of card */
}

/* Tablet */
@media (max-width: 1024px) {
    .acc-preview-scroll-inner {
        grid-auto-columns: calc((100% - calc(var(--preview-cols-tab, var(--g-cols-tab, 2)) - 1) * var(--g-gap, 20px)) / var(--preview-cols-tab, var(--g-cols-tab, 2)));
    }

    .acc-scroll-arrow {
        width: 36px;
        height: 36px;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .acc-scroll-container {
        gap: 0;
    }

    .acc-scroll-arrow {
        width: 32px;
        height: 32px;
    }

    .acc-scroll-arrow svg {
        width: 16px;
        height: 16px;
    }

    .acc-scroll-prev {
        margin-right: 6px;
    }

    .acc-scroll-next {
        margin-left: 6px;
    }

    .acc-preview-scroll-inner {
        grid-auto-columns: calc((100% - calc(var(--preview-cols-mob, var(--g-cols-mob, 1)) - 1) * var(--g-gap, 20px)) / var(--preview-cols-mob, var(--g-cols-mob, 1)));
    }

    .acc-preview-title {
        font-size: 1.2rem;
    }

    .acc-preview-more-link {
        font-size: .8rem;
        padding: 5px 14px;
    }
}

/* ── Grid layout fallback uses existing .acc-grid rules ─────── */

/* ── Book cards in preview: show full cover ─────────────────── */
.acc-preview-section[data-post-type="books"] .acc-card-img-wrap,
.acc-preview-scroll-inner .acc-card-img-wrap {
    background: #f8f8f4;
}

.acc-preview-section[data-post-type="books"] .acc-card-img,
.acc-preview-scroll-inner [data-post-type="books"] .acc-card-img {
    object-fit: contain;
    padding: 6px;
}