/* ── MAGAZINE GRID ── */
.magazine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
    grid-auto-flow: dense;
}

/* ── CARDS COMMON ── */
.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: transform .2s, box-shadow .2s, border-color .2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    animation: fadeUp .4s ease both;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
    border-color: rgba(245, 158, 11, .2);
}

.card-img-wrap {
    position: relative;
    width: 100%;
}

.card-img {
    width: 100%;
    object-fit: cover;
    background: var(--surface2);
    display: block;
}

.card-no-img {
    width: 100%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: var(--text-muted);
}

.card-fav-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    /* RTL fix */
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .2s;
    z-index: 10;
}

.card-fav-btn:hover {
    transform: scale(1.15);
}

.card-fav-btn.active {
    color: #ef4444;
}

.card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
}

.card-cat {
    color: var(--accent);
    font-weight: 700;
    background: rgba(245, 158, 11, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Base Price */
.card-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    margin-top: auto;
}

/* ── REGULAR CARD ── */
.card-regular .card-img,
.card-regular .card-no-img {
    height: 200px;
}

.card-regular .card-desc {
    font-size: 12px;
    color: var(--text-dim);
    height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.card-regular:hover .card-desc {
    height: 48px;
    /* Approx 2 lines */
    opacity: 1;
    margin-bottom: 12px;
}

/* ── FEATURED MAGAZINE CARD ── */
.card-featured {
    grid-column: span 2;
    border-color: rgba(139, 92, 246, 0.3);
}

.card-featured .card-img,
.card-featured .card-no-img {
    height: 340px;
}

.card-featured .card-content {
    padding: 24px;
}

.card-featured .card-title {
    font-size: 24px;
    -webkit-line-clamp: 1;
    line-clamp: 1;
}

.card-featured .card-desc {
    font-size: 14px;
    color: var(--text-dim);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 16px;
}

.card-featured .card-price {
    font-size: 26px;
    color: var(--accent);
}

.card-featured .featured-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.featured-source-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    font-weight: 600;
    transition: all .2s;
}

.featured-source-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

@media(max-width: 600px) {
    .magazine-grid {
        grid-template-columns: 1fr;
    }

    .card-featured {
        grid-column: span 1;
    }

    .card-featured .card-img {
        height: 260px;
    }
}

/* Modal CSS */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    z-index: 250;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    padding: 16px;
}

.modal-overlay.open {
    display: flex;
}

.detail-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

/* Modals base elements */
.close-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, .6);
    border: none;
    color: var(--text);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface2);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 9999;
    border: 1px solid var(--border);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: #10b981;
    color: #10b981;
}

.toast.error {
    border-color: #ef4444;
    color: #ef4444;
}