/**
 * GridStream Carousel Module Styles
 * Version: 2.0.0
 * Copyright (C) 2025 Echoes of the Grid
 * Description: Normalized card sizes, auto-slide animations, and clickable posts
 * Style: Matches GridStream feed cyberpunk aesthetic
 */

/* Carousel Layout - GridStream Style */
.gridstream-carousel {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    overflow: hidden;
    background: linear-gradient(155deg, rgba(78, 0, 24, 0.92) 0%, rgba(18, 0, 12, 0.95) 38%, rgba(8, 9, 14, 0.98) 100%);
    color: #f6f7ff;
    border: 1px solid rgba(255, 40, 95, 0.65);
    border-radius: 18px;
    box-shadow: 0 26px 48px rgba(0, 0, 0, 0.46), 0 0 32px rgba(255, 26, 80, 0.22);
    clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%, 0 18px);
}

.gridstream-carousel::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 48, 110, 0.75);
    border-radius: inherit;
    clip-path: inherit;
    pointer-events: none;
    box-shadow: 0 0 22px rgba(255, 32, 96, 0.55), inset 0 0 18px rgba(255, 0, 76, 0.45);
    mix-blend-mode: screen;
    opacity: 0.65;
}

.gridstream-carousel::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02) 28%, rgba(255, 255, 255, 0.16) 68%, rgba(255, 255, 255, 0.03) 100%);
    opacity: 0.12;
    pointer-events: none;
}

.carousel-container {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    z-index: 1;
}

.carousel-track {
    display: flex;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Auto-slide animation */
.gridstream-carousel[data-auto-slide="true"] .carousel-track {
    animation: slideCarousel 1s ease-in-out;
}

@keyframes slideCarousel {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-100%);
    }
}

.carousel-item {
    min-width: 100%;
    flex-shrink: 0;
    padding: 0 0.5rem;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.carousel-item.active {
    opacity: 1;
}

/* Clickable Card Link - Full card area - GridStream Style */
.post-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.22s ease;
}

.post-card-link:hover {
    transform: none; /* Card itself handles hover transform */
}

.post-card-link:focus {
    outline: 2px solid rgba(255, 128, 200, 0.65);
    outline-offset: 3px;
    border-radius: 16px;
}

/* Normalized Post Card - Fixed Height - GridStream Style */
.post-card {
    position: relative;
    background: linear-gradient(172deg, rgba(32, 0, 18, 0.92) 0%, rgba(10, 12, 20, 0.95) 55%, rgba(6, 8, 14, 0.98) 100%);
    border: 1px solid rgba(255, 36, 90, 0.35);
    border-radius: 16px;
    clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 14px, 100% 100%, 0 100%, 0 14px);
    padding: 1.05rem 1.3rem;
    height: 500px; /* Fixed height for normalization */
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.38);
    overflow: hidden;
    transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.post-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.15) 95%);
    opacity: 0.08;
    pointer-events: none;
}

.post-card > * {
    position: relative;
    z-index: 1;
}

.post-card-link:hover .post-card {
    transform: translateY(-4px);
    border-color: rgba(255, 56, 120, 0.55);
    box-shadow: 0 22px 36px rgba(0, 0, 0, 0.42), 0 0 22px rgba(255, 40, 108, 0.25);
}

/* Post Header - Fixed Height - GridStream Style */
.post-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.85rem;
    flex-shrink: 0;
    min-height: 50px;
}

.post-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid rgba(255, 96, 160, 0.42);
    box-shadow: 0 0 14px rgba(255, 64, 140, 0.28);
    background: radial-gradient(circle at 30% 20%, rgba(255, 90, 160, 0.45), rgba(10, 12, 20, 0.92));
    flex-shrink: 0;
}

.post-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.post-author {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ff9ac6;
    text-shadow: 0 0 12px rgba(255, 84, 156, 0.38);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-date {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fbb3c7;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.post-flag {
    flex-shrink: 0;
    color: rgba(255, 196, 64, 0.85);
    font-size: 1.15rem;
    filter: drop-shadow(0 0 8px rgba(255, 196, 64, 0.5));
}

/* Badges - GridStream Style */
.badge,
.badge-sm {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 999px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    border: 1px solid;
}

.badge-npc {
    border-color: rgba(255, 100, 186, 0.55);
    background: rgba(255, 84, 170, 0.22);
    color: #ffd8f4;
    text-shadow: 0 0 10px rgba(255, 100, 186, 0.5);
}

.badge-page {
    border-color: rgba(132, 232, 255, 0.5);
    background: linear-gradient(145deg, rgba(32, 65, 120, 0.55) 0%, rgba(12, 34, 68, 0.72) 100%);
    color: #d7f3ff;
    box-shadow: inset 0 0 12px rgba(64, 196, 255, 0.28);
}

/* Post Body - Flexible Height with Overflow - GridStream Style */
.post-body {
    flex: 1;
    overflow: hidden;
    margin-bottom: 0.85rem;
    position: relative;
    min-height: 0;
}

.post-text {
    margin: 0;
    line-height: 1.6;
    font-family: "Atkinson Hyperlegible", "Lexend", "Segoe UI", "Verdana", sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: #f4f6ff;
    text-shadow: 0 0 8px rgba(96, 204, 255, 0.2);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 8; /* Limit to 8 lines */
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.show-more-indicator {
    display: inline-block;
    margin-top: 0.5rem;
    color: #ff9ac6;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    position: relative;
    padding-right: 1.5rem;
    text-shadow: 0 0 12px rgba(255, 84, 156, 0.38);
}

.show-more-indicator::after {
    content: '→';
    position: absolute;
    right: 0;
    transition: transform 0.2s ease;
    filter: drop-shadow(0 0 8px rgba(255, 96, 160, 0.45));
}

.post-card-link:hover .show-more-indicator::after {
    transform: translateX(4px);
}

/* Comments Preview Section - Fixed Height - GridStream Style */
.post-comments-preview {
    border-top: 1px solid rgba(255, 36, 90, 0.35);
    padding-top: 0.75rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 72, 132, 0.4) rgba(18, 12, 28, 0.75);
}

.post-comments-preview::-webkit-scrollbar {
    width: 6px;
}

.post-comments-preview::-webkit-scrollbar-track {
    background: rgba(18, 12, 28, 0.75);
}

.post-comments-preview::-webkit-scrollbar-thumb {
    background: rgba(255, 72, 132, 0.4);
    border-radius: 3px;
}

.post-comments-preview::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 128, 200, 0.55);
}

.comments-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #ff9fd4;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.comment-preview {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(32, 0, 18, 0.5);
    border: 1px solid rgba(255, 72, 132, 0.25);
    border-radius: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-preview:hover {
    border-color: rgba(255, 96, 160, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255, 96, 160, 0.35);
    box-shadow: 0 0 10px rgba(255, 64, 140, 0.22);
    background: radial-gradient(circle at 30% 20%, rgba(255, 90, 160, 0.35), rgba(10, 12, 20, 0.8));
}

.comment-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.comment-author {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f9b6d6;
    text-shadow: 0 0 10px rgba(255, 72, 138, 0.34);
}

.comment-text {
    font-size: 0.82rem;
    color: #f4f6ff;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.comments-more {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ff9ac6;
    font-style: italic;
    text-align: center;
    padding: 0.5rem 0;
    text-shadow: 0 0 10px rgba(255, 84, 156, 0.35);
}

/* Post Footer - Fixed Height - GridStream Style */
.post-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.8rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 36, 90, 0.35);
    flex-shrink: 0;
    min-height: 40px;
    max-height: 40px;
}

.post-reactions,
.post-comment-count {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 72, 132, 0.35);
    background: rgba(18, 12, 28, 0.65);
    color: #ffe2f6;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.post-card-link:hover .post-reactions,
.post-card-link:hover .post-comment-count {
    transform: translateY(-1px);
    border-color: rgba(255, 96, 160, 0.45);
    box-shadow: 0 8px 14px rgba(4, 0, 20, 0.35), inset 0 0 14px rgba(255, 88, 160, 0.2);
}

.post-reactions .icon-heart {
    color: rgba(255, 96, 160, 0.85);
    filter: drop-shadow(0 0 8px rgba(255, 64, 140, 0.45));
}

.icon-heart,
.icon-comments,
.icon-pushpin {
    font-size: 0.9rem;
}

/* Carousel Controls */
.carousel-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    gap: 1rem;
}

.carousel-prev,
.carousel-next {
    background: var(--grid-button-bg, #333);
    border: 1px solid var(--grid-border, #555);
    color: var(--grid-text-primary, #fff);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.carousel-prev:hover,
.carousel-next:hover {
    background: var(--grid-button-hover, #444);
}

.carousel-prev:disabled,
.carousel-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-indicators {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

.carousel-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--grid-border, #555);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.3s ease, transform 0.3s ease;
}

.carousel-indicator.active {
    background: var(--grid-accent, #e63946);
    transform: scale(1.2);
}

.carousel-indicator:hover {
    background: var(--grid-text-secondary, #999);
}

/* Carousel Dots Navigation */
.carousel-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--grid-border, #555);
    border: none;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

.carousel-dot.active {
    background: var(--grid-accent, #e63946);
    transform: scale(1.2);
}

.carousel-dot:hover {
    background: var(--grid-text-secondary, #999);
}

/* Accessibility - GridStream Style */
.post-card-link:focus-visible {
    outline: 2px solid rgba(255, 128, 200, 0.75);
    outline-offset: 4px;
    border-radius: 16px;
}

/* Responsive Design - GridStream Style */
@media (max-width: 768px) {
    .gridstream-carousel {
        padding: 0.8rem;
    }
    
    .post-card {
        height: 550px; /* Slightly taller on mobile */
        padding: 1rem 1.1rem;
    }
    
    .post-text {
        -webkit-line-clamp: 6;
    }
    
    .post-comments-preview {
        max-height: 150px;
    }
    
    .carousel-controls {
        margin-top: 1rem;
    }
}

@media (max-width: 480px) {
    .post-card {
        height: 600px;
        padding: 0.875rem;
    }
    
    .post-avatar {
        width: 40px;
        height: 40px;
    }
    
    .post-author {
        font-size: 0.95rem;
    }
    
    .post-date {
        font-size: 0.8rem;
    }
    
    .comment-avatar {
        width: 28px;
        height: 28px;
    }
}

/* Print Styles */
@media print {
    .gridstream-carousel {
        overflow: visible;
    }
    
    .carousel-item {
        opacity: 1;
        page-break-inside: avoid;
    }
    
    .post-card {
        height: auto;
        border: 1px solid #000;
    }
}
