/* css/style.css - Apple Inspired Minimalist Theme */

/* Базовые сбросы и настройки */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Базовый размер шрифта для адаптивности rem */
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    background-color: #f5f5f7; /* Светло-серый фон как у Apple */
    color: #1d1d1f; /* Основной цвет текста */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Контейнер */
.container {
    max-width: 980px; /* Типичная ширина контента для Apple-стиля */
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Заголовки */
h1, h2, h3 {
    font-weight: 600; /* Полужирный для заголовков */
    color: #1d1d1f;
    margin-bottom: 0.8em;
}

h1 {
    font-size: 2.5rem; /* 40px */
}

h2 {
    font-size: 1.75rem; /* 28px */
    margin-top: 2em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #d2d2d7; /* Тонкая серая линия */
}
h2:first-child, section h2:first-of-type {
    margin-top: 0;
}


p {
    margin-bottom: 1em;
}

a {
    color: #007aff; /* Синий цвет ссылок Apple */
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Шапка и подвал */
.site-header {
    background-color: rgba(255, 255, 255, 0.7); /* Полупрозрачный белый */
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 1.5rem 0;
    text-align: center;
    border-bottom: 1px solid #d2d2d7;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header h1 {
    font-size: 1.5rem; /* 24px */
    font-weight: 600;
    margin: 0;
}


.site-footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    font-size: 0.875rem; /* 14px */
    color: #6e6e73; /* Серый для подвала */
    border-top: 1px solid #d2d2d7;
}

/* Главная страница: список рецептов */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    padding-top: 2rem;
}

.recipe-card-link {
    display: block;
    background-color: #ffffff; /* Белый фон карточки */
    border-radius: 18px; /* Скругление как у Apple */
    padding: 20px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    overflow: hidden; /* Для скругления изображения */
}

.recipe-card-link:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    text-decoration: none;
}

.recipe-card-image {
    width: 100%;
    height: 180px; /* Фиксированная высота для единообразия */
    object-fit: cover;
    border-radius: 12px; /* Внутреннее скругление для картинки */
    margin-bottom: 15px;
    background-color: #f5f5f7; /* Плейсхолдер цвет для картинок */
}

.recipe-card-link h3 {
    font-size: 1.25rem; /* 20px */
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 0.5em;
    color: #1d1d1f;
}

.recipe-card-description {
    font-size: 0.9rem; /* 14.4px */
    color: #6e6e73; /* Серый для описания */
    line-height: 1.5;
    height: 3em; /* Ограничение в 2 строки */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}


/* Страница рецепта */
.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    padding: 0.5em 1em;
    border-radius: 8px;
    background-color: #e9e9eb;
    color: #007aff;
    transition: background-color 0.2s;
}
.back-link:hover {
    background-color: #dcdce1;
    text-decoration: none;
}

.recipe-page-title {
    text-align: center;
    margin-bottom: 2rem;
}

.recipe-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 18px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.recipe-main-info {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 2rem;
}

.recipe-image-container {
    flex: 1 1 300px; /* Адаптивность для картинки */
}

.recipe-image-full {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 12px;
    background-color: #f5f5f7;
}

.recipe-description-container {
    flex: 2 1 400px; /* Больше места для описания */
}

/* Калькулятор ингредиентов - табличный вид */
.recipe-calculator-section {
    margin-top: 2rem;
}

.calculator-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.calculator-controls label {
    font-weight: 500;
    font-size: 1rem;
    color: #333;
}

#servings-input {
    padding: 10px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px; /* Скругление Apple */
    width: 100px;
    font-size: 1rem;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#servings-input:focus {
    border-color: #007aff; /* Подсветка при фокусе */
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25); /* Эффект свечения Apple */
    outline: none;
}

.ingredients-table {
    border: 1px solid #e5e5e5; /* Тонкая рамка для таблицы */
    border-radius: 12px;      /* Скругление */
    overflow: hidden;         /* Чтобы скругление работало для дочерних элементов */
    margin-bottom: 1rem;
}

.ingredients-table-header,
.ingredient-row {
    display: flex;
    border-bottom: 1px solid #e5e5e5; /* Разделители строк */
}
.ingredients-table-header {
    background-color: #f9f9f9; /* Очень легкий фон для заголовка */
    font-weight: 500;
    color: #333;
}
#ingredients-list-table-body .ingredient-row:last-child {
    border-bottom: none; /* Убираем рамку у последней строки */
}


.ingredient-name-col,
.ingredient-quantity-col {
    padding: 12px 15px;
    display: flex;
    align-items: center;
}

.ingredient-name-col {
    flex-grow: 1; /* Занимает большую часть пространства */
    flex-basis: 65%;
    color: #1d1d1f;
}

.ingredient-quantity-col {
    flex-basis: 35%;
    justify-content: flex-end; /* Выравнивание по правому краю */
    font-weight: 500; /* Количество делаем чуть жирнее */
    color: #333;
    white-space: nowrap; /* Чтобы не переносилось на новую строку */
}

.ingredient-quantity-col .quantity-value {
    margin-right: 0.3em;
}

/* Примечания к рецепту */
.recipe-notes-text {
    font-size: 0.875rem;
    color: #6e6e73;
    margin-top: 1rem;
    padding: 10px;
    background-color: #f5f5f7;
    border-radius: 8px;
}

/* Инструкции по приготовлению */
.recipe-instructions-section {
    margin-top: 2rem;
}

#instructions-list {
    list-style-type: none; /* Убираем стандартные маркеры */
    padding-left: 0;
    counter-reset: instruction-counter; /* Инициализируем счетчик */
}

#instructions-list li {
    position: relative;
    padding-left: 2.5em; /* Место для кастомного номера */
    margin-bottom: 1em;
    line-height: 1.7;
    color: #333;
}

#instructions-list li::before {
    counter-increment: instruction-counter; /* Увеличиваем счетчик */
    content: counter(instruction-counter) "."; /* Отображаем номер */
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 600;
    color: #007aff; /* Синий для номеров шагов */
    font-size: 1.1em;
    width: 1.8em; /* Ширина для выравнивания */
    text-align: right;
    padding-right: 0.5em;
}


/* Адаптивность */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem; /* 32px */
    }
    .site-header h1 {
        font-size: 1.25rem; /* 20px */
    }

    .recipe-content {
        padding: 20px;
    }

    recipe-main-info {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 0.5rem; /* Более агрессивное уменьшение, как обсуждали */
    }

    .recipe-description-container {
        flex-grow: 0;
        flex-shrink: 0;
        height: auto;
        min-height: initial;
        align-self: flex-start; /* <<< ДОБАВЛЕНО ЭТО СВОЙСТВО */
        /* background-color: lightpink; */ /* Для визуальной проверки границ блока */
    }
    .recipe-description-container h2 {
        margin-top: 0;
        margin-bottom: 0.4em;
    }
    #recipe-description-text {
        margin-top: 0;
        margin-bottom: 0;
        line-height: 1.5;
        /* background-color: lightgreen; */ /* Для визуальной проверки границ текста */
    }

    .recipe-calculator-section,
    .recipe-instructions-section {
        margin-top: 0.8rem;
                              /* УМЕНЬШИМ ЭТО ЗНАЧЕНИЕ ЕЩЕ */
    }

    .ingredient-name-col {
        flex-basis: 60%;
    }
    .ingredient-quantity-col {
        flex-basis: 40%;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    .recipe-grid {
        gap: 15px;
    }

    .recipe-card-link {
        padding: 15px;
        border-radius: 12px;
    }
    .recipe-card-image {
        height: 150px;
    }
    .recipe-card-link h3 {
        font-size: 1.1rem;
    }

    .recipe-content {
        padding: 15px;
        border-radius: 12px;
    }

    .recipe-main-info {
        gap: 10px;
        margin-bottom: 0.5rem; /* Значительно уменьшаем отступ */
    }
    #recipe-description-text {
        font-size: 0.9rem; /* Можно сделать текст чуть меньше */
    }

    .recipe-calculator-section,
    .recipe-instructions-section {
        margin-top: 0.8rem; /* Значительно уменьшаем отступ */
    }

    .ingredients-table-header,
    .ingredient-row {
        font-size: 0.9rem; /* Уменьшаем шрифт в таблице на маленьких экранах */
    }
    .ingredient-name-col,
    .ingredient-quantity-col {
        padding: 10px;
    }

    #instructions-list li {
        padding-left: 2em;
    }
    #instructions-list li::before {
        width: 1.5em;
    }

    .calculator-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    #servings-input {
        width: 100%; /* Поле ввода на всю ширину */
    }
}
