/**
 * Itqan Post Layouts - Frontend Styles
 * Modern, responsive card-based UI
 */

/* Base Reset & Variables */
.itqan-layout {
    --itqan-primary: #6366f1;
    --itqan-primary-dark: #4f46e5;
    --itqan-text: #1e293b;
    --itqan-text-light: #64748b;
    --itqan-bg: #ffffff;
    --itqan-border: #e2e8f0;
    --itqan-radius: 12px;
    --itqan-spacing: 20px;
    --itqan-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--itqan-text);
    box-sizing: border-box;
}

.itqan-layout *,
.itqan-layout *::before,
.itqan-layout *::after {
    box-sizing: inherit;
}

/* Card Base Styles */
.itqan-card {
    background: var(--itqan-bg);
    border-radius: var(--itqan-radius);
    overflow: hidden;
    transition: var(--itqan-transition);
    position: relative;
}

.itqan-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* Card Image */
.itqan-card-image {
    position: relative;
    overflow: hidden;
}

.itqan-card-image a {
    display: block;
    line-height: 0;
}

.itqan-img {
    width: 100%;
    height: auto;
    display: block;
    transition: var(--itqan-transition);
}

.itqan-img-cover {
    object-fit: cover;
}

.itqan-img-contain {
    object-fit: contain;
}

.itqan-card:hover .itqan-img {
    transform: scale(1.05);
}

/* Magazine Layout */
.itqan-magazine {
    display: grid;
    gap: var(--itqan-gap);
    margin-bottom: var(--itqan-gap);
}

.itqan-magazine-main {
    min-height: 400px;
    display: flex;
    align-items: flex-end;
}

.itqan-magazine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--itqan-gap);
}

@media (min-width: 768px) {
    .itqan-magazine {
        grid-template-columns: 1.5fr 1fr;
    }

    .itqan-magazine-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Masonry Layout */
.itqan-masonry {
    column-gap: var(--itqan-gap);
}

.itqan-masonry-item {
    break-inside: avoid;
    transform: translateZ(0);
    /* Fix for column rendering glitch */
}

/* Slider Layout */
.itqan-slider-wrapper {
    position: relative;
    overflow: hidden;
}

.itqan-slider-slide {
    width: 100%;
    /* Full width */
}

.itqan-slider-card {
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.itqan-centered-content {
    max-width: 800px;
    margin: 0 auto;
    background: transparent;
    /* Override default bg */
    pointer-events: none;
    /* Let clicks pass through if needed, though button needs clicks */
}

.itqan-centered-content>* {
    pointer-events: auto;
}

/* Typography Tweaks */
.itqan-title-xl {
    font-size: 2.5em;
    line-height: 1.2;
    margin-bottom: 0.5em;
}

.itqan-title-lg {
    font-size: 1.8em;
    line-height: 1.3;
}

.itqan-title-sm {
    font-size: 1em;
    line-height: 1.4;
}

/* Existing Carousel Fixes */
.itqan-carousel-wrapper {
    position: relative;
}

.itqan-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    gap: var(--itqan-gap);
}

.itqan-carousel::-webkit-scrollbar {
    display: none;
}

.itqan-carousel-slide {
    flex: 0 0 calc(100% - 40px);
    /* Mobile default */
    scroll-snap-align: center;
}

@media (min-width: 768px) {
    .itqan-carousel-slide {
        flex: 0 0 calc(33.333% - var(--itqan-gap));
    }

    .itqan-slider-slide {
        flex: 0 0 100%;
    }
}

.itqan-carousel-prev,
.itqan-carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.itqan-carousel-prev {
    left: 10px;
}

.itqan-carousel-next {
    right: 10px;
}

.itqan-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.itqan-carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    border: none;
    cursor: pointer;
    padding: 0;
}

.itqan-carousel-dot.active {
    background: var(--itqan-primary);
}

/* Hover Effects */
.itqan-hover-lift .itqan-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.itqan-hover-lift .itqan-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.itqan-hover-scale .itqan-card {
    overflow: hidden;
}

.itqan-hover-scale .itqan-card:hover .itqan-img {
    transform: scale(1.1);
}

.itqan-hover-border .itqan-card {
    transition: border-color 0.3s ease;
    border: 2px solid transparent;
}

.itqan-hover-border .itqan-card:hover {
    border-color: var(--itqan-primary);
}

.itqan-hover-shadow .itqan-card {
    transition: box-shadow 0.3s ease;
}

.itqan-hover-shadow .itqan-card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

/* RTL Support */
[dir="rtl"] .itqan-carousel-prev {
    right: 10px;
    left: auto;
    transform: translateY(-50%) rotate(180deg);
}

[dir="rtl"] .itqan-carousel-next {
    left: 10px;
    right: auto;
    transform: translateY(-50%) rotate(180deg);
}

[dir="rtl"] .itqan-card-image-left {
    order: 1;
}

[dir="rtl"] .itqan-card-horizontal-left .itqan-card-image {
    margin-right: 0;
    margin-left: var(--itqan-gap);
}

/* Dark Mode Defaults (Variables) */
:root {
    --itqan-bg-card: #ffffff;
    --itqan-text-primary: #1f2937;
    --itqan-text-secondary: #6b7280;
    --itqan-border-color: #e5e7eb;
}

[data-theme="dark"] {
    --itqan-bg-card: #1f2937;
    --itqan-text-primary: #f3f4f6;
    --itqan-text-secondary: #9ca3af;
    --itqan-border-color: #374151;
}

/* Apply Variables */
.itqan-card {
    background: var(--itqan-bg-card);
    border: 1px solid var(--itqan-border-color);
}

.itqan-card-bg {
    background: transparent;
    /* BG cards use image */
    border: none;
}

.itqan-title a {
    color: var(--itqan-text-primary);
}

.itqan-excerpt {
    color: var(--itqan-text-secondary);
}

.itqan-meta {
    color: var(--itqan-text-secondary);
}

/* Dark Mode Toggle Implementation (if wrapper has dark class) */
.itqan-layout-dark {
    --itqan-bg-card: #1f2937;
    --itqan-text-primary: #f3f4f6;
    --itqan-text-secondary: #9ca3af;
    --itqan-border-color: #374151;
}

.itqan-card-bg {
    position: relative;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.itqan-card-bg-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.itqan-card-bg .itqan-card-content {
    position: relative;
    z-index: 3;
    color: #fff;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    padding: var(--itqan-spacing);
}

.itqan-card-bg .itqan-title a {
    color: #fff;
}

.itqan-card-bg .itqan-excerpt {
    color: rgba(255, 255, 255, 0.9);
}

.itqan-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(0, 0, 0, 0.5) 100%);
    z-index: 2;
}

/* Card Content */
.itqan-card-content {
    padding: var(--itqan-spacing);
}

/* Meta Information */
.itqan-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--itqan-text-light);
}

.itqan-category {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--itqan-primary);
    color: #fff;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.itqan-category-sm {
    padding: 3px 10px;
    font-size: 10px;
}

.itqan-date,
.itqan-author-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.itqan-date svg,
.itqan-author-inline svg {
    opacity: 0.7;
}

/* Title */
.itqan-title {
    margin: 0 0 12px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.itqan-title a {
    color: inherit;
    text-decoration: none;
    transition: var(--itqan-transition);
}

.itqan-title a:hover {
    color: var(--itqan-primary);
}

.itqan-title-sm {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

/* Excerpt */
.itqan-excerpt {
    margin: 0 0 16px;
    color: var(--itqan-text-light);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Author */
.itqan-author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--itqan-text-light);
}

.itqan-author img {
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

/* Button */
.itqan-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--itqan-primary);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-radius: calc(var(--itqan-radius) / 2);
    transition: var(--itqan-transition);
}

.itqan-btn:hover {
    background: var(--itqan-primary-dark);
    transform: translateX(4px);
    color: #fff;
}

.itqan-btn svg {
    transition: var(--itqan-transition);
}

.itqan-btn:hover svg {
    transform: translateX(4px);
}

.itqan-btn-sm {
    padding: 10px 20px;
    font-size: 13px;
}

/* Featured Section */
.itqan-featured-section {
    margin-bottom: var(--itqan-spacing);
}

.itqan-featured-card {
    margin-bottom: var(--itqan-spacing);
}

.itqan-featured-card .itqan-card-image img {
    width: 100%;
    height: 350px;
    object-fit: cover;
}

.itqan-featured-card .itqan-title {
    font-size: 1.75rem;
}

/* List Section */
.itqan-list-section {
    display: flex;
    flex-direction: column;
    gap: var(--itqan-spacing);
}

.itqan-list-card {
    display: flex;
    align-items: center;
    gap: var(--itqan-spacing);
}

.itqan-list-card .itqan-card-image {
    flex-shrink: 0;
    width: 120px;
    height: 90px;
    border-radius: calc(var(--itqan-radius) / 2);
    overflow: hidden;
}

.itqan-list-card .itqan-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.itqan-list-card .itqan-card-content {
    padding: 0;
    flex: 1;
}

.itqan-list-card .itqan-meta {
    margin-bottom: 6px;
}

.itqan-card-horizontal-right {
    flex-direction: row-reverse;
}

/* Grid Layout */
.itqan-grid {
    display: grid;
    gap: var(--itqan-spacing);
}

.itqan-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.itqan-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.itqan-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.itqan-grid-card .itqan-card-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* List (Full Width) Layout */
.itqan-list {
    display: flex;
    flex-direction: column;
    gap: var(--itqan-spacing);
}

.itqan-list-item {
    display: flex;
    gap: var(--itqan-spacing);
}

.itqan-list-item .itqan-card-image {
    flex-shrink: 0;
    width: 280px;
    border-radius: var(--itqan-radius);
    overflow: hidden;
}

.itqan-list-item .itqan-card-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.itqan-list-item .itqan-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.itqan-list-item.itqan-card-horizontal-right {
    flex-direction: row-reverse;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .itqan-grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }

    .itqan-list-item .itqan-card-image {
        width: 220px;
    }
}

@media (max-width: 768px) {

    .itqan-grid-cols-3,
    .itqan-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .itqan-list-item {
        flex-direction: column !important;
    }

    .itqan-list-item .itqan-card-image {
        width: 100%;
    }

    .itqan-list-item .itqan-card-image img {
        height: 220px;
    }

    .itqan-featured-card .itqan-card-image img {
        height: 250px;
    }

    .itqan-title {
        font-size: 1.25rem;
    }

    .itqan-featured-card .itqan-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {

    .itqan-grid-cols-2,
    .itqan-grid-cols-3,
    .itqan-grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .itqan-list-card {
        flex-direction: column !important;
        align-items: stretch;
    }

    .itqan-list-card .itqan-card-image {
        width: 100%;
        height: 180px;
    }

    .itqan-list-card .itqan-card-content {
        padding: var(--itqan-spacing);
    }

    .itqan-card-bg {
        min-height: 300px;
    }
}

/* Animation Effects */
@keyframes itqan-fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.itqan-layout .itqan-card {
    animation: itqan-fadeIn 0.6s ease-out forwards;
}

.itqan-layout .itqan-card:nth-child(1) {
    animation-delay: 0.1s;
}

.itqan-layout .itqan-card:nth-child(2) {
    animation-delay: 0.2s;
}

.itqan-layout .itqan-card:nth-child(3) {
    animation-delay: 0.3s;
}

.itqan-layout .itqan-card:nth-child(4) {
    animation-delay: 0.4s;
}

.itqan-layout .itqan-card:nth-child(5) {
    animation-delay: 0.5s;
}

.itqan-layout .itqan-card:nth-child(6) {
    animation-delay: 0.6s;
}