/* Recettes — style inspiré de Mela : photos, blanc, typographie, peu de boutons. */
:root {
  --bg: #ffffff;
  --surface: #f6f5f2;
  --text: #1c1b19;
  --muted: #74706a;
  --line: #e9e6e1;
  --accent: #c8432b;
  --accent-ink: #ffffff;
  --focus: #c8432b55;
  --radius: 14px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --test-bg: #fff2cc; --test-ink: #7a5300;
  --rec-bg: #efe6ff; --rec-ink: #5a36a6;
  --sem-bg: #ddf3ee; --sem-ink: #19675a;
  --we-bg: #e1ecff; --we-ink: #244f9e;
  --danger-bg: #ffe1dc; --danger-ink: #a6200f;
  --check-bg: #ffead6; --check-ink: #8d4300;
  --like: #2f8a4c; --dislike: #b3361f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --surface: #201f1d; --text: #f1eee9; --muted: #a29d95; --line: #312f2c;
    --accent: #ec6a4f; --focus: #ec6a4f66;
    --test-bg: #45370f; --test-ink: #ffd877;
    --rec-bg: #33284c; --rec-ink: #d2c0ff;
    --sem-bg: #173a33; --sem-ink: #93e2cf;
    --we-bg: #1c2e4d; --we-ink: #a9c6ff;
    --danger-bg: #4d1d16; --danger-ink: #ffb4a6;
    --check-bg: #4a2d12; --check-ink: #ffc18a;
    --like: #6fd08d; --dislike: #ff8a73;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 var(--sans);
  padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------ en-tête */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.3rem; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.topbar form { margin: 0; }
@media (max-width: 440px) {
  .topbar { gap: 4px; }
  .icon-btn.primary span { display: none; }
  .icon-btn.primary { padding: 0 10px; }
}
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; min-width: 38px; padding: 0 10px; border-radius: 999px;
  border: 0; background: transparent; color: var(--text); text-decoration: none;
  cursor: pointer; font-size: .95rem;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); padding: 0 14px; font-weight: 600; }
.icon-btn.primary:hover { filter: brightness(1.05); }
.edit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--like); flex: none; }
.edit-label { font-size: .85rem; color: var(--muted); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-left)); }

/* ------------------------------------------------ accueil */
.search {
  position: relative; margin: 8px 0 14px;
}
.search input[type=search] {
  width: 100%; height: 48px; padding: 0 16px 0 46px;
  border-radius: 14px; border: 0; background: var(--surface); font-size: 1.05rem;
  -webkit-appearance: none; appearance: none;
}
.search svg { position: absolute; left: 15px; top: 14px; width: 20px; height: 20px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: .92rem; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-select {
  width: auto; -webkit-appearance: none; appearance: none; padding: 0 30px 0 14px; font-size: .92rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.count { color: var(--muted); font-size: .9rem; margin: 4px 0 14px; }

.grid {
  display: grid; gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  padding-bottom: 48px;
}
@media (max-width: 520px) { .grid { grid-template-columns: 1fr 1fr; gap: 18px 12px; } }
.card { text-decoration: none; display: block; }
.card .ph {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.card .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .ph img { transform: scale(1.03); }
.ph-empty {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--serif); font-size: 2.6rem; color: var(--muted);
  background: linear-gradient(135deg, var(--surface), var(--line));
}
.card .ph .badges { position: absolute; left: 8px; top: 8px; right: 8px; }
.card h3 { font-family: var(--serif); font-size: 1.08rem; line-height: 1.25; margin: 10px 2px 2px; font-weight: 600; }
.card .meta { color: var(--muted); font-size: .86rem; margin: 0 2px; }
@media (max-width: 520px) { .card h3 { font-size: 1rem; } }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ------------------------------------------------ pastilles */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 600; line-height: 1; padding: 6px 9px; border-radius: 999px;
  letter-spacing: .01em;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-test { background: var(--test-bg); color: var(--test-ink); }
.b-reception { background: var(--rec-bg); color: var(--rec-ink); }
.b-semaine { background: var(--sem-bg); color: var(--sem-ink); }
.b-weekend { background: var(--we-bg); color: var(--we-ink); }
.b-danger { background: var(--danger-bg); color: var(--danger-ink); }
.b-check { background: var(--check-bg); color: var(--check-ink); }
.ph .badge { box-shadow: 0 1px 6px #0002; }

/* ------------------------------------------------ fiche */
.hero { width: 100%; max-height: 62vh; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 900px) { .hero-wrap { max-width: 1200px; margin: 8px auto 0; padding: 0 16px; } .hero { border-radius: 20px; } }
.thumbs { display: flex; gap: 8px; margin: 10px 0 0; overflow-x: auto; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: none; cursor: pointer; flex: none; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 72px; height: 54px; object-fit: cover; }

.recipe-head { max-width: 860px; margin: 26px auto 8px; padding: 0 16px; text-align: center; }
.recipe-head h1 { font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 2.7rem); line-height: 1.12; margin: 6px 0 12px; letter-spacing: -.015em; }
.recipe-head .badges { justify-content: center; }
.recipe-head .desc { color: var(--muted); margin: 14px auto 0; max-width: 680px; }
.facts { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 26px; margin: 18px 0 4px; font-size: .95rem; }
.facts div { text-align: center; }
.facts dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.source { font-size: .9rem; color: var(--muted); margin-top: 12px; }
.source a { color: var(--muted); }
.owner-actions { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }

.alert {
  max-width: 860px; margin: 18px auto 0; padding: 14px 16px; border-radius: var(--radius);
  display: flex; gap: 12px; align-items: flex-start; font-size: .95rem;
}
.alert svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.alert strong { display: block; }
.alert-danger { background: var(--danger-bg); color: var(--danger-ink); }
.alert-check { background: var(--check-bg); color: var(--check-ink); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.recipe-body {
  max-width: 1100px; margin: 30px auto 0; padding: 0 16px;
  display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 48px; align-items: start;
}
@media (max-width: 820px) { .recipe-body { grid-template-columns: 1fr; gap: 30px; } }
.recipe-body h2, .section-title { font-family: var(--serif); font-size: 1.35rem; margin: 0 0 14px; }
.ingredients { position: sticky; top: 74px; }
@media (max-width: 820px) { .ingredients { position: static; } }
.servings {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border-radius: 12px; padding: 6px; margin-bottom: 16px;
}
.servings button {
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--bg); cursor: pointer; font-size: 1.3rem; line-height: 1;
  box-shadow: 0 1px 2px #0001;
}
.servings output { font-weight: 600; text-align: center; flex: 1; }
.family-btn {
  display: block; width: 100%; margin: -8px 0 16px; padding: 8px; border: 0; border-radius: 10px;
  background: none; color: var(--accent); font-weight: 600; font-size: .9rem; cursor: pointer;
}
.family-btn:hover { background: var(--surface); }
.family-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); }
.servings .reset { font-size: .8rem; color: var(--accent); background: none; box-shadow: none; width: auto; padding: 0 6px; }
.ing-section { margin: 18px 0 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.ing-list .q { font-weight: 650; }
.ing-list li.scaled .q { color: var(--accent); }
.ing-list li.alg-danger { color: var(--danger-ink); background: var(--danger-bg); border-radius: 8px; padding-left: 8px; padding-right: 8px; border-bottom-color: transparent; margin: 2px 0; }
.ing-list li.alg-check { color: var(--check-ink); background: var(--check-bg); border-radius: 8px; padding-left: 8px; padding-right: 8px; border-bottom-color: transparent; margin: 2px 0; }

.steps ol { list-style: none; counter-reset: s; margin: 0; padding: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 22px 48px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); font-weight: 700; font-size: .9rem; color: var(--accent);
}
.steps li.done { opacity: .45; }
.steps .step-section { margin: 10px 0 14px; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.steps ol.cont { counter-reset: none; }
.notes { white-space: pre-line; background: var(--surface); padding: 16px 18px; border-radius: var(--radius); margin-top: 8px; }

.family { max-width: 1100px; margin: 40px auto 60px; padding: 0 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; }
@media (max-width: 900px) { .family { grid-template-columns: 1fr; gap: 32px; } }
.family h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 12px; }
.ratings { list-style: none; padding: 0; margin: 0; }
.ratings li { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.rate { display: flex; gap: 4px; }
.rate button {
  width: 38px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; color: var(--muted);
  display: grid; place-items: center;
}
.rate button svg { width: 18px; height: 18px; }
.rate button[aria-pressed="true"].like { background: var(--like); color: #fff; border-color: var(--like); }
.rate button[aria-pressed="true"].dislike { background: var(--dislike); color: #fff; border-color: var(--dislike); }
.rate button:disabled { cursor: default; }
.rate button:disabled:not([aria-pressed="true"]) { opacity: .35; }
.history, .comments { list-style: none; padding: 0; margin: 0; }
.history li, .comments li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.history li .grow, .comments li .grow { flex: 1; }
.history .future { color: var(--muted); font-style: italic; }
.comments .who { font-weight: 600; font-size: .9rem; }
.comments .when { color: var(--muted); font-size: .8rem; }
.comments p { margin: 2px 0 0; white-space: pre-line; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; font-size: 1.1rem; line-height: 1; }
.x:hover { color: var(--dislike); background: var(--surface); }
.muted { color: var(--muted); }
.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form input, .inline-form select, .inline-form textarea { flex: 1; min-width: 0; }
#comment-form textarea { flex: 1 1 100%; min-height: 70px; }
#comment-form select { flex: 1; }
#comment-form .btn { flex: none; }

/* ------------------------------------------------ formulaires */
.field { margin: 0 0 18px; }
.field > label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: .82rem; margin: 4px 0 0; }
input[type=text], input[type=url], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px;
  font-size: 1rem;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: .95rem;
}
.checks input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.page { max-width: 760px; margin: 20px auto 80px; padding: 0 16px; }
.page h1 { font-family: var(--serif); font-size: 2rem; margin: 10px 0 24px; }
.page h2 { font-family: var(--serif); font-size: 1.3rem; margin: 34px 0 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--dislike); }
.btn:disabled { opacity: .55; cursor: progress; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 26px; }
.actions .spacer { flex: 1; }
.slug-field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.slug-field span { padding: 0 4px 0 12px; color: var(--muted); font-size: .95rem; }
.slug-field input { border: 0; border-radius: 0; padding-left: 0; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.photo-item { position: relative; width: 120px; }
.photo-item img { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; }
.photo-item .tools { display: flex; justify-content: space-between; margin-top: 4px; font-size: .8rem; }
.photo-item .tools button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; }
.photo-item .cover-label { font-size: .75rem; color: var(--accent); font-weight: 600; }
.msg { padding: 12px 14px; border-radius: 10px; margin: 12px 0; font-size: .95rem; }
.msg.err { background: var(--danger-bg); color: var(--danger-ink); }
.msg.ok { background: var(--sem-bg); color: var(--sem-ink); }
.msg ul { margin: 6px 0 0; padding-left: 18px; }
.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; text-align: center; }
.login h1 { font-family: var(--serif); }
.login form { text-align: left; margin-top: 20px; }
.login .btn { width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .92rem;
  box-shadow: 0 6px 24px #0003; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media print {
  .topbar, .owner-actions, .family, .servings button, .thumbs { display: none !important; }
  .recipe-body { grid-template-columns: 1fr 2fr; }
}
