/*
 * index.css  Homepage-specific styles
 * SSP TOURS  v2.0 (Emerald Daylight, white theme)
 * All colours from main.css v7.1 tokens, no hex fallbacks.
 *
 * 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
   White splash with the logo in a silver ring and a thin gold rule
   that fills while the page loads.
═══════════════════════════════════════════════════════════════ */

#loading-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--bg-primary);
    z-index: 9999;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    opacity: 1;
    visibility: visible;
    overflow: hidden;
    isolation: isolate;
}

#loading-overlay::after {
    content: "";
    position: absolute;
    left: 50%;
    top: calc(50% + 78px);
    width: 120px;
    height: 2px;
    margin-left: -60px;
    border-radius: var(--radius-full);
    background: var(--sheen-gold);
    transform-origin: left;
    animation: overlayRule 1.6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes overlayRule {
    0%   { transform: scaleX(0); opacity: 1; }
    70%  { transform: scaleX(1); opacity: 1; }
    100% { transform: scaleX(1); opacity: 0; }
}

.loading-logo {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-primary);
    box-shadow: 0 0 0 6px var(--bg-primary), 0 0 0 7px var(--color-royal), var(--shadow-lg);
    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.04); opacity: 0.9; }
}

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


/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT — fade-in on page ready
   No contain property — it breaks position:sticky headers and
   IntersectionObserver measurements on mobile viewports.
   No background, no padding, no z-index — all governed by templates.
═══════════════════════════════════════════════════════════════ */

#main-content {
    visibility: hidden;
    min-height: 100vh;
}
#main-content.ready {
    visibility: visible;
}

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

#error-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--bg-primary);
    color: var(--color-error-text);
    padding: 12px 0;
    text-align: center;
    z-index: 10000;
    border-bottom: 3px solid var(--color-error);
    box-shadow: var(--shadow-lg);
    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 p {
    color: var(--color-error-text);
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.4;
}

#error-message button {
    background: var(--sheen-silver);
    border: 0;
    box-shadow: var(--shadow-royal);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.3s ease;
    font-family: inherit;
    font-size: 13px;
    /* Do not inherit width:100% from main.css mobile rule —
       this is a small inline action button, not a CTA */
    width: auto;
}

#error-message button:hover {
    background: var(--sheen-silver-hover);
}


/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY HELPERS
═══════════════════════════════════════════════════════════════ */

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 10px;
    background: var(--color-navy);
    color: var(--color-white);
    padding: 10px 15px;
    border-radius: var(--radius-md);
    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 var(--color-gold-glow);
    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.
   Pearl skeletons with a soft white sweep.
═══════════════════════════════════════════════════════════════ */

.content-loading {
    background: linear-gradient(90deg, var(--color-pearl) 25%, var(--color-pearl-deep) 50%, var(--color-pearl) 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(--color-pearl);
    border-radius: var(--radius-lg);
    margin: 20px 0;
    border: 1px solid var(--border-primary);
}

.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-primary);
    border: 2px dashed var(--border-gold);
    border-radius: var(--radius-xl);
    margin: 20px;
    font-family: var(--font-primary);
}

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

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

.template-fallback button {
    background: var(--sheen-emerald);
    color: var(--color-white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.3s ease;
    /* Override main.css mobile btn width — this is not a page CTA */
    width: auto;
}

.template-fallback button:hover {
    background: var(--sheen-emerald-hover);
    transform: translateY(-2px);
}


/* ═══════════════════════════════════════════════════════════════
   WBU SECTION — IntersectionObserver compat fix
   Ensures slide-right / slide-left animations are not clipped
   by any parent stacking context on mobile.
═══════════════════════════════════════════════════════════════ */

#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::after,
    .loading-logo,
    .fade-in,
    .slide-in-left,
    .slide-in-right,
    .scale-in,
    .rotate-in {
        animation: none !important;
        transition: none !important;
    }

    #main-content {
        visibility: visible;
        transition: none;
    }
}


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

@media (prefers-contrast: high) {
    #loading-overlay { border: 2px solid var(--text-primary); }
    .loading-logo { animation: none !important; box-shadow: 0 0 0 2px var(--text-primary); }
    #error-message { border: 2px solid var(--color-error-dark); }
    .template-fallback { border-color: var(--text-primary); border-width: 2px; }
    .skip-to-content { border: 2px solid var(--text-primary); }
}


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

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

    #main-content {
        visibility: visible !important;
    }
}
