/**
 * JelaRecept Frontend Styles
 * Theme-neutral, responsive recipe card
 */

/* ===== Reset & Container ===== */
.jr-recipe {
    --jr-radius: 12px;
    --jr-border: #e5e5e5;
    --jr-bg: #ffffff;
    --jr-bg-alt: #fafaf8;
    --jr-text: #1a1a1a;
    --jr-text-muted: #6b7280;
    --jr-accent: #7c6240;
    --jr-accent-light: #a0845c;
    --jr-green: #4a7c59;
    --jr-step-line: #d6d3d1;

    font-family: inherit;
    color: var(--jr-text);
    max-width: 780px;
    margin: 2em auto;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.jr-recipe *,
.jr-recipe *::before,
.jr-recipe *::after {
    box-sizing: border-box;
}

/* ===== Header ===== */
.jr-header {
    margin-bottom: 0;
}

.jr-image {
    width: 100%;
    border-radius: var(--jr-radius);
    overflow: hidden;
    margin-bottom: 1.5em;
}

.jr-image img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.jr-title {
    font-size: 1.75em;
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 0.25em;
    color: var(--jr-text);
}

.jr-description {
    font-size: 1em;
    color: var(--jr-text-muted);
    margin: 0 0 1.25em;
}

/* Meta pills */
.jr-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1.5em;
    padding-bottom: 1.5em;
    border-bottom: 1px solid var(--jr-border);
}

.jr-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--jr-bg-alt);
    border: 1px solid var(--jr-border);
    border-radius: 999px;
    font-size: 0.85em;
}

.jr-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--jr-accent);
}

.jr-meta-label {
    color: var(--jr-text-muted);
    font-weight: 400;
}

.jr-meta-value {
    font-weight: 600;
    color: var(--jr-text);
}

/* ===== Rating ===== */
.jr-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.jr-rating-stars {
    display: flex;
    align-items: center;
    gap: 2px;
}

.jr-star {
    flex-shrink: 0;
}

.jr-star-full {
    color: var(--jr-accent);
}

.jr-star-half {
    color: var(--jr-accent);
}

.jr-star-empty {
    color: var(--jr-border);
}

.jr-rating-text {
    font-size: 0.85em;
    color: var(--jr-text-muted);
    font-weight: 500;
}

/* ===== Body layout ===== */
.jr-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ===== Sections ===== */
.jr-section {
    padding: 1.75em;
    background: var(--jr-bg);
    border: 1px solid var(--jr-border);
    border-radius: var(--jr-radius);
    margin-bottom: 1.5em;
}

.jr-section-title {
    font-size: 1.35em;
    font-weight: 800;
    margin: 0 0 0.15em;
    color: var(--jr-text);
}

/* ===== Ingredients ===== */
.jr-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1.25em;
}

.jr-servings-adjuster {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jr-servings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--jr-border);
    background: var(--jr-bg);
    cursor: pointer;
    color: var(--jr-text);
    transition: background 0.15s, border-color 0.15s;
    padding: 0;
    line-height: 1;
}

.jr-servings-btn:hover {
    background: var(--jr-bg-alt);
    border-color: var(--jr-accent-light);
}

.jr-servings-count {
    font-weight: 700;
    font-size: 0.95em;
    min-width: 70px;
    text-align: center;
    color: var(--jr-text);
}

.jr-ingredients-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.jr-ingredient {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.jr-ingredient:last-child {
    border-bottom: none;
}

.jr-ingredient-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 1em;
    line-height: 1.5;
}

.jr-ingredient-check {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.jr-ingredient-checkbox {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 2px solid var(--jr-border);
    border-radius: 4px;
    margin-top: 2px;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
    background: var(--jr-bg);
}

.jr-ingredient-check:checked + .jr-ingredient-checkbox {
    background: var(--jr-green);
    border-color: var(--jr-green);
}

.jr-ingredient-check:checked + .jr-ingredient-checkbox::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 6px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.jr-ingredient-check:checked ~ .jr-ingredient-text {
    text-decoration: line-through;
    color: var(--jr-text-muted);
}

.jr-ingredient-text {
    flex: 1;
}

.jr-ingredient-amount strong {
    font-weight: 700;
}

.jr-ingredient-notes {
    color: var(--jr-text-muted);
    font-style: italic;
    font-size: 0.9em;
}

/* ===== Steps ===== */
.jr-steps-total-time {
    color: var(--jr-text-muted);
    font-size: 0.9em;
    margin: 0 0 1.5em;
}

.jr-steps-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.jr-step {
    display: flex;
    gap: 16px;
    min-height: 80px;
}

.jr-step:last-child .jr-step-line {
    display: none;
}

.jr-step-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 40px;
}

.jr-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--jr-accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.85em;
    flex-shrink: 0;
}

.jr-step-line {
    flex: 1;
    width: 2px;
    background: var(--jr-step-line);
    margin: 6px 0;
    min-height: 20px;
}

.jr-step-content {
    flex: 1;
    padding-bottom: 2em;
}

.jr-step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.jr-step-title {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0;
    color: var(--jr-text);
}

.jr-step-time {
    font-size: 0.8em;
    color: var(--jr-text-muted);
    background: var(--jr-bg-alt);
    border: 1px solid var(--jr-border);
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 500;
}

.jr-step-text {
    font-size: 0.95em;
    color: var(--jr-text-muted);
    margin: 0.5em 0 0;
    line-height: 1.6;
}

/* Cooking mode button */
.jr-cooking-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    margin-top: 1.5em;
    background: var(--jr-green);
    color: #fff;
    border: none;
    border-radius: var(--jr-radius);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}

.jr-cooking-mode-btn:hover {
    background: #3d6a4a;
}

.jr-cooking-mode-btn:active {
    transform: scale(0.98);
}

/* ===== Nutrition ===== */
.jr-nutrition-subtitle {
    color: var(--jr-text-muted);
    font-size: 0.9em;
    margin: 0 0 1.25em;
}

.jr-nutrition-calories {
    text-align: center;
    margin-bottom: 1.75em;
}

.jr-calories-number {
    display: block;
    font-size: 3em;
    font-weight: 800;
    color: var(--jr-accent);
    line-height: 1.1;
}

.jr-calories-label {
    font-size: 0.9em;
    color: var(--jr-text-muted);
}

.jr-nutrition-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.jr-nutrient-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.jr-nutrient-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.jr-nutrient-name {
    font-size: 0.95em;
    color: var(--jr-text);
}

.jr-nutrient-value {
    font-size: 0.95em;
    font-weight: 700;
    color: var(--jr-text);
}

.jr-nutrient-bar-track {
    width: 100%;
    height: 8px;
    background: #eeeeee;
    border-radius: 4px;
    overflow: hidden;
}

.jr-nutrient-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ===== Cooking Mode Overlay ===== */
.jr-cooking-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: auto;
    animation: jrFadeIn 0.25s ease;
}

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

.jr-cooking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--jr-border);
    flex-shrink: 0;
}

.jr-cooking-header h3 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 700;
}

.jr-cooking-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--jr-border);
    background: none;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--jr-text);
    transition: background 0.15s;
}

.jr-cooking-close:hover {
    background: #f5f5f5;
}

.jr-cooking-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.jr-cooking-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--jr-accent);
    color: #fff;
    font-size: 1.25em;
    font-weight: 700;
    margin-bottom: 16px;
}

.jr-cooking-step-title {
    font-size: 1.5em;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--jr-text);
}

.jr-cooking-step-text {
    font-size: 1.1em;
    color: var(--jr-text-muted);
    max-width: 500px;
    margin: 0 0 12px;
    line-height: 1.6;
}

.jr-cooking-step-time {
    font-size: 0.9em;
    color: var(--jr-text-muted);
    background: var(--jr-bg-alt);
    padding: 4px 16px;
    border-radius: 999px;
    border: 1px solid var(--jr-border);
}

.jr-cooking-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--jr-border);
    flex-shrink: 0;
    gap: 12px;
}

.jr-cooking-nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid var(--jr-border);
    background: var(--jr-bg);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--jr-text);
    transition: background 0.15s;
    font-family: inherit;
}

.jr-cooking-nav-btn:hover {
    background: var(--jr-bg-alt);
}

.jr-cooking-nav-btn.jr-next {
    background: var(--jr-green);
    color: #fff;
    border-color: var(--jr-green);
}

.jr-cooking-nav-btn.jr-next:hover {
    background: #3d6a4a;
}

.jr-cooking-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.jr-cooking-progress {
    font-size: 0.85em;
    color: var(--jr-text-muted);
    font-weight: 500;
}

/* ===== Print styles ===== */
@media print {
    .jr-recipe {
        max-width: 100%;
        margin: 0;
        border: none;
    }

    .jr-cooking-mode-btn,
    .jr-servings-adjuster {
        display: none !important;
    }

    .jr-section {
        break-inside: avoid;
    }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .jr-recipe {
        margin: 1em auto;
    }

    .jr-title {
        font-size: 1.35em;
    }

    .jr-section {
        padding: 1.25em;
    }

    .jr-meta {
        gap: 8px;
    }

    .jr-meta-item {
        padding: 6px 10px;
        font-size: 0.8em;
    }

    .jr-step {
        gap: 12px;
    }

    .jr-step-marker {
        width: 32px;
    }

    .jr-step-number {
        width: 30px;
        height: 30px;
        font-size: 0.75em;
    }

    .jr-step-title {
        font-size: 1em;
    }

    .jr-calories-number {
        font-size: 2.5em;
    }

    .jr-cooking-body {
        padding: 24px 16px;
    }

    .jr-cooking-step-title {
        font-size: 1.2em;
    }

    .jr-cooking-step-text {
        font-size: 1em;
    }

    .jr-cooking-nav-btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }
}
