/* ==========================================================================
   On mange où ? — feuille de style (thème « Bistrot », SPEC.md §6.5)
   ========================================================================== */

/* Literata (SIL Open Font License 1.1) : serif chaleureux, avec un J majuscule classique. */
@font-face {
  font-family: "Literata";
  src: url("/fonts/literata.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-title: "Literata", Georgia, "Times New Roman", serif;
  --title-weight: 600;

  /* Thème « Bistrot » : crème, vert sapin, touches d'orange tomate. */
  --bg: #f6f1e7;
  --bg-deco: radial-gradient(1200px 500px at 10% -10%, #e3eedf 0%, transparent 60%),
             radial-gradient(900px 400px at 110% 0%, #f8e2d3 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #efe9dc;
  --text: #23302a;
  --muted: #6b6f68;
  --line: #e2dccd;
  --accent: #2f5d45;
  --accent-hover: #244a37;
  --accent-ink: #ffffff;
  --accent-soft: #e1ece4;
  --accent-2: #d2552b;
  --accent-2-soft: #fbe5da;
  --danger: #b3361b;
  --ok: #2f5d45;
  --ok-soft: #e1ece4;
  --warn: #a8640a;
  --warn-soft: #fbedd5;
  --violet: #6b4bb8;
  --violet-soft: #ece6fb;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-btn: 999px;
  --border: 1px solid var(--line);
  --shadow: 0 1px 2px rgba(30, 45, 35, .05), 0 4px 16px rgba(30, 45, 35, .06);
  --shadow-hover: 0 2px 4px rgba(30, 45, 35, .06), 0 10px 28px rgba(30, 45, 35, .10);
  --topbar-bg: rgba(255, 255, 255, .85);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b201d;
    --bg-deco: radial-gradient(1200px 500px at 10% -10%, #1f3328 0%, transparent 60%),
               radial-gradient(900px 400px at 110% 0%, #3a2519 0%, transparent 55%);
    --surface: #252b27;
    --surface-2: #2e3530;
    --text: #ece6da;
    --muted: #a3a59d;
    --line: #38403a;
    --accent: #7fb89a;
    --accent-hover: #93c8ab;
    --accent-ink: #11201a;
    --accent-soft: #263a2f;
    --accent-2: #f08a5d;
    --accent-2-soft: #3c2619;
    --danger: #f08a5d;
    --ok: #7fb89a;
    --ok-soft: #263a2f;
    --warn: #e6aa52;
    --warn-soft: #3a2c16;
    --violet: #b9a6ff;
    --violet-soft: #2d2547;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
    --topbar-bg: rgba(37, 43, 39, .85);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 var(--font-body);
  background: var(--bg-deco), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-title); font-weight: var(--title-weight); letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 0; }
h2 { font-size: 1.3rem; margin: 32px 0 10px; }
h3 { font-size: 1.15rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px max(16px, calc((100vw - 1040px) / 2));
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); flex: none;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { font-family: var(--font-title); font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-text em { font-style: italic; font-weight: 400; color: var(--accent-2); }

nav { display: flex; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 7px;
  text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: var(--radius-btn);
  font-size: .95rem; font-weight: 500; transition: background .15s, color .15s;
}
nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav a:hover { color: var(--text); background: var(--surface-2); }
nav a.active { color: var(--accent); background: var(--accent-soft); }
nav[hidden], nav a[hidden] { display: none !important; }

/* Sur téléphone : la navigation devient une barre d'onglets en bas d'écran. */
@media (max-width: 720px) {
  /* pas de backdrop-filter ici : il casserait le position: fixed de la barre d'onglets */
  .topbar { justify-content: center; padding-block: 8px; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
  nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--topbar-bg);
    -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
    border-top: var(--border);
  }
  nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .72rem; flex: 1; max-width: 96px; border-radius: 12px; }
  nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  nav a svg { width: 22px; height: 22px; }
  nav a.active { background: transparent; }
  nav a.active svg { stroke-width: 2.3; }
  main { padding-bottom: 110px !important; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
}

main { max-width: 1040px; margin: 0 auto; padding: 28px 16px 80px; }
main > :first-child { margin-top: 0; }

/* ---------- en-têtes de page ---------- */
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-head > div:not(.avatar) { flex: 1 1 260px; min-width: 0; }
.page-head > .avatar { width: 60px; height: 60px; font-size: 1.5rem; margin: 0; }
.page-head > button, .page-head > .btn { margin-left: auto; }
.page-head > button + button { margin-left: 0; }
.eyebrow { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 1.02rem; }
.hero {
  background: var(--surface); border: var(--border); border-radius: calc(var(--radius) + 6px);
  padding: 28px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero::after {
  content: "🍽️"; position: absolute; right: 24px; top: 50%; transform: translateY(-50%) rotate(-8deg);
  font-size: 4.5rem; opacity: .9; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .12));
}
.hero > div { padding-right: 96px; }
@media (max-width: 520px) { .page-head > button { width: 100%; } .hero { padding: 22px; } .hero::after { font-size: 3rem; right: 14px; } .hero > div { padding-right: 56px; } }

/* ---------- cartes ---------- */
.card {
  background: var(--surface); border: var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin: 14px 0; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 6px; }

/* Accueil : membres d'une famille */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 32px; }
.section-head h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.count-pill {
  font-family: var(--font-body); font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.person {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text);
  background: var(--surface); border: var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.person:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.person .person-info { flex: 1; min-width: 0; }
.person .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .count { color: var(--muted); font-size: .875rem; }
.person .go { color: var(--muted); transition: transform .15s, color .15s; }
.person:hover .go { transform: translateX(3px); color: var(--accent); }
.person.is-me { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.me-tag {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; vertical-align: 2px;
  padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); margin-left: 4px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; color: #fff; font-size: 1.1rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), 0 0 0 3px var(--surface);
}

/* ---------- boutons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.actions:not(:has(*)) { display: none; }
button, .btn {
  font: inherit; font-weight: 600; font-size: .95rem; border: var(--border); background: var(--surface); color: var(--text);
  padding: 9px 18px; border-radius: var(--radius-btn); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
button:hover, .btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--surface-2); }
button:active, .btn:active { transform: translateY(1px); }
button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.actions.big { margin-top: 22px; }
.actions.big button { padding: 12px 26px; font-size: 1rem; }
button.link { border: none; background: none; color: var(--muted); padding: 6px 8px; font-weight: 500; box-shadow: none; }
button.link:hover { color: var(--accent); background: var(--accent-soft); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- formulaires ---------- */
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
input, textarea, select {
  font: inherit; font-weight: 400; padding: 11px 13px; border: var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

/* Connexion */
.auth { max-width: 420px; margin: 7vh auto 40px; padding: 32px; border-radius: calc(var(--radius) + 8px); }
.auth h1 { margin-bottom: 6px; }
.auth form { margin-top: 18px; }
.auth button.primary { width: 100%; padding: 12px; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 0; }
.error:empty { min-height: 0; }

.notice {
  background: var(--accent-soft); border-radius: var(--radius-sm); padding: 12px 16px; margin: 14px 0; font-size: .95rem;
}
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }


#switch-bar {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  align-items: center; justify-content: space-between; padding: 8px 16px;
  background: var(--violet-soft); color: color-mix(in srgb, var(--violet) 75%, var(--text));
  border-bottom: 1px solid color-mix(in srgb, var(--violet) 30%, transparent); font-size: .92rem;
}
#switch-bar .switch-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
#switch-bar button.primary { padding: 4px 12px; font-size: .88rem; }

/* ---------- boîtes de dialogue et notifications ---------- */
dialog {
  border: var(--border); border-radius: calc(var(--radius) + 6px); background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); padding: 26px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(15, 25, 20, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog h3 { margin-top: 0; font-size: 1.35rem; }
dialog .actions { margin-top: 6px; }
.checklist { display: grid; gap: 4px; }
.checklist label { display: flex; align-items: center; gap: 10px; font-weight: 500; padding: 6px 8px; border-radius: 8px; }
.checklist label:hover { background: var(--surface-2); }
.checklist input { width: 18px; height: 18px; accent-color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; visibility: hidden;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  transition: transform .25s, opacity .25s, visibility .25s; max-width: calc(100vw - 32px); z-index: 20;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* ---------- famille, enfants, admin ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .75rem; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.member-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: var(--border); flex-wrap: wrap; }
.member-row:last-child { border-bottom: none; }
.member-row .who { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-weight: 600; }
.member-row .who:hover span:not(.chip) { color: var(--accent); }
.member-row .avatar { width: 36px; height: 36px; margin: 0; font-size: .9rem; }
.member-row .actions { margin-top: 0; }
.copy-box { display: flex; gap: 8px; margin-top: 10px; }
.copy-box input { flex: 1; font-size: .85rem; }
.big-center { text-align: center; padding: 36px 20px; }
.big-center .emoji { font-size: 3rem; line-height: 1; margin-bottom: 10px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Encart de contact */
.contact-card { display: flex; align-items: center; gap: 12px; margin-top: 28px; }
.contact-card > div { flex: 1; min-width: 0; }
.contact-card p { margin: 0; }
.contact-msg .item-desc { white-space: pre-wrap; }
.contact-msg.handled { opacity: .65; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* Groupes sur l'accueil et dans Mon compte */
.group-tile { display: flex; align-items: center; gap: 14px; }
.group-tile .person-info { flex: 1; min-width: 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.empty .emoji { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }
.empty p { margin: 4px 0; }
