/*
 * Extended Theme Styles for Solitaire Publishing
 * Loaded asynchronously to avoid blocking critical render path
 */

/* Victory Animation */
@keyframes cardCascade {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.victory-animation {
    animation: cardCascade 2s ease-in forwards;
}

/* Card Rank & Suit Display */
.card-front {
    display: flex;
    flex-direction: column;
    padding: 4px;
    background: white;
    border-radius: var(--card-radius);
    position: relative;
    height: 100%;
    width: 100%;
}

.card-rank {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.card-suit {
    font-size: 20px;
    line-height: 1;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
}

.card.red {
    color: #c41e3a;
}

.card.black {
    color: #1a1a1a;
}

/* Tableau Card Stacking */
.tableau-pile .card {
    position: absolute;
}

.tableau-pile .card[data-index="0"] { top: 0; }
.tableau-pile .card[data-index="1"] { top: 25px; }
.tableau-pile .card[data-index="2"] { top: 50px; }
.tableau-pile .card[data-index="3"] { top: 75px; }
.tableau-pile .card[data-index="4"] { top: 100px; }
.tableau-pile .card[data-index="5"] { top: 125px; }
.tableau-pile .card[data-index="6"] { top: 150px; }
.tableau-pile .card[data-index="7"] { top: 175px; }
.tableau-pile .card[data-index="8"] { top: 200px; }
.tableau-pile .card[data-index="9"] { top: 225px; }
.tableau-pile .card[data-index="10"] { top: 250px; }
.tableau-pile .card[data-index="11"] { top: 275px; }
.tableau-pile .card[data-index="12"] { top: 300px; }

/* Mobile Stacking (tighter) */
@media (max-width: 768px) {
    .tableau-pile .card[data-index="1"] { top: 18px; }
    .tableau-pile .card[data-index="2"] { top: 36px; }
    .tableau-pile .card[data-index="3"] { top: 54px; }
    .tableau-pile .card[data-index="4"] { top: 72px; }
    .tableau-pile .card[data-index="5"] { top: 90px; }
    .tableau-pile .card[data-index="6"] { top: 108px; }
    .tableau-pile .card[data-index="7"] { top: 126px; }
    .tableau-pile .card[data-index="8"] { top: 144px; }
    .tableau-pile .card[data-index="9"] { top: 162px; }
    .tableau-pile .card[data-index="10"] { top: 180px; }
    .tableau-pile .card[data-index="11"] { top: 198px; }
    .tableau-pile .card[data-index="12"] { top: 216px; }
}

/* Move Counter & Timer */
.game-stats {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 1rem;
    font-size: 1.1rem;
}

.game-stats span {
    opacity: 0.9;
}

.game-stats strong {
    color: var(--gold);
    margin-left: 0.5rem;
}

/* Hint Highlight */
.card.hint-highlight {
    box-shadow: 0 0 0 3px var(--gold), 0 4px 16px var(--card-shadow);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 3px var(--gold), 0 4px 16px var(--card-shadow);
    }
    50% {
        box-shadow: 0 0 0 6px var(--gold), 0 8px 24px rgba(255, 215, 0, 0.6);
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: linear-gradient(135deg, var(--felt-dark) 0%, var(--felt-primary) 100%);
    border-radius: 16px;
    padding: 3rem;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s;
}

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

.modal h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--gold);
}

.modal p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.modal-stats {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.modal-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.modal-stat strong {
    color: var(--gold);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    font-size: 1.5rem;
    opacity: 0.7;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Print Styles */
@media print {
    .header, .controls, .sidebar, .footer, .modal-overlay {
        display: none;
    }

    .game-wrapper {
        grid-template-columns: 1fr;
    }

    body {
        background: white;
        color: black;
    }

    .content-section {
        box-shadow: none;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Styles for Keyboard Navigation */
.card:focus,
.btn:focus,
.card-pile:focus {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

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

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .card-pile {
        border-width: 3px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Dark Mode Adjustments */
[data-theme="dark"] .content-section {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

[data-theme="dark"] .content-section h2,
[data-theme="dark"] .content-section h3,
[data-theme="dark"] .faq-question {
    color: var(--gold);
}

/* Stock Pile Empty State */
.card-pile[data-pile="stock"].empty::after {
    content: '↻';
    font-size: 32px;
    color: rgba(255, 255, 255, 0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Foundation Suit Indicators */
.foundation::after {
    content: attr(data-suit-symbol);
    font-size: 40px;
    color: rgba(255, 255, 255, 0.1);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.foundation[data-suit="hearts"]::after { content: '♥'; color: rgba(196, 30, 58, 0.2); }
.foundation[data-suit="diamonds"]::after { content: '♦'; color: rgba(196, 30, 58, 0.2); }
.foundation[data-suit="clubs"]::after { content: '♣'; color: rgba(26, 26, 26, 0.2); }
.foundation[data-suit="spades"]::after { content: '♠'; color: rgba(26, 26, 26, 0.2); }

/* Smooth Page Transitions */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Selection Color */
::selection {
    background: var(--gold);
    color: var(--text-dark);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-light);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.info {
    border-left: 4px solid var(--gold);
}
