/**
 * TCM Hover Grid Styles
 * Version: 1.0.0
 * Author: Tickled Chilli
 * Author URI: https://tickledchilli.com
 */

/* ========================================
   Elementor Widget Wrapper
   ======================================== */

.tcm-hover-grid-wrapper {
    width: 100%;
    max-width: 100%;
}

/* Elementor widget container fixes */
.elementor-widget-tcm_hover_grid {
    width: 100%;
}

.elementor-widget-tcm_hover_grid .elementor-widget-container {
    width: 100%;
    max-width: 100%;
}

/* ========================================
   Container & Grid Layout
   ======================================== */

.tcm-hover-grid-container {
    width: 100%;
    overflow: hidden;
    border-radius: 30px;
}

.tcm-hover-grid {
    display: flex;
    gap: 2px; /* Gap between columns */
    width: 100%;
    align-items: stretch;
}

/* Each column is a flex container */
.tcm-hover-grid-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px; /* Gap between items in column */
    min-width: 0;
}

/* ========================================
   Grid Items
   ======================================== */

.tcm-hover-grid-item {
    position: relative;
    width: 100%;
    flex: 1; /* Equal height by default */
    min-height: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    cursor: pointer;
    transition: flex 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tcm-hover-grid-item:hover .tcm-grid-item-overlay {
    backdrop-filter: blur(5px);
}

/* Round corners for edge items to match container */
.tcm-hover-grid-column:first-child .tcm-hover-grid-item:first-child {
    border-top-left-radius: 30px;
}

.tcm-hover-grid-column:last-child .tcm-hover-grid-item:first-child {
    border-top-right-radius: 30px;
}

.tcm-hover-grid-column:first-child .tcm-hover-grid-item:last-child {
    border-bottom-left-radius: 30px;
}

.tcm-hover-grid-column:last-child .tcm-hover-grid-item:last-child {
    border-bottom-right-radius: 30px;
}

/* Make items square in initial state */
.tcm-hover-grid-column:first-child .tcm-hover-grid-item {
    aspect-ratio: 1 / 1;
}

.tcm-hover-grid-item.hover-active {
    flex: 1.3; /* Grow to 1.3x (30% increase) */
    z-index: 10;
}

.tcm-hover-grid-item.compressed {
    flex: 0.7; /* Shrink to 0.7x (30% decrease) */
    z-index: 5;
}

/* ========================================
   Links & Overlay
   ======================================== */

.tcm-grid-item-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: inherit; /* Inherit parent's border radius */
}

.tcm-grid-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom, 
        rgba(0, 0, 0, 0.3) 0%, 
        rgba(0, 0, 0, 0.7) 100%
    );
    transition: all 0.3s ease;
    z-index: 1;
    pointer-events: none;
    border-radius: inherit; /* Match parent's border radius */
}

.tcm-hover-grid-item:hover .tcm-grid-item-overlay {
    background: linear-gradient(
        to bottom, 
        rgba(0, 0, 0, 0.5) 0%, 
        rgba(0, 0, 0, 0.85) 100%
    );
}

/* ========================================
   Content & Typography
   ======================================== */

.tcm-grid-item-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px;
    color: white;
    z-index: 2;
}

.tcm-grid-item-title {
    font-size: 30px;
    font-weight: 600;
    margin: 0 0 15px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
    transition: text-shadow 0.3s ease;
}

.tcm-hover-grid-item:hover .tcm-grid-item-title {
    font-size: 50px;
    line-height: 50px;
}

.tcm-grid-item-description {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    overflow: hidden;
}

.tcm-hover-grid-item:hover .tcm-grid-item-description {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
}

.tcm-grid-item-description p {
    margin: 0 0 15px 0;
    font-size: 20px;
    line-height: 25px;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ========================================
   Arrow Button (Purple with Chevron)
   ======================================== */

.tcm-grid-item-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #A000FF; /* Purple background */
    border-radius: 50%;
    transition: all 0.3s ease;
}

.tcm-grid-item-arrow svg {
    width: 20px;
    height: 20px;
    color: white;
}

.tcm-hover-grid-item:hover .tcm-grid-item-arrow {
    background: #8800DD; /* Darker purple on hover */
    transform: translateX(5px);
}

/* ========================================
   Admin Notice Styles
   ======================================== */

.tcm-hover-grid-notice {
    background: #fff;
    border: 1px solid #ddd;
    border-left: 4px solid #ff6b6b;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.tcm-hover-grid-notice p {
    margin: 0;
    color: #333;
}

/* ========================================
   Tablet Responsive (≤1024px)
   ======================================== */

@media (max-width: 1024px) {
    /* Reduce to 2 columns on tablet */
    .tcm-hover-grid-column:nth-child(n+3) {
        display: none;
    }
    
    .tcm-hover-grid-item {
        flex: 1;
    }
    
    .tcm-hover-grid-item.hover-active {
        flex: 1.3; /* 30% increase */
    }
    
    .tcm-hover-grid-item.compressed {
        flex: 0.7; /* 30% decrease */
    }
    
    .tcm-grid-item-title {
        font-size: 28px;
    }
    
    .tcm-grid-item-description p {
        font-size: 14px;
    }
    
    .tcm-grid-item-content {
        padding: 25px;
    }
}

/* ========================================
   Mobile Responsive (≤640px)
   ======================================== */

@media (max-width: 640px) {
    /* Stack columns vertically on mobile */
    .tcm-hover-grid {
        flex-direction: column;
    }
    
    .tcm-hover-grid-column {
        width: 100%;
    }
    
    /* Show all columns stacked */
    .tcm-hover-grid-column:nth-child(n+3) {
        display: flex;
    }
    
    .tcm-hover-grid-item {
        flex: 1;
    }
    
    .tcm-hover-grid-item.hover-active {
        flex: 1.2; /* 20% increase (slightly less on mobile) */
    }
    
    .tcm-hover-grid-item.compressed {
        flex: 0.8; /* 20% decrease (slightly less on mobile) */
    }
    
    .tcm-grid-item-title {
        font-size: 24px;
    }
    
    .tcm-grid-item-content {
        padding: 20px;
    }
    
    .tcm-grid-item-description p {
        font-size: 14px;
    }
    
    .tcm-grid-item-arrow {
        width: 36px;
        height: 36px;
    }
}

/* ========================================
   Touch Device Support
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    .tcm-grid-item-description {
        opacity: 1;
        transform: translateY(0);
        max-height: none;
    }
    
    .tcm-hover-grid-item .tcm-grid-item-arrow {
        background: #A000FF; /* Purple background on touch devices */
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .tcm-hover-grid {
        flex-direction: column;
    }
    
    .tcm-hover-grid-item {
        page-break-inside: avoid;
        flex: none !important;
        height: auto;
        margin-bottom: 20px;
    }
    
    .tcm-grid-item-description {
        opacity: 1 !important;
        max-height: none !important;
    }
}

/* ========================================
   Accessibility & Focus States
   ======================================== */

.tcm-grid-item-link:focus {
    outline: 3px solid #A000FF;
    outline-offset: -3px;
}

.tcm-grid-item-link:focus-visible {
    outline: 3px solid #A000FF;
    outline-offset: -3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tcm-grid-item-overlay {
        background: linear-gradient(
            to bottom, 
            rgba(0, 0, 0, 0.6) 0%, 
            rgba(0, 0, 0, 0.9) 100%
        );
    }
    
    .tcm-grid-item-title,
    .tcm-grid-item-description p {
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tcm-hover-grid-item {
        transition: none !important;
    }
    
    .tcm-grid-item-description,
    .tcm-grid-item-overlay,
    .tcm-grid-item-arrow {
        transition: none !important;
    }
}

/* ========================================
   Loading State (Optional Enhancement)
   ======================================== */

.tcm-hover-grid-item.loading {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: tcm-loading 1.5s infinite;
}

@keyframes tcm-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   TCM Branding
   ======================================== */

/* Custom brand color variable (can be overridden) */
:root {
    --tcm-brand-color: #A000FF;
    --tcm-brand-hover: #8800DD;
}

.tcm-hover-grid-item .tcm-grid-item-arrow {
    background: var(--tcm-brand-color);
}

.tcm-hover-grid-item:hover .tcm-grid-item-arrow {
    background: var(--tcm-brand-hover);
}
