/*
 * index.css — Homepage-specific styles
 * Annora Ceylon · Premium Sri Lanka Tours
 *
 * SCOPE RULES (strict):
 *   ✔  #loading-overlay and its children
 *   ✔  #error-message
 *   ✔  #main-content (opacity/transition on page load only)
 *   ✔  .skip-to-content  .sr-only  (accessibility helpers)
 *   ✔  .fade-in .slide-in-* .scale-in .rotate-in (generic IO helpers)
 *   ✔  .content-loading .template-loading .template-fallback (placeholder states)
 *   ✔  WBU IntersectionObserver compat fix
 *
 *   ✘  body / html — governed by main.css
 *   ✘  Template section backgrounds — governed by each template CSS
 *   ✘  WhatsApp / translate / language — governed by template-header.css
 *   ✘  Any .tt-* .ac-hero* .ac-why* .asl-* .sv-* classes
 */


/* ═══════════════════════════════════════════════════════════════
   LOADING OVERLAY
   Merged from former index-overlay.css — single file, no duplication
═══════════════════════════════════════════════════════════════ */

#loading-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: radial-gradient(120% 120% at 50% 0%, #ffffff 0%, #f7f9ff 45%, #eef3ff 100%);
    z-index: 9999;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    opacity: 1;
    visibility: visible;
    overflow: hidden;
}

/* Animated ambient shimmer */
#loading-overlay::before,
#loading-overlay::after {
    content: "";
    position: absolute;
    inset: -20%;
    background:
        radial-gradient(40% 30% at 20% 15%, rgba(30, 136, 229, 0.10) 0%, transparent 70%),
        radial-gradient(30% 25% at 80% 70%, rgba(212, 175, 55, 0.10) 0%, transparent 70%);
    filter: blur(20px);
    animation: overlayFloat 14s ease-in-out infinite alternate;
    pointer-events: none;
}
#loading-overlay::after {
    animation-delay: -7s;
    transform: rotate(15deg);
}

@keyframes overlayFloat {
    0%   { transform: translate3d(0, 0, 0) scale(1);        opacity: 0.9; }
    100% { transform: translate3d(2%, -2%, 0) scale(1.03);  opacity: 1;   }
}

/* Logo — simple pulse, no extra wrapper elements needed */
.loading-logo {
    width: 104px;
    height: 104px;
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    animation: logoPulse 2.2s ease-in-out infinite;
    will-change: transform, opacity;
    position: relative;
    z-index: 1;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%       { transform: scale(1.06); opacity: 0.92; }
}

/* Hide overlay when loading is complete */
#loading-overlay.loading-complete {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #loading-overlay::before,
    #loading-overlay::after,
    .loading-logo {
        animation: none !important;
    }
}


/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT — fade-in on page ready
   Only opacity + transition. No background, no padding, no z-index.
   Backgrounds are set by each template's own CSS file.
═══════════════════════════════════════════════════════════════ */

#main-content {
    opacity: 0;
    transition: opacity 0.3s ease;
    min-height: 100vh;
    contain: style; /* style isolation only — not layout, avoids breaking sticky/IO */
}

#main-content.ready {
    opacity: 1;
}


/* ═══════════════════════════════════════════════════════════════
   ERROR MESSAGE
═══════════════════════════════════════════════════════════════ */

#error-message {
    display: none;
    z-index: 10000;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: var(--font-primary);
}

#error-message.show {
    display: block;
    animation: slideDown 0.3s ease;
}

#error-message.visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

#error-message button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 12px;
    transition: background 0.3s ease;
    font-family: inherit;
    font-size: 14px;
}

#error-message button:hover {
    background: rgba(255, 255, 255, 0.3);
}


/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY HELPERS
   Kept here as these are index.html specific — not in main.css
═══════════════════════════════════════════════════════════════ */

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 10px;
    background: var(--primary-orange, #FF5722);
    color: var(--text-white, #fff);
    padding: 10px 15px;
    border-radius: 5px;
    z-index: 10001;
    transition: top 0.3s ease;
    font-weight: 600;
    text-decoration: none;
    font-family: var(--font-primary);
    font-size: 14px;
}

.skip-to-content:focus {
    top: 10px;
    box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.5);
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* ═══════════════════════════════════════════════════════════════
   INTERSECTION OBSERVER ANIMATION HELPERS
   Generic utility classes used by index.js observer
═══════════════════════════════════════════════════════════════ */

.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.slide-in-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.slide-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.slide-in-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.slide-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.scale-in {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.scale-in.visible {
    opacity: 1;
    transform: scale(1);
}

.rotate-in {
    opacity: 0;
    transform: rotate(10deg) scale(0.8);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.rotate-in.visible {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}


/* ═══════════════════════════════════════════════════════════════
   LOADING PLACEHOLDER SKELETONS
   Used while template sections are being fetched
═══════════════════════════════════════════════════════════════ */

.content-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loadingShimmer 2s infinite;
    border-radius: 8px;
    height: 20px;
    margin-bottom: 12px;
}

.content-loading.title { height: 32px; width: 60%; margin-bottom: 16px; }
.content-loading.text  { height: 16px; width: 80%; margin-bottom: 8px;  }
.content-loading.text:last-child { width: 40%; }

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

.template-loading {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid var(--border-secondary);
}

.template-loading::after {
    content: 'Loading...';
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-primary);
    font-size: 14px;
}

.template-fallback {
    padding: 40px 20px;
    text-align: center;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-primary);
    border-radius: 12px;
    margin: 20px;
    font-family: var(--font-primary);
}

.template-fallback h2 {
    color: var(--primary-orange);
    margin-bottom: 16px;
    font-size: 24px;
    font-weight: 600;
}

.template-fallback p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.5;
}

.template-fallback button {
    background: var(--primary-orange);
    color: var(--text-white);
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.3s ease;
}

.template-fallback button:hover {
    background: var(--color-gold-dark);
    transform: translateY(-2px);
}


/* ═══════════════════════════════════════════════════════════════
   WBU SECTION — IntersectionObserver compat fix
   Prevents contain:style on #main-content from breaking the
   slide-right / slide-left animations in template-why-book-with-us
═══════════════════════════════════════════════════════════════ */

#why-book-with-us-container [data-wbu-animate="slide-right"],
#why-book-with-us-container [data-wbu-animate="slide-left"] {
    contain: none;
}


/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION
═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    #loading-overlay::before,
    #loading-overlay::after,
    .loading-logo,
    .fade-in,
    .slide-in-left,
    .slide-in-right,
    .scale-in,
    .rotate-in {
        animation: none !important;
        transition: none !important;
    }

    #main-content {
        opacity: 1;
        transition: none;
    }
}


/* ═══════════════════════════════════════════════════════════════
   HIGH CONTRAST
═══════════════════════════════════════════════════════════════ */

@media (prefers-contrast: high) {
    #loading-overlay {
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: none;
        border: 2px solid #000;
    }

    .loading-logo {
        animation: none !important;
    }

    #error-message {
        border: 2px solid #000;
    }

    .template-fallback {
        border-color: #000;
        border-width: 2px;
    }

    .skip-to-content {
        border: 2px solid #000;
    }
}


/* ═══════════════════════════════════════════════════════════════
   DARK MODE — overlay only
═══════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    #loading-overlay {
        background: radial-gradient(120% 120% at 50% 0%, #1a1a2e 0%, #16213e 45%, #0f3460 100%);
    }
}


/* ═══════════════════════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════════════════════ */

@media print {
    #loading-overlay,
    #error-message {
        display: none !important;
    }

    #main-content {
        opacity: 1 !important;
    }
}
