/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --bg-nav: #111111;
    --text: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;
    --border: #d4d4d4;
    --border-light: #e5e5e5;
    --accent: #1a1a1a;
    --accent-light: #e5e5e5;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --radius: 0.375rem;
    --radius-sm: 0.25rem;
    --font-serif: "Georgia", "Times New Roman", "Times", serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html.dark {
    --bg: #111111;
    --bg-card: #1a1a1a;
    --bg-nav: #0a0a0a;
    --text: #e5e5e5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --border: #333333;
    --border-light: #262626;
    --accent: #e5e5e5;
    --accent-light: #262626;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
}

html { font-family: var(--font-serif); line-height: 1.7; color: var(--text); background: var(--bg); }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* ===== Lucide Icons ===== */
.lucide { width: 1em; height: 1em; vertical-align: -0.125em; stroke-width: 1.75; }
.meta-pill .lucide { width: 0.9em; height: 0.9em; }
.note-icon .lucide { width: 1.25rem; height: 1.25rem; }
.pill-theme .lucide { width: 1.1rem; height: 1.1rem; vertical-align: -0.2em; }
.icon-inline { width: 0.85em; height: 0.85em; vertical-align: -0.1em; display: inline; stroke-width: 2; }

/* ===== Navbar ===== */
.navbar {
    background: var(--bg-nav);
    color: #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid #333;
}
.navbar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.search-container { flex: 1; max-width: 28rem; position: relative; }
.search-container input {
    width: 100%;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid #444;
    background: #222;
    color: #e5e5e5;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-container input:focus { border-color: #888; }
.search-container input::placeholder { color: #666; }

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 24rem;
    overflow-y: auto;
    z-index: 60;
}
.search-results.active { display: block; }
.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text);
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.selected { background: var(--accent-light); }
.search-result-name { font-weight: 600; font-family: var(--font-serif); }
.search-result-path { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-sans); }

.nav-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 1rem;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid #555;
    cursor: pointer;
    transition: border-color 0.15s;
    white-space: nowrap;
}
.pill:hover { border-color: #999; }

.pill-recipes {
    background: #ffffff;
    color: #111;
    border-color: #ffffff;
}
.pill-recipes:hover { opacity: 0.9; }
.pill-tags {
    background: transparent;
    color: #ccc;
    border-color: #555;
}
.pill-theme {
    background: transparent;
    color: #e5e5e5;
    font-size: 1rem;
    padding: 0.375rem 0.75rem;
    border-color: #555;
}

html.light .theme-icon-dark { display: none; }
html.dark .theme-icon-light { display: none; }

/* ===== Content ===== */
.content { max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem; }

/* ===== Breadcrumbs ===== */
.breadcrumbs { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.04em; }
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { margin: 0 0.25rem; }

/* ===== Index Page ===== */
.page-title {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--text);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: 1.5rem;
}
.card-grid-dirs {
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-dir {
    border-left: 3px solid var(--text);
}
.card-dir .card-title { font-size: 1.05rem; }
.card-meta { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-sans); }

.card-image { height: 12rem; overflow: hidden; }
.card-image img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(20%); transition: filter 0.3s; }
.card:hover .card-image img { filter: grayscale(0%); }

.card-body { padding: 1rem; flex: 1; }
.card-title { font-family: var(--font-serif); font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.card-description { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }

.tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.7rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--accent-light);
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Tag Cloud ===== */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.tag-cloud-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color 0.2s;
    font-size: 0.95rem;
}
.tag-cloud-item:hover {
    border-color: var(--text);
}
.tag-cloud-name {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--text);
}
.tag-cloud-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    border-radius: var(--radius);
    background: var(--accent-light);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-sans);
    font-weight: 600;
}

/* ===== Serving Selector ===== */
.serving-selector {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}
.serving-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.serving-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.serving-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.serving-btn:hover {
    border-color: var(--text);
    color: var(--text);
}
.serving-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

/* ===== Recipe Page ===== */
.recipe-page {
    display: grid;
    grid-template-columns: 20rem 1fr;
    gap: 3rem;
    align-items: start;
}

.recipe-sidebar { position: sticky; top: 5rem; }

@media (max-width: 768px) {
    .recipe-page { display: flex; flex-direction: column; gap: 0; }
    .recipe-sidebar, .recipe-content { display: contents; }
    .recipe-sidebar > .breadcrumbs { order: 1; }
    .recipe-sidebar > .recipe-title { order: 2; }
    .recipe-content > .recipe-hero-image { order: 3; }
    .recipe-sidebar > *:not(.breadcrumbs):not(.recipe-title) { order: 4; }
    .recipe-content > *:not(.recipe-hero-image) { order: 5; }
}

.recipe-title {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.recipe-description { color: var(--text-secondary); margin-bottom: 0.75rem; font-size: 0.95rem; }

.recipe-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 1rem; }

.metadata-pills { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 1.5rem; }
.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-family: var(--font-sans);
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
a.meta-pill:hover { border-color: var(--text); color: var(--text); }

.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-heading {
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--border);
}

.ingredient-list { display: flex; flex-direction: column; gap: 0.5rem; }
.ingredient-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--border-light);
    font-size: 0.9rem;
}
html.dark .ingredient-item {
    background: var(--bg);
    border-color: var(--border);
}
.ingredient-item.ingredient-optional { opacity: 0.7; border-style: dashed; }
.ingredient-name { font-weight: 500; }
.ingredient-amount { color: var(--text); font-weight: 600; white-space: nowrap; font-size: 0.85rem; }
.optional-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
    background: var(--text-muted);
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 500;
}

.cookware-list { display: flex; flex-direction: column; gap: 0.375rem; }
.cookware-item {
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--border-light);
    font-size: 0.9rem;
    font-weight: 500;
}
html.dark .cookware-item {
    background: var(--bg);
    border-color: var(--border);
}

/* ===== Recipe Content ===== */
.recipe-hero-image {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 2rem;
    max-height: 24rem;
}
.recipe-hero-image img { width: 100%; height: 100%; object-fit: cover; }

.section-header {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.section-header:first-child { margin-top: 0; }

.step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--text);
    color: var(--bg);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.step-content { flex: 1; line-height: 1.75; }
.step-content p { color: var(--text); }

/* Inline badges in steps */
.badge-ingredient {
    display: inline;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
    background: rgba(0,0,0,0.06);
    color: var(--text);
    font-weight: 600;
    font-size: 0.9em;
}
html.dark .badge-ingredient { background: rgba(255,255,255,0.08); }

.badge-cookware {
    display: inline;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
    background: rgba(0,0,0,0.06);
    color: var(--text);
    font-weight: 600;
    font-size: 0.9em;
    font-style: italic;
}
html.dark .badge-cookware { background: rgba(255,255,255,0.08); }

.badge-timer {
    display: inline;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
    background: rgba(0,0,0,0.06);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9em;
}
html.dark .badge-timer { background: rgba(255,255,255,0.08); color: var(--text-secondary); }

/* ===== Notes ===== */
.note {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
html.dark .note { background: var(--bg); border-color: var(--border); border-left-color: var(--text-muted); }
.note-icon { font-size: 1.25rem; flex-shrink: 0; }

/* ===== Print ===== */
@media print {
    .navbar, .search-container, .nav-actions, #theme-toggle { display: none !important; }
    .recipe-page { display: block; }
    .recipe-sidebar { position: static; }
    .step-number { background: #1a1a1a !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .navbar-inner { flex-wrap: wrap; padding: 0.5rem 1rem; }
    .search-container { order: 3; flex-basis: 100%; max-width: 100%; }
    .content { padding: 1rem; }
    .card-grid { grid-template-columns: 1fr; }
    .card-grid-dirs { grid-template-columns: repeat(2, 1fr); }
    .page-title { font-size: 1.5rem; }
}
