/* --- Container and Basic Settings --- */
.z-recipe-card {
    font-family: inherit;
    background-color: #fff;
    color: #111;
    max-width: 1100px;
    margin: 40px auto;
    padding: 0;
    box-sizing: border-box;
    position: relative;
    overflow: visible;
}

.z-recipe-card * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- Element Styling --- */

/* Image */
#z-recipe-img-wrap {
    width: 100%;
    height: 100%;
    display: block;
}

#z-recipe-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Nutrition Info */
#z-recipe-nutrition {
    display: flex;
    align-items: center;
    white-space: nowrap;
    text-transform: uppercase;
    font-weight: 600;
    color: #555;
    gap: 8px;
}

.z-divider { color: #ccc; }

/* Texts */
#z-recipe-title {
    text-transform: uppercase;
    line-height: 1.3;
    font-weight: 700;
    color: #000;
}

#z-recipe-desc {
    font-style: italic;
    line-height: 1.6;
    color: #444;
}

/* Main Button */
#z-recipe-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #111;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
}
#z-recipe-btn:hover {
    background-color: #333;
}

/* --- Ghost Button Style for Navigation --- */
.z-nav-link {
    display: inline-block;
    font-size: 0.75rem;
    color: #111;
    background-color: transparent;
    border: 1px solid #ccc;
    padding: 6px 14px;
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 2px;
    width: auto; 
}

.z-nav-link:hover {
    border-color: #000;
    background-color: #f9f9f9;
    color: #000;
}

/* =========================================
   MOBILE LAYOUT (Max-width: 768px)
   ========================================= */
@media screen and (max-width: 768px) {
    .z-recipe-card {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding-bottom: 20px;
    }
   
    /* ORDER LOGIC (Negative numbers go to top):
       -5: Jump Link (Topmost)
       -4: Badge/Number
       -3: Title
       -2: Image
       0 : Everything else (Desc, Nutrition, Button) flows naturally
       10: Back Link (Bottommost)
    */

    /* 1. Jump Link */
    .z-link-top {
        align-self: center;
        margin-bottom: 15px;
        order: -5;
    }

    /* 2. Badge */
    #z-recipe-badge {
        width: 100%;
        text-align: center;
        font-size: 2.5rem;
        font-weight: bold;
        margin-bottom: 25px; /* Increased spacing */
        color: #000;
        background: transparent;
        position: static;
        order: -4;
    }

    /* 3. Title */
    #z-recipe-title {
        text-align: center;
        font-size: 1.4rem;
        padding: 0 15px;
        margin-bottom: 15px;
        order: -3;
    }
    
    /* 4. Image */
    #z-recipe-img-wrap {
        height: 250px;
        margin-bottom: 20px;
        order: -2; 
    }
    
    /* Description */
    #z-recipe-desc {
        text-align: center;
        padding: 0 20px;
        margin-bottom: 20px;
        font-size: 1rem;
        display: block;
        /* Default order: 0 */
    }
    
    /* Nutrition */
    #z-recipe-nutrition {
        width: 100%;
        justify-content: center;
        margin-bottom: 25px;
        padding: 0 10px;
        gap: 4px;
        font-size: clamp(9px, 3.2vw, 13px);
        /* Default order: 0 */
    }
    
    /* Button */
    #z-recipe-btn {
        width: calc(100% - 40px);
        margin: 0 auto 20px auto;
        padding: 16px 0;
        font-size: 0.9rem;
        /* Default order: 0 */
    }

    /* Last: Back to Top Link */
    .z-link-bottom {
        align-self: center;
        margin-bottom: 10px;
        order: 10; /* Positive number ensures it stays at bottom */
    }
}

/* =========================================
   DESKTOP LAYOUT (Min-width: 769px)
   ========================================= */
@media screen and (min-width: 769px) {

    #z-recipe-title,
    #z-recipe-desc,
    #z-recipe-nutrition,
    #z-recipe-btn,
    .z-nav-link {
        min-width: 0;
    }

    .z-recipe-card {
        display: grid;
        grid-template-columns: 50% 50%;
        grid-template-rows: auto auto auto auto auto auto; 
        gap: 0 40px;
        align-items: center;
        padding-right: 40px;
    }

    /* Image area */
    #z-recipe-img-wrap {
        grid-column: 1 / 2;
        grid-row: 1 / 7;
        height: 100%;
        min-height: 450px;
        position: relative;
    }

    /* Badge */
    #z-recipe-badge {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        z-index: 10;
        background-color: #000;
        color: #fff;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1.2rem;
        font-weight: bold;
        justify-self: start;
        align-self: start;
        margin-top: -15px;
        margin-left: -15px;
    }

    /* Text Column Alignment */
    #z-recipe-title,
    #z-recipe-desc,
    #z-recipe-nutrition,
    #z-recipe-btn,
    .z-nav-link {
        grid-column: 2 / 3;
        text-align: left;
    }

    /* Top Link Placement */
    .z-link-top {
        margin-bottom: 10px;
        align-self: end;
    }

    #z-recipe-title {
        font-size: 2rem;
        margin-bottom: 15px;
    }

    #z-recipe-desc {
        font-size: 1.1rem;
        margin-bottom: 25px;
    }

    /* Nutrition Info - Single Line Fix */
    #z-recipe-nutrition {
        display: flex;
        justify-content: flex-start;
        margin-bottom: 30px;
        white-space: nowrap;
        flex-wrap: nowrap;
        font-size: 11px;
        gap: 6px;
        width: 100%;
        color: #555;
    }

    #z-recipe-btn {
        justify-self: start;
        padding: 14px 40px;
        font-size: 0.9rem;
        margin-bottom: 15px;
    }

    /* Bottom Link Placement */
    .z-link-bottom {
        justify-self: start;
        margin-top: 5px;
    }
}