/* The app's palette, so the site and the phone look like one product. */
:root {
    color-scheme: light dark;
    --bg: #fdf3e7;
    --surface: #ffffff;
    --ink: #1c1b19;
    --muted: #6b6862;
    --line: #e8e0d4;
    --accent: #e07a1f;
    --accent-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171614;
        --surface: #211f1c;
        --ink: #f2efe9;
        --muted: #a29d94;
        --line: #35322d;
        --accent: #fb923c;
        --accent-ink: #1c1b19;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* The footer sits at the bottom of the window when a page is short — a
       category with three recipes used to pull it halfway up the screen, which
       reads as "the page ended early" rather than "this category is small". */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

main { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* ---- header ---------------------------------------------------------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: relative;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 14px;
    padding-bottom: 14px;
}

/* The logo is the whole brand: sized by height so the header row keeps the
   same shape whatever the artwork's aspect ratio is. */
.brand {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    text-decoration: none;
}
.brand img {
    height: 46px;
    width: auto;
}

/* The categories menu ---------------------------------------------------
   A full-width panel under the header rather than a strip that scrolls
   sideways: thirty categories do not fit on one line at any width, and a
   row you have to drag hides most of itself from everybody. */
/* Deliberately not positioned: the panel below is absolute against
   .site-header, so it spans the full width instead of the button's. */
.catmenu { position: static; }

.catmenu summary {
    list-style: none;
    cursor: pointer;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
}
.catmenu summary::-webkit-details-marker { display: none; }
.catmenu summary::after {
    content: "▾";
    margin-left: 8px;
    font-size: 12px;
    color: var(--muted);
}
.catmenu[open] summary { border-color: var(--accent); color: var(--accent); }
.catmenu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.catpanel {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 28px rgba(0, 0, 0, .13);
    padding: 20px 0 24px;
}

.catpanel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 4;
    column-gap: 28px;
}
.catpanel li { break-inside: avoid; }
.catpanel a {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    font-size: 15px;
    text-decoration: none;
    color: var(--ink);
}
.catpanel a:hover { color: var(--accent); }
.catpanel .count { color: var(--muted); font-size: 13px; }

.search { display: flex; gap: 8px; margin-left: auto; flex: 0 1 380px; }
.search input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font-size: 16px;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.search button {
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-ink);
    background: var(--accent);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

/* ---- shared ---------------------------------------------------------- */
/* `main` carries class="wrap", and .wrap's `padding: 0 16px` shorthand zeroes
   the vertical padding — a class outranks a bare element, so this rule has to
   name both or it silently does nothing. The top space is .page-title's own
   margin; this is the gap above the footer, which the last row of cards would
   otherwise sit flush against. */
main.wrap { padding-bottom: 48px; width: 100%; }

.page-title { font-size: 28px; line-height: 1.25; margin: 20px 0 14px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.empty { color: var(--muted); padding: 24px 0; }

.button {
    display: inline-block;
    padding: 11px 18px;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}
.card-photo { aspect-ratio: 4 / 3; background: var(--bg); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 14px; }
.card-body h3 { margin: 0 0 6px; font-size: 16px; line-height: 1.35; }
.card-meta { margin: 0; font-size: 13px; color: var(--muted); display: flex; gap: 12px; }

.pager { display: flex; gap: 16px; align-items: center; justify-content: center; padding: 32px 0; }
.pager a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---- recipe ---------------------------------------------------------- */
.recipe { max-width: 760px; }
.byline { margin: 0 0 18px; font-size: 15px; }
.hero { border-radius: 14px; margin-bottom: 20px; }

.facts {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
    margin: 0 0 28px;
}
.facts li {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
}
.facts b { font-size: 12px; color: var(--muted); font-weight: 600; }

.recipe section { margin-bottom: 32px; }
.recipe h2 { font-size: 21px; margin: 0 0 12px; }

.ingredient-group { font-size: 16px; margin: 18px 0 8px; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li {
    display: flex;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
}
.ingredients b { min-width: 72px; }

.steps { padding-left: 22px; margin: 0; }
.steps li { margin-bottom: 20px; }
.steps p { margin: 0 0 8px; }
.steps img { border-radius: 10px; }
.tip { font-size: 15px; color: var(--muted); font-style: italic; }

.comments { list-style: none; padding: 0; margin: 0; }
.comments li {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}
.comments li.reply { padding-left: 24px; border-left: 2px solid var(--line); }
.comment-author { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.comments p { margin: 0; }
.comment-photo { border-radius: 10px; margin-top: 10px; max-width: 320px; }

/* ---- footer ---------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 24px 0;
    font-size: 14px;
}
.site-footer p { margin: 0; }

.footer-categories { margin-bottom: 20px; }
.footer-categories h2 { font-size: 15px; margin: 0 0 10px; }
.footer-categories ul {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 4;
    column-gap: 24px;
}
.footer-categories li { break-inside: avoid; padding: 4px 0; }
.footer-categories a { color: var(--muted); text-decoration: none; }
.footer-categories a:hover { color: var(--accent); }
.site-footer .footer-legal { margin-top: 6px; }
.footer-legal a:hover { color: var(--accent); }

@media (max-width: 900px) {
    .catpanel ul, .footer-categories ul { columns: 3; }
}

@media (max-width: 680px) {
    .page-title { font-size: 24px; margin-top: 16px; }
    .brand img { height: 38px; }

    /* The search drops to its own line: a logo, a menu button and a search box
       on one row at phone width leaves the box too narrow to read what you
       typed. */
    .header-row { flex-wrap: wrap; gap: 10px; }
    .catmenu { margin-left: auto; }
    .search { flex: 1 0 100%; margin-left: 0; }

    .catpanel ul, .footer-categories ul { columns: 2; }
    .catpanel { max-height: 70vh; overflow-y: auto; }
}

@media (max-width: 380px) {
    .catpanel ul, .footer-categories ul { columns: 1; }
}
