/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    position: relative;
}

/* Шапка */
.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.page-title {
    text-align: center;
    color: white;
    margin-bottom: 10px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 2px 2px 4px rgba(0,0,0,0.3); }
    50% { text-shadow: 0 0 20px rgba(255,215,0,0.5); }
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2em;
    text-align: center;
}

/* Сетка карточек - ВСЕГДА 3 КОЛОНКИ */
.cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Всегда 3 колонки */
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Стили карточки */
.card {
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    background: white;
    position: relative;
    aspect-ratio: 2/3;
    border: 2px solid transparent;
    width: 100%; /* Занимает всю ширину колонки */
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1));
    pointer-events: none;
}

.card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 30px rgba(0,0,0,0.4);
    border-color: gold;
}

.card:active {
    transform: translateY(-5px) scale(1.01);
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s;
}

.card:hover img {
    transform: scale(1.1);
}

/* Номер карты */
.card-number {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: gold;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 2;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    animation: fadeIn 0.3s;
    backdrop-filter: blur(5px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 5% auto;
    padding: 30px;
    width: 90%;
    max-width: 900px;
    border-radius: 30px;
    position: relative;
    animation: slideIn 0.4s;
    border: 3px solid rgba(255, 215, 0, 0.3);
}

@keyframes slideIn {
    from {
        transform: translateY(-100px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 25px;
    top: 15px;
    font-size: 40px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.close:hover {
    color: gold;
    transform: rotate(90deg);
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    display: flex;
    gap: 30px;
    align-items: center;
}

.modal-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 20px;
    box-shadow: 0 20px 30px rgba(0,0,0,0.3);
    border: 4px solid gold;
}

.modal-text {
    flex: 1;
    color: white;
}

#modalTitle {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-size: 32px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

#modalDescription {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    font-size: 18px;
    margin-bottom: 30px;
}

.modal-footer {
    text-align: right;
}

.modal-close-btn {
    background: gold;
    color: #333;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.modal-close-btn:hover {
    background: #ffd700;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255,215,0,0.4);
}

/* Кнопка "Наверх" */
.scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: gold;
    color: #333;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: none;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 99;
}

.scroll-top:hover {
    background: #ffd700;
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(255,215,0,0.4);
}

.scroll-top.show {
    display: flex;
}

/* Индикатор загрузки */
.loading {
    text-align: center;
    color: white;
    font-size: 20px;
    padding: 50px;
    grid-column: 1 / -1;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid white;
    border-top-color: gold;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Временные стили для проверки */
.cards-container:empty::before {
    content: "Карточки не создались! Проверьте JavaScript";
    color: red;
    font-size: 20px;
    text-align: center;
    grid-column: 1 / -1;
}

/* ========== МОБИЛЬНЫЕ НАСТРОЙКИ ========== */
/* Везде оставляем 3 колонки, только меняем размеры */

/* Планшеты */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }
    
    .header {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .page-title {
        font-size: 2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .cards-container {
        grid-template-columns: repeat(3, 1fr); /* Всё ещё 3 колонки */
        gap: 15px;
        padding: 15px;
    }
    
    .card-number {
        top: 5px;
        right: 5px;
        padding: 3px 8px;
        font-size: 12px;
    }
    
    .modal-content {
        width: 90%;
        padding: 20px;
    }
    
    .modal-body {
        flex-direction: column;
        text-align: center;
    }
    
    .modal-image {
        max-width: 200px;
    }
    
    #modalTitle {
        font-size: 24px;
    }
    
    #modalDescription {
        font-size: 16px;
    }
    
    .close {
        right: 15px;
        top: 10px;
        width: 40px;
        height: 40px;
        font-size: 30px;
    }
    
    .scroll-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 22px;
    }
}

/* Маленькие телефоны */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .header {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .page-title {
        font-size: 1.5em;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    .cards-container {
        grid-template-columns: repeat(3, 1fr); /* Всё ещё 3 колонки */
        gap: 8px;
        padding: 8px;
    }
    
    .card {
        border-radius: 8px;
    }
    
    .card-number {
        top: 3px;
        right: 3px;
        padding: 2px 5px;
        font-size: 9px;
        border-radius: 10px;
    }
    
    .modal-content {
        padding: 15px;
    }
    
    .modal-image {
        max-width: 150px;
    }
    
    #modalTitle {
        font-size: 20px;
    }
    
    #modalDescription {
        font-size: 14px;
    }
    
    .modal-close-btn {
        padding: 8px 20px;
        font-size: 14px;
    }
    
    .scroll-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* Очень маленькие телефоны */
@media (max-width: 360px) {
    .page-title {
        font-size: 1.2em;
    }
    
    .cards-container {
        grid-template-columns: repeat(3, 1fr); /* Всё ещё 3 колонки */
        gap: 4px;
    }
    
    .card-number {
        font-size: 8px;
        padding: 1px 4px;
    }
    
    .modal-image {
        max-width: 120px;
    }
}

/* Альбомная ориентация */
@media (max-height: 480px) and (orientation: landscape) {
    .cards-container {
        grid-template-columns: repeat(3, 1fr); /* Всё ещё 3 колонки */
        gap: 10px;
    }
    
    .modal-content {
        margin: 2% auto;
        padding: 15px;
    }
    
    .modal-body {
        flex-direction: row;
    }
    
    .modal-image {
        max-width: 150px;
    }
}
