/* =============================================
   Gallery Page Styles - Local Legends TCG
   ============================================= */

/* CSS Variables */
:root {
    --color-primary: #C41E3A;
    --color-secondary: #1a472a;
    --color-accent: #FFD700;
    --color-dark: #1a1a2e;
    --color-light: #f8f4e8;
    --color-local: #E67E22;
    --color-provincial: #27AE60;
    --color-territorial: #2980B9;
    --color-national: #C41E3A;
    --color-wild: #8E44AD;
    --color-notoriety: #F39C12;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.15);
    --shadow-strong: 0 15px 50px rgba(0, 0, 0, 0.25);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-primary: 'Outfit', sans-serif;
}

/* Reset & Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    color: var(--color-light);
    min-height: 100vh;
    line-height: 1.6;
}

/* Navigation */
.gallery-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 0;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 50px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--color-light);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: var(--transition-smooth);
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-accent);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-accent);
    border-radius: 2px;
}

/* Hero Section */
.gallery-hero {
    padding: 8rem 2rem 4rem;
    text-align: center;
    background: linear-gradient(180deg, rgba(196, 30, 58, 0.1) 0%, transparent 100%);
}

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

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--color-accent) 0%, #fff 50%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
}

.hero-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, #a01830 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-medium);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.btn-icon {
    font-size: 1.2rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-group label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.filter-select {
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: white;
    font-family: var(--font-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.filter-select:hover,
.filter-select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--color-accent);
    outline: none;
}

.filter-select option {
    background: var(--color-dark);
    color: white;
}

/* Main Gallery */
.gallery-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Card Sections */
.card-section {
    margin-bottom: 4rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-section.hidden {
    display: none;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
}

.local-icon {
    background: linear-gradient(135deg, var(--color-local) 0%, #d35400 100%);
}

.provincial-icon {
    background: linear-gradient(135deg, var(--color-provincial) 0%, #1e8449 100%);
}

.territorial-icon {
    background: linear-gradient(135deg, var(--color-territorial) 0%, #1a5276 100%);
}

.national-icon {
    background: linear-gradient(135deg, var(--color-national) 0%, #a01830 100%);
}

.wild-icon {
    background: linear-gradient(135deg, var(--color-wild) 0%, #6c3483 100%);
}

.notoriety-icon {
    background: linear-gradient(135deg, var(--color-notoriety) 0%, #d68910 100%);
}

.rules-icon {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
}

.section-info {
    flex: 1;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.section-description {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
}

.card-count {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.rules-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Card Component */
.card-wrapper {
    perspective: 1000px;
    cursor: pointer;
}

.flip-card {
    position: relative;
    width: 100%;
    aspect-ratio: 2.5/3.5;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

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

.card-wrapper:hover .flip-card:not(.flipped) {
    transform: scale(1.02) rotateY(5deg);
}

.card-wrapper:hover .flip-card.flipped {
    transform: scale(1.02) rotateY(175deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
}

.card-front {
    background: var(--color-dark);
}

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

.card-front img,
.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Image protection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    opacity: 0;
    transition: var(--transition-smooth);
}

.card-wrapper:hover .card-info {
    opacity: 1;
}

.card-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-number {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Modal Styles */
.card-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.card-modal.active {
    display: flex;
}

.modal-content {
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-card-container {
    margin-bottom: 1.5rem;
}

.modal-card-container img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 16px;
    box-shadow: var(--shadow-strong);
}

.modal-info h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-info p {
    color: rgba(255, 255, 255, 0.6);
}

.modal-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-nav-btn {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: white;
    font-family: var(--font-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Footer */
.gallery-footer {
    padding: 3rem 2rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.footer-content p {
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.footer-links a:hover {
    color: var(--color-accent);
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .hero-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .section-header {
        flex-wrap: wrap;
    }

    .card-count {
        width: 100%;
        text-align: center;
        margin-top: 0.5rem;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .gallery-hero {
        padding: 6rem 1rem 2rem;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .gallery-main {
        padding: 1rem;
    }

    .card-section {
        padding: 1rem;
        border-radius: 16px;
    }

    .section-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .section-title {
        font-size: 1.25rem;
    }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .modal-nav {
        flex-direction: column;
    }
}

/* Loading Animation */
.card-wrapper {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation delays for cards */
.card-wrapper:nth-child(1) {
    animation-delay: 0.05s;
}

.card-wrapper:nth-child(2) {
    animation-delay: 0.1s;
}

.card-wrapper:nth-child(3) {
    animation-delay: 0.15s;
}

.card-wrapper:nth-child(4) {
    animation-delay: 0.2s;
}

.card-wrapper:nth-child(5) {
    animation-delay: 0.25s;
}

.card-wrapper:nth-child(6) {
    animation-delay: 0.3s;
}

.card-wrapper:nth-child(7) {
    animation-delay: 0.35s;
}

.card-wrapper:nth-child(8) {
    animation-delay: 0.4s;
}

.card-wrapper:nth-child(9) {
    animation-delay: 0.45s;
}

.card-wrapper:nth-child(10) {
    animation-delay: 0.5s;
}