/* === 1. ПЕРЕМЕННЫЕ И БАЗОВЫЕ НАСТРОЙКИ === 
:root {
    --bg-color: #fdf7f0;
    --accent-color: #f5a623;
    --text-color: #333;
    --border-radius: 16px;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    --font-main: 'Comfortaa', cursive;

    --accent: #d6bfa8;
    --text-dark: #7c5b45;
    --teracot-color: #e67e22;
    --coffe-light-color: #f4e8da;
    --heart-red: #ff4d4d;
    --shadow-mob: rgba(0, 0, 0, 0.15);
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: var(--bg-color);
    color: var(--text-color);
    /* Шрифт плавно меняется от экрана 
    font-size: clamp(14px, 1vw + 10px, 18px); 
}
*/
/* === 2. ОБЩИЕ БЛОКИ И СЕТКА === */
.recipes-of-day,
.recipes-best,
.recipes-catalog {
    background: #fff;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

h1 {
    text-align: center;
    margin-bottom: 0.8rem;
    color: var(--text-dark);
}

.recipe-grid {
    width: 100%;
    display: grid;
    /* Исправлено: minmax(0, 1fr) чтобы колонки были строго равными */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    justify-content: center;
}

/* === 3. КАРТОЧКА РЕЦЕПТА === */
.recipe-card {
    width: 100%;
    background: #fefefe;
    padding: 0.5rem 0.6rem 1rem;
    border-radius: calc(var(--border-radius) / 4);
    text-align: center;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: box-shadow 0.3s, transform 0.3s;
    box-sizing: border-box; /* Чтобы отступы не ломали ширину */
}

.recipe-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.recipe-link {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-grow: 1;
    text-decoration: none;
    color: inherit;
}

.recipe-card img {
    width: 100%;
    /* Исправлено: аспект-рацио делает картинку резиновой */
    aspect-ratio: 1 / 1; 
    height: auto; 
    object-fit: cover;
    border-radius: calc(var(--border-radius) / 2);
    margin-bottom: 6px;
}

.recipe-card h2 {
    /* Исправлено: clamp делает шрифт резиновым */
    font-size: clamp(0.85rem, 2vw, 1.1rem); 
    margin: 10px 0 6px 0;
    /* Обрезка на 3 строки */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3.4em; 
    color: var(--text-dark);
    line-height: 1.1;
    text-align: center;
}

/* === 4. КРАСНОЕ СЕРДЕЧКО (FAVORITE) === */
.favorite-overlay, .fav-container {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
}

.favorite-overlay button, 
.fav-heart-btn, 
.favorite_btn.tab-btn {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(4px);
    border: none !important;
    width: 38px;
    height: 38px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--heart-red);
    font-size: 20px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    padding: 0 !important;
    margin: 0 !important;
}

.favorite-overlay button:hover, 
.fav-heart-btn:hover {
    transform: scale(1.15);
    background: #fff !important;
}

/* === 6. ПАГИНАЦИЯ === */
.pagination { text-align: center; padding: 30px 0; }
.pagination a { 
    padding: 8px 15px; border: 1px solid var(--accent); margin: 0 4px; 
    text-decoration: none; border-radius: 8px; color: var(--text-dark); background: #fff;
}
.pagination a.active { background: var(--teracot-color); color: #fff; border-color: var(--teracot-color); }

/* === 7. МОБИЛЬНАЯ АДАПТАЦИЯ === */
@media (max-width: 840px) {
    .recipe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
}

@media (max-width: 630px) {
    .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    /* Шрифт заголовка станет чуть меньше на телефонах */
    .recipe-card h2 { font-size: clamp(0.8rem, 3vw, 0.9rem); min-height: 3.3em; }
    .favorite-overlay button, .fav-heart-btn { width: 32px; height: 32px; font-size: 16px; }
}

@media (max-width: 240px) {
    .recipe-grid { grid-template-columns: 1fr; gap: 10px; }
}
