/* Book-inspired styles with warm palette and classic typography */
:root {
    /* Colors lifted from Typst styles.typ */
    --primary: #2c1810;
    /* text-primary */
    --cream: #f9f6f2;
    /* secondary */
    --accent: #a0522d;
    /* accent-dark */
    --accent-soft: #d2691e;
    /* accent */
    --text: #2c1810;
    /* main text */
    --text-light: #6b4423;
    --text-muted: #8b6914;
    --card: #f5f2ed;
    /* background-card */
    --bg: #fdfcfa;
    /* background-subtle */
    --border: #e6ddd4;
}

/* Dark theme variables */
[data-theme="dark"] {
    --primary: #f2e8de;
    --cream: #1b120d;
    --accent: #e07a3f;
    --accent-soft: #f1995e;
    --text: #f4ede6;
    --text-light: #d6c6b9;
    --text-muted: #b79f7d;
    --card: #201610;
    --bg: #160f0b;
    --border: #3a2a20;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Georgia, "Times New Roman", Times, serif;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Establish a stacking context so we can place the image behind content */
.recipe {
    position: relative;
}

.wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 1rem;
}

.site-header,
.site-footer {
    border-bottom: 1px solid var(--border);
    background: var(--cream);
}

.site-footer {
    border-top: 1px solid var(--border);
    border-bottom: none;
    color: var(--text-muted);
}

.site-header .wrap,
.site-footer .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: 0.5px;
}

nav a {
    margin-left: .75rem;
    color: var(--text-muted);
    text-decoration: none;
}

nav a:hover {
    color: var(--text);
}

h1,
h2,
h3 {
    line-height: 1.25;
    margin: 0.6em 0 0.4em;
}

h1.recipe-title {
    font-size: clamp(1.6rem, 3.5vw, 2rem);
    font-weight: 400;
    letter-spacing: 0.3px;
    color: var(--primary);
    margin-bottom: .2rem;
    position: relative;
    z-index: 2;
    /* keep the title above the background image */
}

h2 {
    font-family: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui;
    font-size: 0.95rem;
    letter-spacing: 2px;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 600;
}

.category {
    margin: 2rem 0;
}

.cards {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    margin-bottom: .6rem;
    border: 1px solid var(--border);
    background: #eee;
}

.meta span {
    margin-right: .5rem;
    color: var(--text-muted);
    font-size: .9rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: .8rem 0 1rem;
    position: relative;
    z-index: 2;
}

.divider.subtle {
    border-top-color: var(--border);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, auto));
    gap: 8px 14px;
    align-items: baseline;
    margin: 0.2rem 0 0.6rem;
    position: relative;
    z-index: 2;
    /* ensure readability over the background image */
}

.meta-item .label {
    display: block;
    font-family: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui;
    font-size: 0.72rem;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.meta-item .value {
    font-size: 0.9rem;
    color: var(--text-light);
}

.recipe-columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem 2rem;
    position: relative;
    z-index: 2;
}

.recipe-figure {
    /* Decorative background image overlapping the title on the right */
    position: absolute;
    top: .2rem;
    right: -4vw;
    /* let it bleed slightly outside the container */
    width: clamp(240px, 28vw, 480px);
    margin: 0;
    pointer-events: none;
    /* do not intercept clicks */
    z-index: 1;
    /* behind text which is z-index:2 */
}

.recipe-figure img {
    width: 100%;
    height: auto;
    border-radius: 20px;
    border: 0;
    background: transparent;
    box-shadow: none;
    opacity: .13;
    /* faded for background feel */
    filter: saturate(0.9) contrast(0.96);
    display: block;
}

/* Mobile: keep it as a background motif, smaller and further to the right */
@media (max-width: 700px) {

    /* Ensure no horizontal scroll due to the decorative image */
    .recipe {
        overflow-x: clip;
        /* modern */
        overflow-x: hidden;
        /* fallback */
    }

    .recipe-figure {
        top: -.1rem;
        right: -18vw;
        /* push further out so it crops on the right */
        width: min(62vw, 320px);
        /* a tad smaller on mobile */
    }

    .recipe-figure img {
        opacity: .1;
    }
}

.ingredients {
    list-style: none;
    padding: 0;
    margin: 0.3rem 0 0.8rem;
}

.ingredients li {
    display: grid;
    grid-template-columns: 18px 28% 1fr;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px dotted var(--border);
    align-items: center;
}

.ingredients-checkable li.has-checkbox input.ing-check {
    width: 16px;
    height: 16px;
    margin: 0 0 0 2px;
    accent-color: var(--accent);
    align-self: center;
}

.ingredients-checkable li.has-checkbox .amount {
    align-self: center;
}

.ingredients-checkable li.has-checkbox.checked .item {
    text-decoration: line-through;
    color: var(--text-muted);
}

.ingredients-actions {
    display: inline-flex;
    gap: 6px;
    margin-left: .3rem;
    opacity: .65;
    /* slightly muted by default, but always visible */
    transform: translateY(-1px);
    transition: opacity .15s ease, transform .15s ease;
}

/* Actions are placed right after the Zutaten title (H2) */
h2 .ingredients-actions {
    position: relative;
    top: -1px;
}

h2:hover .ingredients-actions,
h2:focus-within .ingredients-actions,
.ingredients-actions:hover,
.ingredients-actions:focus-within {
    opacity: 1;
}

.btn.small {
    font: inherit;
    font-size: 0.8rem;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}

.btn.small:hover {
    filter: brightness(1.05);
}

.btn.small.icon {
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    font-size: 0.85rem;
}

.ingredients .item {
    font-size: 0.95rem;
}

.instructions {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0.3rem 0 0.8rem;
}

.instructions li {
    counter-increment: step;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    align-items: start;
    padding: 6px 0;
}

.instructions li::before {
    content: counter(step);
    font-family: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 300;
    line-height: 1;
}

.notes {
    margin: 0.3rem 0 0.8rem;
    padding-left: 1.1rem;
    color: var(--text-light);
}

.back {
    display: inline-block;
    margin: .5rem 0 1rem;
    color: var(--accent);
    text-decoration: none;
}

.file-meta {
    color: var(--text-muted);
    font-size: .9rem;
}

/* Theme toggle button */
.theme-toggle {
    margin-left: .75rem;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
}

.theme-toggle:hover {
    filter: brightness(1.05);
}