/* painting-recipe.css - レシピ詳細ページ（v2 + 料理中UX + Related）
   ブランド構造「Painting（絵画）」: 物語・情緒・没入
   分割元: style.css @layer components + unlayered セクション */

@layer components {

    /* ── Phase 2: 料理中UX改善 (旧4th @layer components, 統合) ── */

    /* アンカーターゲットのスクロールオフセット（ヘッダー高さ分） */
    #recipe-ingredients,
    #recipe-instructions {
        scroll-margin-top: calc(var(--header-safe-zone) + 20px);
    }

    /* =========================================
       Phase 3 Group A: お気に入り・コピー・共有・チェック
       ========================================= */

    /* お気に入りボタン（共通スタイルは components-common.css に移動済み） */

    /* 詳細ページのお気に入りボタン */
    .favorite-toggle-detail {
        position: static;
        background: transparent;
        backdrop-filter: none;
        min-width: 44px;
        min-height: 44px;
        width: auto;
        height: auto;
        padding: 0.5rem;
    }

    /* お気に入りフィルターバー */
    .favorite-filter-bar {
        padding: 0 1rem 0.5rem;
    }

    .favorite-filter-chip svg {
        margin-right: 0.25rem;
    }

    /* 材料コピーボタン */
    .copy-ingredients-btn {
        font-size: var(--fs-sm);
        color: var(--text-color);
        background: transparent;
        border: 1px solid var(--color-sub);
        border-radius: var(--radius-pill);
        padding: 0.5rem 1.25rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 1rem;
    }

    .copy-ingredients-btn:hover {
        background: var(--hover-accent-bg);
        border-color: var(--color-accent);
        color: var(--color-accent);
    }

    .copy-ingredients-btn.copied {
        background: var(--color-accent);
        border-color: var(--color-accent);
        color: #fff;
    }

    /* モバイル/デスクトップ出し分け（汎用） */
    .mobile-only {
        display: block;
    }
    .desktop-only {
        display: none;
    }
    @media (min-width: 1024px) {
        .mobile-only {
            display: none;
        }
        .desktop-only {
            display: block;
        }
    }

    /* 非表示ユーティリティ */
    .is-hidden {
        display: none;
    }

    /* 材料チェック機能 */
    .ingredient-item {
        cursor: pointer;
        transition: opacity var(--transition-base);
    }

    .ingredient-item.checked {
        opacity: 0.4;
        text-decoration: line-through;
    }

    /* ── Recipe Detail v2 (旧7th @layer components, 統合) ── */

    /* ── レイアウト基盤 ── */
    .recipe-layout-v2 {
        max-width: var(--container-max-width);
        margin: 0 auto;
        padding: var(--header-safe-zone) 0 4rem;
    }

    .recipe-hero-fullbleed + .recipe-layout-v2,
    .breadcrumb-bar + .recipe-layout-v2 {
        padding-top: 0;
    }

    /* コンテンツ幅制御 */
    .content-narrow {
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    .content-wide {
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    @media (max-width: 768px) {
        .content-narrow,
        .content-wide {
            padding-left: 2rem;
            padding-right: 2rem;
        }
    }

    /* ── レシピヘッダー v2 ── */
    .recipe-header-v2 {
        padding-top: 3rem;
        padding-bottom: 1rem;
    }

    .recipe-header-v2 .header-top-row {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 1rem;
    }

    @media (min-width: 1024px) {
        .recipe-header-v2 {
            padding-top: 4rem;
        }
    }

    /* ── アレルゲン（アコーディオン化） ── */
    .allergen-disclosure {
        margin-top: 1.5rem;
        border-top: 1px solid var(--color-sub);
        padding-top: 1rem;
    }

    .allergen-toggle {
        background: none;
        border: none;
        font-family: var(--font-ui);
        font-size: var(--fs-sm);
        font-weight: 700;
        letter-spacing: 0.04em;
        color: #999;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0;
    }

    .allergen-toggle .arrow {
        transition: transform var(--transition-base);
        font-size: var(--fs-xs);
    }

    .allergen-toggle[aria-expanded="true"] .arrow {
        transform: rotate(90deg);
    }

    .allergen-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--transition-base);
    }

    .allergen-content.open {
        max-height: 400px;
    }

    .allergen-badges {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        padding-top: 0.75rem;
    }

    .allergen-disclosure .allergen-badge {
        font-family: var(--font-ui);
        font-size: var(--fs-xs);
        font-weight: 700;
        letter-spacing: 0.02em;
        background: var(--color-sub);
        color: #777;
        padding: 0.2rem 0.6rem;
        border-radius: 2px;
        border: none;
    }

    .info-badge {
        font-family: var(--font-ui);
        font-size: var(--fs-xs);
        font-weight: 700;
        background: var(--hover-accent-bg);
        color: var(--color-accent);
        padding: 0.2rem 0.6rem;
        border-radius: 2px;
    }

    /* ── recipe_story v2（この料理の物語） ── */
    .recipe-story-section {
        padding-top: 4rem;
        padding-bottom: 3rem;
    }

    .recipe-story-section .recipe-story-text {
        font-family: var(--font-base);
        font-size: 1.05rem;
        font-weight: 400;
        letter-spacing: 0.06em;
        line-height: 2.4;
        color: #555;
        font-feature-settings: "palt";
    }

    /* ── 区切り線 ── */
    .section-divider {
        border: none;
        border-top: 1px solid var(--color-sub);
        margin: 2rem auto;
        max-width: 120px;
    }

    /* ── 材料セクション v2 ── */
    .ingredients-section-v2 {
        position: relative;
        padding-top: 3rem;
        padding-bottom: 3rem;
        padding-left: 3rem;
    }

    .ingredients-header {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        margin-bottom: 2rem;
    }

    .section-title-en {
        font-family: var(--font-ui);
        font-size: var(--fs-sm);
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: lowercase;
        color: #999;
        margin: 0;
    }


    /* ── 手順セクション v2（背景番号の大胆化） ── */
    .instructions-section-v2 {
        padding-top: 3rem;
        padding-bottom: 4rem;
    }

    .instructions-section-v2 .section-title-en {
        max-width: calc(720px - 4rem);
        margin: 0 auto 2rem;
    }

    .step-item-v2 {
        position: relative;
        padding: 3rem 0;
    }

    .step-bg-number {
        position: absolute;
        top: 1.5rem;
        left: -0.5rem;
        font-family: var(--font-ui);
        font-size: 6rem;
        font-weight: 700;
        letter-spacing: 0.02em;
        color: rgba(197, 160, 89, 0.08);
        line-height: 1;
        user-select: none;
        pointer-events: none;
    }

    .step-item-v2 .step-text {
        position: relative;
        z-index: 1;
        padding-left: 4.5rem;
        font-size: 1rem;
        line-height: 2.0;
        color: #555;
    }

    .step-item-v2 .step-image {
        margin-top: 1.5rem;
        margin-left: 4.5rem;
        border-radius: 6px;
        overflow: hidden;
        max-width: 480px;
    }

    .step-item-v2 .step-image img {
        width: 100%;
        height: auto;
        display: block;
    }

    @media (max-width: 768px) {
        .step-bg-number {
            font-size: 4rem;
        }

        .step-item-v2 .step-text {
            padding-left: 3rem;
        }

        .step-item-v2 .step-image {
            margin-left: 3rem;
        }
    }

    /* ── Graphic Recording v2 ── */
    .graphic-recording-section {
        padding: 2rem 2rem 3rem;
        text-align: center;
        background: linear-gradient(180deg, var(--bg-color) 0%, rgba(235, 233, 228, 0.15) 100%);
    }

    .graphic-recording-section img {
        max-width: 100%;
        height: auto;
        border-radius: var(--radius-md);
    }

    /* ── Styling Note v2（グラデーション背景 + 2カラム） ── */
    .styling-note-section {
        padding: 6rem 0 5rem;
        background: linear-gradient(180deg, var(--bg-color) 0%, rgba(235, 233, 228, 0.3) 50%, var(--bg-color) 100%);
    }

    .styling-note-inner {
        display: grid;
        grid-template-columns: 1.2fr 1fr;
        gap: 3rem;
        align-items: center;
    }

    .styling-note-image {
        border-radius: var(--radius-md);
        overflow: hidden;
    }

    .styling-note-image img {
        width: 100%;
        height: auto;
        display: block;
    }

    .styling-note-label {
        font-family: var(--font-ui);
        font-size: var(--fs-sm);
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: lowercase;
        color: #999;
        margin-bottom: 1rem;
    }

    .styling-note-body {
        font-size: var(--fs-md);
        line-height: 2.2;
        color: #666;
    }

    .styling-note-author {
        font-family: var(--font-ui);
        font-style: italic;
        font-size: var(--fs-base);
        color: #aaa;
        margin-top: 1.5rem;
    }

    @media (max-width: 768px) {
        .styling-note-inner {
            grid-template-columns: 1fr;
        }
    }

    /* ── クロージング（Peak-End） ── */
    .closing-section {
        padding: 6rem 0;
        text-align: center;
    }

    .closing-message {
        font-family: var(--font-base);
        font-size: 1.4rem;
        font-weight: 500;
        letter-spacing: 0.1em;
        color: var(--color-accent);
        margin-bottom: 0.5rem;
    }

    .closing-hashtag {
        font-family: var(--font-ui);
        font-size: var(--fs-sm);
        font-weight: 700;
        letter-spacing: 0.04em;
        color: #bbb;
    }

    /* ── モバイル版「間（Ma）」調整 ── */
    @media (max-width: 768px) {

        /* M2: セクション間余白のモバイル縮小 */
        .recipe-story-section {
            padding-top: 3rem;
            padding-bottom: 2rem;
        }

        .instructions-section-v2 {
            padding-bottom: 3rem;
        }

        .styling-note-section {
            padding: 4rem 0 3rem;
        }

        .closing-section {
            padding: 4rem 0;
        }

        /* M3: クロージングメッセージのモバイル調整 */
        .closing-message {
            font-size: 1.2rem;
            letter-spacing: 0.08em;
        }

        /* M4: 区切り線のモバイル余白 */
        .section-divider {
            margin: 1.5rem auto;
        }

    }

    /* カードメタ情報のパイプ区切り */
    .card-meta-separator {
        color: var(--color-sub);
        margin: 0 0.15rem;
    }

    /* ── Breathing Grid: フィルターモーダル ── */

    /* アクティブフィルターバー */
    .active-filters-bar {
        text-align: center;
        padding: 1rem 0 1.5rem;
    }
    .active-filters-label {
        font-family: var(--font-base);
        font-size: var(--fs-sm);
        color: var(--color-text-muted);
        letter-spacing: 0.06em;
        display: block;
        margin-bottom: 0.5rem;
    }
    .active-filters-list {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .active-filter-badge {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.35rem 0.9rem;
        background: rgba(197, 160, 89, 0.08);
        border: 1px solid rgba(197, 160, 89, 0.3);
        border-radius: var(--radius-chip);
        font-family: var(--font-base);
        font-size: var(--fs-xs);
        color: var(--text-color);
        text-decoration: none;
        transition: all var(--transition-accent);
    }
    .active-filter-badge:hover {
        background: var(--hover-accent-bg);
        border-color: var(--color-accent);
        color: var(--color-accent);
    }
    .badge-remove {
        color: var(--color-accent);
        font-size: var(--fs-sm);
    }
    .active-filter-clear {
        font-family: var(--font-ui);
        font-size: var(--fs-2xs);
        color: var(--color-accent);
        text-decoration: none;
        margin-left: 0.3rem;
    }
    .active-filters-count {
        display: block;
        font-family: var(--font-ui);
        font-size: var(--fs-2xs);
        color: var(--color-text-muted);
        margin-top: 0.5rem;
        letter-spacing: 0.02em;
    }

    /* モーダルオーバーレイ */
    .filter-modal-overlay {
        position: fixed;
        inset: 0;
        background: var(--color-overlay);
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-base), visibility var(--transition-base);
    }
    .filter-modal-overlay.is-open {
        opacity: 1;
        visibility: visible;
    }

    /* モーダル本体 */
    .filter-modal {
        background: var(--bg-color);
        border-radius: var(--radius-card);
        max-width: 480px;
        width: 90%;
        max-height: 80vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: scale(0.95);
        transition: transform 0.3s cubic-bezier(0.83, 0, 0.17, 1);
    }
    .filter-modal-overlay.is-open .filter-modal {
        transform: scale(1);
    }
    .filter-modal-dragbar {
        display: none;
    }
    .filter-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem 1.5rem 0;
    }
    .filter-modal-title {
        font-family: var(--font-ui);
        font-size: var(--fs-base);
        font-weight: var(--fw-bold);
        letter-spacing: 0.04em;
        color: var(--text-color);
    }
    .filter-modal-close {
        background: none;
        border: none;
        font-size: 1rem;
        color: var(--color-text-muted);
        cursor: pointer;
        padding: 0.5rem;
    }
    .filter-modal-body {
        padding: 1rem 1.5rem 1.5rem;
    }

    /* モーダル表示中のスクロールロック */
    body.modal-open {
        overflow: hidden;
    }

    /* フィルター0件 Empty State */
    .filter-empty-state {
        text-align: center;
        padding: 4rem 2rem;
        font-family: var(--font-base);
        color: var(--color-text-muted);
        font-size: var(--fs-md);
        line-height: 2.0;
        letter-spacing: 0.05em;
    }
    .filter-empty-reset {
        display: inline-block;
        margin-top: 1rem;
        font-size: var(--fs-sm);
        color: var(--color-accent);
        border: 1px solid var(--color-accent);
        border-radius: var(--radius-pill);
        padding: 0.75rem 2rem;
    }

}

/* ===================================
   Related Recipes Section (Unlayered)
   =================================== */
.related-recipes {
    margin-top: 5rem;
    padding: 3rem 0;
    border-top: 1px solid var(--color-sub);
}

.related-recipes-title {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: var(--fs-base);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: var(--color-accent);
    margin-bottom: 2rem;
}

.related-recipes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .related-recipes-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* Related Recipe Card */
.related-recipe-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

/* related-recipe-card: カード画像のホバーは thumbnail img の hover-scale のみ */

.related-recipe-thumbnail {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius-card);
    margin-bottom: 0.75rem;
    background-color: var(--color-sub);
}

.related-recipe-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.related-recipe-card:hover .related-recipe-thumbnail img {
    transform: var(--hover-scale);
}

.related-recipe-no-image {
    width: 100%;
    height: 100%;
    background-color: var(--color-sub);
}

.related-recipe-name {
    font-family: var(--font-base);
    font-size: var(--fs-md);
    font-weight: 500;
    line-height: 1.5;
    color: var(--text-color);
    margin: 0 0 0.25rem 0;
}

.related-recipe-category {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    color: var(--color-accent);
    display: block;
}

/* =========================================
   Typography: Recipe Page-Scoped (Unlayered)
   Unlayered CSS > @layer (Cascade priority)
   ========================================= */

/* -----------------------------------------
   Recipe Page: Emotional Content (Mincho)
   ----------------------------------------- */
.single-recipe .recipe-title,
.single-recipe .recipe-summary,
.single-recipe .author-sign,
.recipe-content p,
.recipe-content h1,
.recipe-content h2,
.recipe-content h3 {
    font-family: var(--font-base);
    font-weight: var(--fw-reg);
}

/* -----------------------------------------
   Recipe Page: Functional UI (Helvetica)
   ----------------------------------------- */
.single-recipe .recipe-label,
.single-recipe .recipe-meta,
.single-recipe h2.vertical-title,
.single-recipe h2.instructions-title,
.single-recipe h3.note-title,
.single-recipe .step-num {
    font-family: var(--font-ui);
    font-weight: var(--fw-bold);
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

/* -----------------------------------------
   Ingredient Amount (Special Case)
   ----------------------------------------- */
.ingredient-amount {
    font-family: var(--font-base);
    font-weight: 500;
    font-feature-settings: normal;
    font-variant-numeric: normal;
    letter-spacing: 0.05em;
}

.ingredient-unit {
    font-size: var(--fs-md);
    margin-left: 0.1em;
}

/* =========================================
   Recipe Detail v2 — Unlayered Overrides
   既存の unlayered スタイル（.recipe-title, .recipe-meta 等）を
   上書きするため、@layer の外に配置
   ========================================= */

/* レシピヘッダー v2: タイトル */
.recipe-header-v2 .recipe-title {
    font-size: 1.8rem;
    font-weight: 500;
    line-height: 1.6;
    margin: 0 0 1rem;
}

@media (min-width: 1024px) {
    .recipe-header-v2 .recipe-title {
        font-size: 2rem;
    }
}

/* レシピヘッダー v2: メタ情報（ゴールド→グレー、モックアップ準拠） */
.recipe-header-v2 .recipe-meta {
    color: #999;
    font-size: var(--fs-sm);
}

.recipe-header-v2 .recipe-meta-icon {
    color: #999;
    stroke: #999;
}

/* レシピヘッダー v2: サマリー */
.recipe-header-v2 .recipe-summary {
    font-size: 0.92rem;
    line-height: 2;
    color: #777;
    margin-top: 0.5rem;
}

/* お気に入りボタン v2: ヘッダー内丸ボタン */
.recipe-header-v2 .favorite-toggle-detail {
    background: none;
    border: 1px solid var(--color-sub);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-accent);
    transition: background var(--transition-base);
    flex-shrink: 0;
    padding: 0;
    backdrop-filter: none;
}

.recipe-header-v2 .favorite-toggle-detail:hover {
    background: var(--hover-accent-bg);
}

/* M5: 関連レシピ（unlayered override）
   既存 .related-recipes（line 2668）が unlayered のため、
   @layer components 内では上書きできない */
.recipe-layout-v2 .related-recipes {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    padding: 4rem 2rem 0;
}

.recipe-layout-v2 .related-recipes-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
    .recipe-layout-v2 .related-recipes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .recipe-layout-v2 .related-recipes {
        padding: 3rem 2rem 0;
    }

    .recipe-layout-v2 .related-recipes-grid {
        grid-template-columns: 1fr;
    }
}

/* 詳細ページのお気に入りボタン
   unlayered: components-common.css の .favorite-toggle を上書き
   .favorite-toggle.favorite-toggle-detail で詳細度を上げて確実に勝たせる */
.favorite-toggle.favorite-toggle-detail {
    position: static;
    top: auto;
    right: auto;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    min-width: 44px;
    min-height: 44px;
    width: auto;
    height: auto;
    padding: 0.5rem;
}
