/* ============================================
   Memory Game Specific Styles
   ============================================ */

/* Variable aliases for backward compatibility */
:root {
    --color-primary: var(--primary-color);
    --color-dark: var(--dark-color);
    --color-text: var(--dark-color);
    --color-gray-1: var(--gray-color);
    --color-gray-2: var(--gray-light);
    --color-light: var(--light-color);
    --color-lighter: var(--lighter-color);
    --color-white: var(--white);
    --color-black: var(--black);
    --color-success: #2E7D32;
    --transition: var(--transition-medium);
}

/* Override background for memory game */
body {
    background-color: var(--lighter-color);
}

/* Screen reader only */
.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;
}

/* Header customization for memory game */
.header {
    padding: 1rem 1rem;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.header p {
    font-size: 0.95rem;
    opacity: 0.95;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 1rem;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.game-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat {
    font-size: 1rem;
    color: var(--gray-color);
}

.stat strong {
    color: var(--dark-color);
    font-weight: 700;
}

/* Button */
.btn {
    background-color: var(--color-primary);
    color: var(--color-white);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn:hover {
    background-color: var(--color-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background-color: var(--color-gray-2);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background-color: var(--color-gray-1);
}

.btn-secondary:hover {
    background-color: var(--color-dark);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 56px;
    height: 56px;
    background-color: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
    z-index: 100;
}

.fab:hover {
    background-color: var(--color-dark);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.fab:active {
    transform: scale(1.05);
}

.fab svg {
    width: 28px;
    height: 28px;
}

@media (max-width: 768px) {
    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
    }
    
    .fab svg {
        width: 24px;
        height: 24px;
    }
}

/* Game Boards Container */
.game-boards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 1rem 0;
}

@media (max-width: 768px) {
    .game-boards-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.board-section {
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.board-section.inactive {
    opacity: 0.5;
    pointer-events: none;
}

.board-section.active {
    box-shadow: 0 0 0 3px var(--color-primary), 0 4px 12px rgba(191, 66, 84, 0.3);
}

.board-title {
    color: var(--color-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .game-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Card */
.card {
    aspect-ratio: 3/4;
    min-height: 280px;
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

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

/* Data cards are always visible */
.card.data-always-visible {
    transform: rotateY(180deg);
}

.card.matched {
    opacity: 1;
    cursor: default;
    pointer-events: none;
    transform: rotateY(180deg) !important;
}

.card.matched .card-back {
    border: 3px solid var(--color-success);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.card-front {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-dark) 100%);
    color: var(--color-white);
}

.card-front::before {
    content: "?";
    font-size: 4rem;
    font-weight: 700;
    opacity: 0.3;
}

.card-back {
    background-color: var(--color-white);
    transform: rotateY(180deg);
    overflow: hidden;
}

/* Graph Card */
.card-back.graph-card {
    padding: 0.5rem;
}

.graph-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-lighter);
    border-radius: var(--border-radius);
    padding: 0.25rem;
}

.graph-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-light) 0%, var(--color-lighter) 100%);
    border: 2px dashed var(--color-gray-2);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-1);
    font-size: 0.8rem;
    text-align: center;
}

.graph-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Story Card */
.card-back.story-card {
    padding: 0.75rem;
}

.story-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.story-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.story-text {
    font-size: 1rem;
    color: var(--color-text);
    line-height: 1.5;
    overflow-y: auto;
}

/* Game Message */
.game-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 46, 53, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: var(--transition);
}

.game-message.hidden {
    opacity: 0;
    pointer-events: none;
}

.message-content {
    background-color: var(--color-white);
    padding: 3rem 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.message-content h2 {
    color: var(--color-primary);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.message-content p {
    color: var(--color-text);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    background-color: var(--color-white);
    border-top: 1px solid var(--color-light);
    padding: 0.5rem 0.5rem;
    text-align: center;
    color: var(--color-gray-1);
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer p {
    margin: 0.15rem 0;
    font-size: 0.85rem;
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--color-dark);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .game-stats {
        justify-content: space-around;
    }

    .message-content {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }

    .message-content h2 {
        font-size: 1.5rem;
    }
}

/* Animations */
@keyframes flipIn {
    from {
        transform: rotateY(0deg);
    }
    to {
        transform: rotateY(180deg);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.card.shake {
    animation: shake 0.4s;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.card.pulse {
    animation: pulse 0.6s;
}

/* Zoom Icon */
.zoom-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background-color: rgba(191, 66, 84, 0.9);
    color: var(--color-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    z-index: 10;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.zoom-icon:hover {
    background-color: rgba(191, 66, 84, 1);
    transform: scale(1.1);
}

.zoom-icon:active {
    transform: scale(0.95);
}

/* Zoom Modal */
.zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.zoom-modal.hidden {
    display: none;
}

.zoom-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.zoom-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background-color: var(--color-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: zoomIn 0.3s ease-out;
}

.zoom-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 40px;
    height: 40px;
    background-color: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.zoom-close:hover {
    background-color: var(--color-dark);
    transform: scale(1.1) rotate(90deg);
}

.zoom-graph-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 500px;
    min-height: 400px;
}

.zoom-graph-container img {
    max-width: 100%;
    height: auto;
    width: 800px;
}

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

@media (max-width: 768px) {
    .zoom-modal-content {
        max-width: 95vw;
        max-height: 95vh;
        padding: 1.5rem;
    }
    
    .zoom-graph-container {
        min-width: auto;
        min-height: auto;
    }
    
    .zoom-graph-container img {
        width: 100%;
    }
}
