/**
 * File: css/animations.css
 * CSS cho các hiệu ứng và animations của ứng dụng coi bói bài tây
 */

/* Hiệu ứng lật bài */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.card-front {
    background-color: white;
    transform: rotateY(180deg);
}

.card-back {
    background-color: #6a1b9a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front img, .card-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Hiệu ứng xuất hiện cho các màn hình */
.screen {
    animation: fadeIn 0.5s ease-out;
}

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

/* Hiệu ứng cho các nút */
.primary-btn, .secondary-btn, .tertiary-btn {
    position: relative;
    overflow: hidden;
}

.primary-btn:after, .secondary-btn:after, .tertiary-btn:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.primary-btn:focus:not(:active)::after, 
.secondary-btn:focus:not(:active)::after, 
.tertiary-btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

/* Hover effects */
.primary-btn:hover, .secondary-btn:hover, .tertiary-btn:hover {
    transform: translateY(-3px);
    transition: transform 0.3s ease;
}

/* Hiệu ứng nhấp nháy cho loading */
@keyframes blink {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

.loading span {
    animation: blink 1.4s infinite both;
}

.loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Hiệu ứng cho tin nhắn chat */
.chat-message {
    animation: slideIn 0.3s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

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

/* Hiệu ứng nền magical */
.magical-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.magical-bg:before {
    content: '';
    position: absolute;
    width: 300%;
    height: 300%;
    top: -100%;
    left: -100%;
    background: linear-gradient(
        to bottom right,
        rgba(106, 27, 154, 0.2),
        rgba(156, 39, 176, 0.2),
        rgba(233, 30, 99, 0.2),
        rgba(106, 27, 154, 0.2)
    );
    animation: magicalBg 15s linear infinite;
    opacity: 0.4;
}

@keyframes magicalBg {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Hiệu ứng đổi màu cho lá bài được chọn */
.card.selected .card-front {
    box-shadow: 0 0 15px 5px rgba(233, 30, 99, 0.7);
    transition: box-shadow 0.3s ease;
}

/* Hiệu ứng phóng to cho lá bài */
.card:hover .card-inner {
    transform: scale(1.05) rotateY(180deg);
    transition: transform 0.3s ease;
}

.card:not(.flipped):hover .card-inner {
    transform: scale(1.05);
}

/* Hiệu ứng cho lịch sử coi bói */
.history-item {
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateX(5px);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Hiệu ứng nhấp nháy cho các thông báo */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(233, 30, 99, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(233, 30, 99, 0); }
    100% { box-shadow: 0 0 0 0 rgba(233, 30, 99, 0); }
}

.notification {
    animation: pulse 2s infinite;
}

/* Hiệu ứng cho toast notification */
.toast {
    animation: slideInUp 0.5s, fadeOut 0.5s 2.5s;
    animation-fill-mode: forwards;
}

@keyframes slideInUp {
    from {
        transform: translate(-50%, 30px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

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

/* Hiệu ứng loading khi nhận kết quả */
.spinner {
    width: 40px;
    height: 40px;
    margin: 20px auto;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top: 4px solid var(--accent-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hiệu ứng nổi bật cho kết quả coi bói */
.highlight-text {
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    display: inline;
}

/* Hiệu ứng cho modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: var(--border-radius-md);
    width: 90%;
    max-width: 500px;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

/* Hiệu ứng chuyển tiếp giữa các màn hình */
.screen-exit {
    animation: fadeOut 0.3s forwards;
}

.screen-enter {
    animation: fadeIn 0.3s forwards;
}

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

/* Hiệu ứng phát sáng cho lá bài */
.glow-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    z-index: -1;
    background: radial-gradient(
        circle at 50% 50%,
        rgba(233, 30, 99, 0.5),
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
}

.card:hover .glow-effect {
    opacity: 1;
}

/* Hiệu ứng khi chọn kiểu trải bài */
.spread-option.selected {
    background-color: rgba(106, 27, 154, 0.3);
    border-left: 3px solid var(--accent-color);
    transform: translateX(5px);
}

/* Hiệu ứng typing cho chat */
.typing {
    display: flex;
    align-items: center;
    column-gap: 4px;
}

.typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-color);
    opacity: 0.4;
}

.typing span:nth-child(1) {
    animation: typing 1s infinite;
}

.typing span:nth-child(2) {
    animation: typing 1s 0.25s infinite;
}

.typing span:nth-child(3) {
    animation: typing 1s 0.5s infinite;
}

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-5px);
        opacity: 0.8;
    }
}