/* ==========================================================================
   Family Recipes
   Every colour is a custom property defined twice: once here, once in the
   prefers-color-scheme block. Nothing below those two blocks hard-codes one.
   ========================================================================== */

@font-face {
    font-family: 'Fraunces';
    src: url('fonts/fraunces.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Source Sans 3';
    src: url('fonts/source-sans-3.woff2') format('woff2');
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #eceef3;
    --text: #344060;
    --muted: #6b6b6b;
    --border: #dfdfdf;
    --rule: #344060;

    --chip-bg: #e3e7f0;
    --chip-text: #344060;
    --chip-border: #b5bccb;

    --accent: #b01d18;
    --accent-hover: #8e1713;
    --on-accent: #ffffff;

    --link: #335a85;
    --link-hover: #344060;
    --focus: #335a85;

    --hero-bg: #435071;
    --hero-text: #ffffff;
    --hero-dim: #e4e8f1;
    --hero-label: #c9d0e0;
    --hero-scrim: rgba(38, 46, 66, 0.58);
    --hero-field-bg: #526189;
    --hero-field-border: #8a96b5;

    --ok-bg: #e6f2e8;
    --ok-text: #1f5130;
    --err-bg: #fbe9e8;
    --err-text: #8e1713;

    --shadow: 0 1px 3px rgba(20, 26, 40, 0.08), 0 8px 24px rgba(20, 26, 40, 0.06);
    --radius: 12px;
    --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --sans: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #15171c;
        --surface: #1d2027;
        --surface-2: #242832;
        --text: #e3e7f0;
        --muted: #a0a8b8;
        --border: #2e333d;
        --rule: #55607a;

        --chip-bg: #2a3140;
        --chip-text: #dce3f0;
        --chip-border: #454f63;

        --accent: #e0574f;
        --accent-hover: #ee6d65;
        --on-accent: #1a0d0c;

        --link: #93b7e0;
        --link-hover: #b6d0ee;
        --focus: #93b7e0;

        --hero-bg: #232b40;
        --hero-text: #ffffff;
        --hero-dim: #dce2ee;
        --hero-label: #98a3bd;
        --hero-scrim: rgba(10, 13, 22, 0.64);
        --hero-field-bg: #333c52;
        --hero-field-border: #566486;

        --ok-bg: #1b2f22;
        --ok-text: #a7d7b6;
        --err-bg: #33191a;
        --err-text: #f0a9a4;

        --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
    }
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    /* Generous by default: most reading happens on a phone on a counter. */
    font-size: 1.0625rem;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.15;
    margin: 0;
}

a {
    color: var(--link);
}

a:hover {
    color: var(--link-hover);
}

img {
    max-width: 100%;
    height: auto;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.container {
    width: min(1180px, 100% - 40px);
    margin-inline: auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------- top bar */

.topbar {
    position: relative;
    z-index: 20;
}

.topbar__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 0;
}

.topbar--solid {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* On the home page the bar sits on top of the hero photo. */
.topbar--over {
    position: absolute;
    inset: 0 0 auto 0;
    background: transparent;
    border: 0;
    color: var(--hero-text);
}

.brand {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    color: inherit;
}

.topbar--solid .brand {
    color: var(--text);
}

.topbar__links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar__links a,
.menu__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    text-decoration: none;
    color: inherit;
    font-size: 1rem;
}

.topbar--solid .topbar__links a {
    color: var(--link);
}

.topbar__links a:hover,
.menu__button:hover {
    background: rgba(127, 140, 170, 0.18);
}

/* ------------------------------------------------------------------ menu */

.menu {
    position: relative;
}

.menu__button {
    list-style: none;
    cursor: pointer;
    border: 1px solid currentColor;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    color: inherit;
}

.menu__button::-webkit-details-marker {
    display: none;
}

.menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    padding: 6px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.menu__panel a,
.menu__panel button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.menu__panel a:hover,
.menu__panel button:hover {
    background: var(--surface-2);
}

.menu__panel .danger {
    color: var(--accent);
}

.menu__sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--border);
}

/* ------------------------------------------------------------------ hero */

.hero {
    position: relative;
    background-color: var(--hero-bg);
    background-size: cover;
    background-position: center;
    color: var(--hero-text);
    overflow: hidden;
}

/* The scrim is what keeps white text legible over an arbitrary photo. */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--hero-scrim);
}

.hero__inner {
    position: relative;
    z-index: 1;
    padding: 132px 0 108px;
    text-align: center;
}

.hero h1 {
    font-size: clamp(2.25rem, 7vw, 4.25rem);
    margin-bottom: 18px;
}

.hero__lede {
    margin: 0 auto 28px;
    max-width: 44ch;
    font-size: clamp(1rem, 2.2vw, 1.25rem);
    color: var(--hero-dim);
}

.hero__wave {
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 90px;
    z-index: 1;
    display: block;
}

.hero__wave path {
    fill: var(--bg);
}

/* --------------------------------------------------------------- search */

.searchbar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 6px;
    background: var(--surface);
    border-radius: 999px;
    box-shadow: var(--shadow);
}

.searchbar svg {
    flex: none;
    margin-left: 14px;
    color: var(--muted);
}

.searchbar input {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    border: 0;
    background: none;
    outline: none;
    font: inherit;
    font-size: 1.1rem;
    color: var(--text);
}

.hero__selects {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
}

.hero__selects label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8125rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hero-dim);
    text-align: left;
}

.hero__selects select {
    width: 220px;
    max-width: 44vw;
    height: 44px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--hero-field-border);
    background: var(--hero-field-bg);
    color: var(--hero-text);
    font: inherit;
    text-transform: none;
    letter-spacing: 0;
}

/* --------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 26px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: var(--accent-hover);
    color: var(--on-accent);
}

.btn--ghost {
    background: transparent;
    color: var(--link);
    border: 1px solid var(--chip-border);
}

.btn--ghost:hover {
    background: var(--surface-2);
    color: var(--link-hover);
}

.btn--small {
    min-height: 40px;
    padding: 0 16px;
    font-size: 0.9375rem;
    border-radius: 8px;
}

.btn--danger {
    background: none;
    color: var(--accent);
    border: 1px solid var(--chip-border);
}

.btn--danger:hover {
    background: var(--err-bg);
    color: var(--err-text);
}

/* -------------------------------------------------------------- sections */

.section {
    padding: 56px 0;
}

.section__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--rule);
    margin-bottom: 4px;
}

.section__head h2 {
    font-size: clamp(1.5rem, 3.5vw, 2.125rem);
}

.section__centered {
    text-align: center;
    margin-bottom: 40px;
}

.section__centered h2 {
    font-size: clamp(1.75rem, 4.5vw, 2.625rem);
    margin-bottom: 8px;
}

.section__centered p {
    margin: 0;
    color: var(--muted);
}

/* ------------------------------------------------------------ categories */

.tiles {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 36px 24px;
}

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--text);
}

.tile__disc {
    display: grid;
    place-items: center;
    width: 100%;
    max-width: 160px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--chip-bg);
    color: var(--hero-bg);
    transition: transform 0.15s ease;
}

@media (prefers-color-scheme: dark) {
    .tile__disc {
        color: var(--text);
    }
}

.tile:hover .tile__disc {
    transform: translateY(-3px);
}

.tile__disc svg {
    width: 45%;
    height: 45%;
}

.tile__name {
    font-family: var(--serif);
    font-size: 1.25rem;
    text-align: center;
}

.tile__count {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-top: -10px;
}

/* ----------------------------------------------------------- recipe list */

.recipe-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}

.recipe-row:hover .recipe-row__title {
    text-decoration: underline;
}

.recipe-row__thumb {
    flex: none;
    width: 120px;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: 10px;
    background: var(--surface-2);
}

.recipe-row__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recipe-row__title {
    font-family: var(--serif);
    font-size: 1.4rem;
}

.recipe-row__meta {
    color: var(--muted);
    font-size: 1rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 13px;
    border-radius: 999px;
    background: var(--chip-bg);
    color: var(--chip-text);
    border: 1px solid transparent;
    font-size: 0.9375rem;
    text-decoration: none;
}

a.chip:hover {
    border-color: var(--chip-border);
}

/* ------------------------------------------------------------- filtering */

.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}

.filters__row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 180px;
}

.field label,
.field > span {
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.field input[type='text'],
.field input[type='search'],
.field input[type='password'],
.field input[type='file'],
.field select,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--chip-border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.field textarea {
    min-height: 200px;
    line-height: 1.55;
    resize: vertical;
    font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
    font-size: 0.975rem;
}

.field__hint {
    font-size: 0.875rem;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}

.field__error {
    font-size: 0.9rem;
    color: var(--err-text);
    text-transform: none;
    letter-spacing: 0;
}

.chip-filter {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.chip-filter__legend {
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

/* The checkbox is the control; the label is the chip. */
.chip-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip-toggle span {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--chip-bg);
    color: var(--chip-text);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9375rem;
}

.chip-toggle input:checked + span {
    background: var(--accent);
    color: var(--on-accent);
}

.chip-toggle input:focus-visible + span {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.filters__actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 18px;
}

.filters__toggle {
    display: none;
}

.results__count {
    color: var(--muted);
    margin: 0 0 8px;
}

.empty {
    padding: 48px 0;
    text-align: center;
    color: var(--muted);
}

/* ------------------------------------------------------------ recipe page */

.recipe-hero {
    width: 100%;
    max-height: 460px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 28px;
    background: var(--surface-2);
}

.recipe-head {
    margin-bottom: 26px;
}

.recipe-head h1 {
    font-size: clamp(2rem, 5.5vw, 3rem);
    margin-bottom: 12px;
}

.byline {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 1.05rem;
}

.byline img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.facets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
}

.recipe-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    gap: 48px;
    align-items: start;
    margin-top: 36px;
}

.recipe-body h2 {
    font-size: 1.5rem;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--rule);
    margin-bottom: 14px;
}

.prose {
    font-size: 1.125rem;
    line-height: 1.75;
}

.prose :first-child {
    margin-top: 0;
}

.prose :last-child {
    margin-bottom: 0;
}

.prose ul,
.prose ol {
    padding-left: 1.3em;
}

.prose li {
    margin-bottom: 0.5em;
}

.prose h1,
.prose h2,
.prose h3 {
    font-size: 1.25rem;
    margin: 1.5em 0 0.4em;
    border: 0;
    padding: 0;
}

/* --------------------------------------------------------------- manage */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 28px;
}

.panel > h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.panel__hint {
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0 0 18px;
}

.lookup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.lookup-row__name {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.lookup-row input[type='text'] {
    flex: 1 1 160px;
    min-width: 0;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--chip-border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.lookup-row form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.count {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    flex: none;
}

.icon-cell {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--chip-bg);
    color: var(--hero-bg);
    flex: none;
}

@media (prefers-color-scheme: dark) {
    .icon-cell {
        color: var(--text);
    }
}

.icon-cell svg {
    width: 24px;
    height: 24px;
}

details.reveal > summary {
    cursor: pointer;
    color: var(--link);
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

details.reveal[open] > summary {
    margin-bottom: 10px;
}

/* ---------------------------------------------------------------- flash */

.flash {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
}

.flash--ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.flash--error {
    background: var(--err-bg);
    color: var(--err-text);
}

/* --------------------------------------------------------------- footer */

.footer {
    margin-top: 64px;
    padding: 26px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.95rem;
}

.footer__inner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

/* ---------------------------------------------------------------- login */

.login {
    max-width: 420px;
    margin: 72px auto;
}

.login h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.login p {
    color: var(--muted);
    margin-top: 0;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .recipe-body {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .tiles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 26px 14px;
    }
}

@media (max-width: 760px) {
    .container {
        width: min(1180px, 100% - 32px);
    }

    .hero__inner {
        padding: 104px 0 76px;
        text-align: left;
    }

    .hero__lede {
        margin-left: 0;
    }

    .searchbar {
        border-radius: 14px;
        padding: 4px;
    }

    .searchbar input {
        font-size: 1.05rem;
    }

    .hero__wave {
        height: 50px;
    }

    .hero__selects {
        justify-content: flex-start;
    }

    /* Filters collapse behind a toggle on narrow screens. */
    .filters__toggle {
        display: inline-flex;
    }

    .filters__panel {
        display: none;
    }

    .filters--open .filters__panel {
        display: block;
        margin-top: 18px;
    }

    .recipe-row {
        flex-direction: row;
        align-items: flex-start;
    }

    .recipe-row__thumb {
        width: 84px;
    }

    .recipe-row__title {
        font-size: 1.2rem;
    }

    .section {
        padding: 40px 0;
    }
}

@media (max-width: 460px) {
    .tiles {
        gap: 20px 10px;
    }

    .tile__name {
        font-size: 1.05rem;
    }
}

/* -------------------------------------------------------------- printing */

@media print {
    .topbar,
    .footer,
    .filters,
    .hero__wave,
    .recipe-hero,
    .menu,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }

    .recipe-body {
        grid-template-columns: 1fr;
        gap: 18pt;
    }

    .chip {
        border: 1px solid #999;
        background: none;
    }

    a {
        color: #000;
        text-decoration: none;
    }
}
