/* recipe_detail.css v2 — ギャラリーデザインに統一 */
@import url("theme.css");

/* ═══════════════════════════════
   サブナビ（スティッキー）
═══════════════════════════════ */
.rd-subnav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--secondary-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    position: sticky;
    top: 50px;
    z-index: 900;
    min-height: 48px;
    box-sizing: border-box;
}
@media (max-width: 768px) {
    .rd-subnav { top: 100px; }
}
.rd-back-btn {
    background: none;
    border: 1.5px solid var(--secondary-hover, #ccc);
    border-radius: 50px;
    padding: 5px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-color);
    white-space: nowrap;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.rd-back-btn:hover {
    background: var(--container-transparent);
    border-color: var(--accent-color);
}
.rd-subnav-title {
    flex: 1;
    font-weight: 700;
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-color);
}
.rd-img-toggle {
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--text-color);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

/* ═══════════════════════════════
   ページコンテナ
═══════════════════════════════ */
.rd-page {
    max-width: 780px;
    margin: 0 auto;
    padding: 20px 16px 80px;
    box-sizing: border-box;
}

/* ═══════════════════════════════
   ヒーロー（メイン画像 + 概要）
═══════════════════════════════ */
.rd-hero {
    background: var(--section-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.09);
}
.rd-hero-img-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--secondary-bg);
}
.rd-hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    display: block;
    transition: transform 0.3s ease;
}
.rd-hero-img:hover { transform: scale(1.02); }
.rd-hero-img-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
}
/* カテゴリバッジ（ギャラリーと共通クラス使用） */
.rd-hero-cat {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}
.rd-cat-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}
.rd-cat-主食   { background: rgba(255, 112, 67, 0.92); }
.rd-cat-主菜   { background: rgba(229, 57, 53, 0.92); }
.rd-cat-副菜   { background: rgba(67, 160, 71, 0.92); }
.rd-cat-汁物   { background: rgba(30, 136, 229, 0.92); }
.rd-cat-デザート { background: rgba(142, 36, 170, 0.92); }
.rd-cat-その他  { background: rgba(96, 125, 139, 0.8); }

.rd-hero-body {
    padding: 20px 24px 24px;
}
.rd-hero-title {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0 0 10px;
    color: var(--text-color);
    line-height: 1.25;
}
.rd-hero-desc {
    font-size: 0.92rem;
    color: var(--text-color);
    opacity: 0.72;
    margin: 0 0 18px;
    line-height: 1.65;
}
.rd-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.rd-stat {
    background: var(--primary-bg);
    border-radius: 10px;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    gap: 2px;
}
.rd-stat-val {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
}
.rd-stat-label {
    font-size: 0.7rem;
    color: var(--text-color);
    opacity: 0.6;
}
.rd-edit-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--accent-color);
    text-decoration: none;
    border: 1.5px solid var(--accent-color);
    padding: 6px 16px;
    border-radius: 50px;
    transition: background 0.15s, color 0.15s;
    margin-top: 4px;
}
.rd-edit-link:hover { background: var(--accent-color); color: #fff; }

/* ═══════════════════════════════
   セクションカード共通
═══════════════════════════════ */
.rd-card {
    background: var(--section-bg);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    margin-top: 18px;
    overflow: hidden;
}
.rd-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}
.rd-section-title::before {
    content: '';
    display: block;
    width: 4px;
    height: 1em;
    border-radius: 2px;
    background: var(--accent-color);
    flex-shrink: 0;
}

/* ═══════════════════════════════
   材料リスト
═══════════════════════════════ */
.rd-ingredient-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.88rem;
}
.rd-ingredient-row:last-child { border-bottom: none; }
.rd-ing-name {
    font-weight: 600;
    color: var(--text-color);
    flex: 2;
    min-width: 0;
}
.rd-ing-remark {
    color: var(--text-color);
    opacity: 0.58;
    flex: 2;
    font-size: 0.8rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rd-ing-qty {
    color: var(--text-color);
    flex: 1;
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.9rem;
}
.rd-ing-status {
    flex-shrink: 0;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 50px;
    font-weight: 600;
    min-width: 48px;
    text-align: center;
}

/* 在庫ステータス */
.status-sufficient { background: #e0ffe0; color: #2a7a2a; }
.status-low { background: #fff3cd; color: #856404; }
.status-out { background: #ffe0e0; color: #c82333; }
.status-virtual { background: #cce5ff; color: #004085; }

/* ═══════════════════════════════
   作り方ステップ
═══════════════════════════════ */
.rd-steps {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rd-step {
    display: flex;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    align-items: flex-start;
}
.rd-step:last-child { border-bottom: none; }
.rd-step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.rd-step-body { flex: 1; min-width: 0; }
.rd-step-desc {
    margin: 0 0 10px;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-color);
}
.rd-step-img {
    width: 100%;
    max-width: 200px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    display: block;
    transition: transform 0.2s ease;
}
.rd-step-img:hover { transform: scale(1.02); }

/* ═══════════════════════════════
   栄養情報（折りたたみ）
═══════════════════════════════ */
.rd-details > summary {
    list-style: none;
    cursor: pointer;
}
.rd-details > summary::-webkit-details-marker { display: none; }
.rd-details > summary .rd-section-title { cursor: pointer; }
.rd-details > summary .rd-chevron { margin-left: auto; font-size: 0.8rem; opacity: 0.6; transition: transform 0.2s; }
.rd-details[open] > summary .rd-chevron { transform: rotate(180deg); }

.rd-nutrition-wrap {
    padding: 4px 0 4px;
    overflow-x: auto;
}
.rd-nutrition-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.rd-nutrition-table th {
    background: var(--primary-bg);
    padding: 8px 10px;
    font-weight: 600;
    color: var(--text-color);
    text-align: right;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    white-space: nowrap;
}
.rd-nutrition-table th:first-child { text-align: left; }
.rd-nutrition-table td {
    padding: 7px 10px;
    color: var(--text-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    text-align: right;
}
.rd-nutrition-table td:first-child { text-align: left; }
.rd-nutrition-total td {
    background: var(--primary-bg);
    font-weight: 700;
    border-bottom: none;
}

/* ═══════════════════════════════
   関連情報・メタ情報
═══════════════════════════════ */
.rd-meta-body { padding: 12px 20px 16px; }
.rd-meta-row {
    font-size: 0.85rem;
    color: var(--text-color);
    margin-bottom: 10px;
    line-height: 1.5;
}
.rd-meta-row:last-child { margin-bottom: 0; }
.rd-meta-row a { color: var(--accent-color); }
.rd-related-list {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}
.rd-related-list li { padding: 3px 0; }
.rd-related-list a {
    color: var(--accent-color);
    font-size: 0.88rem;
    text-decoration: none;
}
.rd-related-list a:hover { text-decoration: underline; }
.rd-meta-pre {
    font-size: 0.82rem;
    color: var(--text-color);
    opacity: 0.65;
    white-space: pre-wrap;
    margin: 4px 0 0;
    font-family: inherit;
    line-height: 1.5;
}

/* ═══════════════════════════════
   画像拡大モーダル
═══════════════════════════════ */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
}
.image-modal.open { display: flex; }
.image-modal-content {
    max-width: 92vw;
    max-height: 88vh;
    border-radius: 10px;
    object-fit: contain;
}
.image-modal-close {
    position: absolute;
    top: 18px;
    right: 28px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
}
.image-modal-close:hover { opacity: 0.7; }

/* ═══════════════════════════════
   モバイル
═══════════════════════════════ */
@media (max-width: 640px) {
    .rd-page { padding: 14px 12px 60px; }
    .rd-hero-title { font-size: 1.3rem; }
    .rd-hero-body { padding: 14px 16px 18px; }
    .rd-step { gap: 10px; padding: 14px 14px; }
    .rd-step-img { max-width: 120px; }
    .rd-section-title { padding: 12px 14px; }

    /* 材料行：2行レイアウト（1行目: 食材名＋数量＋状態、2行目: 備考） */
    .rd-ingredient-row {
        padding: 8px 14px;
        flex-wrap: wrap;
        align-items: baseline;
    }
    .rd-ing-name { order: 1; flex: 1; }
    .rd-ing-qty  { order: 2; flex: 0 0 auto; }
    .rd-ing-status { order: 3; flex: 0 0 auto; }
    .rd-ing-remark {
        order: 4;
        flex: 0 0 100%;
        white-space: normal;
        margin-top: 2px;
        padding-left: 0;
    }
    .rd-ing-remark:empty { display: none; }
}
