/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: #fdfaf7;
    color: #3a3a3a;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Шапка */
.header {
    background-color: #fff;
    padding: 30px 0;
    text-align: center;
    border-bottom: 1px solid #f0e6dd;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #5a3e2b;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 1rem;
    color: #9c7b62;
    margin-top: 5px;
}

/* Заголовок каталога */
.catalog-header {
    text-align: center;
    margin: 40px 0 30px;
}

.catalog-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #5a3e2b;
    margin-bottom: 10px;
}

.catalog-header p {
    color: #7a6a5f;
    max-width: 600px;
    margin: 0 auto;
}

/* Сетка каталога */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

/* Карточка товара */
.cake-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.cake-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

/* Фото торта: показываем целиком, без обрезки.
   Все фото с сайта — 600×500 (пропорция 6:5), поэтому карточки остаются
   ровными, а «нестандартные» снимки просто вписываются в рамку. */
.cake-image {
    width: 100%;
    aspect-ratio: 6 / 5;
    height: auto;
    object-fit: contain;   /* contain = фото целиком, cover = обрезает */
    object-position: center;
    background-color: #f5ede6; /* Цвет заглушки и полей вокруг фото */
    display: block;
}

/* Запасной вариант для старых браузеров без aspect-ratio */
@supports not (aspect-ratio: 6 / 5) {
    .cake-image {
        height: 220px;
    }
}

.cake-image.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c2b2a5;
    font-size: 3rem;
    font-weight: 300;
}

.cake-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.cake-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #3a2e26;
    margin-bottom: 8px;
}

.cake-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: #c07a4a;
    margin-bottom: 12px;
}

.cake-description {
    font-size: 0.9rem;
    color: #7a6a5f;
    margin-bottom: 20px;
    flex-grow: 1;
}

.order-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background-color: #5a3e2b;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-align: center;
}

.order-btn:hover {
    background-color: #c07a4a;
}

/* Модальное окно */
body.modal-open {
    overflow: hidden;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    padding: 35px;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.modal-content h2 {
    font-size: 1.4rem;
    margin-bottom: 5px;
    color: #5a3e2b;
}

#selected-cake-name {
    color: #7a6a5f;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Галерея фото в модальном окне */
.cake-gallery[hidden],
.gallery-thumbs[hidden],
.field-error[hidden] {
    display: none;
}

.cake-gallery {
    margin-bottom: 18px;
}

.gallery-main {
    display: block;
    width: 100%;
    aspect-ratio: 6 / 5;
    object-fit: contain;
    object-position: center;
    background-color: #f5ede6;
    border-radius: 12px;
    cursor: zoom-in;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.gallery-thumb {
    width: 64px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #f5ede6;
    cursor: pointer;
    transition: border-color 0.2s, opacity 0.2s;
    opacity: 0.75;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-thumb:hover {
    opacity: 1;
}

.gallery-thumb.active {
    border-color: #c07a4a;
    opacity: 1;
}

.cake-card .cake-image {
    cursor: pointer;
}

#order-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

#order-form input,
#order-form textarea {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

#order-form input:focus,
#order-form textarea:focus {
    outline: none;
    border-color: #c07a4a;
}

#order-form input.invalid {
    border-color: #d9534f;
    background-color: #fff6f5;
}

.field-error {
    margin: -10px 0 15px;
    font-size: 0.85rem;
    color: #c0392b;
}

/* Ловушка для спам-ботов: поле есть в DOM, но не видно людям */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Статус отправки заявки */
.form-status {
    margin: 0 0 15px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.form-status[hidden] {
    display: none;
}

.form-status.success {
    background-color: #eef7ee;
    color: #2e6b32;
    border: 1px solid #cfe6d0;
}

.form-status.error {
    background-color: #fdeeee;
    color: #a33a34;
    border: 1px solid #f2cdcb;
}

.submit-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Модальное окно на маленьких экранах */
@media (max-height: 720px) {
    .modal {
        align-items: flex-start;
        overflow-y: auto;
        padding: 20px 0;
    }

    .modal-content {
        padding: 25px;
    }

    .gallery-thumb {
        width: 54px;
        height: 45px;
    }
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background-color: #c07a4a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.submit-btn:hover {
    background-color: #a8653b;
}

/* Футер */
.footer {
    background-color: #f5ede6;
    padding: 20px 0;
    text-align: center;
    font-size: 0.9rem;
    color: #9c7b62;
    margin-top: 40px;
}

/* Пометка «цена за 1 кг» */
.price-note {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #9c7b62;
}

/* Адаптивность */
@media (max-width: 600px) {
    .catalog-grid {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 1.5rem;
    }
}