/* Advanced Animated Text Widget - Frontend Styles */

/* Debug mode - empty state */
.aatw-container.aatw-empty {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ddd;
    background: #f9f9f9;
}

.aatw-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100px;
    overflow: visible;
}

/* Responsive container heights */
@media (max-width: 1024px) {
    .aatw-container {
        min-height: 80px;
    }
}

@media (max-width: 767px) {
    .aatw-container {
        min-height: 60px;
    }
}

.aatw-word {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
}

.aatw-word.active {
    opacity: 1;
    visibility: visible;
}

.aatw-word-text {
    position: relative;
    z-index: 2;
    display: inline-block;
}

.aatw-word-text {
    display: inline-block;
    position: relative;
}

/* Letter Animation Styles */
.aatw-word .aatw-letter {
    display: inline-block;
    position: relative;
    will-change: transform, opacity;
    transform-origin: center;
}

/* Initial state - letters hidden */
.aatw-word:not(.active) .aatw-letter {
    opacity: 0;
}

/* Active word - letters visible */
.aatw-word.active .aatw-letter {
    opacity: 1;
}

/* Keyframes for Odd Letters (Fall Down Entry) */
@keyframes letterFallDown {
    0% {
        opacity: 0;
        transform: translateY(-100px) rotateX(-90deg);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

/* Keyframes for Even Letters (Rise Up Entry) */
@keyframes letterRiseUp {
    0% {
        opacity: 0;
        transform: translateY(100px) rotateX(90deg);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

/* Keyframes for Odd Letters (Fall Down Exit) */
@keyframes letterExitDown {
    0% {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: translateY(100px) rotateX(90deg);
    }
}

/* Keyframes for Even Letters (Rise Up Exit) */
@keyframes letterExitUp {
    0% {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) rotateX(-90deg);
    }
}

/* ===========================================
   NEW ANIMATION TYPES
   =========================================== */

/* FADE Animation */
.aatw-word[data-current-animation="fade"].animating-in .aatw-letter {
    animation: letterFadeIn var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="fade"].animating-out .aatw-letter {
    animation: letterFadeOut var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes letterFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* SLIDE LEFT Animation */
.aatw-word[data-current-animation="slide-left"].animating-in .aatw-letter {
    animation: letterSlideInLeft var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="slide-left"].animating-out .aatw-letter {
    animation: letterSlideOutLeft var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes letterSlideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100px);
    }
}

/* SLIDE RIGHT Animation */
.aatw-word[data-current-animation="slide-right"].animating-in .aatw-letter {
    animation: letterSlideInRight var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="slide-right"].animating-out .aatw-letter {
    animation: letterSlideOutRight var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterSlideInRight {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes letterSlideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* SLIDE UP Animation */
.aatw-word[data-current-animation="slide-up"].animating-in .aatw-letter {
    animation: letterSlideInUp var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="slide-up"].animating-out .aatw-letter {
    animation: letterSlideOutUp var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterSlideInUp {
    from {
        opacity: 0;
        transform: translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* SLIDE DOWN Animation */
.aatw-word[data-current-animation="slide-down"].animating-in .aatw-letter {
    animation: letterSlideInDown var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="slide-down"].animating-out .aatw-letter {
    animation: letterSlideOutDown var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

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

@keyframes letterSlideOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(100px);
    }
}

/* ZOOM IN Animation */
.aatw-word[data-current-animation="zoom-in"].animating-in .aatw-letter {
    animation: letterZoomIn var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="zoom-in"].animating-out .aatw-letter {
    animation: letterZoomOut var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterZoomIn {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes letterZoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0);
    }
}

/* ZOOM OUT Animation */
.aatw-word[data-current-animation="zoom-out"].animating-in .aatw-letter {
    animation: letterZoomOutIn var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="zoom-out"].animating-out .aatw-letter {
    animation: letterZoomOutOut var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterZoomOutIn {
    from {
        opacity: 0;
        transform: scale(3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes letterZoomOutOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(3);
    }
}

/* ROTATE IN Animation */
.aatw-word[data-current-animation="rotate-in"].animating-in .aatw-letter {
    animation: letterRotateIn var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="rotate-in"].animating-out .aatw-letter {
    animation: letterRotateOut var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterRotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes letterRotateOut {
    from {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
    to {
        opacity: 0;
        transform: rotate(180deg) scale(0);
    }
}

/* FLIP Animation */
.aatw-word[data-current-animation="flip"].animating-in .aatw-letter {
    animation: letterFlipIn var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="flip"].animating-out .aatw-letter {
    animation: letterFlipOut var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterFlipIn {
    from {
        opacity: 0;
        transform: perspective(400px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
}

@keyframes letterFlipOut {
    from {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
    to {
        opacity: 0;
        transform: perspective(400px) rotateY(-90deg);
    }
}

/* BOUNCE Animation */
.aatw-word[data-current-animation="bounce"].animating-in .aatw-letter {
    animation: letterBounceIn var(--entry-duration) cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="bounce"].animating-out .aatw-letter {
    animation: letterBounceOut var(--exit-duration) cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
    animation-delay: var(--letter-delay);
}

@keyframes letterBounceIn {
    0% {
        opacity: 0;
        transform: scale(0) translateY(-50px);
    }
    50% {
        transform: scale(1.2) translateY(0);
    }
    70% {
        transform: scale(0.9) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes letterBounceOut {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    30% {
        transform: scale(1.1) translateY(-10px);
    }
    100% {
        opacity: 0;
        transform: scale(0) translateY(50px);
    }
}

/* FALL-RISE Animation (Original - kept for backward compatibility) */
.aatw-word[data-current-animation="fall-rise"].animating-in .aatw-letter.odd {
    animation: letterFallDown var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="fall-rise"].animating-in .aatw-letter.even {
    animation: letterRiseUp var(--entry-duration) ease-out forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="fall-rise"].animating-out .aatw-letter.odd {
    animation: letterExitDown var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

.aatw-word[data-current-animation="fall-rise"].animating-out .aatw-letter.even {
    animation: letterExitUp var(--exit-duration) ease-in forwards;
    animation-delay: var(--letter-delay);
}

/* Background styles - full width/height */
.aatw-word.has-background {
    /* ✅ background-position kaldırıldı - JavaScript tarafından kontrol edilecek */
    background-size: cover;
    background-repeat: no-repeat;
}

.aatw-word.has-background .aatw-word-text {
    padding: 20px 40px;
    border-radius: 8px;
}

/* Text mask option - SVG mask approach */
.aatw-word.use-text-mask {
    position: absolute; /* FIXED: absolute pozisyon korunmalı */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex; /* FIXED: flex display korunmalı */
    align-items: center;
    justify-content: center;
}

/* Hide default text when mask is active */
.aatw-word.use-text-mask .aatw-word-text {
    position: relative;
    z-index: 3;
    display: inline-block; /* FIXED: inline-block tutulmalı */
}

/* SVG mask container */
.aatw-word .aatw-svg-mask-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.aatw-word .aatw-svg-mask-container svg {
    width: 100%;
    height: 100%;
}

/* For browsers that support background-clip */
@supports (background-clip: text) or (-webkit-background-clip: text) {
    /* Parent'a background-clip uygula */
    .aatw-word.use-text-mask .aatw-word-text {
        position: relative;
        background-clip: text !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        color: transparent !important;
    }
    
    /* MASK MODUNDA: Basit fade animasyonu - harf animasyonu YOK */
    .aatw-word.use-text-mask {
        transition: opacity var(--entry-duration, 800ms) ease-in-out;
    }
    
    .aatw-word.use-text-mask:not(.active) {
        opacity: 0;
    }
    
    .aatw-word.use-text-mask.active {
        opacity: 1;
    }
    
    /* Hide SVG mask for supported browsers */
    .aatw-word.use-text-mask .aatw-svg-mask-container {
        display: none;
    }
}
/* Typography Base */
.aatw-word .aatw-word-text {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.2;
}

/* Tablet Typography */
@media (max-width: 1024px) {
    .aatw-word .aatw-word-text {
        font-size: 36px;
    }
}

/* Mobile Typography */
@media (max-width: 767px) {
    .aatw-word .aatw-word-text {
        font-size: 28px;
    }
}

/* Background Overlay */
.aatw-word .aatw-background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.aatw-word .aatw-word-text {
    position: relative;
    z-index: 2;
}

/* Video/Image Mask Wrapper */
.aatw-word.use-text-mask .aatw-video-mask-wrapper,
.aatw-word.use-text-mask .aatw-slideshow-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    clip-path: polygon(0 0, 0 0, 0 0, 0 0); /* Will be updated by JS */
}

/* Text mask mode - text determines size */
.aatw-word.use-text-mask .aatw-word-text {
    position: relative;
    display: inline-block;
    /* Text stays visible, video clips to it */
}
.aatw-word .aatw-video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.aatw-word .aatw-video-container video,
.aatw-word .aatw-video-container iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    transform: translate(-50%, -50%);
    object-fit: cover;
}

/* Video text mask mode - FIXED APPROACH */
.aatw-word .aatw-video-container.aatw-video-text-mask {
    z-index: 1;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* FIXED: Video mask için backdrop-filter ve clip-path yaklaşımı */
.aatw-word.use-text-mask .aatw-video-container.aatw-video-text-mask {
    /* Video normal gösterilir ancak mask ile kırpılır */
    -webkit-mask-image: linear-gradient(white, white);
    mask-image: linear-gradient(white, white);
    -webkit-mask-composite: source-in;
    mask-composite: intersect;
}

.aatw-word.use-text-mask .aatw-word-text {
    position: relative;
    z-index: 2;
    /* Text mask için background-clip kullanılacak */
    background-clip: text !important;
    -webkit-background-clip: text !important;
}

/* Slideshow Container - Full size */
.aatw-word .aatw-slideshow-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.aatw-slideshow-container .aatw-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
    background-size: cover;
    background-position: center;
}

.aatw-slideshow-container .aatw-slide.active {
    opacity: 1;
    z-index: 1;
}

/* Slideshow Transitions */
.aatw-slideshow-container.transition-fade .aatw-slide {
    transition: opacity 0.5s ease;
}

.aatw-slideshow-container.transition-slide .aatw-slide {
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.aatw-slideshow-container.transition-slide .aatw-slide:not(.active) {
    transform: translateX(100%);
}

.aatw-slideshow-container.transition-zoom .aatw-slide {
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.aatw-slideshow-container.transition-zoom .aatw-slide.active {
    animation: zoomSlide 0.5s ease;
}

@keyframes zoomSlide {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Ken Burns Effect */
.aatw-slideshow-container.ken-burns .aatw-slide.active {
    /* ✅ Duration ve easing JavaScript'ten kontrol edilir */
    animation: kenBurns var(--ken-burns-duration, 10s) var(--ken-burns-easing, linear);
}

@keyframes kenBurns {
    0% {
        transform: scale(1) translate(0, 0);
    }
    100% {
        transform: scale(1.1) translate(2%, 2%);
    }
}

/* Text Stroke Support with Background */
.aatw-word.has-text-background.has-stroke .aatw-word-text {
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke-color: inherit;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .aatw-word {
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .aatw-word {
        font-size: 0.7em;
    }
}

/* Accessibility */
.aatw-container[aria-live] {
    position: relative;
}

/* Loading State */
.aatw-container.loading {
    min-height: 100px;
}

.aatw-container.loading::before {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, currentColor, transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Print Styles */
@media print {
    .aatw-word {
        position: static !important;
        opacity: 1 !important;
        display: inline !important;
    }
    
    .aatw-word::after {
        content: ' ';
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .aatw-word {
        text-shadow: none;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .aatw-word,
    .aatw-letter,
    .aatw-slide {
        animation: none !important;
        transition: none !important;
    }
    
    .aatw-word {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Custom Scrollbar for Container */
.aatw-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.aatw-container::-webkit-scrollbar-track {
    background: transparent;
}

.aatw-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.aatw-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}
