/* style.css - 菜谱模板专用样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
/* 屏幕显示样式 */
body {
    background: #f8f5f0;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, 'Noto Sans', sans-serif;
    line-height: 1.5;
    color: #2c2418;
    padding: 1.5rem;
}
/* 打印工具栏 */
.print-toolbar {
    max-width: 1280px;
    margin: 0 auto 1rem auto;
    text-align: right;
    position: sticky;
    top: 10px;
    z-index: 100;
}
.print-btn {
    background: #d5843e;
    border: none;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: 40px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    font-family: inherit;
}
.print-btn:hover {
    background: #b8682c;
    transform: translateY(-1px);
}
.print-btn:active {
    transform: translateY(1px);
}
/* 主卡片容器 */
.recipe-container {
    max-width: 1280px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 2rem;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.2s ease;
}
/* 主图区域 */
.recipe-hero {
    width: 100%;
    background: #e9e2d8;
    overflow: hidden;
}
.hero-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    aspect-ratio: 16 / 9;
    transition: transform 0.3s ease;
}
.hero-image:hover {
    transform: scale(1.02);
}
/* 内容区内部间距 */
.recipe-inner {
    padding: 2rem 2rem 2.5rem;
}
/* 菜名 + 元数据行 */
.recipe-head {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #f0eae2;
    padding-bottom: 1rem;
}
.recipe-title {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #3a2c1f;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}
.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    align-items: center;
}
.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #f2ede7;
    padding: 0.3rem 1rem;
    border-radius: 40px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #624c37;
}
.meta-tag::before {
    content: "•";
    font-weight: 900;
    font-size: 1.1rem;
    color: #c9772e;
}
.meta-tag:first-child::before {
    content: "🍽️";
    font-size: 0.9rem;
}
.meta-tag:last-child::before {
    content: "🥘";
}
/* 菜品内容描述 */
.recipe-description {
    background: #fefaf5;
    padding: 1.2rem 1.5rem;
    border-radius: 1.25rem;
    margin-bottom: 2rem;
    border-left: 5px solid #e0a878;
    font-size: 1rem;
    color: #4a3724;
    line-height: 1.6;
}
.section-title {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #3a2c1f;
    letter-spacing: -0.2px;
}
.section-title i {
    font-size: 1.6rem;
    font-weight: normal;
}
/* 用料区域 */
.ingredients-grid {
    background: #ffffff;
    border-radius: 1.25rem;
    margin-bottom: 2.5rem;
    border: 1px solid #f0e2d4;
    padding: 1.5rem 1.8rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}
.ingredients-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.8rem 1.5rem;
    list-style: none;
}
.ingredients-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    padding: 0.3rem 0;
    border-bottom: 1px dashed #f0e2d4;
}
.ingredients-list li::before {
    content: "✓";
    color: #d5843e;
    font-weight: bold;
    background: #fef3e8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 30px;
    font-size: 0.85rem;
}
/* 做法步骤 (屏幕版带图) */
.step-card {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    background: #fefcf9;
    border-radius: 1.25rem;
    margin-bottom: 1.8rem;
    padding: 1.2rem 1.2rem 1.2rem 1.5rem;
    transition: all 0.2s;
    border: 1px solid #f3e9e0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}
.step-card:hover {
    background: #fffbf5;
    border-color: #e6cfba;
}
.step-info {
    flex: 2;
    min-width: 180px;
}
.step-number {
    display: inline-block;
    background: #d5843e;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 60px;
    margin-bottom: 0.7rem;
    box-shadow: 0 2px 6px rgba(213, 132, 62, 0.3);
}
.step-desc {
    font-size: 1rem;
    color: #2c2418;
    line-height: 1.6;
    margin-top: 0.3rem;
}
.step-image {
    flex: 1;
    min-width: 140px;
    max-width: 200px;
}
.step-image img {
    width: 100%;
    height: auto;
    border-radius: 1rem;
    object-fit: cover;
    aspect-ratio: 4 / 3;
    box-shadow: 0 8px 14px -6px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s;
    background: #ece3d9;
}
.step-image img:hover {
    transform: scale(1.02);
}
.attribution {
    text-align: center;
    font-size: 0.75rem;
    color: #9b8a74;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #efe3d6;
}
/* 响应式 */
@media (max-width: 760px) {
    body {
        padding: 0.8rem;
    }
    .recipe-inner {
        padding: 1.2rem;
    }
    .recipe-title {
        font-size: 1.8rem;
    }
    .section-title {
        font-size: 1.4rem;
    }
    .step-card {
        flex-direction: column;
        padding: 1.2rem;
    }
    .step-image {
        max-width: 100%;
        width: 100%;
    }
    .step-image img {
        aspect-ratio: 16/9;
    }
    .ingredients-grid {
        padding: 1rem;
    }
    .ingredients-list {
        grid-template-columns: 1fr;
    }
    .print-toolbar {
        text-align: center;
        position: relative;
        top: 0;
        margin-bottom: 0.8rem;
    }
}
@media (max-width: 480px) {
    .recipe-title {
        font-size: 1.6rem;
    }
}

/* ========= 终极加固：打印/PDF 跨平台兼容样式 ========= */
@media print {
    @page {
        size: A4 !important;
        margin: 1.2cm !important;
        orphans: 0 !important;
        widows: 0 !important;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }
    html, body {
        width: 210mm !important;
        height: 297mm !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
    }
    /* 隐藏不需要打印的元素 */
    .print-toolbar,
    .attribution,
    .step-image,
    .recipe-meta,
    .recipe-description,
    .hero-image:hover,
    .step-card:hover {
        display: none !important;
        visibility: hidden !important;
    }
    /* 主容器网格布局 */
    .recipe-container {
        display: grid !important;
        grid-template-columns: 65mm auto !important;
        grid-template-areas:
            "hd hd"
            "img steps"
            "ing steps" !important;
        gap: 4mm 6mm !important;
        width: 100% !important;
        max-width: 100% !important;
        background: #fff !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
    }
    .recipe-inner {
        display: contents !important;
    }
    /* 标题 */
    .recipe-head {
        grid-area: hd !important;
        border-bottom: 0.5px solid #999 !important;
        padding-bottom: 2mm !important;
        margin-bottom: 2mm !important;
    }
    .recipe-title {
        font-size: 16px !important;
        font-weight: bold !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.3 !important;
    }
    /* 主图 */
    .recipe-hero {
        grid-area: img !important;
        width: 100% !important;
        max-width: 60mm !important;
    }
    .hero-image {
        width: 100% !important;
        height: auto !important;
        max-width: 60mm !important;
        object-fit: cover !important;
        border: 0.5px solid #ddd !important;
        border-radius: 1mm !important;
    }
    /* 用料清单 */
    .ingredients-grid {
        grid-area: ing !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: none !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
    .section-title {
        font-size: 13px !important;
        font-weight: bold !important;
        margin: 0 0 2mm 0 !important;
        padding: 0 !important;
    }
    .ingredients-list {
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .ingredients-list li {
        font-size: 11px !important;
        line-height: 1.4 !important;
        padding: 1px 0 !important;
        margin: 0 !important;
        border: none !important;
    }
    .ingredients-list li::before {
        content: "✓ " !important;
        color: #666 !important;
        margin-right: 1mm !important;
        background: none !important;
        width: auto !important;
        height: auto !important;
    }
    /* 步骤区域：序号+文字同行 */
    .steps-area {
        grid-area: steps !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .step-card {
        display: block !important;
        padding: 0 0 3mm 0 !important;
        margin: 0 0 3mm 0 !important;
        border-bottom: 0.3px dotted #ccc !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
    .step-card:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    .step-info {
        display: flex !important;
        align-items: flex-start !important;
        gap: 2mm !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .step-number {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        line-height: 20px !important;
        font-size: 11px !important;
        font-weight: bold !important;
        color: #fff !important;
        background: #666 !important;
        border-radius: 50% !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .step-desc {
        display: inline !important;
        font-size: 11px !important;
        line-height: 20px !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
        flex: 1 !important;
        white-space: normal !important;
    }
}

/* ========== 兼容两种步骤卡片布局（屏幕显示，不影响打印） ========== */
.step-card:has(.step-info .step-image) {
    display: block;
}
.step-card:has(.step-info .step-image) .step-info {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: start;
    background: inherit;
    border: none;
    padding: 0;
}
.step-card:has(.step-info .step-image) .step-info .step-number,
.step-card:has(.step-info .step-image) .step-info .step-desc {
    grid-column: 1;
}
.step-card:has(.step-info .step-image) .step-info .step-image {
    grid-column: 2;
    grid-row: span 2;
    max-width: 200px;
    margin: 0;
}
.step-card:has(.step-info .step-image) .step-info .step-image img {
    width: 100%;
    height: auto;
    max-width: 180px;
}
.step-card:has(.step-info .step-image) .step-info .step-number {
    margin-bottom: 0.5rem;
}
/* 降级方案：不支持 :has() 时 */
@supports not (selector(:has(a))) {
    .step-card .step-info .step-image {
        text-align: center;
        margin: 1rem 0;
    }
    .step-card .step-info .step-image img {
        max-width: 100%;
        height: auto;
    }
}
/* ==================== 主图左右悬浮翻页箭头（全自动） ==================== */
.recipe-hero {
    position: relative !important;
}
.page-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    text-decoration: none;
    z-index: 999;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}
.page-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}
.page-arrow.prev {
    left: 15px;
}
.page-arrow.next {
    right: 15px;
}
/* 打印时隐藏箭头 */
@media print {
    .page-arrow {
        display: none !important;
    }
}