/* Matbakh Oum Loutfi : palette terre cuite / safran / zellige */
:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece0;
  --text: #2b231d;
  --muted: #74685c;
  --line: #e6dccc;
  --accent: #b4532a;        /* terre cuite */
  --accent-ink: #fdf8f0;
  --saffron: #d9952b;
  --green: #2f6b55;         /* zellige */
  --draft-bg: #2f6b55;
  --draft-ink: #f2fbf6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 24px rgba(60, 40, 20, .07);
  --font: "Inter", system-ui, "Segoe UI", sans-serif;
  --font-title: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1714;
    --surface: #24201c;
    --surface-2: #2d2823;
    --text: #efe7dc;
    --muted: #ab9f92;
    --line: #3b342d;
    --accent: #e08a5c;
    --accent-ink: #1a1714;
    --saffron: #e9b25a;
    --green: #6fbf9c;
    --draft-bg: #1f3a30;
    --draft-ink: #cdeee0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1714; --surface: #24201c; --surface-2: #2d2823; --text: #efe7dc; --muted: #ab9f92;
  --line: #3b342d; --accent: #e08a5c; --accent-ink: #1a1714; --saffron: #e9b25a; --green: #6fbf9c;
  --draft-bg: #1f3a30; --draft-ink: #cdeee0; color-scheme: dark;
}
:lang(ar) { --font: "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; --font-title: "Noto Naskh Arabic", serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.65 var(--font);
}
:lang(ar) body, body:lang(ar) { font-size: 19px; line-height: 1.85; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-title); line-height: 1.2; font-weight: 700; }
h1 { font-size: clamp(30px, 5vw, 46px); margin: .2em 0 .35em; }
h2 { font-size: 26px; margin: 1.6em 0 .6em; }
h3 { font-size: 18px; margin: 1.2em 0 .4em; color: var(--green); font-family: var(--font); font-weight: 600; }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

/* Bandeau prototype */
.draft { background: var(--draft-bg); color: var(--draft-ink); text-align: center; font-size: 14px; padding: 6px 16px; }

/* En-tête */
.top {
  max-width: 1120px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-title); font-weight: 700; font-size: 20px; }
.brand svg { width: 30px; height: 30px; color: var(--accent); }
/* Menu déroulant des langues */
.menu-langue { position: relative; }
.menu-langue summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text); user-select: none;
}
.menu-langue summary::-webkit-details-marker { display: none; }
.menu-langue summary:hover { border-color: var(--muted); }
.menu-langue summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-langue svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-langue svg:first-child { color: var(--accent); }
.menu-langue .fleche { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.menu-langue[open] .fleche { transform: rotate(180deg); }
.menu-langue ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20; min-width: 160px;
  list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.menu-langue li a { display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: 15px; }
.menu-langue li a:hover { background: var(--surface-2); }
.menu-langue li a[aria-current] { font-weight: 600; color: var(--accent); }
.menu-langue li a[aria-current]::after { content: " ✓"; }
.menu-langue a:lang(ar), .menu-langue span:lang(ar) { font-family: "Noto Naskh Arabic", serif; }

.langs { display: flex; gap: 4px; flex-wrap: wrap; }
.langs a {
  text-decoration: none; color: var(--muted); font-size: 14px; padding: 5px 10px; border-radius: 999px; border: 1px solid transparent;
}
.langs a:hover { border-color: var(--line); color: var(--text); }
.langs a[aria-current] { background: var(--surface-2); color: var(--text); border-color: var(--line); font-weight: 600; }
.langs a:lang(ar) { font-family: "Noto Naskh Arabic", serif; }

/* Accueil */
.hero {
  text-align: center; padding: 48px 16px 28px; margin-top: 8px; border-radius: var(--radius);
  background:
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--saffron) 18%, transparent), transparent 55%),
    radial-gradient(circle at 85% 100%, color-mix(in srgb, var(--green) 14%, transparent), transparent 55%),
    var(--surface-2);
}
.hero-ar { font-family: "Noto Naskh Arabic", serif; font-size: 26px; color: var(--accent); margin: 0; }
.lead { color: var(--muted); font-size: 19px; max-width: 640px; margin: 0 auto 1em; }
.recipe .lead { margin: 0 0 1em; }
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink); text-decoration: none;
  padding: 10px 20px; border-radius: 999px; font-weight: 600;
}
.btn:hover { filter: brightness(1.07); }
.section-title { text-align: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s ease;
}
.card:hover { transform: translateY(-3px); }
.card img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.card-body { padding: 14px 18px 20px; }
.card h3 { font-family: var(--font-title); color: var(--text); font-size: 21px; margin: .4em 0 .3em; }
.card p { color: var(--muted); font-size: 15px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chip {
  display: inline-block; font-size: 13px; font-weight: 600; color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent); padding: 2px 10px; border-radius: 999px;
}

/* Recherche et filtres de l'accueil */
.filtres { margin: -6px 0 20px; }
.recherche {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 16px; max-width: 560px; box-shadow: var(--shadow);
}
.recherche:focus-within { border-color: var(--accent); }
.recherche svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.recherche input { border: 0; background: none; outline: none; font: inherit; color: var(--text); padding: 11px 0; width: 100%; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.puce {
  font: inherit; font-size: 14px; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 5px 14px;
}
.puce span { color: var(--muted); font-size: 12px; margin-inline-start: 2px; }
.puce:hover { border-color: var(--green); }
.puce[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: var(--bg); }
.puce[aria-pressed="true"] span { color: inherit; opacity: .8; }
.compte { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.card[hidden] { display: none; }
.aucune { color: var(--muted); text-align: center; padding: 30px 0; }
a.chip { text-decoration: none; }
a.chip:hover { text-decoration: underline; }

/* Accueil : présentation + catégories */
.hero.accueil { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; text-align: start; padding: 36px 32px; }
.hero.accueil .lead { margin: 0 0 .8em; max-width: none; }
.hero.accueil h1 { font-size: clamp(26px, 4vw, 38px); }
.portrait { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.recherche-form { margin: 24px auto 0; }
.recherche-form button {
  font: inherit; font-size: 14px; font-weight: 600; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); padding: 7px 16px; margin-inline-end: -10px; flex: none;
}
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.tuile {
  position: relative; display: block; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3;
  text-decoration: none; color: #fff; box-shadow: var(--shadow); background: var(--surface-2);
}
.tuile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.tuile:hover img { transform: scale(1.04); }
.tuile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0) 60%); }
.tuile-nom, .tuile-nb { position: absolute; inset-inline-start: 16px; z-index: 1; }
.tuile-nom { bottom: 30px; font-family: var(--font-title); font-weight: 700; font-size: 21px; line-height: 1.2; }
.tuile-nb { bottom: 10px; font-size: 13px; opacity: .9; }
.titre-liste { margin-bottom: 0; }
@media (max-width: 640px) {
  .hero.accueil { grid-template-columns: 1fr; text-align: center; padding: 28px 18px; }
  .portrait { margin: 0 auto; width: 112px; height: 112px; }
  .tuiles { grid-template-columns: 1fr 1fr; gap: 12px; }
  .tuile-nom { font-size: 17px; bottom: 26px; inset-inline-start: 12px; }
  .tuile-nb { inset-inline-start: 12px; }
}

/* Page de connexion (espace de validation) */
.connexion { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.connexion .portrait { width: 96px; height: 96px; }
.connexion form { display: flex; flex-direction: column; gap: 10px; text-align: start; margin-top: 18px; }
.connexion input { font: inherit; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.connexion .btn { border: 0; cursor: pointer; font: inherit; font-weight: 600; }
.erreur { color: #b3261e; font-weight: 600; }

/* Recette */
.barre-recette { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.edit {
  font-size: 14px; font-weight: 600; text-decoration: none; color: var(--accent-ink); background: var(--accent);
  padding: 5px 14px; border-radius: 999px;
}
.edit[hidden] { display: none; }
.back { display: inline-block; margin: 6px 0 14px; text-decoration: none; font-size: 15px; }
.back::before { content: "← "; }
[dir="rtl"] .back::before { content: "→ "; }
.recipe-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; }
.recipe-hero img { border-radius: var(--radius); aspect-ratio: 4 / 3; object-fit: cover; width: 100%; box-shadow: var(--shadow); }
.meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.meta div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; font-size: 15px; }
:lang(ar) .meta dt { text-transform: none; letter-spacing: 0; font-size: 14px; }

.frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.cols { display: grid; grid-template-columns: minmax(280px, 1fr) 1.7fr; gap: 36px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 22px 18px; position: sticky; top: 16px; box-shadow: var(--shadow);
}
.panel h2 { margin-top: .9em; }
.hint { color: var(--muted); font-size: 14px; margin-top: -.4em; }
.ingr { list-style: none; padding: 0; margin: 0; }
.ingr li { border-bottom: 1px dashed var(--line); }
.ingr li:last-child { border-bottom: 0; }
.ingr label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; cursor: pointer; }
.ingr input { margin-top: .45em; accent-color: var(--green); width: 17px; height: 17px; flex: none; }
.ingr input:checked + span { color: var(--muted); text-decoration: line-through; }
.ingr b { color: var(--accent); font-weight: 600; }

.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; }
.steps li {
  counter-increment: s; position: relative; padding-inline-start: 52px; padding-bottom: 18px; margin-bottom: 4px;
}
.steps li::before {
  content: counter(s); position: absolute; inset-inline-start: 0; top: 0; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-family: var(--font);
}
.steps p { margin: 4px 0 6px; }
.seek {
  font: inherit; font-size: 13px; color: var(--green); background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 12px 3px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seek:hover { border-color: var(--green); }
.seek svg { width: 11px; height: 11px; fill: currentColor; }
[dir="rtl"] .seek svg { transform: scaleX(-1); }

.tips {
  margin-top: 28px; padding: 4px 22px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--saffron) 13%, var(--surface));
  border-inline-start: 4px solid var(--saffron);
}
.tips h2 { font-size: 21px; margin-top: .8em; }
.tips li { margin: 6px 0; }

/* Page de choix de langue */
.choose { text-align: center; padding-top: 18vh; }
.langs.big { justify-content: center; margin-top: 24px; }
.langs.big a { font-size: 18px; padding: 10px 20px; border-color: var(--line); background: var(--surface); }

.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 20px 16px 32px; text-align: center; color: var(--muted); font-size: 14px; }

@media (max-width: 820px) {
  .recipe-hero, .cols { grid-template-columns: 1fr; gap: 20px; }
  .panel { position: static; }
  .hero { padding: 36px 16px 22px; }
}
@media print {
  .draft, .top, .video, .seek, .back, .foot, .langs { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { box-shadow: none; position: static; }
}
