/**
 * Homepage Responsive Enhancements
 * 
 * Optimizes text wrapping, line-height, and grid layouts
 * for 1366px, 1920px, and mobile resolutions
 */

/* ============================================
   TEXT WRAPPING AND LINE-HEIGHT OPTIMIZATIONS
   ============================================ */

/* Base text wrapping */
body,
p,
span,
div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Optimal line-height for readability */
body {
    line-height: 1.6;
}

p {
    line-height: 1.7;
}

/* Heading line-heights */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Text balance for headings */
.text-balance {
    text-wrap: balance;
}

/* ============================================
   GRID LAYOUT OPTIMIZATIONS - 1366px
   ============================================ */

@media (min-width: 1366px) and (max-width: 1535px) {
    /* Popular Destinations Grid */
    .grid.grid-cols-2.sm\:grid-cols-2.lg\:grid-cols-3.xl\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1rem;
    }
    
    /* Featured Sections Grid */
    .featured-grid,
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.25rem;
    }
    
    /* 4-column featured grids */
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1rem;
    }
    
    /* Prevent text overflow in cards */
    .card,
    .listing-card {
        min-width: 0;
    }
    
    .card h3,
    .listing-card h3 {
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .card p,
    .listing-card p {
        font-size: 0.875rem;
        line-height: 1.5;
    }
}

/* ============================================
   GRID LAYOUT OPTIMIZATIONS - 1920px
   ============================================ */

@media (min-width: 1920px) {
    /* Popular Destinations Grid - Show 5 items */
    .grid.grid-cols-2.sm\:grid-cols-2.lg\:grid-cols-3.xl\:grid-cols-4 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 1.5rem;
    }
    
    /* Featured Sections Grid */
    .featured-grid,
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1.75rem;
    }
    
    /* 4-column featured grids - Show 5 items */
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 1.5rem;
    }
    
    /* Larger text on very large screens */
    .card h3,
    .listing-card h3 {
        font-size: 1.125rem;
        line-height: 1.4;
    }
    
    .card p,
    .listing-card p {
        font-size: 1rem;
        line-height: 1.6;
    }
}

/* ============================================
   FLEXBOX OVERFLOW PREVENTION
   ============================================ */

/* Prevent flex items from causing overflow */
.flex {
    min-width: 0;
}

.flex > * {
    min-width: 0;
    flex-shrink: 1;
}

/* Flex wrap where needed */
.flex-nowrap {
    flex-wrap: nowrap;
}

@media (max-width: 1023px) {
    .flex-nowrap {
        flex-wrap: wrap;
    }
}

/* ============================================
   HERO SECTION TEXT OPTIMIZATION
   ============================================ */

.hero-section h1 {
    line-height: 1.2;
    font-weight: 700;
}

.hero-section p {
    line-height: 1.6;
    font-weight: 400;
}

@media (min-width: 1366px) and (max-width: 1535px) {
    .hero-section h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }
    
    .hero-section p {
        font-size: 1.125rem;
        line-height: 1.6;
    }
}

@media (min-width: 1920px) {
    .hero-section h1 {
        font-size: 3rem;
        line-height: 1.2;
    }
    
    .hero-section p {
        font-size: 1.25rem;
        line-height: 1.6;
    }
}

/* ============================================
   CARD CONTENT OPTIMIZATION
   ============================================ */

/* Ensure card text doesn't overflow */
.card-title,
.listing-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.8em;
}

.card-description,
.listing-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    min-height: 4.5em;
}

/* ============================================
   SECTION HEADINGS OPTIMIZATION
   ============================================ */

section h2 {
    line-height: 1.3;
    font-weight: 600;
    word-wrap: break-word;
}

@media (min-width: 1366px) and (max-width: 1535px) {
    section h2 {
        font-size: 1.875rem;
        line-height: 1.3;
    }
}

@media (min-width: 1920px) {
    section h2 {
        font-size: 2.25rem;
        line-height: 1.3;
    }
}

/* ============================================
   SEARCH BAR OPTIMIZATION
   ============================================ */

.wcs-search-container {
    max-width: 100%;
    overflow-x: hidden;
}

.wcs-search-form {
    max-width: 100%;
}

.wcs-form-field {
    min-width: 0;
}

.wcs-search-input,
.wcs-search-select {
    max-width: 100%;
    min-width: 0;
}

/* ============================================
   POPULAR DESTINATIONS OPTIMIZATION
   ============================================ */

.popular-destinations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    max-width: 100%;
}

@media (min-width: 1366px) and (max-width: 1535px) {
    .popular-destinations-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1rem;
    }
}

@media (min-width: 1920px) {
    .popular-destinations-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 1.5rem;
    }
}

/* ============================================
   FEATURED SECTIONS OPTIMIZATION
   ============================================ */

.featured-section {
    max-width: 100%;
    overflow-x: hidden;
}

.featured-section .grid {
    max-width: 100%;
    gap: 1rem;
}

@media (min-width: 1366px) and (max-width: 1535px) {
    .featured-section .grid {
        gap: 1.25rem;
    }
}

@media (min-width: 1920px) {
    .featured-section .grid {
        gap: 1.75rem;
    }
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 767px) {
    /* Stack all grids on mobile */
    .grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Optimize text sizes for mobile */
    h1 {
        font-size: 1.875rem;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    p {
        font-size: 0.9375rem;
        line-height: 1.6;
    }
    
    /* Prevent horizontal scroll on mobile */
    * {
        max-width: 100vw;
    }
}

/* ============================================
   TABLET OPTIMIZATIONS
   ============================================ */

@media (min-width: 768px) and (max-width: 1023px) {
    /* 2-column layouts on tablet */
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3,
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
    
    /* Popular destinations - 3 columns on tablet */
    .grid.grid-cols-2.sm\:grid-cols-2.lg\:grid-cols-3.xl\:grid-cols-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1rem;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Prevent text overflow */
.text-no-overflow {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Multi-line clamp */
.text-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Responsive text sizes */
.text-responsive {
    font-size: clamp(0.875rem, 1.5vw, 1rem);
    line-height: 1.6;
}

/* ============================================
   CONTAINER PADDING OPTIMIZATION
   ============================================ */

@media (min-width: 1366px) and (max-width: 1535px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1920px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ============================================
   IMAGE OPTIMIZATION
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* Aspect ratio preservation */
.aspect-ratio-preserve {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* ============================================
   BUTTON AND LINK TEXT OPTIMIZATION
   ============================================ */

button,
a,
.btn {
    word-wrap: break-word;
    white-space: normal;
}

/* Prevent button text from breaking awkwardly */
@media (min-width: 768px) {
    button,
    .btn {
        white-space: nowrap;
    }
}

