/* Shared stylesheet for the CoMo Recipes GitHub Pages site. */

/* Theme variables: light is the default; the dark overrides below are applied
   either by OS preference (when no explicit choice is stored) or by the
   `data-theme` attribute set by assets/theme.js. Keep the two dark blocks in sync. */

:root {
    color-scheme: light;
    --paper: #f6f1e7;
    --surface: #fffcf5;
    --ink: #2c2519;
    --muted: #7c715c;
    --accent: #a84e24;
    --accent-soft: #f0e0cf;
    --border: #e0d5bf;
    --note-surface: #f9eed3;
    --note-border: #d9a441;
    --shadow: 0 1px 2px rgba(44, 37, 25, 0.06), 0 4px 16px rgba(44, 37, 25, 0.05);
    --tag-bg-s: 55%;
    --tag-bg-l: 88%;
    --tag-fg-s: 60%;
    --tag-fg-l: 30%;
    --theme-toggle-icon: "\263E\FE0E";
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #211d15;
    --surface: #2b261c;
    --ink: #ece4d3;
    --muted: #a99e86;
    --accent: #e09861;
    --accent-soft: #453221;
    --border: #40382a;
    --note-surface: #37301f;
    --note-border: #b98a3a;
    --shadow: none;
    --tag-bg-s: 30%;
    --tag-bg-l: 24%;
    --tag-fg-s: 45%;
    --tag-fg-l: 78%;
    --theme-toggle-icon: "\2600\FE0E";
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --paper: #211d15;
        --surface: #2b261c;
        --ink: #ece4d3;
        --muted: #a99e86;
        --accent: #e09861;
        --accent-soft: #453221;
        --border: #40382a;
        --note-surface: #37301f;
        --note-border: #b98a3a;
        --shadow: none;
        --tag-bg-s: 30%;
        --tag-bg-l: 24%;
        --tag-fg-s: 45%;
        --tag-fg-l: 78%;
        --theme-toggle-icon: "\2600\FE0E";
    }
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.0625rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h2 {
    margin: 0 0 1rem;
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Top bar */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 0;
}

.index-page .top-bar {
    max-width: 93rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-family: var(--serif);
    font-size: 0.9rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
}

.brand:hover {
    color: var(--accent);
}

.brand-logo {
    width: 1.9rem;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

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

.back-link {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

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

@media (max-width: 560px) {
    .back-link {
        display: none;
    }
}

.icon-link {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    color: var(--muted);
}

.icon-link svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
}

.icon-link:hover {
    color: var(--accent);
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
}

.theme-toggle::before {
    content: var(--theme-toggle-icon);
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.icon-link:focus-visible,
.theme-toggle:focus-visible,
.tag-filter .tag:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Recipe pages */

.recipe {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
}

.recipe-header {
    margin: 1.5rem 0 2.25rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.recipe-header h1 {
    margin: 0 0 0.85rem;
    font-size: clamp(2.1rem, 5vw, 3rem);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: 0.01em;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Tag chips: each tag carries its own hue via an inline `--tag-hue` custom property */

.tag {
    --tag-hue: 25;
    padding: 0.25rem 0.8rem;
    border: 0;
    border-radius: 999px;
    background: hsl(var(--tag-hue) var(--tag-bg-s) var(--tag-bg-l));
    color: hsl(var(--tag-hue) var(--tag-fg-s) var(--tag-fg-l));
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tag a {
    color: inherit;
    text-decoration: none;
}

.recipe-body {
    display: grid;
    gap: 2.25rem;
    align-items: start;
}

@media (min-width: 760px) {
    .recipe-body {
        grid-template-columns: minmax(17rem, 25rem) 1fr;
        gap: 3rem;
    }

    .ingredients {
        position: sticky;
        top: 1.5rem;
    }
}

/* Ingredients card with checkable items */

.ingredients {
    padding: 1.5rem 1.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.ingredient + .ingredient {
    border-top: 1px solid var(--border);
}

.ingredient label {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    padding: 0.55rem 0;
    cursor: pointer;
}

.ingredient input {
    flex: none;
    margin: 0;
    transform: translateY(0.15em);
    accent-color: var(--accent);
}

.amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ingredient input:checked + .ingredient-text {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-color: var(--muted);
}

/* Notes callout */

.notes {
    margin-bottom: 2.25rem;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--note-border);
    border-radius: 0 10px 10px 0;
    background: var(--note-surface);
}

.notes h2 {
    margin-bottom: 0.5rem;
}

.note-list {
    margin: 0;
    padding-left: 1.1rem;
}

.note-list li + li {
    margin-top: 0.4rem;
}

/* Numbered instruction steps */

.step-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.step-list li {
    position: relative;
    margin-bottom: 1.4rem;
    padding-left: 3.25rem;
    counter-increment: step;
}

.step-list li:last-child {
    margin-bottom: 0;
}

.step-list li::before {
    content: counter(step);
    position: absolute;
    top: -0.1em;
    left: 0;
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent);
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 600;
}

/* Index page */

.site-header {
    max-width: 93rem;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 0.5rem;
    text-align: center;
}

.site-logo {
    width: 76px;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 1.1rem;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(2.4rem, 6vw, 3.4rem);
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    line-height: 1.1;
}

.tagline {
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

.search-bar {
    max-width: 26rem;
    margin: 1.75rem auto 0;
}

#recipe-search {
    width: 100%;
    padding: 0.7rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 0.95rem;
}

#recipe-search::placeholder {
    color: var(--muted);
}

#recipe-search:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Tag filter: click chips to narrow the index to recipes carrying every selected tag */

.tag-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    max-width: 60rem;
    margin: 1.25rem auto 0;
}

.tag-filter .tag {
    cursor: pointer;
}

.tag-filter .tag.selected {
    background: hsl(var(--tag-hue) 55% 34%);
    color: hsl(var(--tag-hue) 60% 95%);
}

.letter-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.6rem 1rem;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(6px);
    font-family: var(--sans);
}

.letter-nav a {
    display: grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.letter-nav a:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.index-grid {
    max-width: 93rem;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 3rem;
    columns: 15rem;
    column-gap: 2.5rem;
}

.letter-section {
    break-inside: avoid;
    margin-bottom: 1.9rem;
    scroll-margin-top: 4rem;
}

.letter-section h2 {
    margin: 0 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--accent);
}

.letter-section ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.letter-section li a {
    display: block;
    margin: 0 -0.6rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    color: var(--ink);
    text-decoration: none;
}

.letter-section li a:hover {
    background: var(--surface);
    color: var(--accent);
}

.no-results {
    margin: 2rem auto;
    max-width: 93rem;
    padding: 0 1.5rem;
    text-align: center;
    color: var(--muted);
    font-family: var(--sans);
}

/* Print */

@media print {
    body {
        background: #fff;
        color: #000;
    }

    .top-bar,
    .search-bar,
    .tag-filter,
    .letter-nav {
        display: none;
    }

    .recipe-body {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .ingredients {
        position: static;
        box-shadow: none;
    }

    .step-list li,
    .letter-section {
        break-inside: avoid;
    }
}
