/**
 * Recipe Formatting Styles
 * 
 * Advanced layout styles for multi-column recipes, container boxes,
 * visual markers, and compact print optimization.
 * 
 * Version: 2.1
 * File Revision: 2.0
 * Created: February 7, 2026 10:40 PM Pacific Time
 * Updated: 2026-02-18
 * Author: Tim Ha
 */

/* ============================================
   MULTI-COLUMN LAYOUTS (Equal Width)
   ============================================ */

.recipe-cols {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
    clear: both;
}

.recipe-col {
    flex: 1 1 auto;
    min-width: 200px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-sizing: border-box;
}

/* Specific column widths */
.recipe-cols-2 .recipe-col {
    flex-basis: calc(50% - 10px);
}

.recipe-cols-3 .recipe-col {
    flex-basis: calc(33.333% - 14px);
}

.recipe-cols-4 .recipe-col {
    flex-basis: calc(25% - 16px);
}

/* ============================================
   PERCENTAGE-WIDTH COLUMNS (Custom Widths)
   ============================================ */

.recipe-cols-pct {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    clear: both;
}

.recipe-col-pct {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-sizing: border-box;
    min-width: 0; /* Allow flex items to shrink below content size */
}

/* Column headers */
.recipe-col h3,
.recipe-col h4,
.recipe-col strong,
.recipe-col-pct h3,
.recipe-col-pct h4,
.recipe-col-pct strong {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 6px;
}

/* Lists inside columns */
.recipe-col ul,
.recipe-col ol,
.recipe-col-pct ul,
.recipe-col-pct ol {
    margin: 10px 0;
    padding-left: 20px;
}

.recipe-col li,
.recipe-col-pct li {
    margin: 6px 0;
    line-height: 1.6;
}

/* ============================================
   FEATURE BLOCK (Full-Width Highlight)
   ============================================ */

.recipe-feature {
    width: 100%;
    margin: 24px 0;
    padding: 24px 28px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 5px solid #6c757d;
    border-radius: 0 10px 10px 0;
    box-sizing: border-box;
    font-size: 1.05em;
    line-height: 1.7;
    position: relative;
}

.recipe-feature strong,
.recipe-feature h3,
.recipe-feature h4 {
    color: #2c3e50;
    margin-top: 0;
}

/* Themed feature block when inside recipe-pages-content */
.recipe-pages-content .recipe-feature {
    border-left-color: var(--recipe-primary, #D4745C);
    background: linear-gradient(135deg, var(--recipe-info-bar-bg, #f8f9fa) 0%, var(--recipe-container-bg, #e9ecef) 100%);
}

/* ============================================
   BOX CONTAINERS
   ============================================ */

.recipe-box {
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    margin: 8px;
    transition: box-shadow 0.3s ease;
}

.recipe-box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Box widths */
.recipe-box-1 {
    width: 98%;
    display: block;
    margin: 15px auto;
}

.recipe-box-2 {
    width: 47%;
    display: inline-block;
    vertical-align: top;
}

.recipe-box-3 {
    width: 31%;
    display: inline-block;
    vertical-align: top;
}

.recipe-box-4 {
    width: 23%;
    display: inline-block;
    vertical-align: top;
}

/* Box headers */
.recipe-box h3,
.recipe-box h4 {
    margin-top: 0;
    color: #495057;
    font-size: 1.1em;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

/* Box lists */
.recipe-box ul,
.recipe-box ol {
    margin: 8px 0;
    padding-left: 24px;
}

.recipe-box li {
    margin: 5px 0;
}

/* ============================================
   VISUAL ICON MARKERS (10 markers)
   ============================================ */

.recipe-icon {
    display: inline-block;
    font-size: 1.2em;
    line-height: 1;
    vertical-align: middle;
}

/* Original 4 markers */
.recipe-icon-warning {
    color: #ff6b35;
    font-weight: bold;
}

.recipe-icon-tip {
    color: #ffa500;
    font-weight: bold;
}

.recipe-icon-time {
    color: #4a90e2;
    font-weight: bold;
}

.recipe-icon-technique {
    color: #50c878;
    font-weight: bold;
}

/* 6 new markers (V1.28) */
.recipe-icon-add {
    color: #28a745;
    font-weight: bold;
}

.recipe-icon-substitute {
    color: #6f42c1;
    font-weight: bold;
}

.recipe-icon-optional {
    color: #868e96;
    font-weight: bold;
}

.recipe-icon-yield {
    color: #d63384;
    font-weight: bold;
}

.recipe-icon-variation {
    color: #0dcaf0;
    font-weight: bold;
}

.recipe-icon-nutrition {
    color: #198754;
    font-weight: bold;
}

/* Highlighted icon lines */
p:has(.recipe-icon),
li:has(.recipe-icon) {
    background: #fffef5;
    padding: 8px 12px;
    border-left: 3px solid;
    margin: 10px 0;
    border-radius: 4px;
}

p:has(.recipe-icon-warning),
li:has(.recipe-icon-warning) {
    border-left-color: #ff6b35;
    background: #fff5f5;
}

p:has(.recipe-icon-tip),
li:has(.recipe-icon-tip) {
    border-left-color: #ffa500;
    background: #fffef5;
}

p:has(.recipe-icon-time),
li:has(.recipe-icon-time) {
    border-left-color: #4a90e2;
    background: #f0f8ff;
}

p:has(.recipe-icon-technique),
li:has(.recipe-icon-technique) {
    border-left-color: #50c878;
    background: #f0fff4;
}

p:has(.recipe-icon-add),
li:has(.recipe-icon-add) {
    border-left-color: #28a745;
    background: #f0fff4;
}

p:has(.recipe-icon-substitute),
li:has(.recipe-icon-substitute) {
    border-left-color: #6f42c1;
    background: #f8f0ff;
}

p:has(.recipe-icon-optional),
li:has(.recipe-icon-optional) {
    border-left-color: #868e96;
    background: #f8f9fa;
}

p:has(.recipe-icon-yield),
li:has(.recipe-icon-yield) {
    border-left-color: #d63384;
    background: #fff0f6;
}

p:has(.recipe-icon-variation),
li:has(.recipe-icon-variation) {
    border-left-color: #0dcaf0;
    background: #f0faff;
}

p:has(.recipe-icon-nutrition),
li:has(.recipe-icon-nutrition) {
    border-left-color: #198754;
    background: #f0fff4;
}

/* ============================================
   COMPACT MODE (Single-page optimization)
   ============================================ */

.recipe-compact {
    line-height: 1.4;
}

.recipe-compact p {
    margin: 0.4em 0;
}

.recipe-compact li {
    margin: 0.25em 0;
}

.recipe-compact h1 {
    margin: 0.3em 0;
    font-size: 1.8em;
}

.recipe-compact h2 {
    margin: 0.5em 0 0.3em 0;
    font-size: 1.4em;
}

.recipe-compact h3 {
    margin: 0.4em 0 0.2em 0;
    font-size: 1.2em;
}

.recipe-compact h4 {
    margin: 0.3em 0 0.15em 0;
    font-size: 1.1em;
}

.recipe-compact ul,
.recipe-compact ol {
    margin: 0.5em 0;
    padding-left: 1.8em;
}

.recipe-compact .recipe-cols {
    margin: 12px 0;
    gap: 12px;
}

.recipe-compact .recipe-col {
    padding: 10px;
}

.recipe-compact .recipe-box {
    margin: 5px;
    padding: 8px;
}

.recipe-compact .recipe-feature {
    margin: 12px 0;
    padding: 14px 18px;
}

/* ============================================
   INLINE IMAGES ([img] markup) — V1.35
   ============================================ */

.recipe-inline-image {
    margin: 20px 0;
    line-height: 0;
    text-align: center;
}

.recipe-inline-img {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

/* Size: small (40% width, centered) */
.recipe-inline-image-small {
    max-width: 40%;
    margin-left: auto;
    margin-right: auto;
}

/* Size: half (50% width, centered) */
.recipe-inline-image-half {
    max-width: 50%;
    margin-left: auto;
    margin-right: auto;
}

.recipe-inline-image-small .recipe-inline-img,
.recipe-inline-image-half .recipe-inline-img {
    width: 100%;
}

/* Float: left (50% width, text wraps right) */
.recipe-inline-image-left {
    float: left;
    max-width: 50%;
    margin: 4px 24px 12px 0;
}

/* Float: right (50% width, text wraps left) */
.recipe-inline-image-right {
    float: right;
    max-width: 50%;
    margin: 4px 0 12px 24px;
}

/* Clearfix for floated images */
.recipe-inline-image-clear {
    clear: both;
    height: 0;
    overflow: hidden;
}

/* ============================================
   PRINT OPTIMIZATIONS
   ============================================ */

@media print {
    /* Overall compact print layout */
    body {
        font-size: 11pt;
        line-height: 1.3;
        color: #000;
    }
    
    .recipe-pages-content {
        max-width: 100%;
        margin: 0;
        padding: 0.4in;
    }
    
    /* Typography */
    .recipe-pages-content h1 {
        font-size: 18pt;
        margin: 0.2em 0;
        page-break-after: avoid;
    }
    
    .recipe-pages-content h2 {
        font-size: 14pt;
        margin: 0.4em 0 0.2em 0;
        page-break-after: avoid;
    }
    
    .recipe-pages-content h3 {
        font-size: 12pt;
        margin: 0.3em 0 0.15em 0;
        page-break-after: avoid;
    }
    
    .recipe-pages-content h4 {
        font-size: 11pt;
        margin: 0.25em 0 0.1em 0;
        page-break-after: avoid;
    }
    
    /* Compact spacing */
    .recipe-pages-content p,
    .recipe-pages-content li {
        margin: 0.15em 0;
        line-height: 1.3;
    }
    
    .recipe-pages-content ul,
    .recipe-pages-content ol {
        margin: 0.3em 0;
        padding-left: 1.5em;
    }
    
    /* Remove double spacing */
    br + br {
        display: none;
    }
    
    /* Columns in print */
    .recipe-cols {
        display: flex;
        gap: 12px;
        margin: 10px 0;
    }
    
    .recipe-col,
    .recipe-col-pct {
        padding: 8px;
        border: 1px solid #ccc;
        background: #f9f9f9;
    }
    
    /* Feature block in print */
    .recipe-feature {
        border-left: 3px solid #000;
        background: #f5f5f5;
        padding: 10px 14px;
        margin: 10px 0;
        page-break-inside: avoid;
    }
    
    /* Boxes in print */
    .recipe-box {
        border: 1px solid #999;
        margin: 4px;
        padding: 6px;
        page-break-inside: avoid;
    }
    
    /* Icons in black and white */
    .recipe-icon {
        font-size: 1.1em;
    }
    
    .recipe-icon-warning,
    .recipe-icon-tip,
    .recipe-icon-time,
    .recipe-icon-technique,
    .recipe-icon-add,
    .recipe-icon-substitute,
    .recipe-icon-optional,
    .recipe-icon-yield,
    .recipe-icon-variation,
    .recipe-icon-nutrition {
        color: #000;
        font-weight: bold;
    }
    
    /* Icon highlighting */
    p:has(.recipe-icon),
    li:has(.recipe-icon) {
        background: #f5f5f5;
        border-left: 2px solid #000;
        padding: 4px 8px;
    }
    
    /* Hide non-essential elements */
    .no-print,
    .recipe-print-wrapper,
    nav,
    header,
    footer,
    aside,
    .sidebar,
    .widget-area,
    .site-header,
    .site-footer,
    .comments-area,
    .post-navigation,
    .entry-meta,
    .entry-footer {
        display: none !important;
    }
    
    /* Prevent page breaks in critical sections */
    .recipe-col,
    .recipe-col-pct,
    .recipe-box,
    .recipe-feature,
    .recipe-section {
        page-break-inside: avoid;
    }
    
    /* Images */
    img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    /* Inline images in print */
    .recipe-inline-image {
        margin: 10px 0;
        page-break-inside: avoid;
    }

    .recipe-inline-img {
        max-height: 300px;
    }

    .recipe-inline-image-left,
    .recipe-inline-image-right {
        float: none;
        max-width: 100%;
        margin: 10px 0;
    }

    .recipe-inline-image-small,
    .recipe-inline-image-half {
        max-width: 100%;
    }
    
    /* Links */
    a[href]:after {
        content: "";
    }
    
    /* Ensure single page fit when possible */
    @page {
        margin: 0.5in;
        size: letter portrait;
    }
}

/* ============================================
   MOBILE RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    /* Stack columns on mobile */
    .recipe-cols {
        flex-direction: column;
    }
    
    .recipe-col,
    .recipe-col-pct {
        width: 100% !important;
        max-width: 100% !important;
        flex-basis: 100% !important;
        flex: 0 0 100% !important;
        margin: 8px 0;
    }
    
    /* Full width boxes on mobile */
    .recipe-box {
        width: 100% !important;
        display: block !important;
        margin: 8px 0;
    }
    
    /* Feature block mobile */
    .recipe-feature {
        padding: 18px 20px;
        margin: 16px 0;
    }
    
    /* Inline images: collapse floats on mobile */
    .recipe-inline-image-left,
    .recipe-inline-image-right {
        float: none;
        max-width: 100%;
        margin: 20px 0;
    }

    .recipe-inline-image-small,
    .recipe-inline-image-half {
        max-width: 100%;
    }

    /* Larger touch targets */
    .recipe-icon {
        font-size: 1.3em;
        margin-right: 10px;
    }
    
    /* Adjust padding for mobile */
    .recipe-col,
    .recipe-col-pct,
    .recipe-box {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .recipe-pages-content {
        font-size: 14px;
    }
    
    .recipe-cols {
        gap: 12px;
    }
    
    .recipe-col,
    .recipe-col-pct,
    .recipe-box {
        padding: 10px;
    }
    
    .recipe-feature {
        padding: 14px 16px;
        font-size: 0.95em;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .recipe-col,
    .recipe-col-pct {
        border: 2px solid #000;
        background: #fff;
    }
    
    .recipe-box {
        border: 2px solid #000;
        box-shadow: none;
    }
    
    .recipe-feature {
        border-left: 5px solid #000;
        background: #fff;
    }
    
    .recipe-icon {
        font-weight: 900;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .recipe-box {
        transition: none;
    }
}

/* Focus styles for keyboard navigation */
.recipe-col:focus-within,
.recipe-col-pct:focus-within,
.recipe-box:focus-within,
.recipe-feature:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.clear {
    clear: both;
    display: block;
    height: 0;
    overflow: hidden;
}

.recipe-section {
    margin: 20px 0;
    padding: 15px 0;
}

.recipe-highlight {
    background: #fffbcc;
    padding: 12px;
    border-left: 4px solid #ffc107;
    margin: 15px 0;
    border-radius: 4px;
}

/* Text alignment utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Spacing utilities */
.mt-1 { margin-top: 0.5em; }
.mt-2 { margin-top: 1em; }
.mt-3 { margin-top: 1.5em; }

.mb-1 { margin-bottom: 0.5em; }
.mb-2 { margin-bottom: 1em; }
.mb-3 { margin-bottom: 1.5em; }

/* ============================================
   DEBUG MODE (for template development)
   ============================================ */

.recipe-debug .recipe-cols {
    border: 2px dashed red;
}

.recipe-debug .recipe-col,
.recipe-debug .recipe-col-pct {
    border: 2px dashed blue;
}

.recipe-debug .recipe-box {
    border: 2px dashed green;
}

.recipe-debug .recipe-feature {
    border: 2px dashed purple;
}

.recipe-debug .recipe-icon {
    border: 1px solid orange;
}
