/* ==========================================================================
   Cadeaux en famille — feuille de style (thème « Chaleureux »)
   ========================================================================== */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces.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: "Fraunces", Georgia, "Times New Roman", serif;
  --title-weight: 600;

  --bg: #f7f1ea;
  --bg-deco: radial-gradient(1200px 500px at 10% -10%, #fbe3d6 0%, transparent 60%),
             radial-gradient(900px 400px at 110% 0%, #f6e7c9 0%, transparent 55%);
  --surface: #fffdf9;
  --surface-2: #f3ebe2;
  --text: #2a1f1c;
  --muted: #7c6c64;
  --line: #eadccf;
  --accent: #9e2a3a;
  --accent-hover: #86202f;
  --accent-ink: #ffffff;
  --accent-soft: #f6e1e1;
  --gold: #c08a2e;
  --ok: #2e7a50;
  --ok-soft: #e0f0e6;
  --warn: #a8640a;
  --warn-soft: #fbedd5;
  --violet: #6b4bb8;
  --violet-soft: #ece6fb;
  --progress: linear-gradient(90deg, #d9a441, #c08a2e);

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1513;
    --bg-deco: radial-gradient(1200px 500px at 10% -10%, #3a1d20 0%, transparent 60%),
               radial-gradient(900px 400px at 110% 0%, #33281a 0%, transparent 55%);
    --surface: #241d1b;
    --surface-2: #2e2523;
    --text: #f3ebe5;
    --muted: #ad9d94;
    --line: #3b302d;
    --accent: #e0707f;
    --accent-hover: #ea8592;
    --accent-ink: #1a1012;
    --accent-soft: #3b2226;
    --gold: #e1b25c;
    --ok: #74c895;
    --ok-soft: #1d3326;
    --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(36, 29, 27, .82);
    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); }

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; }
.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);
}

/* ---------- liste de cadeaux ---------- */
.gifts { display: grid; gap: 12px; margin-top: 18px; }
.gift { margin: 0; position: relative; border-left: 5px solid var(--line); padding-left: 20px; transition: box-shadow .15s; }
.gift:hover { box-shadow: var(--shadow-hover); }
.gift[data-status="libre"] { border-left-color: var(--ok); }
.gift[data-status="reserve"], .gift[data-status="complet"] { border-left-color: var(--accent); }
.gift[data-status="partiel"] { border-left-color: var(--gold); }
.gift[data-status="mine"] { border-left-color: var(--accent-soft); }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-title { font-family: var(--font-title); font-weight: var(--title-weight); font-size: 1.2rem; line-height: 1.3; margin: 0; word-break: break-word; }
.item-title a { color: var(--text); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-decoration-thickness: 2px; }
.item-title a:hover { color: var(--accent); }
.item-desc { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.price {
  font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
  background: var(--surface-2); padding: 3px 11px; border-radius: 999px; font-size: .95rem;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 650;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.libre { background: var(--ok-soft); color: var(--ok); }
.badge.reserve, .badge.complet { background: var(--accent-soft); color: var(--accent); }
.badge.partiel { background: var(--warn-soft); color: var(--warn); }
.badge.secret { background: var(--violet-soft); color: var(--violet); }
.badge.secret::before { content: "♥"; width: auto; height: auto; background: none; font-size: .8em; }
.gift .small.muted { margin: 10px 0 0; }
.gift .small:not(.muted) { margin: 4px 0 0; }

.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--progress); border-radius: 999px; transition: width .4s; }

/* ---------- 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); }
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(--accent); }
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; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; }
.tabs button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.error { color: var(--accent); 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;
}
.notice-secret { background: var(--violet-soft); color: color-mix(in srgb, var(--violet) 75%, var(--text)); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

.comments { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 10px; }
.comment { margin: 6px 0; font-size: .95rem; }
.comment b { margin-right: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; }

/* ---------- 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(30, 15, 10, .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; }
.kid .item-title a { color: var(--text); text-decoration: none; }
.kid .item-title a:hover { color: var(--accent); }
.kid p.small { margin: 6px 0 0; }
.removed { opacity: .7; border-style: dashed; }
.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; } }

/* Secret Santa */
.santa-pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin: 10px 0; border-radius: var(--radius-sm); background: var(--surface-2); }
.santa-pick p { margin: 0; font-weight: 600; }
.santa-secret:not([hidden]) { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.santa-secret .who { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.santa details { margin: 8px 0; }
.santa summary { cursor: pointer; }
.santa-excl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 6px; border-radius: var(--radius-sm); background: var(--surface-2); }
.santa-excl-add { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.santa-excl-add select { flex: 1; min-width: 0; }
