/* =========================================================================
   GARATRON · Atelier Recettes — styles.css
   Univers "atelier culinaire premium" : crème, beige, taupe, terre cuite,
   olive, brun profond. Mobile-first, responsive, optimisé iPhone (safe-area).
   ========================================================================= */

:root {
  /* Palette chaude & naturelle */
  --cream: #f6efe3;
  --cream-2: #efe6d6;
  --beige: #e6d9c2;
  --taupe: #b9a98f;
  --taupe-dark: #8c7b62;
  --terracotta: #c0623d;
  --terracotta-soft: #d98a68;
  --olive: #6f7a4f;
  --olive-soft: #8a9466;
  --brown: #3a2c22;
  --brown-soft: #5c483a;
  --paper: #fffdf8;
  --line: #ddcfb8;
  --shadow: 0 1px 2px rgba(58, 44, 34, .06), 0 8px 24px rgba(58, 44, 34, .08);
  --shadow-sm: 0 1px 2px rgba(58, 44, 34, .08);

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;

  --font-display: "Fraunces", "Hoefler Text", Georgia, "Times New Roman", serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --maxw: 720px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--brown);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(192, 98, 61, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(111, 122, 79, .07), transparent 55%),
    var(--cream);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); /* place pour la nav fixe */
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; color: var(--brown); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; color: var(--brown-soft); }
a { color: var(--terracotta); }

/* ---------- Layout ---------- */
.app { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  background: linear-gradient(180deg, var(--cream) 70%, rgba(246, 239, 227, 0));
}
.topbar .brand { display: flex; align-items: center; gap: 10px; max-width: var(--maxw); margin: 0 auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--terracotta), var(--olive));
  display: grid; place-items: center; color: var(--paper); font-family: var(--font-display);
  font-weight: 700; box-shadow: var(--shadow-sm);
}
.brand-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }
.brand-sub { font-size: .72rem; color: var(--taupe-dark); letter-spacing: .04em; text-transform: uppercase; }

.view { padding: 8px 0 24px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 10px; }
.section-title .hint { font-size: .78rem; color: var(--taupe-dark); }

/* ---------- Cards ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card.flat { box-shadow: var(--shadow-sm); }
.card-row { display: flex; gap: 12px; align-items: center; }

/* ---------- Badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--cream-2); color: var(--brown-soft); white-space: nowrap;
}
.badge.olive { background: rgba(111,122,79,.12); border-color: rgba(111,122,79,.3); color: #515b35; }
.badge.terra { background: rgba(192,98,61,.12); border-color: rgba(192,98,61,.3); color: #9c4d2f; }
.badge.equip { background: var(--brown); color: var(--cream); border-color: var(--brown); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Stats / metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric { background: var(--cream-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.metric .val { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; line-height: 1; }
.metric .lbl { font-size: .72rem; color: var(--taupe-dark); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.metric.accent { background: linear-gradient(135deg, rgba(192,98,61,.14), rgba(111,122,79,.12)); }

/* macro bars */
.macro-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: .85rem; }
.macro-row .name { width: 78px; color: var(--brown-soft); }
.macro-row .bar { flex: 1; height: 8px; background: var(--beige); border-radius: 999px; overflow: hidden; }
.macro-row .bar > span { display: block; height: 100%; border-radius: 999px; }
.bar-prot > span { background: var(--terracotta); }
.bar-gluc > span { background: var(--olive); }
.bar-lip  > span { background: var(--taupe); }
.macro-row .qty { width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Recipe cards (catalog) ---------- */
.recipe-card { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.recipe-card:active { transform: scale(.99); }
.recipe-card .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.recipe-card .desc { font-size: .88rem; color: var(--brown-soft); margin: 6px 0 10px; }
.recipe-card .foot { display: flex; flex-wrap: wrap; gap: 10px; font-size: .8rem; color: var(--taupe-dark); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; }
.recipe-card .foot b { color: var(--brown); font-weight: 600; }
.recipe-thumb {
  width: 56px; height: 56px; border-radius: var(--r-md); flex: 0 0 auto;
  background: linear-gradient(135deg, var(--terracotta-soft), var(--olive-soft));
  display: grid; place-items: center; font-size: 1.5rem;
}

/* ---------- Forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--brown-soft); margin: 0 0 5px; }
.field { margin-bottom: 14px; }
input, select {
  width: 100%; font: inherit; color: var(--brown);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 11px 12px; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { outline: 2px solid var(--olive-soft); outline-offset: 1px; border-color: var(--olive-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint-text { font-size: .76rem; color: var(--taupe-dark); margin-top: -8px; margin-bottom: 12px; }

/* segmented control (objectif / variantes) */
.segment { display: flex; gap: 6px; flex-wrap: wrap; }
.segment button {
  flex: 1 1 auto; min-width: 84px; font: inherit; font-size: .85rem; font-weight: 600;
  padding: 9px 8px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--paper); color: var(--brown-soft); cursor: pointer;
}
.segment button.active { background: var(--brown); color: var(--cream); border-color: var(--brown); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  padding: 12px 16px; border-radius: var(--r-md); width: 100%;
}
.btn-primary { background: var(--terracotta); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:active { background: #a9532f; }
.btn-olive { background: var(--olive); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--brown); }
.btn-sm { width: auto; padding: 8px 12px; font-size: .85rem; border-radius: var(--r-sm); }
.btn-row { display: flex; gap: 10px; }

/* stepper portions */
.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; width: max-content; }
.stepper button { font: inherit; font-size: 1.3rem; width: 46px; height: 46px; border: none; background: var(--cream-2); color: var(--brown); cursor: pointer; }
.stepper .count { min-width: 64px; text-align: center; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }

/* ---------- Ingredient / shopping list rows ---------- */
.ing-list, .shop-list { list-style: none; margin: 0; padding: 0; }
.ing-list li, .shop-list li {
  display: flex; align-items: center; gap: 10px; padding: 11px 4px;
  border-bottom: 1px solid var(--line); font-size: .92rem;
}
.ing-list li:last-child, .shop-list li:last-child { border-bottom: none; }
.ing-list .qty { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--brown); font-weight: 600; white-space: nowrap; }
.ing-list .add { flex: 0 0 auto; }
.ing-opt { color: var(--taupe-dark); font-size: .8rem; }
.add-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--olive-soft);
  background: rgba(111,122,79,.12); color: var(--olive); font-size: 1.1rem; cursor: pointer; line-height: 1;
}
.add-btn.added { background: var(--olive); color: #fff; border-color: var(--olive); }

.shop-list .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--taupe); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.shop-list .check.on { background: var(--olive); border-color: var(--olive); color: #fff; }
.shop-list li.done .nom { text-decoration: line-through; color: var(--taupe-dark); }
.shop-list .del { margin-left: 8px; background: none; border: none; color: var(--taupe-dark); cursor: pointer; font-size: 1.1rem; }

/* steps */
.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; }
.steps li { position: relative; padding: 0 0 14px 38px; color: var(--brown-soft); font-size: .92rem; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--brown); color: var(--cream); display: grid; place-items: center; font-size: .8rem; font-weight: 700;
  font-family: var(--font-body);
}

/* notice / disclaimer */
.notice { font-size: .78rem; color: var(--taupe-dark); background: var(--cream-2); border: 1px dashed var(--line); border-radius: var(--r-md); padding: 10px 12px; }
.notice b { color: var(--brown-soft); }

/* compare to profile */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare-cell { background: var(--cream-2); border-radius: var(--r-md); padding: 10px; text-align: center; }
.compare-cell .pct { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.compare-cell .lbl { font-size: .7rem; text-transform: uppercase; color: var(--taupe-dark); letter-spacing: .03em; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; font-size: .8rem; font-weight: 600; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--brown-soft); cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--olive); color: #fff; border-color: var(--olive); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(58,44,34,.06);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; cursor: pointer; color: var(--taupe-dark); font-size: .68rem; font-weight: 600; padding: 4px 8px; }
.nav-item .ico { font-size: 1.15rem; line-height: 1; }
.nav-item.active { color: var(--terracotta); }
.nav-badge { position: absolute; transform: translate(14px, -8px); background: var(--terracotta); color: #fff; font-size: .6rem; min-width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; }

/* back link */
.back { background: none; border: none; color: var(--taupe-dark); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 0; display: inline-flex; gap: 6px; align-items: center; }

/* empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--taupe-dark); }
.empty .ico { font-size: 2.4rem; }

.muted { color: var(--taupe-dark); }
.right { text-align: right; }
.mt { margin-top: 14px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: none; }

/* desktop niceties */
@media (min-width: 760px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  body { padding-bottom: 40px; }
  .bottom-nav { position: sticky; bottom: 16px; margin: 16px auto; max-width: var(--maxw); border-radius: 999px; border: 1px solid var(--line); }
}
