:root {
    --bg: #FAF8F4;
    --surface: #FFFFFF;
    --line: #E8E1D4;
    --ink: #3F2B1D;
    --ink-soft: #85735C;
    --accent: #D9822B;
    --accent-ink: #9A5717;
    --accent-bg: #F7E6CF;
    --green: #4C7238;
    --radius: 14px;
    --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.6;
}

img { max-width: 100%; display: block; }
a { color: var(--accent-ink); }

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

.wrap {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 16px;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(250, 248, 244, 0.92);
    backdrop-filter: saturate(1.4) blur(8px);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
}

.brand {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--ink);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-link {
    flex-shrink: 0;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-bg);
}

.site-footer {
    margin-top: 64px;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding-top: 20px;
    padding-bottom: 28px;
}

/* ---------------------------------------------------------------- home */

.hero {
    padding: 36px 0 20px;
    max-width: 640px;
}

.hero h1 { font-size: clamp(2rem, 7vw, 3.2rem); }
.hero p { margin: 10px 0 0; color: var(--ink-soft); font-size: 1.1rem; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 8px 0 24px;
}

.search { flex: 1 1 280px; }

.search input {
    width: 100%;
    font: inherit;
    font-size: 16px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
}

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

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

.chip {
    font: inherit;
    font-size: 0.95rem;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
    gap: 16px 14px;
}

@media (min-width: 640px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 28px 22px; }
}

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

.card-photo {
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent-bg), #EFE0D6);
    display: grid;
    place-items: center;
}

.card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.card a:hover .card-photo img { transform: scale(1.04); }

.card-photo span {
    font-family: var(--serif);
    font-size: 3rem;
    color: var(--accent-ink);
}

.card-body { padding: 10px 2px 0; }
.card-body h2 { font-size: 1.05rem; }
@media (min-width: 640px) { .card-body h2 { font-size: 1.2rem; } }
.card-meta { margin: 4px 0 0; font-size: 0.85rem; color: var(--ink-soft); }

.empty { color: var(--ink-soft); text-align: center; padding: 40px 0; }

/* ---------------------------------------------------------------- ricetta */

.back-link {
    display: inline-block;
    margin: 20px 0 16px;
    font-size: 0.95rem;
    text-decoration: none;
}

.recipe-header { max-width: 960px; }

.recipe-photo {
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 3 / 2;
    margin-bottom: 22px;
    background: var(--accent-bg);
}

@media (min-width: 760px) { .recipe-photo { aspect-ratio: 16 / 9; } }

.recipe-photo img { width: 100%; height: 100%; object-fit: cover; }

.kicker {
    margin: 0 0 6px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-ink);
}

.recipe-header h1 { font-size: clamp(1.9rem, 6vw, 3rem); }

.recipe-times { margin: 10px 0 0; color: var(--ink-soft); }

.recipe-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 600;
    font-size: 1rem;
    padding: 12px 22px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #BF6F1F; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }

@media (max-width: 480px) {
    .recipe-actions .btn { flex: 1 1 auto; }
}

.recipe-body {
    display: grid;
    gap: 36px;
    margin-top: 36px;
}

@media (min-width: 860px) {
    .recipe-body { grid-template-columns: 340px 1fr; gap: 56px; align-items: start; }
    .ingredients { position: sticky; top: 76px; }
}

.ingredients {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 20px;
}

.ingredients h2, .steps h2 { font-size: 1.6rem; margin-bottom: 14px; }

.control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.control strong { color: var(--ink); }

.stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.stepper button {
    width: 40px;
    height: 40px;
    border: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 1.25rem;
    cursor: pointer;
}

.stepper input {
    width: 48px;
    height: 40px;
    border: 0;
    text-align: center;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    -moz-appearance: textfield;
    appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pan-fields input {
    width: 58px;
    font: inherit;
    font-size: 16px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
}

.pan-note { margin: 0 0 6px; font-size: 0.85rem; color: var(--green); }

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

.ingredient-list li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.ingredient-list li:last-child { border-bottom: 0; }

.ingredient-list .qty { font-weight: 700; white-space: nowrap; text-align: right; }

.ingredient-list .ingredient-section-title {
    display: block;
    border-bottom: 0;
    padding: 18px 0 2px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-ink);
}

.steps h3 { font-size: 1.25rem; margin: 26px 0 10px; }

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

.step-list li {
    counter-increment: step;
    position: relative;
    padding: 0 0 20px 48px;
}

.step-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent-ink);
    font-family: var(--serif);
    font-weight: 700;
    display: grid;
    place-items: center;
}

.notes {
    margin-top: 12px;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: var(--accent-bg);
}

.notes h3 { margin: 0 0 6px; font-size: 1.1rem; }
.notes p { margin: 0; white-space: pre-line; }

/* ---------------------------------------------------------------- stampa */

@media print {
    body { background: #fff; font-size: 11pt; }
    .site-header, .site-footer, .no-print, .stepper button { display: none !important; }
    .recipe-photo { aspect-ratio: 21 / 9; }
    .recipe-body { grid-template-columns: 1fr 1.6fr; gap: 28px; }
    .ingredients { position: static; border: 0; padding: 0; }
    .stepper { border: 0; }
}
