/* Recipe cooking tools: YouTube embed, timers, wake lock */

/* ── YouTube video ── */
.recipe-video-card {
    margin-top: 24px;
}

.recipe-video-wrap {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 16px;
    background: #111;
}

.recipe-video-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ── Tools wrapper ── */
.recipe-tools-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
    margin: 24px auto;
    padding: 20px 22px;
    background: linear-gradient(135deg, #fff3e6, #fdeadb);
    border: 1px solid #f2d9bb;
    border-radius: 18px;
}

@media (prefers-color-scheme: dark) {
    .recipe-tools-wrap { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.1); }
}
:root[data-theme="dark"] .recipe-tools-wrap { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.1); }

/* ── Wake lock button ── */
.recipe-wakelock-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font: inherit;
    font-size: 13px;
    color: var(--text, #2a1a12);
    background: #fff;
    border: 1px solid var(--border, #e8d9cc);
    border-radius: 50px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}

.recipe-wakelock-btn:hover { background: #fff4ed; border-color: #d9bfae; }

.recipe-wakelock-btn.recipe-wakelock--active {
    color: #7b4f1a;
    background: #fff4e0;
    border-color: #f2c97f;
}

.recipe-wakelock-icon { font-size: 15px; }

/* ── Timers section ── */
.recipe-timers {
    flex: 1 1 300px;
    min-width: 0;
}

.recipe-timers-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.recipe-timers-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted, #7a6558);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.recipe-timers-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.recipe-timer-preset {
    padding: 5px 11px;
    font: inherit;
    font-size: 13px;
    color: var(--accent, #c0613a);
    background: transparent;
    border: 1px solid var(--accent, #c0613a);
    border-radius: 50px;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.recipe-timer-preset:hover {
    background: var(--accent, #c0613a);
    color: #fff;
}

.recipe-timers-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ── Individual timer ── */
.recipe-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border, #e8d9cc);
    border-radius: 14px;
    transition: border-color .15s;
}

@media (prefers-color-scheme: dark) {
    .recipe-timer { background: rgba(255,255,255,.07); }
}
:root[data-theme="dark"] .recipe-timer { background: rgba(255,255,255,.07); }

.recipe-timer--running { border-color: #f2a97f; }
.recipe-timer--done { border-color: #4caf50; background: #f0fff0; }

.recipe-timer-label {
    font-size: 12px;
    color: var(--muted, #7a6558);
    white-space: nowrap;
}

.recipe-timer-display {
    font-variant-numeric: tabular-nums;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text, #2a1a12);
    min-width: 3.2ch;
    text-align: center;
}

.recipe-timer--done .recipe-timer-display { color: #2e7d32; }

.recipe-timer-btn {
    padding: 4px 8px;
    font: inherit;
    font-size: 14px;
    background: transparent;
    border: 1px solid var(--border, #e8d9cc);
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    transition: background .12s;
}

.recipe-timer-btn:hover { background: var(--surface-soft, #fff4ed); }
.recipe-timer-reset { opacity: .55; }
.recipe-timer-reset:hover { opacity: 1; }

.recipe-timer-close {
    opacity: .55;
    color: #b3453b;
}
.recipe-timer-close:hover {
    opacity: 1;
    background: rgba(179, 69, 59, .1);
}

/* ── Улучшенное выравнивание блока инструментов ── */
.recipe-tools-wrap {
    padding: clamp(20px, 3vw, 28px);
    border-radius: var(--radius-large, 18px);
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .recipe-tools-wrap {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 18px;
    }
    .recipe-wakelock-btn {
        justify-content: center;
        width: 100%;
    }
    .recipe-timers-head {
        justify-content: space-between;
    }
    .recipe-timers-presets {
        justify-content: flex-start;
    }
    .recipe-timer-preset {
        flex: 1 1 calc(25% - 6px);
        text-align: center;
    }
    .recipe-timers-list {
        justify-content: stretch;
    }
    .recipe-timer {
        flex: 1 1 100%;
        justify-content: space-between;
    }
}

.recipe-timer-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.recipe-timer--running .recipe-timer-btn:first-of-type {
    background: #c0613a;
    color: #fff;
    border-color: #c0613a;
}
.recipe-timer-close {
    background: #fdece7;
    color: #c0613a;
    border-color: transparent;
}
.recipe-timer-close:hover {
    background: #fbd8ce;
}


/* ==========================================================
   Performance v2.1 — recipe cover LCP / CLS contract
   ========================================================== */

/*
 * The recipe cover is inserted after the recipe API request.
 *
 * Reserve a stable visual box so the rest of the recipe does not
 * jump when the full-size photograph finishes loading.
 *
 * object-fit: contain remains intentional because recipe covers may
 * be portrait or landscape and should not be aggressively cropped.
 */
.recipe-cover {
    aspect-ratio: 4 / 3;
}

.recipe-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/*
 * On narrow screens we keep the same reserved ratio.
 * The mobile edge-to-edge stylesheet may remove radius/borders,
 * but must not remove the geometry reservation.
 */
@media (max-width: 520px) {
    .recipe-cover {
        aspect-ratio: 4 / 3;
    }
}


/* ==========================================================
   Recipe Header 2.0
   ========================================================== */

/*
 * The recipe hero is now a single full-width information card.
 * The former right-hand summary duplicated metadata and created
 * unnecessary empty space on shorter recipes.
 */
.recipe-page .recipe-hero {
    grid-template-columns: minmax(0, 1fr);
}

.recipe-page .recipe-intro {
    width: 100%;
    box-sizing: border-box;
}

/*
 * Recipe metadata uses the same visual language as recipe cards.
 * Difficulty is deliberately stronger; secondary facts stay quiet.
 */
.recipe-page .recipe-meta {
    align-items: center;
    gap: 9px;
}

.recipe-page .recipe-meta-item {
    display: inline-flex;
    align-items: center;

    min-height: 34px;
    box-sizing: border-box;

    padding: 7px 12px;

    border: 1px solid transparent;
    border-radius: 999px;

    line-height: 1.2;
}

/*
 * These difficulty colours intentionally match recipe-cards.css.
 * That stylesheet remains the canonical palette and its contrast
 * is covered by recipe-card-contrast.py.
 */
.recipe-page .recipe-meta-item.difficulty-easy {
    background: #dff3df !important;
    border-color: #b8ddb8 !important;
    color: #32733a !important;
}

.recipe-page .recipe-meta-item.difficulty-medium {
    background: #ffe8a8 !important;
    border-color: #e9c96a !important;
    color: #855800 !important;
}

.recipe-page .recipe-meta-item.difficulty-hard {
    background: #ffdada !important;
    border-color: #e8aaaa !important;
    color: #a03939 !important;
}

.recipe-page .recipe-meta-time,
.recipe-page .recipe-meta-views {
    white-space: nowrap;
}

@media (max-width: 520px) {
    .recipe-page .recipe-meta {
        gap: 8px;
    }

    .recipe-page .recipe-meta-item {
        min-height: 32px;
        padding: 7px 10px;
        font-size: 13px;
    }
}

/* ==========================================================
   Mobile recipe edge-to-edge — final cascade contract
   ========================================================== *//* ==========================================================
   Mobile recipe edge-to-edge — viewport contract
   ========================================================== */

/*
 * Public recipe pages deliberately use the complete phone width.
 *
 * The main cover is rendered inside #recipe-app.
 * Cooking tools are NOT children of .recipe-page: recipe-tools.js
 * inserts .recipe-tools-wrap immediately after #recipe-app.
 *
 * Therefore these two blocks intentionally use different selectors.
 * Desktop layout remains unchanged.
 */
@media (max-width: 640px) {

    /*
     * Main recipe photograph.
     *
     * Use a viewport breakout rather than relying on the width of
     * an ancestor container. This guarantees that the photograph
     * reaches both physical edges of the phone viewport.
     */
    .recipe-page > .recipe-cover {
        width: 100vw;
        max-width: none;

        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);

        aspect-ratio: auto;

        border-left: 0;
        border-right: 0;
        border-radius: 0;

        box-shadow: none;
    }

    .recipe-page > .recipe-cover img,
    .recipe-page > .recipe-cover .recipe-image {
        display: block;

        width: 100%;
        max-width: none;
        height: auto;

        object-fit: initial;

        border-radius: 0;
    }

    /*
     * Cooking tools are a sibling of #recipe-app, not its child.
     *
     * Do not prefix this selector with .recipe-page.
     * The wrapper itself becomes full viewport width while its
     * internal controls keep comfortable horizontal padding.
     */
    .recipe-tools-wrap.container {
        width: 100vw;
        max-width: none;

        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);

        padding: 18px 16px;

        border-left: 0;
        border-right: 0;
        border-radius: 0;

        box-shadow: none;
    }
}
