/* 
 * Cinematic Hero Styles (Unified Canvas)
 * Rizal Standard Academy Landing Page
 */

:root {
    --hero-navy-dark: #07122b;
    --hero-navy-mid: #0d1e40;
    --hero-gold: #c5a85d;
    --hero-text: #ffffff;
    --hero-text-dim: rgba(255, 255, 255, 0.85);
    
    /* CSS Variables for Overlay Brightness - Re-tuned for group photo contrast */
    --hero-overlay-start: rgba(7, 18, 43, 0.85); /* 85% deep navy behind text on left */
    --hero-overlay-mid: rgba(7, 18, 43, 0.52);   /* Smooth transition at 55% */
    --hero-overlay-end: rgba(7, 18, 43, 0.15);   /* Fades to 15% to let alumni faces pop on right */
}

.cinematic-hero {
    position: relative;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--hero-navy-dark);
    overflow: hidden;
    display: flex;
    align-items: center;
    color: var(--hero-text);
    padding-top: var(--header-h, 80px); /* Offset for navbar */
    z-index: 1;
}

/* --- 1. UNIFIED BACKGROUND --- */
.ch-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(circle at 60% 50%, rgba(13, 27, 75, 0.4) 0%, transparent 80%);
}
.ch-bg__glow {
    position: absolute;
    top: 50%;
    left: 55%;
    width: 90vmin;
    height: 90vmin;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(235, 175, 55, 0.15) 0%, rgba(197, 168, 93, 0.05) 40%, transparent 70%); /* Warmer amber/gold glow */
    opacity: 0;
    animation: chFadeIn 2s ease forwards 0.3s;
}
.ch-bg__rings {
    position: absolute;
    top: 50%;
    left: 55%;
    width: 80vmin;
    height: 80vmin;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(197, 168, 93, 0.04);
    box-shadow: 0 0 40px rgba(197, 168, 93, 0.02) inset;
    opacity: 0;
    animation: chFadeIn 3s ease forwards 0.3s;
}
.ch-bg__grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: 0;
    animation: chFadeIn 2s ease forwards 0.3s;
}

/* --- 2. FOREGROUND TEXT --- */
.ch-content {
    position: relative;
    z-index: 20;
    width: 100%;
    display: flex;
    justify-content: flex-start;
}
.ch-text {
    max-width: 550px;
}
.ch-eyebrow {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--hero-gold);
    margin-bottom: 1.25rem;
    opacity: 0;
    animation: chFadeInUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.8s;
}
.ch-headline {
    font-size: clamp(2.2rem, 5.5vw, 4rem);
    line-height: 1.12;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    overflow-wrap: break-word;
    word-break: break-word;
}
.ch-headline-part-1 {
    display: inline-block;
    opacity: 0;
    animation: chFadeInUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.9s;
}
.ch-headline-part-2 {
    display: inline-block;
    opacity: 0;
    animation: chFadeInUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 1.0s;
    color: var(--hero-gold);
}
.ch-desc {
    font-size: 1.15rem;
    line-height: 1.6;
    font-weight: 500;
    color: var(--hero-text-dim);
    margin-bottom: 2.5rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    opacity: 0;
    animation: chFadeInUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 1.1s;
    max-width: 450px;
}
.ch-actions {
    display: flex;
    gap: 1rem;
    opacity: 0;
    animation: chFadeInUp 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 1.2s;
}

/* --- 3. REVEAL ZONE (SLIDESHOW) --- */
.ch-reveal-zone {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0;
    pointer-events: none;
}
.is-animating .ch-reveal-zone {
    animation: chImageReveal 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards 2.9s;
}

.ch-slideshow {
    position: absolute;
    inset: 0;
    background-color: var(--hero-navy-dark);
    /* Very soft mask to avoid heavy dark corners */
    mask-image: radial-gradient(circle at 65% 50%, black 0%, rgba(0,0,0,0.9) 60%, transparent 100%);
    -webkit-mask-image: radial-gradient(circle at 65% 50%, black 0%, rgba(0,0,0,0.9) 60%, transparent 100%);
}
.ch-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 38%; /* Keeps group photo faces uncropped */
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0;
    transform: scale(1);
    transition: opacity 1.2s ease, transform 1.2s ease;
    filter: brightness(1.02) saturate(1.06); /* Natural warm lighting */
}
.ch-slide.active {
    opacity: 1; /* Full opacity to let colors pop */
    transform: scale(1.05); /* Slow Ken Burns effect */
    transition: opacity 1.2s ease, transform 12s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .ch-slide, .ch-slide.active {
        transform: scale(1);
        transition: opacity 1.2s ease;
    }
}

.ch-slideshow-overlay {
    position: absolute;
    inset: 0;
    /* Ensure text is always readable using customizable variables */
    background: linear-gradient(90deg, var(--hero-overlay-start) 0%, var(--hero-overlay-start) 28%, var(--hero-overlay-mid, rgba(7,18,43,0.52)) 55%, var(--hero-overlay-end) 90%, transparent 100%);
    pointer-events: none;
}

.ch-slide-info {
    position: absolute;
    bottom: 15%;
    right: 15%;
    text-align: right;
    opacity: 0;
    transition: opacity 1s ease 4.5s;
    z-index: 10;
}
.is-animating .ch-slide-info {
    opacity: 1;
}
.ch-slide-count {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--hero-gold);
    margin-bottom: 0.4rem;
}
.ch-slide-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.75rem;
    font-style: italic;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.ch-slide-progress-bar {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin-top: 12px;
    border-radius: 2px;
    overflow: hidden;
}
.ch-slide-progress-fill {
    height: 100%;
    background: var(--hero-gold);
    width: 0%;
    transition: width 0.1s linear;
}

/* --- 4. THE LOGO AS A WINDOW --- */
.ch-logo-container {
    position: absolute;
    top: 50%;
    left: 62%; /* Moved slightly more to the right */
    width: 280px; /* Ensure it's visually important but elegant */
    height: 280px;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 10;
    opacity: 0;
    animation: chLogoSettle 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards 0.5s;
    /* Subtle depth/shadow to make it look premium */
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.6)) drop-shadow(0 0 20px rgba(197, 168, 93, 0.15));
    pointer-events: none; /* Prevent blocking clicks after it fades out */
}

.ch-logo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
    border-radius: 50%;
}
.ch-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%; 
}

/* Perfect 45-degree diagonal split */
.ch-logo--top {
    clip-path: polygon(-5% -5%, 105% -5%, -5% 105%);
}
.ch-logo--bottom {
    clip-path: polygon(105% -5%, 105% 105%, -5% 105%);
}

/* The Split Animation */
.is-animating .ch-logo--top {
    animation: chSplitTop 1.6s cubic-bezier(0.22, 1, 0.36, 1) forwards 2.5s;
}
.is-animating .ch-logo--bottom {
    animation: chSplitBottom 1.6s cubic-bezier(0.22, 1, 0.36, 1) forwards 2.5s;
}

/* --- KEYFRAMES --- */
@keyframes chFadeIn {
    to { opacity: 1; }
}
@keyframes chFadeInUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes chLogoSettle {
    from { transform: translate(-50%, -50%) scale(1.05); opacity: 0; filter: blur(5px); }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0px); }
}
@keyframes chSplitTop {
    0% { transform: translate(0, 0); opacity: 1; }
    40% { transform: translate(-12px, -12px); opacity: 1; } /* Separation before fade */
    100% { transform: translate(-20px, -20px); opacity: 0; } /* Fully fades out */
}
@keyframes chSplitBottom {
    0% { transform: translate(0, 0); opacity: 1; }
    40% { transform: translate(12px, 12px); opacity: 1; }
    100% { transform: translate(20px, 20px); opacity: 0; }
}
@keyframes chImageReveal {
    0% { opacity: 0; transform: scale(0.98) translate(-10px, -10px); filter: brightness(0.8); }
    100% { opacity: 1; transform: scale(1) translate(0, 0); filter: brightness(1); }
}

/* --- PLACEHOLDER GRIDS (Unchanged) --- */
.stories-grid, .gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: clamp(1.25rem, 3vw, 2rem);
    margin-top: 3rem;
}
.story-card {
    background: var(--surface-color, #ffffff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid rgba(13,27,75,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.story-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.story-image-box {
    width: 100%;
    aspect-ratio: 16/9;
    background: #f3f7ff;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(13,27,75,0.05);
}
.story-no-image {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: rgba(13,27,75,0.2);
}
.story-no-image svg {
    width: 48px;
    height: 48px;
}
.story-carousel {
    width: 100%;
    height: 100%;
    position: relative;
}
.carousel-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}
/* 1 Image: Always visible */
.carousel-img.count-1 {
    opacity: 1;
}
/* 2 Images: Fade animation (8s cycle) */
@keyframes fadeTwo {
    0%, 45% { opacity: 1; }
    50%, 95% { opacity: 0; }
    100% { opacity: 1; }
}
.carousel-img.count-2.img-1 { animation: fadeTwo 8s infinite; }
.carousel-img.count-2.img-2 { animation: fadeTwo 8s infinite -4s; }

/* 3 Images: Fade animation (12s cycle) */
@keyframes fadeThree {
    0%, 28% { opacity: 1; }
    33%, 95% { opacity: 0; }
    100% { opacity: 1; }
}
.carousel-img.count-3.img-1 { animation: fadeThree 12s infinite; }
.carousel-img.count-3.img-2 { animation: fadeThree 12s infinite -8s; }
.carousel-img.count-3.img-3 { animation: fadeThree 12s infinite -4s; }

.story-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.story-quote {
    font-size: 1rem;
    font-style: italic;
    color: var(--text-main, #374151);
    margin: 0 0 1.25rem 0;
    line-height: 1.5;
    word-break: break-word;
}
.story-author-modern {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(13,27,75,0.06);
}
.story-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(13,27,75,0.1);
}
.story-author-text {
    text-align: left;
}
.story-author-text strong {
    display: block;
    color: var(--hero-navy-mid);
    font-size: 0.95rem;
    line-height: 1.2;
}
.story-author-text span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light, #6b7280);
    margin-top: 0.15rem;
}
.gallery-item {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    aspect-ratio: 4/3;
    position: relative;
    background-color: #f8fafc;
    border: 1px solid rgba(13,27,75,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.gallery-img-wrap {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}
.gallery-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gallery-item:hover .gallery-img-wrap img:not(.img-error) {
    transform: scale(1.03);
}
.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.25rem 1.25rem;
    background: linear-gradient(to top, rgba(13,27,75,0.8) 0%, transparent 100%);
    color: white;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.gallery-item:hover .gallery-caption {
    opacity: 1;
    transform: translateY(0);
}
.gallery-caption-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    font-family: 'Cormorant Garamond', serif;
}

/* Error State UI */
.has-error img {
    opacity: 0 !important;
}
.gallery-error-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #94a3b8;
    background: #f1f5f9;
    opacity: 0;
    pointer-events: none;
}
.has-error .gallery-error-state {
    opacity: 1;
}
.gallery-error-state i {
    width: 32px;
    height: 32px;
}
.gallery-error-state span {
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .ch-logo-container { width: 220px; height: 220px; left: 62%; }
    .ch-headline { font-size: clamp(2.4rem, 4.5vw, 3.2rem); }
    .ch-text { max-width: 440px; }
}

@media (max-width: 768px) {
    .cinematic-hero {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        padding-top: calc(var(--header-h, 72px) + 1.5rem);
        padding-bottom: 3rem;
        min-height: 100vh;
        min-height: 100dvh;
    }
    .ch-content { 
        justify-content: center; 
        margin-top: 0; 
        padding: 0 1rem;
    }
    .ch-text { 
        max-width: 100%; 
        display: flex; 
        flex-direction: column; 
        align-items: center; 
    }
    .ch-eyebrow {
        font-size: 0.8rem;
        letter-spacing: 3px;
        margin-bottom: 0.75rem;
    }
    .ch-headline {
        font-size: clamp(1.85rem, 6.5vw, 2.75rem);
        line-height: 1.15;
        margin-bottom: 1rem;
    }
    .ch-desc {
        font-size: clamp(0.95rem, 3.2vw, 1.1rem);
        margin-bottom: 1.75rem;
        max-width: 400px;
    }
    .ch-actions { 
        flex-direction: column; 
        width: 100%; 
        max-width: 320px; 
        gap: 0.75rem;
    }
    .ch-actions .btn-primary,
    .ch-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
    .ch-logo-container { 
        top: 50%; 
        left: 50%; 
        width: clamp(160px, 35vw, 210px); 
        height: clamp(160px, 35vw, 210px); 
        opacity: 0.25;
        filter: drop-shadow(0 10px 25px rgba(0,0,0,0.5));
    }
    .ch-slide {
        object-position: center 32%; /* Preserves faces on narrow mobile screens */
    }
    .ch-slideshow {
        mask-image: none;
        -webkit-mask-image: none;
    }
    .ch-slideshow-overlay {
        background: linear-gradient(180deg, rgba(7, 18, 43, 0.88) 0%, rgba(7, 18, 43, 0.72) 48%, rgba(7, 18, 43, 0.92) 100%);
    }
    .ch-slide-info { 
        bottom: clamp(0.5rem, 2vh, 1.25rem); 
        right: 1rem; 
        text-align: right; 
        transform: none; 
        max-width: 60%;
        pointer-events: none;
    }
    .ch-slide-count {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }
    .ch-slide-title {
        font-size: clamp(0.95rem, 3vw, 1.25rem);
    }
    .ch-slide-progress-bar {
        margin-top: 6px;
    }
}

@media (max-width: 480px) {
    .ch-actions {
        max-width: 100%;
    }
    .ch-actions .btn-primary,
    .ch-actions .btn-secondary {
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .cinematic-hero {
        min-height: auto;
        padding-top: calc(var(--header-h, 60px) + 1rem);
        padding-bottom: 2rem;
    }
    .ch-content {
        margin-top: 0;
    }
    .ch-logo-container {
        display: none;
    }
    .ch-headline {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }
    .ch-desc {
        margin-bottom: 1rem;
    }
    .ch-actions {
        flex-direction: row;
        max-width: 100%;
    }
}
