/**
 * Single Recipe Page
 *
 * Mockup-aligned recipe layout with hero, info box,
 * tabbed content, servings calculator, and wake lock toggle.
 *
 * @package enhed
 */

/* ==========================================================================
   Recipe Hero — Dominant color background, label + title above image
   ========================================================================== */

.recipe-hero {
    position: relative;
    padding: calc(80px + var(--space-8)) 0 var(--space-8);
    background-color: var(--hero-color, var(--color-greige));
    text-align: center;
    overflow: hidden;
}

.recipe-hero__bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 80% 60% at 50% 60%,
        rgba(255, 255, 255, 0.10) 0%,
        transparent 70%
    );
    pointer-events: none;
}

.recipe-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(0, 0, 0, 0.12) 100%
    );
    pointer-events: none;
}

.recipe-hero .container {
    position: relative;
    z-index: 1;
}

/* "Opskrift" content type label */
.recipe-hero__label {
    display: inline-block;
    padding: var(--space-1) var(--space-4);
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: var(--color-paper);
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: var(--radius-full);
    margin-bottom: var(--space-4);
}

/* Title above the image */
.recipe-hero__title {
    font-family: var(--font-accent);
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: var(--font-normal);
    color: var(--color-paper);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-2);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}

/* Creator byline directly below headline */
.recipe-hero__byline {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--color-paper);
    margin-bottom: var(--space-6);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}

/* Full-width landscape hero image with rounded corners */
.recipe-hero__image {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.20),
        0 2px 8px rgba(0, 0, 0, 0.08);
}

.recipe-hero__image img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

/* Caption below image */
.recipe-hero__caption {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: rgba(255, 244, 230, 0.70);
    margin-top: var(--space-3);
    margin-bottom: 0;
}

/* Light hero variant */
.has-light-hero .recipe-hero__label {
    color: var(--color-chokolade);
    background: rgba(61, 28, 15, 0.08);
    border-color: rgba(61, 28, 15, 0.15);
}

.has-light-hero .recipe-hero__title {
    color: var(--color-chokolade);
    text-shadow: 0 1px 8px rgba(255, 255, 255, 0.5);
}

.has-light-hero .recipe-hero__byline {
    color: var(--color-chokolade);
    text-shadow: 0 1px 8px rgba(255, 255, 255, 0.5);
}

.has-light-hero .recipe-hero__caption {
    color: rgba(61, 28, 15, 0.6);
}


/* ==========================================================================
   Recipe Intro (above tabs)
   ========================================================================== */

.recipe-intro {
    padding: var(--space-4) 0 0;
    background: var(--color-paper);
}

.recipe-intro .prose {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Recipe Info Box — Servings, prep time, cook time, wake lock
   ========================================================================== */

.recipe-info-bar {
    background: var(--color-paper);
    padding: var(--space-6) 0 0;
}

.recipe-info-box {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-6);
    padding: var(--space-5) var(--space-6);
    background: var(--color-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-lines);
}

.recipe-info-box__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    text-align: center;
    min-width: 0;
}

.recipe-info-box__label {
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.recipe-info-box__value {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.recipe-info-box__divider {
    width: 1px;
    height: 36px;
    background: var(--color-lines);
    flex-shrink: 0;
}

/* Servings calculator */
.recipe-servings {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--color-paper);
    border: 1px solid var(--color-lines);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-2);
}

.recipe-servings__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--color-lines);
    border-radius: 50%;
    font-family: var(--font-body);
    font-size: var(--text-lg);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
    padding: 0;
}

.recipe-servings__btn:hover {
    background: var(--color-action);
    border-color: var(--color-action);
    color: var(--color-white);
}

.recipe-servings__btn:active {
    transform: scale(0.92);
}

.recipe-servings__count {
    min-width: 24px;
    text-align: center;
    font-family: var(--font-body);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

/* Wake lock toggle */
.recipe-wakelock {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
}

.recipe-wakelock__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.recipe-wakelock__track {
    position: relative;
    display: block;
    width: 44px;
    height: 24px;
    background: var(--color-lines);
    border-radius: var(--radius-full);
    transition: background var(--transition);
}

.recipe-wakelock__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--color-white);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform var(--transition);
}

.recipe-wakelock__input:checked + .recipe-wakelock__track {
    background: var(--color-action);
}

.recipe-wakelock__input:checked + .recipe-wakelock__track .recipe-wakelock__thumb {
    transform: translateX(20px);
}

.recipe-wakelock__text {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
}

.recipe-wakelock__input:checked ~ .recipe-wakelock__text {
    color: var(--color-action);
}

/* Hide wake lock when API not supported */
.recipe-info-box__wakelock[hidden] {
    display: none;
}


/* ==========================================================================
   Recipe Tabs — Sticky navigation between Ingredienser / Fremgangsmaade
   ========================================================================== */

.recipe-body {
    padding: 0 0 var(--space-12);
    background: var(--color-paper);
}

.recipe-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-lines);
    margin-bottom: var(--space-8);
    position: sticky;
    top: 72px;
    z-index: var(--z-sticky);
    background: var(--color-paper);
    padding-top: var(--space-6);
}

.recipe-tabs__btn {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font-ui);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.recipe-tabs__btn:hover {
    color: var(--color-text-primary);
}

.recipe-tabs__btn.is-active {
    color: var(--color-text-primary);
    border-bottom-color: var(--color-action);
}


/* ==========================================================================
   Recipe Content — Structured sections
   ========================================================================== */

.recipe-content {
    /* Default: show all content */
}

/* When JS activates tabs, sections get show/hide classes */
.recipe-body .recipe-section {
    display: none;
    animation: recipeFadeIn 0.3s ease;
}

.recipe-body .recipe-section.is-visible {
    display: block;
}

@keyframes recipeFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Ingredient list styling */
.recipe-body .recipe-section--ingredienser ul {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-6);
}

.recipe-body .recipe-section--ingredienser li {
    position: relative;
    padding: var(--space-3) 0 var(--space-3) var(--space-6);
    border-bottom: 1px solid rgba(214, 201, 189, 0.4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    line-height: var(--leading-normal);
}

.recipe-body .recipe-section--ingredienser li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-action);
}

.recipe-body .recipe-section--ingredienser li:last-child {
    border-bottom: none;
}

/* Sub-section headings in ingredients (e.g., "Mandelbund:", "Fyld:") */
.recipe-body .recipe-section--ingredienser .recipe-subsection-title {
    font-family: var(--font-body);
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
    margin-top: var(--space-6);
    margin-bottom: var(--space-2);
    padding-left: 0;
}

.recipe-body .recipe-section--ingredienser .recipe-subsection-title::before {
    display: none;
}

/* Ingredient quantity highlighting */
.recipe-content [data-ingredient-qty] {
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
    transition: color var(--transition);
}

/* Procedure / Fremgangsmaade styling */
.recipe-body .recipe-section--fremgangsmaade p {
    margin-bottom: var(--space-4);
    line-height: var(--leading-relaxed);
}

.recipe-body .recipe-section--fremgangsmaade ol {
    counter-reset: recipe-step;
    list-style: none;
    padding: 0;
}

.recipe-body .recipe-section--fremgangsmaade ol li {
    counter-increment: recipe-step;
    position: relative;
    padding-left: calc(var(--space-10) + var(--space-2));
    margin-bottom: var(--space-6);
    line-height: var(--leading-relaxed);
}

.recipe-body .recipe-section--fremgangsmaade ol li::before {
    content: counter(recipe-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-action);
    color: var(--color-white);
    font-family: var(--font-ui);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    border-radius: 50%;
}

/* Intro text (before ingredients) */
/* Introduktion tab styling */
.recipe-body .recipe-section--introduktion .prose {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
}

.recipe-body .recipe-section--introduktion .prose p {
    margin-bottom: var(--space-4);
}

.recipe-body .recipe-section--introduktion .text-muted {
    color: var(--color-text-muted);
    font-style: italic;
}

.recipe-body .recipe-section--intro p {
    font-size: var(--text-md);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-4);
}

/* Section headings within content */
.recipe-content h2,
.recipe-content h3 {
    font-family: var(--font-accent);
    font-weight: var(--font-normal);
    color: var(--color-text-primary);
    margin-top: var(--space-8);
    margin-bottom: var(--space-4);
}

.recipe-content h2 {
    font-size: var(--text-2xl);
}

.recipe-content h3 {
    font-size: var(--text-xl);
}

/* Bold paragraph as sub-section title (common pattern in recipe content) */
.recipe-body .recipe-section--ingredienser p strong {
    display: block;
    font-size: var(--text-md);
    color: var(--color-text-primary);
    margin-top: var(--space-6);
    margin-bottom: var(--space-2);
}

/* Nutrition info line */
.recipe-content .recipe-nutrition {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-style: italic;
    padding: var(--space-4);
    background: var(--color-secondary);
    border-radius: var(--radius-md);
    margin-top: var(--space-6);
}

/* Servings info line */
.recipe-content .recipe-base-servings {
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-medium);
}


/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .recipe-hero {
        padding: calc(80px + var(--space-6)) 0 var(--space-6);
    }

    .recipe-hero__title {
        font-size: clamp(1.5rem, 5vw, 2rem);
        margin-bottom: var(--space-4);
    }

    .recipe-info-box {
        flex-direction: column;
        gap: var(--space-3);
        padding: var(--space-4);
    }

    .recipe-info-box__divider {
        width: 100%;
        height: 1px;
    }

    .recipe-info-box__item {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }

    .recipe-tabs {
        top: 60px;
    }

    .recipe-tabs__btn {
        font-size: var(--text-sm);
        padding: var(--space-3) var(--space-2);
    }
}

@media (max-width: 480px) {
    .recipe-hero__image {
        border-radius: var(--radius-md);
    }

    .recipe-tabs {
        top: 56px;
    }
}

/* Override single-hero__figure max-width for recipe — follow outer container grid */
.recipe-hero .single-hero__figure {
    max-width: 100%;
}
