/**
 * Tavasanbar Blog Widget Pro - Styles
 * 
 * Optimized for Core Web Vitals (LCP, CLS, INP)
 * No render-blocking, minimal CSS footprint
 *
 * @package Tavasanbar_Blog_Widget_Pro
 * @since 2.0.0
 */

/* ==========================================
   CSS Custom Properties (Variables)
   ========================================== */
.tsb-blog-section {
    --tsb-primary: #00d3f3;
    --tsb-primary-light: #5ce1f5;
    --tsb-primary-dark: #00a8c4;
    --tsb-bg: #020617;
    --tsb-card-bg: rgba(15, 23, 42, 0.6);
    --tsb-border: rgba(255, 255, 255, 0.06);
    --tsb-text: rgba(255, 255, 255, 0.5);
    --tsb-radius: 1.25rem;
    --tsb-transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ==========================================
   Screen Reader Only (Accessibility)
   ========================================== */
.tsb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================
   Main Section
   ========================================== */
.tsb-blog-section {
    padding: 5rem 1.5rem 4rem;
    background: linear-gradient(180deg, var(--tsb-bg), #0a1128, var(--tsb-bg));
    color: #fff;
    direction: rtl;
    position: relative;
    overflow: hidden;
    z-index: 10;
}

.tsb-blog-section::before,
.tsb-blog-section::after {
    content: "";
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.tsb-blog-section::before {
    inset: 0;
    background-image: 
        linear-gradient(rgba(0, 211, 243, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 211, 243, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(circle, #000 30%, transparent 90%);
    -webkit-mask-image: radial-gradient(circle, #000 30%, transparent 90%);
}

.tsb-blog-section::after {
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 211, 243, 0.06), transparent 70%);
}

/* ==========================================
   Wrapper
   ========================================== */
.tsb-wrap {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* ==========================================
   Header
   ========================================== */
.tsb-header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.tsb-decorator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    max-width: 20rem;
}

.tsb-decorator::before,
.tsb-decorator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 211, 243, 0.5), transparent);
}

.tsb-decorator i {
    width: 10px;
    height: 10px;
    background: var(--tsb-primary);
    transform: rotate(45deg);
    margin: 0 1rem;
    box-shadow: 0 0 15px rgba(0, 211, 243, 0.8);
    flex-shrink: 0;
    display: block;
}

.tsb-section-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 900;
    margin: 0 0 0.8rem;
    line-height: 1.3;
}

.tsb-section-title span {
    background: linear-gradient(135deg, var(--tsb-primary-light), var(--tsb-primary), var(--tsb-primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tsb-section-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.05rem;
    max-width: 550px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ==========================================
   Grid Layout
   ========================================== */
.tsb-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
    list-style: none;
    padding: 0;
    margin-top: 0;
}

/* Desktop Columns */
@media (min-width: 1024px) {
    .tsb-grid.tsb-cols-1 { grid-template-columns: 1fr; }
    .tsb-grid.tsb-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .tsb-grid.tsb-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .tsb-grid.tsb-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .tsb-grid.tsb-cols-5 { grid-template-columns: repeat(5, 1fr); }
    .tsb-grid.tsb-cols-6 { grid-template-columns: repeat(6, 1fr); }
}

/* Tablet Columns */
@media (min-width: 640px) and (max-width: 1023px) {
    .tsb-grid.tsb-cols-tablet-1 { grid-template-columns: 1fr; }
    .tsb-grid.tsb-cols-tablet-2 { grid-template-columns: repeat(2, 1fr); }
    .tsb-grid.tsb-cols-tablet-3 { grid-template-columns: repeat(3, 1fr); }
    .tsb-grid.tsb-cols-tablet-4 { grid-template-columns: repeat(4, 1fr); }
    .tsb-grid { gap: 1.75rem; }
}

/* Mobile Grid */
@media (max-width: 639px) {
    .tsb-grid.tsb-mobile-grid.tsb-cols-mobile-1 { grid-template-columns: 1fr; }
    .tsb-grid.tsb-mobile-grid.tsb-cols-mobile-2 { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile Horizontal Scroll */
@media (max-width: 639px) {
    .tsb-grid.tsb-mobile-scroll {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 1rem;
        gap: 1rem;
    }
    
    .tsb-grid.tsb-mobile-scroll::-webkit-scrollbar {
        display: none;
    }
    
    .tsb-grid.tsb-mobile-scroll .tsb-card-item {
        min-width: 85%;
        max-width: 85%;
        scroll-snap-align: center;
        flex-shrink: 0;
    }
}

/* ==========================================
   Card Item
   ========================================== */
.tsb-card-item {
    margin: 0;
    padding: 0;
}

/* ==========================================
   Card
   ========================================== */
.tsb-card {
    background: var(--tsb-card-bg);
    border: 1px solid var(--tsb-border);
    border-radius: var(--tsb-radius);
    overflow: hidden;
    transition: var(--tsb-transition);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    transform: translateY(40px);
    will-change: transform, opacity;
}

.tsb-card.tsb-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Card Hover */
@media (hover: hover) {
    .tsb-card:hover {
        border-color: rgba(0, 211, 243, 0.3);
        transform: translateY(-6px);
        box-shadow: 
            0 20px 40px -10px rgba(0, 0, 0, 0.5),
            0 0 30px rgba(0, 211, 243, 0.08);
    }
}

/* Focus State (Accessibility) */
.tsb-card:focus-within {
    outline: 2px solid var(--tsb-primary);
    outline-offset: 2px;
}

/* Card Link */
.tsb-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
    outline: none;
}

.tsb-card-link:focus {
    outline: none;
}

/* ==========================================
   Card Figure / Image - CLS Optimized
   ========================================== */
.tsb-card-figure {
    position: relative;
    width: 100%;
    padding-top: 58%; /* Aspect ratio */
    overflow: hidden;
    background: #0f172a;
    margin: 0;
    contain: layout style paint;
}

.tsb-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

@media (hover: hover) {
    .tsb-card:hover .tsb-card-img {
        transform: scale(1.08);
    }
}

/* Image Gradient Overlay */
.tsb-card-figure::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9), transparent);
    z-index: 1;
    pointer-events: none;
}

/* Image Placeholder */
.tsb-img-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

.tsb-img-placeholder svg {
    width: 48px;
    height: 48px;
    color: rgba(0, 211, 243, 0.3);
}

/* ==========================================
   Category Badge
   ========================================== */
.tsb-card-cat {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    background: rgba(0, 211, 243, 0.15);
    border: 1px solid rgba(0, 211, 243, 0.3);
    color: var(--tsb-primary);
    padding: 0.3rem 0.85rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    backdrop-filter: blur(8px);
}

/* ==========================================
   Card Body
   ========================================== */
.tsb-card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ==========================================
   Meta Information
   ========================================== */
.tsb-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.9rem;
    flex-wrap: wrap;
}

.tsb-meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
}

.tsb-meta-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    flex-shrink: 0;
}

/* ==========================================
   Card Title
   ========================================== */
.tsb-card-title {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.7;
    margin: 0 0 0.75rem;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

@media (hover: hover) {
    .tsb-card:hover .tsb-card-title {
        color: var(--tsb-primary-light);
    }
}

/* ==========================================
   Excerpt
   ========================================== */
.tsb-card-excerpt {
    font-size: 0.88rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 1.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

/* ==========================================
   Read More Link
   ========================================== */
.tsb-card-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--tsb-primary);
    font-size: 0.85rem;
    font-weight: 700;
    align-self: flex-start;
    padding: 0.5rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.3s, border-color 0.3s;
}

.tsb-card-more svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

@media (hover: hover) {
    .tsb-card:hover .tsb-card-more {
        color: var(--tsb-primary-light);
        border-bottom-color: rgba(0, 211, 243, 0.3);
    }
    
    .tsb-card:hover .tsb-card-more svg {
        transform: translateX(-4px);
    }
}

/* ==========================================
   Mobile Swipe Hint
   ========================================== */
.tsb-swipe-hint {
    display: none;
}

@media (max-width: 639px) {
    .tsb-mobile-scroll ~ .tsb-swipe-hint {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.75rem;
        color: rgba(255, 255, 255, 0.4);
        font-size: 0.8rem;
        animation: tsb-swipe-pulse 2s ease-in-out infinite;
    }
    
    .tsb-swipe-icon svg {
        width: 20px;
        height: 20px;
    }
}

@keyframes tsb-swipe-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ==========================================
   Dots Navigation
   ========================================== */
.tsb-dots {
    display: none;
}

@media (max-width: 639px) {
    .tsb-mobile-scroll ~ .tsb-dots {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
        margin-bottom: 2rem;
    }
    
    .tsb-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.15);
        border: none;
        padding: 0;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .tsb-dot:focus {
        outline: 2px solid var(--tsb-primary);
        outline-offset: 2px;
    }
    
    .tsb-dot-active,
    .tsb-dot:focus {
        background: var(--tsb-primary);
        box-shadow: 0 0 10px rgba(0, 211, 243, 0.5);
        width: 24px;
        border-radius: 4px;
    }
}

/* ==========================================
   Footer Button
   ========================================== */
.tsb-footer {
    text-align: center;
}

.tsb-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, rgba(0, 211, 243, 0.12), rgba(0, 211, 243, 0.06));
    border: 1px solid rgba(0, 211, 243, 0.25);
    color: var(--tsb-primary);
    padding: 0.9rem 2.2rem;
    border-radius: 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    font-family: inherit;
    transition: all 0.4s ease;
    cursor: pointer;
}

.tsb-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

@media (hover: hover) {
    .tsb-btn:hover {
        background: linear-gradient(135deg, var(--tsb-primary), var(--tsb-primary-dark));
        color: var(--tsb-bg);
        border-color: var(--tsb-primary);
        transform: translateY(-3px);
        box-shadow: 0 10px 30px rgba(0, 211, 243, 0.25);
    }
    
    .tsb-btn:hover svg {
        transform: translateX(-4px);
    }
}

.tsb-btn:focus {
    outline: 2px solid var(--tsb-primary);
    outline-offset: 2px;
}

/* ==========================================
   Empty State
   ========================================== */
.tsb-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px dashed rgba(0, 211, 243, 0.2);
    border-radius: var(--tsb-radius);
}

.tsb-empty svg {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    display: block;
    color: rgba(0, 211, 243, 0.3);
}

.tsb-empty h3 {
    font-size: 1.3rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 0.5rem;
}

.tsb-empty p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.7;
}

/* ==========================================
   Fade Animation
   ========================================== */
.tsb-fade {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.tsb-fade.tsb-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================
   Reduced Motion (Accessibility)
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .tsb-card,
    .tsb-fade,
    .tsb-card-img,
    .tsb-card-more svg,
    .tsb-btn svg,
    .tsb-dot {
        transition: none;
        animation: none;
    }
    
    .tsb-card,
    .tsb-fade {
        opacity: 1;
        transform: none;
    }
    
    .tsb-swipe-hint {
        animation: none;
        opacity: 0.6;
    }
}

/* ==========================================
   High Contrast Mode (Accessibility)
   ========================================== */
@media (prefers-contrast: high) {
    .tsb-card {
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .tsb-card-title {
        color: #fff;
    }
    
    .tsb-card-excerpt,
    .tsb-meta-item {
        color: rgba(255, 255, 255, 0.8);
    }
}

/* ==========================================
   Print Styles
   ========================================== */
@media print {
    .tsb-blog-section {
        background: #fff;
        color: #000;
    }
    
    .tsb-blog-section::before,
    .tsb-blog-section::after {
        display: none;
    }
    
    .tsb-card {
        background: #fff;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
    
    .tsb-card-title,
    .tsb-section-title span {
        color: #000;
        background: none;
        -webkit-background-clip: unset;
    }
    
    .tsb-dots,
    .tsb-swipe-hint {
        display: none;
    }
}
