/**
 * Homepage Responsive Fixes V2
 * Fixes layout breaking, text wrapping, and alignment issues
 */

/* Container max-width fixes */
.container {
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

@media (min-width: 1536px) {
    .container {
        max-width: 1536px;
    }
}

/* Grid fixes for different screen sizes */
.grid {
    display: grid;
    gap: 1.5rem;
}

/* Prevent text wrapping issues */
.grid > * {
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Featured sections grid responsive */
.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .xl\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Prevent layout shift on load */
.grid > * {
    animation: fadeInUp 0.3s ease-in-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fix heading overflow */
h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Section spacing consistency */
section {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

@media (min-width: 1024px) {
    section {
        padding-top: 4rem;
        padding-bottom: 4rem;
    }
}

/* Card consistent sizing */
.bg-white.rounded-xl {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Image aspect ratio maintenance */
.relative.h-48,
.relative.aspect-square {
    position: relative;
    overflow: hidden;
}

.relative.h-48 img,
.relative.aspect-square img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Flexbox alignment fixes */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

/* Text alignment responsive */
.text-center {
    text-align: center;
}

@media (min-width: 768px) {
    .md\:text-left {
        text-align: left;
    }
}

/* Prevent content jumping */
* {
    box-sizing: border-box;
}

/* Smooth transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Fix popular destinations overflow */
.popular-destinations-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.popular-destinations-section::-webkit-scrollbar {
    height: 6px;
}

.popular-destinations-section::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.popular-destinations-section::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.popular-destinations-section::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Campaign carousel fixes */
.campaign-carousel {
    display: flex !important;
    flex-wrap: nowrap;
    gap: 1.5rem;
}

.campaign-carousel .flex-shrink-0 {
    flex-shrink: 0;
}

/* Search bar responsive */
.wcs-search-fields {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .wcs-search-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .wcs-search-fields {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Mobile menu fixes */
@media (max-width: 1023px) {
    .lg\:hidden {
        display: block;
    }
    
    .hidden.lg\:flex {
        display: none;
    }
}

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Fix mega menu positioning */
.mega-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    width: 100%;
    max-width: 100vw;
}

/* Line clamp utility */
.line-clamp-1 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.line-clamp-2 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.line-clamp-3 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

/* Aspect ratio helpers */
.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}

/* Truncate text */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Performance optimization */
img {
    content-visibility: auto;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
