/**
 * Zeal Ad Manager
 *
 * This file contains the styles and animations for the "Animated Ad" format.
 */

/**
 * TABLE OF CONTENTS
 * --------------------------------------------------------------------------
 * 1.0 - Base Animated Ad Styles & Layout
 * 2.0 - Dimension-Specific Adjustments
 * 3.0 - Animation Trigger Logic
 * 3.1 - Template 1: Classic Slide
 * 3.2 - Template 2: Focus Zoom
 * 3.3 - Template 3: Text Spotlight
 * 3.4 - Template 4: Cinematic Ken Burns
 * 3.5 - Template 5: Image Reveal
 * 3.6 - Template 6: Glitch & Decode
 * 4.0 - Keyframe Definitions
 * --------------------------------------------------------------------------
 */


/* --- 1.0 - Base Animated Ad Styles & Layout --- */
.zam-anim-ad-unit {
    position: relative;
    overflow: hidden;
    background: #ddd;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

.zam-anim-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), filter 0.4s ease;
    z-index: 1;
}

.zam-anim-content {
    position: relative;
    z-index: 2;
    padding: 20px;
    flex-grow: 1; /* Allow content to fill available space */
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
}

.zam-anim-logo-wrapper {
    text-align: center;
    margin-bottom: 10px;
    opacity: 0;
}

.zam-anim-logo {
    max-width: 120px;
    max-height: 40px;
    display: inline-block;
}

.zam-anim-headline,
.zam-anim-description,
.zam-anim-button {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    margin: 0;
    opacity: 0;
}

.zam-anim-headline {
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.5px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zam-anim-description {
    line-height: 1.5;
    margin-top: 8px;
    font-weight: 400;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zam-anim-button {
    position: absolute;
    z-index: 3;
    padding: 12px;
    width: 80%;
    left: 10%;
    bottom: 10px;
    text-align: center;
    font-weight: 600;
    border-radius: 6px;
    background-color: #4A90E2;
    box-sizing: border-box;
}


/* --- 2.0 - Dimension-Specific Adjustments --- */

/* Default: Spotlight (300x250) */
.zam-anim-ad-unit.is-spotlight {
    width: 300px;
    height: 250px;
}
.is-spotlight .zam-anim-headline { font-size: 26px; }
.is-spotlight .zam-anim-description { font-size: 14px; }
.is-spotlight .zam-anim-button {
    bottom: 20px;
    left: 20px;
    right: 20px;
    width: auto;
}

/* Portrait (300x500) */
.zam-anim-ad-unit.is-portrait {
    width: 300px;
    height: 500px;
}
.is-portrait .zam-anim-content { justify-content: flex-end; padding-bottom: 100px; }
.is-portrait .zam-anim-headline { font-size: 32px; -webkit-line-clamp: 2; }
.is-portrait .zam-anim-description { font-size: 16px; -webkit-line-clamp: 3; margin-top: 15px;}
.is-portrait .zam-anim-button {
    bottom: 30px;
    left: 30px;
    right: 30px;
    width: auto;
}
.is-portrait .zam-anim-focus-zoom .zam-anim-content,
.is-portrait .zam-anim-text-spotlight .zam-anim-content {
    justify-content: center;
    padding-bottom: 20px;
}

/* Banner (728x90) */
.zam-anim-ad-unit.is-banner {
    width: 728px;
    height: 90px;
    max-width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 0 15px;
}
.is-banner .zam-anim-content {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    flex-grow: 1;
}
.is-banner .zam-anim-logo-wrapper {
    margin: 0 20px 0 0;
    flex-shrink: 0;
}
.is-banner .zam-anim-logo { max-height: 50px; }
.is-banner .zam-anim-text-container { flex-grow: 1; }
.is-banner .zam-anim-headline { font-size: 22px; text-align: left; }
.is-banner .zam-anim-description { font-size: 14px; margin-top: 2px; text-align: left; }
.is-banner .zam-anim-button {
    margin-top: 20px;
    width: 150px;
    position: static;
    margin-left: 30px;
    padding: 10px 25px;
    white-space: nowrap;
    flex-shrink: 0;
    opacity: 0;
}
.is-banner .zam-anim-text-spotlight .zam-anim-headline,
.is-banner .zam-anim-text-spotlight .zam-anim-description {
    text-align: left;
}


/* --- 3.0 - Animation Trigger Logic --- */

/* 3.1 - Template 1: Classic Slide */
.zam-is-animating.zam-anim-classic-slide .zam-anim-headline {
    animation: zam-slide-in-left 6.0s cubic-bezier(0.2, 0.8, 0.2, 1) 1.0s infinite forwards;
}
.zam-is-animating.zam-anim-classic-slide .zam-anim-description {
    animation: zam-slide-in-right 6.0s cubic-bezier(0.2, 0.8, 0.2, 1) 2.0s infinite forwards;
}
.zam-is-animating.zam-anim-classic-slide .zam-anim-button {
    animation: zam-slide-in-bottom 5.0s cubic-bezier(0.2, 0.8, 0.2, 1) 3.0s infinite forwards;
}

/* 3.2 - Template 2: Focus Zoom */
.zam-is-animating.zam-anim-focus-zoom .zam-anim-background {
    animation: zam-slow-zoom 50.0s ease-in-out infinite alternate;
}
.zam-is-animating.zam-anim-focus-zoom .zam-anim-logo-wrapper {
    animation: zam-fade-in 7.5s ease 1.0s infinite forwards;
}
.zam-is-animating.zam-anim-focus-zoom .zam-anim-headline {
    animation: zam-slide-in-bottom 6.0s ease 2.5s infinite forwards;
}
.zam-is-animating.zam-anim-focus-zoom .zam-anim-description {
    display: none;
}
.zam-is-animating.zam-anim-focus-zoom .zam-anim-button {
    animation: zam-fade-in 7.5s ease 4.0s infinite forwards;
}

/* 3.3 - Template 3: Text Spotlight */
.zam-is-animating.zam-anim-text-spotlight .zam-anim-background {
    filter: brightness(0.6) blur(2px);
}
.zam-is-animating.zam-anim-text-spotlight .zam-anim-background::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%; width: 1px; height: 1px;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    animation: zam-light-reveal 20.0s ease-out infinite;
}
.zam-is-animating.zam-anim-text-spotlight .zam-anim-headline {
    animation: zam-fade-blur-in 7.5s ease 3.0s infinite forwards;
}
.zam-is-animating.zam-anim-text-spotlight .zam-anim-description {
    animation: zam-fade-blur-in 7.5s ease 4.0s infinite forwards;
}
.zam-is-animating.zam-anim-text-spotlight .zam-anim-button {
    animation: zam-fade-scale-in 6.0s ease 5.5s infinite forwards;
}

/* 3.4 - Template 4: Cinematic Ken Burns */
.zam-is-animating.zam-anim-ken-burns .zam-anim-background {
    animation: zam-ken-burns 12s ease-in-out infinite alternate;
}
.zam-is-animating.zam-anim-ken-burns .zam-anim-logo-wrapper {
    animation: zam-ken-burns-fade-up 8s ease 1s infinite forwards;
}
.zam-is-animating.zam-anim-ken-burns .zam-anim-headline {
    animation: zam-ken-burns-fade-up 8s ease 1.5s infinite forwards;
}
.zam-is-animating.zam-anim-ken-burns .zam-anim-description {
    animation: zam-ken-burns-fade-up 8s ease 2s infinite forwards;
}
.zam-is-animating.zam-anim-ken-burns .zam-anim-button {
    animation: zam-ken-burns-fade-up 8s ease 2.5s infinite forwards;
}

/* 3.5 - Template 5: Image Reveal (Enhanced) */
.zam-anim-image-reveal .zam-anim-background-after {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 2;
    clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
}
.zam-anim-image-reveal .zam-anim-content,
.zam-anim-image-reveal .zam-anim-button {
    z-index: 3;
}
.zam-is-animating.zam-anim-image-reveal .zam-anim-background-after {
    animation: zam-diagonal-wipe 7s ease-in-out 1s infinite;
}
.zam-is-animating.zam-anim-image-reveal .zam-anim-headline {
    animation: zam-reveal-text-anim 7s ease 1.5s infinite forwards;
}
.zam-is-animating.zam-anim-image-reveal .zam-anim-description {
    animation: zam-reveal-text-anim 7s ease 1.8s infinite forwards;
}
.zam-is-animating.zam-anim-image-reveal .zam-anim-button {
    animation: zam-reveal-text-anim 7s ease 2.1s infinite forwards;
}

/* 3.6 - Template 6: Glitch & Decode */
.zam-anim-glitch-decode::before,
.zam-anim-glitch-decode::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    z-index: 5;
    opacity: 0;
}
.zam-is-animating.zam-anim-glitch-decode {
    animation: zam-glitch-main 4s steps(1, end) infinite;
}
.zam-is-animating.zam-anim-glitch-decode::before {
    animation: zam-glitch-sub 4s steps(1, end) infinite;
    background-color: #ff00c1;
    mix-blend-mode: screen;
}
.zam-is-animating.zam-anim-glitch-decode::after {
    animation: zam-glitch-sub 4s steps(1, end) infinite reverse;
    background-color: #00ffc1;
    mix-blend-mode: screen;
}
.zam-anim-glitch-decode .zam-anim-headline,
.zam-anim-glitch-decode .zam-anim-description {
    opacity: 1; /* Override base opacity for JS control */
    transition: opacity 0.3s ease;
}
.zam-is-animating.zam-anim-glitch-decode .zam-anim-button {
    animation: zam-fade-in 4s ease 1.5s infinite forwards;
}


/* --- 4.0 - Keyframe Definitions --- */

@keyframes zam-fade-in {
    0%, 20%, 100% { opacity: 0; }
    50%, 80% { opacity: 1; }
}

@keyframes zam-slide-in-bottom {
    0%, 20%, 100% { opacity: 0; transform: translateY(25px); }
    50%, 80% { opacity: 1; transform: translateY(0); }
}

@keyframes zam-slide-in-left {
    0%, 20%, 100% { opacity: 0; transform: translateX(-25px); }
    50%, 80% { opacity: 1; transform: translateX(0); }
}

@keyframes zam-slide-in-right {
    0%, 20%, 100% { opacity: 0; transform: translateX(25px); }
    50%, 80% { opacity: 1; transform: translateX(0); }
}

@keyframes zam-slow-zoom {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

@keyframes zam-light-reveal {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(500); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

@keyframes zam-fade-scale-in {
    0%, 20%, 100% { opacity: 0; transform: scale(0.9); }
    50%, 80% { opacity: 1; transform: scale(1); }
}

@keyframes zam-fade-blur-in {
    0%, 20%, 100% { opacity: 0; filter: blur(8px); transform: scale(0.95); }
    50%, 80% { opacity: 1; filter: blur(0); transform: scale(1); }
}

@keyframes zam-ken-burns {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.15) translate(-3%, 2%); }
}

@keyframes zam-ken-burns-fade-up {
    0%, 15%, 85%, 100% { opacity: 0; transform: translateY(10px); }
    30%, 70% { opacity: 1; transform: translateY(0); }
}

@keyframes zam-diagonal-wipe {
    0% { clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); }
    40%, 60% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
    100% { clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%); }
}

@keyframes zam-reveal-text-anim {
    0%, 30%, 100% { opacity: 0; transform: translateY(15px); }
    50%, 80% { opacity: 1; transform: translateY(0); }
}

@keyframes zam-glitch-main {
    0% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
    2% { clip-path: polygon(0 42%, 100% 42%, 100% 55%, 0 55%); }
    4% { clip-path: polygon(0 22%, 100% 22%, 100% 95%, 0 95%); }
    6% { clip-path: polygon(0 77%, 100% 77%, 100% 82%, 0 82%); }
    8%, 100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
}

@keyframes zam-glitch-sub {
    0%, 100% { opacity: 1; transform: translateX(0); }
    2% { opacity: 1; transform: translateX(10px); }
    4% { opacity: 0.3; transform: translateX(-10px); }
    6% { opacity: 1; transform: translateX(5px); }
    8% { opacity: 0.5; transform: translateX(-2px); }
}