/* ==========================================================================
   Cook Interactive — Ingredient Checkboxes + Cook Mode
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. INGREDIENT CHECKBOXES
   -------------------------------------------------------------------------- */

/* Progress counter above ingredient list */
.kf-ingredient-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #8a7e6e;
    letter-spacing: 0.3px;
}

.kf-ingredient-progress-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kf-ingredient-progress-bar {
    width: 80px;
    height: 4px;
    background: #efe9e0;
    border-radius: 2px;
    overflow: hidden;
}

.kf-ingredient-progress-fill {
    height: 100%;
    background: #2B354F;
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

.kf-ingredient-clear {
    background: none;
    border: none;
    color: #8a7e6e;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.kf-ingredient-clear:hover {
    color: #2B354F;
}

/* Ingredient row — make entire row tappable */
#recipe-card li.p-ingredient {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    transition: opacity 0.2s ease, background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    padding-left: 12px;
    transform: translateZ(0);
}

#recipe-card li.p-ingredient:hover {
    background: #fdf9f5;
}

/* Circle checkbox (matches cook mode drawer style) */
#recipe-card li.p-ingredient .kf-circle-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    border: 2px solid #e5ded4;
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

#recipe-card li.p-ingredient .kf-circle-check svg {
    display: none;
    color: #fff;
}

/* Checked state */
#recipe-card li.p-ingredient.kf-checked {
    opacity: 0.5;
}

#recipe-card li.p-ingredient.kf-checked .kf-circle-check {
    background: #2B354F;
    border-color: #2B354F;
}

#recipe-card li.p-ingredient.kf-checked .kf-circle-check svg {
    display: block;
}

#recipe-card li.p-ingredient.kf-checked .kf-ingredient-text {
    text-decoration: line-through;
    text-decoration-color: #8a7e6e;
}

/* --------------------------------------------------------------------------
   2. COOK MODE BUTTON
   -------------------------------------------------------------------------- */

.kf-cook-mode-btn {
    white-space: nowrap;
}

.kf-cook-mode-btn svg {
    vertical-align: middle;
}

.kf-badge-new {
    display: inline-block;
    background: #c4714b;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 6px;
    line-height: 1.4;
    margin-left: 2px;
    vertical-align: top;
    position: relative;
    top: -2px;
}

/* --------------------------------------------------------------------------
   3. COOK MODE OVERLAY
   -------------------------------------------------------------------------- */

.kf-cook-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    z-index: 9999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: kfCookFadeIn 0.25s ease;
}

@keyframes kfCookFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
.kf-cook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2B354F 0%, #3d4a6b 100%);
    color: #fff;
    flex-shrink: 0;
    border-bottom: 3px solid #c4714b;
}

.kf-cook-header-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.kf-cook-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.kf-cook-step-counter {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 2px;
}

.kf-cook-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 16px;
    transition: background 0.2s;
}

.kf-cook-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Body */
.kf-cook-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 20px 120px;
}

.kf-cook-step-name {
    font-size: 22px;
    font-weight: 700;
    color: #2B354F;
    margin: 0 0 16px;
    line-height: 1.3;
}

.kf-cook-step-text {
    font-size: 18px;
    line-height: 1.65;
    color: #3a3f4b;
    margin-bottom: 20px;
}

.kf-cook-step-text p {
    margin: 0 0 12px;
}

.kf-cook-step-text p:last-child {
    margin-bottom: 0;
}

/* Step photo — originals are 400x225, don't upscale */
.kf-cook-step-photo {
    margin: 24px auto;
    border-radius: 12px;
    overflow: hidden;
    max-width: 500px;
    background: #f8f5f0;
    border: 1px solid #e8e2d9;
}

.kf-cook-step-photo img {
    width: 100%;
    height: auto;
    display: block;
}

/* Tip callout */
.kf-cook-step-tip {
    background: #fef9f0;
    border-left: 3px solid #f59e0b;
    border-radius: 0 10px 10px 0;
    padding: 12px 16px;
    margin: 16px 0;
}

.kf-cook-step-tip-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #b45309;
    margin-bottom: 4px;
}

.kf-cook-step-tip-text {
    font-size: 15px;
    line-height: 1.5;
    color: #5a5040;
}

/* Per-step ingredients */
.kf-cook-step-ingredients {
    margin-top: 20px;
    padding: 16px;
    background: #f8f5f0;
    border-radius: 12px;
    border: 1px solid #e8e2d9;
}

.kf-cook-step-ingredients-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8a7e6e;
    margin-bottom: 8px;
}

.kf-cook-step-ingredients ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kf-cook-step-ingredients li {
    padding: 6px 0;
    font-size: 15px;
    color: #3a3f4b;
    border-bottom: 1px solid #efe9e0;
}

.kf-cook-step-ingredients li:last-child {
    border-bottom: none;
}

/* Footer */
.kf-cook-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #e8e2d9;
    box-shadow: 0 -4px 12px rgba(120, 90, 50, 0.07);
}

.kf-cook-prev,
.kf-cook-next {
    flex: 1;
    height: 56px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
}

.kf-cook-prev {
    background: #f5f0ea;
    color: #2B354F;
}

.kf-cook-prev:hover {
    background: #efe9e0;
}

.kf-cook-next {
    background: linear-gradient(135deg, #2B354F 0%, #3d4a6b 100%);
    color: #fff;
}

.kf-cook-next:hover {
    background: linear-gradient(135deg, #3d4a6b 0%, #4d5c80 100%);
}

.kf-cook-prev:active,
.kf-cook-next:active {
    transform: scale(0.97);
}

.kf-cook-prev:disabled,
.kf-cook-next:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

.kf-cook-ingredients-toggle {
    background: none;
    border: 1px solid #e8e2d9;
    border-radius: 12px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    color: #2B354F;
    transition: background 0.2s;
}

.kf-cook-ingredients-toggle:hover {
    background: #f8f5f0;
}

/* --------------------------------------------------------------------------
   4. INGREDIENT DRAWER (in Cook Mode)
   -------------------------------------------------------------------------- */

.kf-cook-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000001;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.kf-cook-drawer-backdrop.kf-visible {
    opacity: 1;
}

.kf-cook-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    z-index: 10000002;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
}

.kf-cook-drawer.kf-visible {
    transform: translateY(0);
}

.kf-cook-drawer-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
    flex-shrink: 0;
}

.kf-cook-drawer-handle::after {
    content: '';
    width: 40px;
    height: 4px;
    background: #e5ded4;
    border-radius: 2px;
}

.kf-cook-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 12px;
    border-bottom: 1px solid #e8e2d9;
    flex-shrink: 0;
}

.kf-cook-drawer-title {
    font-size: 15px;
    font-weight: 700;
    color: #2B354F;
}

.kf-cook-drawer-close {
    background: none;
    border: none;
    color: #8a7e6e;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
}

.kf-cook-drawer-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 20px 20px;
    flex: 1;
}

.kf-cook-drawer-group-title {
    font-size: 13px;
    font-weight: 700;
    color: #2B354F;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 16px 0 8px;
}

.kf-cook-drawer-body ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kf-cook-drawer-body li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid #efe9e0;
    font-size: 15px;
    color: #3a3f4b;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity 0.2s;
}

.kf-cook-drawer-body li:last-child {
    border-bottom: none;
}

.kf-cook-drawer-body li .kf-drawer-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #e5ded4;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.kf-cook-drawer-body li.kf-checked .kf-drawer-check {
    background: #2B354F;
    border-color: #2B354F;
}

.kf-cook-drawer-body li.kf-checked .kf-drawer-check svg {
    display: block;
}

.kf-cook-drawer-body li .kf-drawer-check svg {
    display: none;
    width: 12px;
    height: 12px;
    color: #fff;
}

.kf-cook-drawer-body li.kf-checked {
    opacity: 0.5;
    text-decoration: line-through;
    text-decoration-color: #8a7e6e;
}

/* --------------------------------------------------------------------------
   5. MEDIAVINE AD SUPPRESSION (Cook Mode + Ingredient Drawer)
   -------------------------------------------------------------------------- */

/* When cook mode overlay is open, hide all Mediavine sticky/adhesion ads */
body.kf-cook-active #fixed_container_bottom,
body.kf-cook-active [data-adhesion],
body.kf-cook-active .mv-ad-sticky,
body.kf-cook-active .mv-sticky-bottom,
body.kf-cook-active .adunitwrapper[style*="fixed"] {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* --------------------------------------------------------------------------
   6. PRINT HIDING
   -------------------------------------------------------------------------- */

@media print {
    .kf-ingredient-progress,
    .kf-cook-mode-btn,
    .kf-cook-overlay,
    .kf-cook-drawer-backdrop,
    .kf-cook-drawer,
    .kf-check-icon {
        display: none !important;
    }

    #recipe-card li.p-ingredient.kf-checked {
        opacity: 1;
        text-decoration: none;
    }
}

/* --------------------------------------------------------------------------
   6. RESPONSIVE — DESKTOP (two-column, distance-readable)
   -------------------------------------------------------------------------- */

@media (min-width: 769px) {
    .kf-cook-header {
        padding: 16px 40px;
    }

    .kf-cook-title {
        font-size: 18px;
    }

    .kf-cook-step-counter {
        font-size: 14px;
        letter-spacing: 1px;
    }

    .kf-cook-body {
        padding: 40px 48px 120px;
        max-width: 900px;
        margin: 0 auto;
        width: 100%;
    }

    /* Step name — large, distance-readable */
    .kf-cook-step-name {
        font-size: 32px;
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 2px solid #efe9e0;
    }

    /* Directions text — big for distance reading */
    .kf-cook-step-text {
        font-size: 24px;
        line-height: 1.7;
    }

    /* Photo — centered, reasonable size */
    .kf-cook-step-photo {
        margin: 24px auto;
        max-width: 500px;
    }

    .kf-cook-step-tip-text {
        font-size: 15px;
    }

    .kf-cook-step-ingredients {
        margin-top: 24px;
        max-width: 500px;
    }

    .kf-cook-step-ingredients li {
        font-size: 16px;
    }

    /* Footer — constrained width on desktop */
    .kf-cook-footer {
        max-width: 600px;
        margin: 0 auto;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
        padding: 16px 32px;
    }

    .kf-cook-prev,
    .kf-cook-next {
        height: 52px;
        border-radius: 12px;
        font-size: 16px;
    }
}

/* --------------------------------------------------------------------------
   7. RESPONSIVE — MOBILE
   -------------------------------------------------------------------------- */

@media (max-width: 576px) {
    .kf-cook-header {
        padding: 10px 16px;
    }

    .kf-cook-title {
        font-size: 14px;
    }

    .kf-cook-body {
        padding: 20px 16px 120px;
    }

    .kf-cook-step-name {
        font-size: 20px;
    }

    .kf-cook-step-text {
        font-size: 17px;
    }

    .kf-cook-footer {
        padding: 10px 16px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        gap: 8px;
        bottom: 200px;
    }

    .kf-cook-body {
        padding-bottom: 300px; /* footer height + 200px ad clearance */
    }

    .kf-cook-prev,
    .kf-cook-next {
        height: 52px;
        font-size: 15px;
        border-radius: 10px;
    }

    .kf-cook-ingredients-toggle {
        width: 52px;
        height: 52px;
        border-radius: 10px;
    }

    .kf-ingredient-progress {
        font-size: 12px;
    }

    .kf-ingredient-progress-bar {
        width: 60px;
    }
}
