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

:root {
    --bg:        #f7f7f5;
    --surface:   #ffffff;
    --border:    #e5e5e0;
    --text:      #1c1c1a;
    --muted:     #6b6b66;
    --accent:    #e8622c;
    --accent-dk: #c94e1e;
    --danger:    #d64545;
    --radius:    12px;
    --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

h1, h2 { line-height: 1.2; }

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

img { max-width: 100%; display: block; }

.container {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 14px;
    padding-bottom: 14px;
}
.site-header__logo { font-weight: 700; font-size: 1.15rem; }
.site-header__nav { display: flex; align-items: center; gap: 16px; }
.site-header__nav a { color: var(--muted); font-weight: 500; }
.site-header__nav a:hover { color: var(--text); }

/* ---------- Layout ogólny ---------- */
main.container { padding-top: 32px; padding-bottom: 64px; }

.page-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
}
.page-head h1 { margin: 0; font-size: 1.8rem; }
.page-head__count { color: var(--muted); font-size: .95rem; }

/* ---------- Przyciski ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #cfcfc8; }
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn--primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

.btn--danger {
    background: var(--surface);
    border-color: var(--danger);
    color: var(--danger);
}
.btn--danger:hover { background: var(--danger); color: #fff; }

.btn--add {
    margin-top: 10px;
    background: transparent;
    border-style: dashed;
    color: var(--muted);
}
.btn--add:hover { color: var(--accent); border-color: var(--accent); }

.btn--icon {
    padding: 0;
    width: 38px;
    height: 38px;
    font-size: 1.3rem;
    line-height: 1;
    flex: 0 0 auto;
    color: var(--muted);
}
.btn--icon:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- Lista przepisów ---------- */
.recipe-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}
.recipe-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .12s, box-shadow .12s;
}
.recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,.08);
}
.recipe-card__media {
    aspect-ratio: 4 / 3;
    background: #f0efe9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.recipe-card__media img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card__placeholder { font-size: 2.4rem; opacity: .5; }
.recipe-card__body { padding: 14px 16px; }
.recipe-card__title { margin: 0 0 4px; font-size: 1.05rem; }
.recipe-card__meta { margin: 0; color: var(--muted); font-size: .88rem; }

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state p { color: var(--muted); margin: 0 0 18px; }

/* ---------- Formularz ---------- */
.form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.form__field { margin-bottom: 18px; }
.form__field label {
    display: block;
    font-weight: 600;
    font-size: .92rem;
    margin-bottom: 6px;
}
.form__hint { display: block; color: var(--muted); font-size: .82rem; margin-top: 5px; }

input[type="text"],
input[type="number"],
input[type="file"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232,98,44,.15);
}
textarea { resize: vertical; }

.form__section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
    margin: 0 0 18px;
}
.form__section legend {
    font-weight: 600;
    padding: 0 8px;
}

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.row--ingredient input:nth-child(1) { flex: 2; }
.row--ingredient input:nth-child(2) { flex: 1; }
.row--ingredient input:nth-child(3) { flex: 1; }
.row--step input { flex: 1; }
.row__index {
    flex: 0 0 auto;
    min-width: 22px;
    color: var(--muted);
    font-weight: 600;
    text-align: right;
}

.form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

/* ---------- Alert ---------- */
.alert {
    border-radius: 9px;
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: .95rem;
}
.alert--error {
    background: #fdecec;
    border: 1px solid #f5b5b5;
    color: #a12626;
}
.alert ul { margin: 0; padding-left: 20px; }

/* ---------- Szczegóły przepisu ---------- */
.back-link { color: var(--muted); font-size: .9rem; }
.back-link:hover { color: var(--accent); }

.recipe { }
.recipe__head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 12px 0 20px;
}
.recipe__head h1 { margin: 0; font-size: 2rem; }
.badge {
    background: #f0efe9;
    color: var(--muted);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}
.recipe__image {
    width: 100%;
    height: 380px;
    object-fit: contain;      /* zachowaj proporcje, nie przycinaj */
    object-position: center;  /* wąskie zdjęcie wyśrodkuj */
    background: #f0efe9;       /* tło letterboxa po bokach/górze */
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.recipe__block { margin-bottom: 28px; }
.recipe__block h2 {
    font-size: 1.2rem;
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.recipe__notes { color: #333; margin: 0; }

.ingredient-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.ingredient-list li {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.ingredient-list li:last-child { border-bottom: none; }
.ingredient-list__amount {
    flex: 0 0 110px;
    color: var(--muted);
    font-weight: 600;
}
.ingredient-list__name { flex: 1; }

.step-list {
    margin: 0;
    padding-left: 22px;
}
.step-list li {
    padding: 6px 0 6px 4px;
    margin-bottom: 4px;
}

.recipe__actions {
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: 40px;
}
.site-footer p { margin: 0; color: var(--muted); font-size: .85rem; text-align: center; }

/* ---------- Responsywność ---------- */
@media (max-width: 560px) {
    .row--ingredient { flex-wrap: wrap; }
    .row--ingredient input { flex: 1 1 100%; }
    .row--ingredient .btn--icon { flex: 0 0 auto; }
    .recipe__head h1 { font-size: 1.6rem; }
}
