/* ========================================
   HIGH-PERFORMANCE WRITING GRID STYLES
   ======================================== */

/* ========================================
   SIMPLIFIED CATEGORY STYLING
   ======================================== */

/* Category-specific backgrounds for text-only posts */
.feature-post.category-writing {
    background: linear-gradient(135deg, 
        rgba(100, 150, 255, 0.05) 0%, 
        rgba(100, 150, 255, 0.02) 100%) !important;
    border-left: 3px solid rgba(100, 150, 255, 0.3);
}

.feature-post.category-design {
    background: linear-gradient(135deg, 
        rgba(255, 150, 100, 0.05) 0%, 
        rgba(255, 150, 100, 0.02) 100%) !important;
    border-left: 3px solid rgba(255, 150, 100, 0.3);
}

.feature-post.category-tools {
    background: linear-gradient(135deg, 
        rgba(150, 255, 100, 0.05) 0%, 
        rgba(150, 255, 100, 0.02) 100%) !important;
    border-left: 3px solid rgba(150, 255, 100, 0.3);
}

.feature-post.category-development {
    background: linear-gradient(135deg, 
        rgba(255, 100, 150, 0.05) 0%, 
        rgba(255, 100, 150, 0.02) 100%) !important;
    border-left: 3px solid rgba(255, 100, 150, 0.3);
}

/* Default category fallback */
.feature-post[class*="category-"]:not(.category-writing):not(.category-design):not(.category-tools):not(.category-development) {
    background: linear-gradient(135deg, 
        rgba(200, 200, 200, 0.05) 0%, 
        rgba(200, 200, 200, 0.02) 100%) !important;
    border-left: 3px solid rgba(200, 200, 200, 0.3);
}

/* Enhanced stacked meta layout for editorial grid */
.post-meta-stacked {
    display: flex;
    flex-direction: column;
}

.category-wrapper {
    display: flex;
    align-items: flex-start;
}

.compact-meta-stacked {
    display: flex;
    flex-direction: column;
}

.compact-category {
    display: flex;
    align-items: flex-start;
}

/* Enhanced tag styling for better visual hierarchy */
.category-wrapper .tag,
.compact-category .tag {
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Ensure proper text wrapping for long titles */
.post-meta-stacked .title,
.compact-meta-stacked + h4.title {
    word-wrap: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
}

/* Clean spacing for stacked layout */
.post-meta-stacked time {
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.compact-meta-stacked time {
    margin-bottom: 0.25rem;
    font-weight: 700;
}

/* Consistent visual rhythm */
.category-wrapper,
.compact-category {
    margin-bottom: 0.75rem;
}

/* ========================================
   SIMPLIFIED WRITING GRID LAYOUT
   ======================================== */

/* Simple row-based grid container */
.writing-grid-simple {
    margin: 2rem 0;
    padding: 0;
}

/* Base card styling for all post types */
.writing-grid-simple .card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
    height: 100%;
}

/* Large posts (first row - 2 across) */
.writing-grid-simple .large-post {
    background: rgba(255,255,255,0.04);
}

.writing-grid-simple .large-post:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

/* Medium posts (second row - 3 across) */
.writing-grid-simple .medium-post {
    background: rgba(255,255,255,0.03);
}

.writing-grid-simple .medium-post:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

/* Small posts (remaining rows - 4 across) */
.writing-grid-simple .small-post {
    background: rgba(255,255,255,0.02);
}

.writing-grid-simple .small-post:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* Posts without media - compact styling */
.writing-grid-simple .writing-post:not(.has-media) {
    background: rgba(255,255,255,0.03);
}

.writing-grid-simple .writing-post:not(.has-media) .card-content {
    padding: 1.5rem;
}

/* Writing Grid Images & Videos - Fixed Aspect Ratios */
.writing-grid-image,
.writing-grid-video {
    transition: transform 0.25s ease;
    will-change: transform;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

/* Video container and indicator styling */
.video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.hover-preview-video {
    cursor: pointer;
    transition: transform 0.25s ease, opacity 0.2s ease;
    width: 100%;
    height: 100%;
}

.hover-preview-video:hover {
    opacity: 0.9;
}

/* Video progress ring indicator - Modern flexbox approach */
.video-progress-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-ring-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.play-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.play-icon-svg {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.progress-ring-bg {
    transition: stroke 0.3s ease;
}

.progress-ring-progress {
    transition: stroke-dashoffset 0.1s ease-out, stroke 0.3s ease;
    transform-origin: center;
}

.play-icon {
    transition: fill 0.3s ease;
}

/* Hover states */
.video-container:hover .video-progress-indicator {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.video-container:hover .progress-ring-bg {
    stroke: rgba(255, 255, 255, 0.5);
}

/* Size variations for different post types */
.writing-grid-simple .large-post .video-progress-indicator {
    width: 80px;
    height: 80px;
}

.writing-grid-simple .medium-post .video-progress-indicator {
    width: 70px;
    height: 70px;
}

.writing-grid-simple .small-post .video-progress-indicator {
    width: 50px;
    height: 50px;
}

/* Scale play icon with container */
.writing-grid-simple .large-post .play-icon-svg {
    width: 32px;
    height: 32px;
}

.writing-grid-simple .medium-post .play-icon-svg {
    width: 28px;
    height: 28px;
}

.writing-grid-simple .small-post .play-icon-svg {
    width: 20px;
    height: 20px;
}

/* Pulse animation when complete */
@keyframes progress-complete-pulse {
    0% { 
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.8;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
}

.video-progress-indicator.complete {
    animation: progress-complete-pulse 0.8s ease-in-out;
}

.video-progress-indicator.complete .progress-ring-progress {
    stroke: rgba(255, 255, 255, 1);
    stroke-dashoffset: 0;
}

.video-progress-indicator.complete .play-icon {
    fill: rgba(255, 255, 255, 1);
}

/* Mobile responsive adjustments for progress ring */
@media screen and (max-width: 768px) {
    .writing-grid-simple .large-post .video-progress-indicator {
        width: 60px;
        height: 60px;
    }
    .writing-grid-simple .medium-post .video-progress-indicator {
        width: 50px;
        height: 50px;
    }
    .writing-grid-simple .small-post .video-progress-indicator {
        width: 40px;
        height: 40px;
    }
    .writing-grid-simple .large-post .play-icon-svg {
        width: 24px;
        height: 24px;
    }
    .writing-grid-simple .medium-post .play-icon-svg {
        width: 20px;
        height: 20px;
    }
    .writing-grid-simple .small-post .play-icon-svg {
        width: 16px;
        height: 16px;
    }
}

/* Ensure figures use Bulma's aspect ratio system */
.writing-grid-simple .card-image figure {
    margin: 0;
}

/* Hover effects for media - different scales for different sizes */
.writing-grid-simple .large-post:hover .writing-grid-image,
.writing-grid-simple .large-post:hover .writing-grid-video {
    transform: scale(1.03);
}

.writing-grid-simple .medium-post:hover .writing-grid-image,
.writing-grid-simple .medium-post:hover .writing-grid-video {
    transform: scale(1.02);
}

.writing-grid-simple .small-post:hover .writing-grid-image,
.writing-grid-simple .small-post:hover .writing-grid-video {
    transform: scale(1.015);
}

/* Ensure 16:9 aspect on small card media even if Bulma helper is missing */
.writing-grid-simple .card-image .image.is-16by9 {
    aspect-ratio: 16 / 9;
}

/* Minimal CTA link styling for cards */
.writing-grid-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    line-height: 1;
    color: var(--color-text, #fff);
    text-decoration: none;
    border: 1px solid var(--color-border-light);
    border-radius: 9999px;
    padding: 0.35rem 0.6rem;
    background: transparent;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.writing-grid-cta:hover {
    border-color: rgba(255,255,255,0.5);
    background-color: rgba(255,255,255,0.06);
}

.writing-grid-cta .icon {
    display: inline-flex;
    width: 1em;
    height: 1em;
}

/* ========================================
   PERFORMANCE & ACCESSIBILITY
   ======================================== */

/* Responsive grid layout */
@media screen and (max-width: 1200px) {
    .writing-grid-simple .columns {
        margin-bottom: 1.5rem !important;
    }
}

@media screen and (max-width: 768px) {
    .writing-grid-simple {
        margin: 1rem 0;
    }
    .writing-grid-simple .columns {
        margin-bottom: 1rem !important;
    }
    /* Mobile optimizations - disable transforms to prevent jank */
    .writing-grid-simple .large-post:hover,
    .writing-grid-simple .medium-post:hover,
    .writing-grid-simple .small-post:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    .writing-grid-simple .large-post:hover .writing-grid-image,
    .writing-grid-simple .large-post:hover .writing-grid-video,
    .writing-grid-simple .medium-post:hover .writing-grid-image,
    .writing-grid-simple .medium-post:hover .writing-grid-video,
    .writing-grid-simple .small-post:hover .writing-grid-image,
    .writing-grid-simple .small-post:hover .writing-grid-video {
        transform: none;
    }
    /* Enhanced mobile video interaction */
    .video-container {
        position: relative;
        cursor: pointer;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    .video-progress-indicator {
        opacity: 0.9 !important;
        transform: translate(-50%, -50%) scale(1.1) !important;
    }
    .writing-grid-video {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    /* Larger touch targets for better UX */
    .video-container::after {
        content: '';
        position: absolute;
        top: -15px;
        left: -15px;
        right: -15px;
        bottom: -15px;
        z-index: 1;
        pointer-events: auto;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .writing-grid-simple .large-post,
    .writing-grid-simple .medium-post,
    .writing-grid-simple .small-post {
        transition: none !important;
    }
    .writing-grid-simple .large-post:hover,
    .writing-grid-simple .medium-post:hover,
    .writing-grid-simple .small-post:hover {
        transform: none !important;
    }
    .writing-grid-image,
    .writing-grid-video {
        transition: none !important;
    }
    .writing-grid-simple .large-post:hover .writing-grid-image,
    .writing-grid-simple .large-post:hover .writing-grid-video,
    .writing-grid-simple .medium-post:hover .writing-grid-image,
    .writing-grid-simple .medium-post:hover .writing-grid-video,
    .writing-grid-simple .small-post:hover .writing-grid-image,
    .writing-grid-simple .small-post:hover .writing-grid-video {
        transform: none !important;
    }
}

/* Writing grid border fixes - prevent double borders */
.writing-grid-simple .card {
    border: none !important;
}

.writing-grid-simple .writing-post {
    border: 1px solid var(--color-border-light) !important;
    box-shadow: none;
}

.writing-grid-simple .card-image,
.writing-grid-simple .card-header,
.writing-grid-simple .card-content {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
}

/* Mobile refinements for stacked layout */
@media screen and (max-width: 768px) {
    .category-wrapper,
    .compact-category {
        margin-bottom: 0.5rem;
    }
}

