/* Custom Home Page Styles */

/* Main Grid Container: Use CSS Grid */
.home-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-auto-rows: minmax(320px, auto);
    gap: 10px;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 10px;
    background-color: #f9f9f9;
}

/* Remove structural CSS from these wrappers if they exist and are not needed */
.grid-row,
.grid-column-left,
.grid-column-right,
.grid-row-inner {
    display: contents; /* Make them part of the parent grid */
}

/* Base styles for all grid items */
.grid-item {
    position: relative;
    overflow: hidden;
    background-color: #e5e5e5;
    margin: 0;
    padding: 0;
    min-height: 320px;
}

.tile-media,
.tile-media img,
.tile-media video {
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}

/* --- PRECISE TILE PLACEMENT BASED ON DESIGN --- */

/* Row 1: Tiles 1-6 */
/* 1. The Internetvention (Large - spans 2x2) */
.grid-area-intervention {
    grid-column: 1 / span 2;
    grid-row: 1 / span 2;
    min-height: 650px;
}

/* 2. SPIKES Asia Winner (Small) */
.grid-area-spikes {
    grid-column: 3 / span 1;
    grid-row: 1 / span 1;
}

/* 3. Travel Associates (Small) */
.grid-area-travel {
    grid-column: 4 / span 1;
    grid-row: 1 / span 1;
}

/* 4. BCM Watch Reel (Small) */
.grid-area-reel {
    grid-column: 3 / span 1;
    grid-row: 2 / span 1;
}

/* 5. Mumbrella Awards (Small) */
.grid-area-awards {
    grid-column: 4 / span 1;
    grid-row: 2 / span 1;
}

/* 6. Messi Fragrances (Large - spans 2x2) */
.grid-area-messi {
    grid-column: 1 / span 2;
    grid-row: 3 / span 2;
    min-height: 650px;
}

/* Row 2: Tiles 7-12 */
/* 7. Containers for Change (Small) */
.grid-area-containers {
    grid-column: 3 / span 1;
    grid-row: 3 / span 1;
}

/* 8. Visit Sunshine Coast (Small) */
.grid-area-sunshine {
    grid-column: 4 / span 1;
    grid-row: 3 / span 1;
}

/* 9. Griffith University (Large - spans 2x2) */
.grid-area-griffith {
    grid-column: 3 / span 2;
    grid-row: 4 / span 2;
    min-height: 650px;
}

/* 10. Crimsafe (Large - spans 2x2) */
.grid-area-crimsafe {
    grid-column: 1 / span 2;
    grid-row: 5 / span 2;
    min-height: 650px;
}

/* 11. Veracity (Small) */
.grid-area-veracity {
    grid-column: 3 / span 1;
    grid-row: 6 / span 1;
}

/* 12. Sunny Queen Farms (Small) */
.grid-area-sunnyqueen {
    grid-column: 4 / span 1;
    grid-row: 6 / span 1;
}

/* Row 3: Tiles 13-21 */
/* 13. IVY PR (Small) */
.grid-area-ivy {
    grid-column: 1 / span 1;
    grid-row: 7 / span 1;
}

/* 14. Apollo Motorhomes (Small) */
.grid-area-apollo {
    grid-column: 2 / span 1;
    grid-row: 7 / span 1;
}

/* 15. Multiplier Mindset (Large - spans 2x2) */
.grid-area-multiplier {
    grid-column: 3 / span 2;
    grid-row: 7 / span 2;
    background-color: #ededed;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    height: 580px !important; /* Force specific height */
    max-height: 580px !important;
    overflow: hidden;
    padding: 2rem 3rem;
    box-sizing: border-box;
    align-self: start;
    justify-self: start;
}

/* 16. Queensland Fire and Emergency Service (Small) */
.grid-area-qfes {
    grid-column: 1 / span 1;
    grid-row: 8 / span 1;
}

/* 17. Effie Awards Winner (Small) */
.grid-area-effie {
    grid-column: 2 / span 1;
    grid-row: 8 / span 1;
}

/* Bottom row: Tiles 18-21 */
/* 18. X partial (Small) */
.grid-area-xpartial {
    grid-column: 1 / span 1;
    grid-row: 9 / span 1;
}

/* 19. MRQ (Small) */
.grid-area-mrq {
    grid-column: 2 / span 1;
    grid-row: 9 / span 1;
}

/* 20. X different (Small) */
.grid-area-xflash {
    grid-column: 3 / span 1;
    grid-row: 9 / span 1;
}

/* 21. Car on street (Small) */
.grid-area-holden {
    grid-column: 4 / span 1;
    grid-row: 9 / span 1;
}

/* Remove old placeholder areas */
.grid-area-placeholder1,
.grid-area-placeholder2,
.grid-area-brandcreative,
.grid-area-probono {
    display: none;
}

/* Remove or comment out old/conflicting sizing rules */
.grid-item.large-left,
.grid-item.large-right,
.grid-item.medium-tall,
.grid-item.medium,
.grid-item.small,
.grid-item.quarter {
    /* These specific sizings are overridden by the grid-area placements */
    /* You might want to keep some base height/width or remove them */
    flex: unset;
    width: unset;
    height: unset; /* Explicit height is now handled by grid-row span and min-height */
    /* grid-column: unset; remove if these were set before */
}


/* Tile Link, Tile Media, Tile Overlay - existing styles should be fine */
.tile-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.tile-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tile-media video,
.tile-media img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tile-media video {
    z-index: 2;
}

.tile-media img {
    z-index: 1;
}

/* Hide video on mobile, show image fallback */
@media (max-width: 768px) {
    .tile-media video {
        display: none;
    }
}

/* Enhanced overlay gradient and behavior */
.tile-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.75rem;
    background: linear-gradient(to top, 
        rgba(0,0,0,0.9) 0%, 
        rgba(0,0,0,0.65) 30%, 
        rgba(0,0,0,0.3) 60%, 
        rgba(0,0,0,0) 100%);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 3;
    transform: translateY(5px);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Add subtle hover color overlay to make text more legible */
.grid-item::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 70%, rgba(0,0,0,0.5) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
}

.grid-item:hover::after {
    opacity: 1;
}

.grid-item:hover .tile-overlay,
.video-lightbox:hover .tile-overlay {
    opacity: 1;
    transform: translateY(0);
}

.tile-overlay h3 {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    line-height: 1.4;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    position: relative;
    transform: translateY(5px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grid-item:hover .tile-overlay h3 {
    transform: translateY(0);
}

/* Different text size treatments for larger tiles */
.grid-area-intervention .tile-overlay h3,
.grid-area-messi .tile-overlay h3,
.grid-area-griffith .tile-overlay h3,
.grid-area-placeholder1 .tile-overlay h3,
.grid-area-placeholder2 .tile-overlay h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Special treatment for "Read" links */
.tile-overlay h3:only-child {
    /* This targets overlays with only "Read" text */
    position: relative;
    display: inline-block;
}

.tile-overlay h3:only-child::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #fff;
    transition: width 0.3s ease;
}

.grid-item:hover .tile-overlay h3:only-child::after {
    width: 100%;
}

/* Video Lightbox Trigger - Enhanced */
.video-lightbox {
    cursor: pointer;
}

.video-lightbox .tile-overlay h3::after {
    content: none !important;
}

.video-lightbox:hover .tile-overlay h3::after {
    transform: scale(1.1);
    opacity: 1;
}

/* Lightbox Styles */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 10001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

/* Container adjustments */
body .container-wrap {
    background-color: #f9f9f9;
}

/* Fix header spacing if needed */
body.home #ajax-content-wrap {
    padding-top: 0;
}

/* Remove any unwanted margins from theme */
body.home .container-wrap > .main-content {
    padding-top: 0;
}

/* Responsive Design */
@media (max-width: 1500px) {
    .home-grid-container {
        padding: 0 10px;
    }
}

@media (max-width: 1480px) { /* Slightly wider than 1470 to ensure it kicks in*/
    /* Adjustments for slightly smaller desktop if needed, otherwise main grid handles it */
}

/* Tablet View: Targeting screens <= 1000px */
@media (max-width: 1000px) {
    .home-grid-container {
        grid-template-columns: 1fr 1fr; /* 2 columns */
        grid-auto-rows: minmax(280px, auto); /* Base height for one 'cell' */
        gap: 8px;
        padding: 8px;
    }

    /* Default for all items on tablet: 1x1 cell */
    .grid-item,
    .grid-area-intervention, .grid-area-spikes, .grid-area-travel,
    .grid-area-reel, .grid-area-awards, .grid-area-messi,
    .grid-area-containers, .grid-area-sunshine, .grid-area-griffith,
    .grid-area-crimsafe, .grid-area-veracity, .grid-area-sunnyqueen,
    .grid-area-ivy, .grid-area-apollo, .grid-area-multiplier,
    .grid-area-qfes, .grid-area-effie, .grid-area-xpartial,
    .grid-area-mrq, .grid-area-xflash, .grid-area-holden {
        grid-column: span 1; /* Default to 1 column span */
        grid-row: span 1;    /* Default to 1 row span */
        min-height: 280px; /* Base height for 1-row items */
    }

    /* Larger items to span 2 columns and 2 rows on tablet */
    .grid-area-intervention,
    .grid-area-messi,
    .grid-area-griffith,
    .grid-area-crimsafe {
        grid-column: 1 / -1; /* Span both columns */
        grid-row: span 2;
        min-height: calc(2 * 280px + 8px); /* 2 * base_row_height + 1 * gap */
    }

    .grid-area-multiplier {
        grid-column: 1 / -1; /* Span both columns */
        grid-row: span 2;
        min-height: auto; /* Content driven, but occupies 2x2 cell space */
        height: auto !important;
        max-height: none !important;
        padding: 2rem !important; /* Ensure padding is maintained */
    }

    .tile-overlay h3 {
        font-size: 1rem; /* Adjust text size for tablet */
    }

    .grid-area-intervention .tile-overlay h3,
    .grid-area-messi .tile-overlay h3,
    .grid-area-griffith .tile-overlay h3,
    .grid-area-crimsafe .tile-overlay h3 {
        font-size: 1.2rem; /* Slightly larger for prominent items */
    }
}

/* Mobile View: Targeting screens <= 768px */
@media (max-width: 768px) {
    .home-grid-container {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Always 2 columns */
        grid-auto-rows: minmax(200px, auto);
        gap: 10px;
        padding: 10px;
    }

    /* Reset ALL desktop grid positioning for mobile */
    .grid-item,
    .grid-area-intervention, .grid-area-spikes, .grid-area-travel,
    .grid-area-reel, .grid-area-awards, .grid-area-messi,
    .grid-area-containers, .grid-area-sunshine, .grid-area-griffith,
    .grid-area-crimsafe, .grid-area-veracity, .grid-area-sunnyqueen,
    .grid-area-ivy, .grid-area-apollo, .grid-area-multiplier,
    .grid-area-qfes, .grid-area-effie, .grid-area-xpartial,
    .grid-area-mrq, .grid-area-xflash, .grid-area-holden {
        /* Reset all desktop positioning */
        grid-column: unset !important;
        grid-row: unset !important;
        /* Default to small tile (1 column) */
        grid-column: span 1;
        min-height: 200px;
        width: 100%;
        height: auto;
    }

    /* Large tiles: span both columns (full width) */
    .grid-area-intervention,
    .grid-area-messi,
    .grid-area-griffith,
    .grid-area-crimsafe,
    .grid-area-multiplier {
        grid-column: 1 / -1 !important; /* Span both columns */
        grid-row: unset !important; /* Let it flow naturally */
        min-height: 300px;
        width: 100%;
    }

    /* Force the multiplier section to behave properly on mobile */
    main.home-grid-container > .multiplier-section.grid-area-multiplier.multiplier-large-tile {
        height: 440px !important;
        min-height: 440px !important;
        max-height: 440px !important;
        background: #f1f1f1 !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        position: relative !important;
        box-sizing: border-box !important;
        padding: 32px 16px 16px 16px !important;
        z-index: 10 !important;
    }
    
    /* Multiplier content layout */
    main.home-grid-container > .multiplier-section.grid-area-multiplier.multiplier-large-tile .multiplier-flex {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        height: 100% !important;
        width: 100% !important;
        position: relative !important;
    }
    
    .multiplier-section.grid-area-multiplier.multiplier-large-tile .multiplier-text {
        width: 85% !important;
        z-index: 2 !important;
    }
    
    /* Typography for mobile */
    main.home-grid-container > .multiplier-section.grid-area-multiplier.multiplier-large-tile .multiplier-headline {
        font-size: 1.65rem !important;
        line-height: 1.1 !important;
        margin-bottom: 1.1rem !important;
        color: #222 !important;
        font-weight: 700 !important;
    }
    
    .multiplier-section.grid-area-multiplier.multiplier-large-tile .multiplier-support {
        font-size: 1.08rem !important;
        line-height: 1.45 !important;
        color: #444 !important;
        margin-bottom: 0 !important;
    }
    
    /* Show and position the X icon on mobile */
    main.home-grid-container > .multiplier-section.grid-area-multiplier.multiplier-large-tile .multiplier-x-wrapper {
        display: block !important;
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        z-index: 20 !important;
    }
    
    .multiplier-section.grid-area-multiplier.multiplier-large-tile .multiplier-x-icon {
        width: 56px !important;
        height: 56px !important;
        opacity: 1 !important;
        display: block !important;
    }
    
    .grid-area-apollo::after {
        display: none !important;
        content: none !important;
    }

    .tile-media video {
        display: block; /* Ensure videos are shown */
    }

    .tile-overlay {
        padding: 1.25rem; /* Adjust overlay padding */
        background: linear-gradient(to top, 
            rgba(0,0,0,0.85) 0%, 
            rgba(0,0,0,0.6) 35%, 
            rgba(0,0,0,0.2) 70%, 
            rgba(0,0,0,0) 100%);
    }

    .tile-overlay h3 {
        font-size: 0.9rem; /* Adjust text size for mobile */
        transform: translateY(0); /* Remove hover transform for mobile if active by default */
    }
    
    .grid-area-intervention .tile-overlay h3,
    .grid-area-messi .tile-overlay h3,
    .grid-area-griffith .tile-overlay h3,
    .grid-area-crimsafe .tile-overlay h3 {
        font-size: 1.1rem; 
    }

    .lightbox-close {
        top: 15px !important;
        right: 15px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 1.5rem !important;
    }
    .lightbox-content {
        width: 95vw !important;
        max-width: none !important;
        height: 0 !important;
        padding-bottom: 56.25% !important; /* 16:9 aspect ratio */
        margin: 0 auto !important;
    }
    .video-container {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }
    .video-container iframe {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        border-radius: 4px !important;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.grid-item {
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
}

.grid-item:nth-child(1) { animation-delay: 0.1s; }
.grid-item:nth-child(2) { animation-delay: 0.2s; }
.grid-item:nth-child(3) { animation-delay: 0.3s; }
.grid-item:nth-child(4) { animation-delay: 0.4s; }

/* Hover Effects */
.grid-item {
    transition: transform 0.3s ease;
}

.grid-item:hover {
    transform: scale(1.02);
}

.grid-item:hover .tile-media video,
.grid-item:hover .tile-media img {
    transform: translate(-50%, -50%) scale(1.05);
    transition: transform 0.6s ease;
}

/* Loading State */
.tile-media {
    background-color: #e5e5e5;
}

.tile-media::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
    z-index: 0;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.tile-media video:not([src=""]) ~ ::before,
.tile-media img:not([src=""]) ~ ::before {
    display: none;
}

/* Remove old flexbox rules for .grid-row, .grid-column-left, .grid-column-right, .grid-row-inner */
/* This section is now fully commented out as display: contents is used on these elements from the start */
/*
.grid-row,
.grid-column-left,
.grid-column-right,
.grid-row-inner {
    flex: unset !important;
    width: unset !important;
    flex-direction: unset !important;
    gap: unset !important;
}
*/

.multiplier-section .multiplier-content h2 {
    font-size: 2.0rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: #0a0a0a;
}

.multiplier-section .multiplier-content p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #333;
    margin-bottom: 0;
    max-width: none;
}

.multiplier-section .multiplier-icon {
    display: none; /* Hide the large X image, as design uses textual/dot X */
}

.headline-x-icon {
    width: 0.7em; /* Slightly smaller */
    height: 0.7em; /* Slightly smaller */
    display: inline-block;
    vertical-align: middle; /* Changed from baseline */
    margin-left: 0.25em; /* Adjusted spacing slightly */
    /* If it's an SVG and you want to control fill color via CSS and it's designed for it: */
    /* fill: #0adb0a; */ 
}

/* Remove previously added reset that might be causing layout issues */
.grid-area-reel,
.grid-area-awards,
.grid-area-containers,
.grid-area-sunshine,
.grid-area-veracity,
.grid-area-sunnyqueen,
.grid-area-ivy,
.grid-area-apollo,
.grid-area-probono,
.grid-area-qfes,
.grid-area-crimsafe,
.grid-area-brandcreative,
.grid-area-mrq,
.grid-area-xflash,
.grid-area-holden,
.grid-area-placeholder2 {
    margin-top: 0;
}

/* Specific fix for the multiplier tile only */
.home-grid-container .multiplier-section.grid-area-multiplier.multiplier-large-tile {
    height: 650px !important;
    max-height: 650px !important;
    margin: 0 !important;
    padding: 3rem !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    background-color: #f1f1f1 !important;
}

/* Adjust the internal flex container */
.multiplier-section.multiplier-large-tile .multiplier-flex {
    height: 100%;
    align-items: center;
    padding: 0;
}

/* Ensure the text is properly sized and spaced */
.multiplier-section.multiplier-large-tile .multiplier-headline {
    margin-bottom: 1.5rem;
}

/* Ensure the X icon is properly positioned */
.multiplier-section.multiplier-large-tile .multiplier-x-icon {
    margin: 0;
}

.reel-label {
    display: flex;
    align-items: center;
    gap: 0.4em;
    white-space: nowrap;
}

.reel-label .play-icon {
    font-size: 1em;
    opacity: 0.8;
    transition: transform 0.3s, opacity 0.3s;
    margin-left: 0.2em;
    display: inline-block;
    vertical-align: middle;
    color: #fff;
}

.video-lightbox:hover .reel-label .play-icon {
    transform: scale(1.1);
    opacity: 1;
}

.reel-label span {
    color: #fff;
} 