/* Base styles */
:root {
    --bg-color: #fafafa;
    --card-bg: #ffffff;
    --text-color: #333;
    --text-muted: #666;
    --border-color: #e0e0e0;
    --accent-color: #2d5a27;
    --accent-light: #4a8c42;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Search */
.search-bar {
    margin-bottom: 2rem;
}

.search-bar input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Recipe grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Recipe card */
.recipe-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.recipe-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.recipe-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.recipe-card .description {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recipe-card .meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.recipe-card .meta-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
}

.recipe-card .meta-item strong {
    color: var(--text-color);
}

/* Loading and error states */
.loading, .error {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.error {
    color: #c00;
}

/* Recipe detail page */
.recipe-detail {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    grid-column: 1 / -1;
}

.recipe-detail h1 {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.recipe-detail .timing-bar {
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.recipe-detail .timing-item {
    text-align: center;
}

.recipe-detail .timing-item .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-color);
}

.recipe-detail .timing-item .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.recipe-detail .description {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.recipe-detail .source {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.recipe-detail .source a {
    color: var(--accent-light);
}

/* Sections */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.3rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

/* Shopping list */
.shopping-table {
    width: 100%;
    border-collapse: collapse;
}

.shopping-table th,
.shopping-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.shopping-table th {
    background: var(--bg-color);
    font-weight: 600;
}

.category-header {
    font-weight: 600;
    background: var(--bg-color);
}

/* Timeline table */
.timeline-table {
    width: 100%;
    border-collapse: collapse;
}

.timeline-table th,
.timeline-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.timeline-table th {
    background: var(--bg-color);
    font-weight: 600;
}

.timeline-total {
    background: var(--bg-color);
}

/* Graphical Timeline */
.timeline-gantt {
    margin-top: 1.5rem;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1rem 1rem 2.5rem 1rem;
    position: relative;
}

.timeline-axis {
    position: absolute;
    bottom: 0.5rem;
    left: 140px;  /* match label width */
    right: 1rem;
    height: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.timeline-marker {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    top: 0.25rem;
}

.timeline-marker::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    left: 50%;
    width: 1px;
    height: 0.4rem;
    background: var(--border-color);
}

.timeline-row {
    display: flex;
    align-items: center;
    height: 2rem;
    margin-bottom: 0.5rem;
}

.timeline-label {
    width: 120px;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 500;
    padding-right: 1rem;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-bars {
    flex: 1;
    position: relative;
    height: 1.25rem;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
}

.timeline-bar {
    position: absolute;
    height: 100%;
    border-radius: 4px;
    min-width: 4px;
}

.timeline-bar-active {
    background: var(--accent-color);
}

.timeline-bar-passive {
    background: repeating-linear-gradient(
        45deg,
        var(--accent-light),
        var(--accent-light) 3px,
        rgba(74, 140, 66, 0.3) 3px,
        rgba(74, 140, 66, 0.3) 6px
    );
}

/* Legend */
.timeline-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-left: 140px;  /* align with bars */
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 1rem;
    height: 0.75rem;
    border-radius: 2px;
}

.legend-active {
    background: var(--accent-color);
}

.legend-passive {
    background: repeating-linear-gradient(
        45deg,
        var(--accent-light),
        var(--accent-light) 3px,
        rgba(74, 140, 66, 0.3) 3px,
        rgba(74, 140, 66, 0.3) 6px
    );
}

.legend-wall {
    margin-left: auto;
    font-weight: 500;
}

/* Timeline responsive */
@media (max-width: 600px) {
    .timeline-label {
        width: 80px;
        font-size: 0.75rem;
    }
    .timeline-axis {
        left: 100px;
    }
    .timeline-legend {
        padding-left: 100px;
        flex-wrap: wrap;
    }
}

.timeline-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.75rem;
    padding-left: 140px;
}

@media (max-width: 600px) {
    .timeline-note {
        padding-left: 100px;
    }
}

/* Mise en place */
.mise-item {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.mise-item .label {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    margin-right: 0.5rem;
}

.mise-item .description {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.mise-item ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.mise-item li {
    margin-bottom: 0.3rem;
}

/* Steps */
.step {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.step:last-child {
    border-bottom: none;
}

.step-number {
    background: var(--accent-color);
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
}

.step-content {
    flex: 1;
}

.step-requires {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.step-timing {
    font-size: 0.85rem;
    color: var(--accent-light);
}

/* Notes */
.note {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.note-title {
    font-weight: 600;
    margin-bottom: 0.3rem;
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    grid-column: 1 / -1;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-light);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Print view */
.print-view {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    grid-column: 1 / -1;
}

.print-view pre {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
}

/* Page header (back link + actions) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    grid-column: 1 / -1;
    align-self: start;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Back link */
.back-link {
    color: var(--accent-light);
    text-decoration: none;
    display: inline-block;
    padding: 0.5rem 0;
    line-height: 1.4;
}

.back-link:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .recipe-grid {
        grid-template-columns: 1fr;
    }

    .recipe-detail .timing-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* Timeline tooltip */
.timeline-tooltip {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.timeline-tooltip.visible {
    opacity: 1;
}

/* Print styles */
@media print {
    /* Hide all UI elements */
    .actions,
    .back-link,
    .search-bar,
    .page-header,
    .btn,
    header,
    #timeline-tooltip {
        display: none !important;
    }

    /* Reset page layout */
    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    .container {
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .recipe-detail, .print-view {
        border: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
        background: white;
    }

    /* Print view: only show the pre content */
    .print-view pre {
        font-family: 'Courier', monospace;
        font-size: 10pt;
        line-height: 1.2;
        margin-left: 0.5in;
        margin-top: 0;
        margin-bottom: 0;
        page-break-after: always;
    }

    .print-view pre:last-child {
        page-break-after: avoid;
    }

    /* Ensure recipe grid doesn't add spacing */
    .recipe-grid {
        display: block;
        padding: 0;
        margin: 0;
    }
}
