/**
 * MCAST News Carousel - Frontend Styles
 * 
 * Professional carousel styling with MCAST branding
 * Fully responsive and accessible
 * 
 * @package MCAST_News_Carousel
 * @since 1.0.0
 * 
 * EDUCATIONAL NOTE: This stylesheet demonstrates:
 * - CSS Grid and Flexbox for modern layouts
 * - Responsive design with mobile-first approach
 * - CSS custom properties (variables) for theming
 * - Accessibility considerations
 * - Performance optimizations
 */

/* ============================================================================
   CAROUSEL WRAPPER
   ============================================================================ */

.mcast-news-carousel-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.mcast-news-carousel {
    position: relative;
    padding: 20px 0;
    border-radius: 8px;
}

/* No posts message */
.mcast-nc-no-posts {
    text-align: center;
    padding: 60px 20px;
    font-size: 16px;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

/* ============================================================================
   CAROUSEL ITEM (POST CARD)
   ============================================================================ */

.carousel-item {
    margin: 0 15px; /* Spacing between slides */
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    height: auto;
    display: flex !important; /* Slick uses display:block, we need flex */
    flex-direction: column;
}

.carousel-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-color: #000043;
}

/* ============================================================================
   POST IMAGE
   ============================================================================ */

.post-image-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f0f0f0;
}

/* Aspect ratio control using data attribute */
.post-image-wrapper[data-aspect-ratio="16:9"] {
    padding-bottom: 56.25%; /* 16:9 = 9/16 = 0.5625 */
}

.post-image-wrapper[data-aspect-ratio="4:3"] {
    padding-bottom: 75%; /* 4:3 = 3/4 = 0.75 */
}

.post-image-wrapper[data-aspect-ratio="1:1"] {
    padding-bottom: 100%; /* 1:1 = 1/1 = 1.0 */
}

.post-image-wrapper[data-aspect-ratio="3:2"] {
    padding-bottom: 66.67%; /* 3:2 = 2/3 = 0.6667 */
}

.post-image-wrapper[data-aspect-ratio="21:9"] {
    padding-bottom: 42.86%; /* 21:9 = 9/21 = 0.4286 */
}

.post-image-wrapper a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

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

.carousel-item:hover .post-image {
    transform: scale(1.05);
}

/* Placeholder for posts without featured image */
.post-image-wrapper:empty::before {
    content: "📰";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
}

/* ============================================================================
   POST CONTENT
   ============================================================================ */

.post-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Category Badge */
.post-category {
    margin-bottom: 10px;
}

.post-category a {
    display: inline-block;
    padding: 4px 12px;
    background: #f0f0f0;
    color: #666;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.post-category a:hover {
    background: #000043;
    color: #fff;
}

/* Post Title */
.post-title {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
}

.post-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: #0066cc;
}

/* Post Date */
.post-date {
    margin-bottom: 12px;
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
}

.post-date::before {
    content: "📅";
    margin-right: 6px;
    opacity: 0.7;
}

/* Post Excerpt */
.post-excerpt {
    margin-bottom: 15px;
    line-height: 1.6;
    flex: 1; /* Push read-more to bottom */
}

/* Read More Link */
.post-read-more {
    margin-top: auto; /* Stick to bottom */
}

.read-more {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 8px 0;
}

.read-more:hover {
    transform: translateX(5px);
}

.read-more span {
    margin-left: 5px;
    transition: transform 0.2s ease;
}

.read-more:hover span {
    transform: translateX(3px);
}

/* ============================================================================
   SLICK CAROUSEL CUSTOMIZATION
   ============================================================================ */

/* Arrows */
.mcast-news-carousel .slick-prev,
.mcast-news-carousel .slick-next {
    z-index: 100;
    width: 50px;
    height: 50px;
}

.mcast-news-carousel .slick-prev {
    left: -60px;
}

.mcast-news-carousel .slick-next {
    right: -60px;
}

.mcast-news-carousel .slick-prev:before,
.mcast-news-carousel .slick-next:before {
    font-size: 40px;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.mcast-news-carousel .slick-prev:hover:before,
.mcast-news-carousel .slick-next:hover:before {
    opacity: 1;
    transform: scale(1.1);
}

/* Dots */
.mcast-news-carousel .slick-dots {
    bottom: -40px;
}

.mcast-news-carousel .slick-dots li button:before {
    font-size: 12px;
    opacity: 0.4;
    transition: all 0.2s ease;
}

.mcast-news-carousel .slick-dots li:hover button:before,
.mcast-news-carousel .slick-dots li.slick-active button:before {
    opacity: 1;
}

/* Slick Track */
.mcast-news-carousel .slick-track {
    display: flex;
    align-items: stretch; /* Equal height cards */
}

.mcast-news-carousel .slick-slide {
    height: auto;
}

.mcast-news-carousel .slick-slide > div {
    height: 100%;
}

/* Equal Height Cards Enhancement */
.mcast-news-carousel.equal-height .slick-slide {
    display: flex !important;
}

.mcast-news-carousel.equal-height .carousel-item {
    height: 100%;
}

/* ============================================================================
   STYLE PRESET VARIATIONS
   ============================================================================ */

/* Professional Card Style (MCAST Official) */
.mcast-news-carousel.preset-professional .carousel-item {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: none;
    transition: all 0.3s ease;
}

.mcast-news-carousel.preset-professional .carousel-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 67, 0.15);
    transform: translateY(-4px);
}

.mcast-news-carousel.preset-professional .post-image-wrapper {
    margin: 0;
    border-radius: 0;
}

.mcast-news-carousel.preset-professional .post-footer {
    background: #000043;
    color: #ffffff;
    margin-top: auto;
}

.mcast-news-carousel.preset-professional .post-footer .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Compact List Style */
.mcast-news-carousel.preset-compact .carousel-item {
    min-height: 120px !important;
}

.mcast-news-carousel.preset-compact .post-title {
    font-size: 16px !important;
}

.mcast-news-carousel.preset-compact .post-excerpt {
    font-size: 13px !important;
}

/* Overlay Style */
.mcast-news-carousel.preset-overlay .carousel-item {
    min-height: 400px;
}

.mcast-news-carousel.preset-overlay .post-image {
    transition: transform 0.5s ease;
}

.mcast-news-carousel.preset-overlay .carousel-item:hover .post-image {
    transform: scale(1.1);
}

/* Minimal Style */
.mcast-news-carousel.preset-minimal .carousel-item {
    border-width: 0 0 0 4px;
    border-style: solid;
    transition: border-color 0.3s ease;
}

.mcast-news-carousel.preset-minimal .carousel-item:hover {
    border-left-width: 8px;
}

/* Magazine Style */
.mcast-news-carousel.preset-magazine .slick-list {
    overflow: visible;
}

.mcast-news-carousel.preset-magazine .slick-slide:not(:first-child) .carousel-item {
    min-height: 300px;
}

/* Image Position Variations */
.carousel-item[data-image-position="left"] .post-image-wrapper {
    float: left;
    margin-right: 20px;
    margin-bottom: 15px;
}

.carousel-item[data-image-position="bottom"] {
    display: flex;
    flex-direction: column-reverse;
}

.carousel-item[data-image-position="background"] .post-image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.carousel-item[data-image-position="background"] .post-content {
    position: relative;
    z-index: 1;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet (768px - 1199px) */
@media screen and (max-width: 1199px) {
    .mcast-news-carousel .slick-prev {
        left: -40px;
    }
    
    .mcast-news-carousel .slick-next {
        right: -40px;
    }
    
    .carousel-item {
        margin: 0 10px;
    }
    
    .post-title {
        font-size: 18px;
    }
}

/* Small Tablet (768px - 991px) */
@media screen and (max-width: 991px) {
    .mcast-news-carousel-wrapper {
        padding: 30px 15px;
    }
    
    .mcast-news-carousel .slick-prev,
    .mcast-news-carousel .slick-next {
        width: 40px;
        height: 40px;
    }
    
    .mcast-news-carousel .slick-prev:before,
    .mcast-news-carousel .slick-next:before {
        font-size: 32px;
    }
}

/* Mobile (< 768px) */
@media screen and (max-width: 767px) {
    .mcast-news-carousel-wrapper {
        padding: 20px 10px;
    }
    
    /* Move arrows inside on mobile */
    .mcast-news-carousel .slick-prev {
        left: 10px;
    }
    
    .mcast-news-carousel .slick-next {
        right: 10px;
    }
    
    .mcast-news-carousel .slick-prev,
    .mcast-news-carousel .slick-next {
        background: rgba(0, 0, 67, 0.8);
        border-radius: 50%;
        width: 36px;
        height: 36px;
    }
    
    .mcast-news-carousel .slick-prev:before,
    .mcast-news-carousel .slick-next:before {
        color: #fff;
        font-size: 24px;
    }
    
    .carousel-item {
        margin: 0 8px;
    }
    
    .post-content {
        padding: 15px;
    }
    
    .post-title {
        font-size: 16px;
    }
    
    .post-excerpt {
        font-size: 13px;
    }
}

/* Extra Small Mobile (< 480px) */
@media screen and (max-width: 479px) {
    .post-title {
        font-size: 15px;
    }
    
    .post-excerpt {
        font-size: 12px;
    }
    
    .post-content {
        padding: 12px;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus states for keyboard navigation */
.carousel-item:focus-within {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

.post-title a:focus,
.post-category a:focus,
.read-more:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .carousel-item,
    .post-image,
    .post-title a,
    .read-more,
    .slick-prev:before,
    .slick-next:before {
        transition: none;
    }
    
    .carousel-item:hover {
        transform: none;
    }
    
    .carousel-item:hover .post-image {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .carousel-item {
        border-width: 2px;
    }
    
    .post-category a {
        border: 1px solid currentColor;
    }
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.mcast-news-carousel.loading {
    opacity: 0.5;
    pointer-events: none;
}

.mcast-news-carousel.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #000043;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .mcast-news-carousel .slick-prev,
    .mcast-news-carousel .slick-next,
    .mcast-news-carousel .slick-dots {
        display: none !important;
    }
    
    .carousel-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
