/* ==========================================================================
   Story Mosaic Block - Fully Responsive Version
   Handles all screen sizes from mobile to ultra-wide displays
   ========================================================================== */

/* Main Wrapper - Base Styles */
.blz-story-mosaic {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: visible;
    background: #F5F5F0;
    z-index: 1;
}

.story-mosaic-block {
    position: relative;
    isolation: isolate;
    margin-bottom: 0;
}

/* Full Width Support */
.blz-story-mosaic.alignfull {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.blz-story-mosaic.alignwide {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* Background Layer */
.mosaic-background {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.mosaic-bgcolor {
    width: 100%;
    height: 100%;
    position: relative;
}

.mosaic-bgimage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
}

.mosaic-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.02;
    background-image: radial-gradient(circle, #000 1px, transparent 1px);
    background-size: 15px 15px;
    pointer-events: none;
}

/* Grid Wrapper - Responsive Container */
.mosaic-grid-wrapper {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3rem);
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* CSS Grid Layout - Responsive Base */
.mosaic-grid {
    display: grid;
    gap: clamp(1rem, 2vw, 2rem);
    position: relative;
    width: 100%;
    max-width: 100%;
    transform: none !important;
    will-change: auto;
}

/* Panel Base Styles */
.mosaic-panel {
    background: white;
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 35px 80px rgba(0, 0, 0, 0.2), 
                0 15px 40px rgba(0, 0, 0, 0.15), 
                0 5px 15px rgba(0, 0, 0, 0.1);
    will-change: opacity;
    height: auto;
    transform-origin: center center;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Panel hover effects */
.mosaic-panel:hover {
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.25), 
                0 20px 50px rgba(0, 0, 0, 0.2), 
                0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Lock panels when revealed */
.blz-story-mosaic.all-revealed .mosaic-panel {
    transform: none !important;
    will-change: auto !important;
    transition: box-shadow 0.3s ease !important;
}

/* ==========================================================================
   RESPONSIVE GRID SYSTEM
   ========================================================================== */

/* Ultra-wide screens (1920px+) */
@media (min-width: 1920px) {
    .mosaic-grid-wrapper {
        max-width: 1600px;
        padding: 4rem;
    }
    
    .mosaic-grid {
        grid-template-columns: repeat(12, 1fr);
        gap: 2.5rem;
    }
}

/* Desktop (1400px - 1919px) */
@media (min-width: 1400px) and (max-width: 1919px) {
    .mosaic-grid {
        grid-template-columns: repeat(12, 1fr);
        gap: 2rem;
    }
}

/* Laptop/Small Desktop (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .mosaic-grid {
        grid-template-columns: repeat(10, 1fr);
        gap: 1.75rem;
    }
}

/* Tablet Landscape (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .mosaic-grid-wrapper {
        padding: 2.5rem;
        min-height: auto;
    }
    
    .mosaic-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 1.5rem;
    }
}

/* Tablet Portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .mosaic-grid-wrapper {
        padding: 2rem;
        min-height: auto;
    }
    
    .mosaic-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 1.25rem;
    }
}

/* Large Mobile (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .mosaic-grid-wrapper {
        padding: 1.5rem;
        min-height: auto;
    }
    
    .mosaic-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
}

/* Mobile (< 576px) */
@media (max-width: 575px) {
    .mosaic-grid-wrapper {
        padding: 1rem;
        min-height: auto;
    }
    
    .mosaic-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* ==========================================================================
   LAYOUT CONFIGURATIONS BY PANEL COUNT
   ========================================================================== */

/* Default Panel Heights - Responsive */
.panel-hero {
    min-height: clamp(280px, 35vh, 420px);
}

.panel-wide {
    min-height: clamp(180px, 25vh, 250px);
}

.panel-tall {
    min-height: clamp(200px, 28vh, 300px);
}

.panel-medium {
    min-height: clamp(180px, 25vh, 250px);
}

.panel-small {
    min-height: clamp(150px, 20vh, 200px);
}

/* ========== 3 PANELS - Responsive Layout ========== */
/* Desktop */
@media (min-width: 1200px) {
    .mosaic-count-3 .mosaic-panel:nth-child(1) {
        grid-column: span 7;
        grid-row: span 2;
    }
    
    .mosaic-count-3 .mosaic-panel:nth-child(2) {
        grid-column: span 5;
        grid-row: span 1;
    }
    
    .mosaic-count-3 .mosaic-panel:nth-child(3) {
        grid-column: span 5;
        grid-row: span 1;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    .mosaic-count-3 .mosaic-panel:nth-child(1) {
        grid-column: span 4;
        grid-row: span 2;
    }
    
    .mosaic-count-3 .mosaic-panel:nth-child(2) {
        grid-column: span 4;
        grid-row: span 1;
    }
    
    .mosaic-count-3 .mosaic-panel:nth-child(3) {
        grid-column: span 4;
        grid-row: span 1;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .mosaic-count-3 .mosaic-panel {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }
}

/* ========== 4 PANELS - Responsive Layout ========== */
/* Desktop */
@media (min-width: 1200px) {
    .mosaic-count-4 .mosaic-panel:nth-child(1) {
        grid-column: span 6;
        grid-row: span 2;
    }
    
    .mosaic-count-4 .mosaic-panel:nth-child(2) {
        grid-column: span 6;
        grid-row: span 1;
    }
    
    .mosaic-count-4 .mosaic-panel:nth-child(3) {
        grid-column: span 3;
        grid-row: span 1;
    }
    
    .mosaic-count-4 .mosaic-panel:nth-child(4) {
        grid-column: span 3;
        grid-row: span 1;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    .mosaic-count-4 .mosaic-panel:nth-child(1) {
        grid-column: span 4;
        grid-row: span 2;
    }
    
    .mosaic-count-4 .mosaic-panel:nth-child(2) {
        grid-column: span 4;
        grid-row: span 2;
    }
    
    .mosaic-count-4 .mosaic-panel:nth-child(3) {
        grid-column: span 4;
        grid-row: span 1;
    }
    
    .mosaic-count-4 .mosaic-panel:nth-child(4) {
        grid-column: span 4;
        grid-row: span 1;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .mosaic-count-4 .mosaic-panel {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }
}

/* ========== 5 PANELS - Responsive Layout ========== */
/* Desktop */
@media (min-width: 1200px) {
    .mosaic-count-5 .mosaic-panel:nth-child(1) {
        grid-column: span 6;
        grid-row: span 2;
    }
    
    .mosaic-count-5 .mosaic-panel:nth-child(2) {
        grid-column: span 6;
        grid-row: span 1;
    }
    
    .mosaic-count-5 .mosaic-panel:nth-child(3) {
        grid-column: span 6;
        grid-row: span 1;
    }
    
    .mosaic-count-5 .mosaic-panel:nth-child(4) {
        grid-column: span 6;
        grid-row: span 1;
    }
    
    .mosaic-count-5 .mosaic-panel:nth-child(5) {
        grid-column: span 6;
        grid-row: span 1;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    .mosaic-count-5 .mosaic-panel:nth-child(1) {
        grid-column: span 4;
        grid-row: span 2;
    }
    
    .mosaic-count-5 .mosaic-panel:nth-child(2),
    .mosaic-count-5 .mosaic-panel:nth-child(3) {
        grid-column: span 4;
        grid-row: span 1;
    }
    
    .mosaic-count-5 .mosaic-panel:nth-child(4),
    .mosaic-count-5 .mosaic-panel:nth-child(5) {
        grid-column: span 3;
        grid-row: span 1;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .mosaic-count-5 .mosaic-panel {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }
}

/* ========== 6 PANELS - Responsive Layout ========== */
/* Desktop */
@media (min-width: 1200px) {
    .mosaic-count-6 .mosaic-panel:nth-child(1) {
        grid-column: span 5;
        grid-row: span 2;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(2) {
        grid-column: span 4;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(3) {
        grid-column: span 3;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(4) {
        grid-column: span 3;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(5) {
        grid-column: span 4;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(6) {
        grid-column: 1 / -1;
        grid-row: span 1;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1199px) {
    .mosaic-count-6 .mosaic-panel:nth-child(1) {
        grid-column: span 3;
        grid-row: span 2;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(2) {
        grid-column: span 3;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(3) {
        grid-column: span 3;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(4),
    .mosaic-count-6 .mosaic-panel:nth-child(5) {
        grid-column: span 3;
        grid-row: span 1;
    }
    
    .mosaic-count-6 .mosaic-panel:nth-child(6) {
        grid-column: 1 / -1;
        grid-row: span 1;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .mosaic-count-6 .mosaic-panel {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }
}

/* ==========================================================================
   CONTENT STYLES - Responsive Typography
   ========================================================================== */

/* Panel Content */
.mosaic-content {
    padding: clamp(1.5rem, 3vw, 2.5rem);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1;
    overflow: visible;
    position: relative;
    z-index: 1;
}

/* Numbers */
.mosaic-number {
    position: absolute;
    top: clamp(1rem, 2vw, 1.5rem);
    right: clamp(1rem, 2vw, 1.5rem);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 900;
    color: rgba(255, 0, 110, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1;
    z-index: 1;
}

.panel-hero .mosaic-number {
    font-size: clamp(2rem, 5vw, 4rem);
}

/* Labels */
.mosaic-label {
    display: inline-block;
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

/* Titles - Responsive */
.mosaic-title {
    font-size: clamp(1.25rem, 3vw, 2rem);
    font-weight: 700;
    color: #52ddc4;
    margin: 0 0 0.75rem 0;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

.panel-hero .mosaic-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.panel-small .mosaic-title {
    font-size: clamp(1.125rem, 2.5vw, 1.5rem);
}

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

.mosaic-title a:hover {
    color: #3fc4ac;
}

/* Text Content - Responsive */
.mosaic-text {
    font-size: clamp(0.875rem, 1.5vw, 1.125rem);
    line-height: 1.55;
    color: #666;
    margin-bottom: 1rem;
    flex: 1;
    overflow: visible;
}

.panel-hero .mosaic-text {
    font-size: clamp(1rem, 1.75vw, 1.25rem);
    line-height: 1.65;
}

.panel-small .mosaic-text {
    font-size: clamp(0.875rem, 1.25vw, 1.05rem);
}

.mosaic-text p {
    margin: 0 0 0.875rem 0;
}

.mosaic-text p:last-child {
    margin-bottom: 0;
}

/* Images - Responsive Heights */
.mosaic-image {
    width: 100%;
    height: clamp(120px, 20vw, 250px);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    margin: 0;
    border-radius: 1rem 1rem 0 0;
}

.panel-hero .mosaic-image {
    height: clamp(150px, 25vw, 320px);
}

.panel-tall .mosaic-image {
    height: clamp(140px, 22vw, 200px);
}

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

.mosaic-panel:hover .mosaic-image img {
    transform: scale(1.05);
}

/* Links */
.mosaic-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #000;
    font-weight: 600;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.mosaic-link:hover {
    color: #FF006E;
    gap: 0.75rem;
}

.mosaic-link svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.mosaic-link:hover svg {
    transform: translateX(3px);
}

/* Connection Lines */
.mosaic-connector {
    display: none; /* Hide on smaller screens */
}

@media (min-width: 1200px) {
    .mosaic-connector {
        display: block;
        position: absolute;
        width: 2px;
        height: 50px;
        background: linear-gradient(to bottom, #FF006E, transparent);
        bottom: -50px;
        left: 50%;
        transform: translateX(-50%);
        transform-origin: top center;
        z-index: -1;
    }
    
    .panel-hero .mosaic-connector {
        width: 100px;
        height: 2px;
        background: linear-gradient(to right, #FF006E, transparent);
        bottom: auto;
        top: 50%;
        left: auto;
        right: -100px;
        transform: translateY(-50%);
    }
}

/* Scroll Indicator */
.mosaic-scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    font-size: clamp(0.75rem, 1.5vw, 0.875rem);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    animation: bounce 2s infinite;
    z-index: 10;
}

/* Hide scroll indicator on mobile */
@media (max-width: 767px) {
    .mosaic-scroll-indicator {
        display: none;
    }
}

.mosaic-scroll-indicator svg {
    width: 24px;
    height: 24px;
}

@keyframes bounce {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(10px);
    }
}

/* Empty State */
.mosaic-empty-state {
    grid-column: 1 / -1;
    padding: 4rem 2rem;
    text-align: center;
    background: white;
    border: 2px dashed #ddd;
    color: #999;
    border-radius: 1rem;
}

/* ==========================================================================
   SPECIAL RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Disable animations on mobile for better performance */
@media (max-width: 767px) {
    .mosaic-panel {
        transition: box-shadow 0.2s ease !important;
    }
    
    .mosaic-image img {
        transition: none;
    }
    
    /* Force all panels visible on mobile */
    .mosaic-panel {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
    
    .mosaic-number {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Disable pin scrolling on tablets and below */
@media (max-width: 1199px) {
    .blz-story-mosaic {
        min-height: auto !important;
    }
    
    .mosaic-grid-wrapper {
        min-height: auto !important;
    }
    
    /* Ensure all panels are visible */
    .mosaic-panel {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
}

/* Ultra-wide optimization */
@media (min-width: 2560px) {
    .mosaic-grid-wrapper {
        max-width: 1920px;
    }
    
    .mosaic-grid {
        gap: 3rem;
    }
    
    .panel-hero {
        min-height: 500px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .mosaic-panel:hover {
        box-shadow: 0 35px 80px rgba(0, 0, 0, 0.2), 
                    0 15px 40px rgba(0, 0, 0, 0.15), 
                    0 5px 15px rgba(0, 0, 0, 0.1);
    }
    
    .mosaic-panel:hover .mosaic-image img {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .blz-story-mosaic {
        background: white;
    }
    
    .mosaic-panel {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .mosaic-scroll-indicator,
    .mosaic-connector {
        display: none !important;
    }
    
    .mosaic-grid {
        display: block;
    }
    
    .mosaic-panel {
        margin-bottom: 2rem;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .mosaic-panel,
    .mosaic-image img,
    .mosaic-link,
    .mosaic-link svg {
        transition: none !important;
    }
    
    .mosaic-scroll-indicator {
        animation: none;
    }
    
    .mosaic-panel {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .mosaic-panel {
        border: 2px solid currentColor;
    }
    
    .mosaic-title {
        color: #00a88e;
    }
    
    .mosaic-text {
        color: #333;
    }
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
    .blz-story-mosaic {
        background: #1a1a1a;
    }
    
    .mosaic-panel {
        background: #2a2a2a;
        color: #e0e0e0;
    }
    
    .mosaic-title {
        color: #6ee7d4;
    }
    
    .mosaic-text,
    .mosaic-label {
        color: #b0b0b0;
    }
    
    .mosaic-link {
        color: #e0e0e0;
    }
    
    .mosaic-pattern {
        background-image: radial-gradient(circle, #fff 1px, transparent 1px);
        opacity: 0.01;
    }
}