/* ========================================
   hanun.ai - Cinematic Reverie
   ======================================== */

:root {
    --linen-white: #F5F0E8;
    --parchment-warm: #EDE4D3;
    --charcoal-noir: #1C1A17;
    --warm-graphite: #4A4640;
    --amber-celluloid: #C6923A;
    --slate-twilight: #4A6178;
    --dusk-violet: #6B5B7B;
    --grain-sepia: #B8A88A;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--linen-white);
    color: var(--charcoal-noir);
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
    filter: saturate(0.85);
}

/* --- Film Grain --- */
.film-grain {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.035;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    background-size: 512px 512px;
    animation: grain 120ms steps(3) infinite;
}

@keyframes grain {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-10%, -10%); }
    66% { transform: translate(5%, -15%); }
}

/* --- Grid Overlay --- */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 2s ease;
    background-image:
        repeating-linear-gradient(
            90deg,
            rgba(184, 168, 138, 0.08) 0px,
            rgba(184, 168, 138, 0.08) 1px,
            transparent 1px,
            transparent calc(100% / 12)
        ),
        repeating-linear-gradient(
            0deg,
            rgba(184, 168, 138, 0.05) 0px,
            rgba(184, 168, 138, 0.05) 1px,
            transparent 1px,
            transparent 64px
        );
}

.grid-overlay.visible {
    opacity: 1;
}

/* --- Typography --- */
h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(4rem, 15vw, 12rem);
    letter-spacing: 0.06em;
    line-height: 1.1;
    text-transform: uppercase;
    color: var(--charcoal-noir);
}

h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    letter-spacing: 0.06em;
    line-height: 1.25;
    text-transform: uppercase;
    color: var(--charcoal-noir);
}

h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
    margin-bottom: 0.75rem;
    color: var(--charcoal-noir);
}

p {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.015em;
    margin-bottom: 1.5rem;
    color: var(--charcoal-noir);
}

/* --- Scenes --- */
.scene {
    position: relative;
    overflow: hidden;
}

.scene-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.scene-content {
    position: relative;
    z-index: 2;
}

/* --- Scene 1: Opening --- */
.scene-opening {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--linen-white);
}

.opening-bg {
    background:
        radial-gradient(ellipse at 70% 30%, rgba(198, 146, 58, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 30% 70%, rgba(107, 91, 123, 0.04) 0%, transparent 50%),
        var(--linen-white);
}

.scene-opening .scene-content {
    text-align: center;
}

.title-stagger {
    display: inline-flex;
    overflow: hidden;
}

.char {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
    animation: charReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.char:nth-child(1) { animation-delay: 0.3s; }
.char:nth-child(2) { animation-delay: 0.36s; }
.char:nth-child(3) { animation-delay: 0.42s; }
.char:nth-child(4) { animation-delay: 0.48s; }
.char:nth-child(5) { animation-delay: 0.54s; }
.char:nth-child(6) { animation-delay: 0.60s; }
.char:nth-child(7) { animation-delay: 0.66s; }
.char:nth-child(8) { animation-delay: 0.72s; }

.char.dot {
    color: var(--amber-celluloid);
}

@keyframes charReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.foreground-meta {
    margin-top: 2rem;
}

.meta-rule {
    border: none;
    height: 1px;
    background: var(--amber-celluloid);
    opacity: 0.3;
    width: 60px;
    margin: 0 auto 1rem;
}

.meta-stamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-graphite);
    opacity: 0.5;
}

/* --- Scene 2: Establishing --- */
.scene-establishing {
    min-height: 120vh;
    padding: 10vh clamp(2rem, 8vw, 6rem);
    background: var(--linen-white);
}

.establishing-bg {
    background:
        radial-gradient(ellipse at 80% 50%, rgba(198, 146, 58, 0.05) 0%, transparent 50%),
        var(--parchment-warm);
    opacity: 0.4;
}

.establishing-content {
    max-width: 38ch;
    padding-top: 10vh;
}

.establishing-content p {
    color: var(--charcoal-noir);
}

.scene-annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--grain-sepia);
    opacity: 0.4;
    display: block;
    margin-top: 2rem;
}

/* --- Scene 3: Close-up --- */
.scene-closeup {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--parchment-warm);
}

.closeup-bg {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(237, 228, 211, 0.8) 0%, transparent 70%),
        var(--parchment-warm);
}

.statement {
    font-size: clamp(4rem, 9vw, 10rem);
    letter-spacing: 0.15em;
    text-align: center;
    line-height: 1.05;
}

/* --- Scene 4: Montage --- */
.scene-montage {
    min-height: 150vh;
    padding: 10vh clamp(2rem, 6vw, 5rem);
    background: var(--linen-white);
}

.montage-bg {
    background: var(--linen-white);
}

.montage-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(1.5rem, 3vw, 3rem);
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.montage-card {
    background: var(--parchment-warm);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    border-radius: 2px;
    box-shadow: 0 8px 32px rgba(107, 91, 123, 0.08);
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.montage-card p {
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: var(--warm-graphite);
}

.card-wide {
    grid-column: span 2;
}

.card-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--grain-sepia);
    opacity: 0.5;
    display: block;
    margin-top: 0.5rem;
}

/* --- Scene 5: Fade --- */
.scene-fade {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--charcoal-noir);
    padding: 2rem;
}

.fade-content {
    text-align: center;
    max-width: 50ch;
}

.fade-text {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--linen-white);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.fade-rule {
    border: none;
    height: 1px;
    background: var(--amber-celluloid);
    opacity: 0.3;
    width: 120px;
    margin: 0 auto 2rem;
}

.fade-cursor {
    width: 2px;
    height: 20px;
    background: var(--amber-celluloid);
    margin: 0 auto;
    animation: cursorPulse 3s ease-in-out infinite;
}

@keyframes cursorPulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.6; }
}

/* --- Reveal: Dissolve --- */
[data-reveal="dissolve"] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal="dissolve"].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Reveal: Wipe --- */
[data-reveal="wipe"] {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 1.2s cubic-bezier(0.77, 0, 0.175, 1);
}

[data-reveal="wipe"].revealed {
    clip-path: inset(0 0 0 0);
}

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

    [data-reveal="dissolve"],
    [data-reveal="wipe"] {
        opacity: 1;
        transform: none;
        clip-path: none;
    }

    .char {
        opacity: 1;
        transform: none;
    }

    .film-grain {
        display: none;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .montage-grid {
        grid-template-columns: 1fr;
    }

    .card-wide {
        grid-column: span 1;
    }

    .establishing-content {
        max-width: 90vw;
    }
}
