/* Noël en famille — univers « BD cel-shadée » : cases encrées, aplats, récitatifs jaunes, bulles. */
:root {
  --paper: #f3e7d1;
  --paper-2: #e8d7b8;
  --card: #fffaf0;
  --ink: #161210;
  --ink-soft: #5d5046;
  --line: #161210;
  --red: #d1361f;
  --red-ink: #8e1f10;
  --camel: #d9822b;
  --gold: #f6c92e;
  --navy: #1f2b45;
  --sea: #9cb8c6;
  --pine: #2d6a4a;
  --pine-soft: #d4e8d3;
  --red-soft: #f7d4c8;
  --gold-soft: #fbe7a6;
  --sea-soft: #d6e6ee;
  --dots: rgba(22, 18, 16, .09);
  --shadow: 5px 5px 0 var(--line);
  --shadow-sm: 3px 3px 0 var(--line);
  --radius: 5px;
  --border: 3px solid var(--line);
  --font-display: 'Bangers', 'Impact', 'Arial Black', sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1a22;
    --paper-2: #26242e;
    --card: #2b2833;
    --ink: #f6ead4;
    --ink-soft: #bdb0a0;
    --line: #000;
    --red: #e64a30;
    --red-ink: #ffb19f;
    --gold: #f6c92e;
    --pine: #5fbf8a;
    --pine-soft: #1f3a2d;
    --red-soft: #4a2219;
    --gold-soft: #4a3d14;
    --sea-soft: #22364a;
    --dots: rgba(255, 240, 210, .06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1a22; --paper-2: #26242e; --card: #2b2833; --ink: #f6ead4; --ink-soft: #bdb0a0;
  --line: #000; --red: #e64a30; --red-ink: #ffb19f; --gold: #f6c92e; --pine: #5fbf8a;
  --pine-soft: #1f3a2d; --red-soft: #4a2219; --gold-soft: #4a3d14; --sea-soft: #22364a; --dots: rgba(255, 240, 210, .06); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  /* trame Ben-Day, comme une planche imprimée */
  background-image: radial-gradient(var(--dots) 1.3px, transparent 1.6px);
  background-size: 9px 9px;
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
#app { position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1; margin: 0; letter-spacing: .03em; }
h1 { font-size: clamp(2.3rem, 10vw, 3rem); }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.boot { display: grid; place-items: center; min-height: 100dvh; font-size: 3rem; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-6deg); } }

/* ------------------------------------------------ mise en page */
.shell { max-width: 620px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom)); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.stack-sm { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.eyebrow {
  display: inline-block; justify-self: start; align-self: start; width: fit-content;
  font: 400 1rem/1.2 var(--font-display); letter-spacing: .06em; text-transform: uppercase;
  background: var(--gold); color: #161210; border: 2.5px solid var(--line); padding: 2px 9px 1px;
  box-shadow: 2px 2px 0 var(--line); transform: rotate(-1.5deg); margin-bottom: 8px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.topbar .back { text-decoration: none; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------ cartes */
.card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
}
.card.tight { padding: 14px; }
.card.red { background: var(--red); color: #fff8ee; }
.card.red .muted { color: #ffe1d8; }
.card.gold { background: var(--gold-soft); }
.card.pine { background: var(--pine-soft); }
.card.sea { background: var(--sea-soft); }
a.card { text-decoration: none; display: block; transition: transform .15s ease, box-shadow .15s ease; }
@media (hover: hover) { a.card:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--line); } }
a.card:active { transform: translate(2px, 2px); box-shadow: var(--shadow-sm); }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 2px -4px; }
.section-title a { font: 400 1.1rem/1 var(--font-display); letter-spacing: .05em; text-decoration: none; color: var(--red); }

/* ------------------------------------------------ hero illustré */
.hero { padding: 0; overflow: hidden; display: grid; aspect-ratio: 5 / 4; max-height: 400px; width: 100%; }
.hero > * { grid-area: 1 / 1; min-height: 0; }
.hero-img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.hero-text {
  align-self: stretch; padding: 16px 16px 14px;
  background: linear-gradient(to top, rgba(22, 18, 16, .75) 0%, rgba(22, 18, 16, 0) 38%);
  color: #fff8ee;
}
.hero-text h1 { color: #fff8ee; text-shadow: 3px 3px 0 var(--line), -1.5px -1.5px 0 var(--line), 1.5px -1.5px 0 var(--line), -1.5px 1.5px 0 var(--line); }
.hero-text .eyebrow { color: #161210; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2.5px solid var(--line); border-radius: 4px; padding: 3px 9px 2px;
  font-weight: 900; font-size: .82rem; background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.chip.red { background: var(--red); color: #fff8ee; }
.chip.gold { background: var(--gold); color: #2b1d18; }
.chip.pine { background: var(--pine); color: #fff; }
.chip.flat { box-shadow: none; }

/* ------------------------------------------------ avatars */
.avatar {
  --s: 48px;
  width: var(--s); height: var(--s); flex: none;
  border-radius: 50%; border: 2.5px solid var(--line);
  overflow: hidden; background: var(--gold);
  display: grid; place-items: center;
  font: 900 calc(var(--s) * .42) / 1 var(--font-display); color: #2b1d18;
  box-shadow: var(--shadow-sm);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xl { --s: 112px; box-shadow: var(--shadow); border-width: 3px; }
.avatar.lg { --s: 72px; }
.avatar.sm { --s: 36px; border-width: 2px; box-shadow: none; }
.avatar.xs { --s: 26px; border-width: 2px; box-shadow: none; font-size: .7rem; }
.avatars { display: flex; }
.avatars .avatar { margin-left: -10px; }
.avatars .avatar:first-child { margin-left: 0; }

/* ------------------------------------------------ boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  border: var(--border); border-radius: 6px;
  background: var(--card); color: var(--ink);
  font: 400 1.2rem/1 var(--font-display); letter-spacing: .05em; padding-top: 12px; text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--red); color: #fff8ee; }
.btn.gold { background: var(--gold); color: #2b1d18; }
.btn.pine { background: var(--pine); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; padding: 8px 10px; font: 800 .95rem/1.2 var(--font-body); letter-spacing: 0; }
.btn.small { min-height: 38px; padding: 8px 12px 6px; font-size: 1.02rem; border-width: 2.5px; border-radius: 5px; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 1.55rem; border-radius: 6px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none;
  border: 2.5px solid var(--line); border-radius: 5px; background: var(--card); cursor: pointer; box-shadow: var(--shadow-sm);
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn svg, .btn svg { width: 20px; height: 20px; }

/* ------------------------------------------------ formulaires */
label.field { display: grid; gap: 6px; font-weight: 800; font-size: .9rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2.5px solid var(--line); border-radius: 5px; background: var(--card);
  font-size: 16px; font-weight: 600;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, .switch input:focus-visible + span {
  outline: 3px solid var(--gold); outline-offset: 2px;
}
.form-grid { display: grid; gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--red); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 50px; height: 30px; border-radius: 99px; border: 2px solid var(--line); background: var(--paper-2); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); transition: transform .2s cubic-bezier(.3, 1.4, .6, 1); }
.switch input:checked + span { background: var(--pine); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ------------------------------------------------ listes d'idées */
.item { display: grid; gap: 6px; }
.item-head { display: flex; gap: 10px; align-items: flex-start; }
.item-title { font-weight: 800; font-size: 1.04rem; line-height: 1.3; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .86rem; color: var(--ink-soft); font-weight: 700; }
.item-meta a { color: var(--red); text-decoration: none; }
.item-note { font-size: .92rem; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.item.taken { background: var(--paper-2); }
.item.taken .item-title { text-decoration: line-through; text-decoration-thickness: 2px; opacity: .75; }
.star { color: var(--gold); font-size: 1.1rem; }
.over { color: var(--red); }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: .8rem; padding: 2px 9px; border-radius: 4px; border: 2.5px solid var(--line); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
.status.empty { background: var(--paper-2); }
.status.open { background: var(--gold-soft); }
.status.complete { background: var(--pine); color: #fff; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 8px; margin: 0 -4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 3px 6px; border: 2.5px solid var(--line); border-radius: 5px; background: var(--card); font: 400 1.1rem/1 var(--font-display); letter-spacing: .04em; text-decoration: none; white-space: nowrap; cursor: pointer; }
.tab[aria-current="true"] { background: var(--ink); color: var(--paper); }

.empty-state { text-align: center; padding: 28px 18px; display: grid; gap: 10px; justify-items: center; }
.empty-state .big-emoji { font-size: 2.6rem; }

/* ------------------------------------------------ nouvelles */
.news { display: grid; gap: 0; }
.news-item { display: flex; gap: 12px; padding: 12px 2px; border-bottom: 2px dashed color-mix(in srgb, var(--line) 25%, transparent); align-items: flex-start; }
.news-item:last-child { border-bottom: 0; }
.news-item.unread .news-text { font-weight: 800; }
.news-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); border: 2px solid var(--line); margin-top: 7px; flex: none; }
.news-dot.read { background: transparent; border-color: color-mix(in srgb, var(--line) 30%, transparent); }

/* ------------------------------------------------ navigation basse */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom)); z-index: 20;
  width: min(588px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border: var(--border); border-radius: 6px; box-shadow: var(--shadow);
  padding: 6px;
}
.nav a {
  display: grid; justify-items: center; gap: 2px; padding: 6px 2px 4px; border-radius: 4px;
  text-decoration: none; font: 400 .92rem/1 var(--font-display); letter-spacing: .05em; position: relative; color: var(--ink-soft);
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { background: var(--red); color: #fff8ee; }
.badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  background: var(--gold); color: #2b1d18; border: 2px solid var(--line);
  font-size: .7rem; font-weight: 900; display: grid; place-items: center;
}

/* ------------------------------------------------ personne tirée */
.match { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.match h2 { font-size: 1.7rem; }
.ribbon {
  position: absolute; top: -14px; right: 14px;
  background: var(--gold); color: #161210; border: 2.5px solid var(--line); padding: 2px 10px 0;
  font: 400 1.05rem/1.2 var(--font-display); letter-spacing: .05em; text-transform: uppercase;
  box-shadow: var(--shadow-sm); transform: rotate(2.5deg);
}

/* ------------------------------------------------ roulette */
.wheel-wrap { position: relative; width: min(92vw, 420px); aspect-ratio: 1; margin: 12px auto 4px; }
.wheel {
  width: 100%; height: 100%; border-radius: 50%;
  border: 4px solid var(--line); box-shadow: 6px 6px 0 var(--line);
  transition: transform 6.2s cubic-bezier(.12, .7, .08, 1);
  will-change: transform; background: var(--card);
}
.wheel svg { width: 100%; height: 100%; display: block; }
.pointer {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 52px; z-index: 2; filter: drop-shadow(2px 3px 0 var(--line));
}
.hub {
  position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  width: 22%; aspect-ratio: 1; border-radius: 50%; background: var(--gold);
  border: 4px solid var(--line); display: grid; place-items: center; font-size: 2rem; z-index: 2;
}
.reveal { animation: pop .6s cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border: 1.5px solid var(--line); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ------------------------------------------------ admin */
.member-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 2px dashed color-mix(in srgb, var(--line) 25%, transparent); }
.member-row:last-child { border-bottom: 0; }
.member-row .controls { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 6px; }
.member-row select { min-height: 36px; padding: 4px 8px; font-size: .9rem; border-width: 2px; border-radius: 10px; width: auto; }
.pairs { display: grid; gap: 8px; }
.pair { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; }
details.card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '+'; font: 900 1.6rem/1 var(--font-display); }
details.card[open] > summary::after { content: '–'; }
details.card[open] > summary { margin-bottom: 14px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.gallery button { padding: 0; border: 2.5px solid var(--line); border-radius: 50%; overflow: hidden; aspect-ratio: 1; cursor: pointer; background: var(--paper-2); }
.gallery button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

/* ------------------------------------------------ dialogue & toast */
dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 40px);
  border: var(--border); border-radius: 6px; box-shadow: 7px 7px 0 var(--line);
  background: var(--card); color: var(--ink); padding: 20px;
}
dialog::backdrop { background: rgba(21, 14, 10, .55); }
dialog[open] { animation: pop .3s cubic-bezier(.2, 1.3, .5, 1); }

#toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--gold); color: #161210; border: 3px solid var(--line); box-shadow: 4px 4px 0 var(--line);
  padding: 10px 16px 8px; border-radius: 4px; font: 400 1.15rem/1.15 var(--font-display); letter-spacing: .04em; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------ connexion */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { max-width: 440px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.login .tree { font-size: 4rem; line-height: 1; }

@media (min-width: 720px) {
  .shell { padding-top: 32px; }
  .hero { aspect-ratio: 16 / 10; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .wheel { transition: transform .4s ease-out !important; }
}


/* ------------------------------------------------ BD : bulles, cases, onomatopées */
.hero { transform: rotate(-.6deg); }
.bubble {
  position: relative; display: inline-block; background: #fffaf0; color: #161210;
  border: 3px solid var(--line); border-radius: 50% / 46%; padding: 14px 22px 12px;
  font: 400 clamp(1.7rem, 8vw, 2.3rem)/1 var(--font-display); letter-spacing: .03em;
  box-shadow: 3px 3px 0 var(--line);
}
.bubble::after {
  content: ''; position: absolute; left: 22%; bottom: -19px; width: 26px; height: 22px;
  background: #fffaf0; border-right: 3px solid var(--line); border-bottom: 3px solid var(--line);
  clip-path: polygon(0 0, 100% 0, 100% 100%); transform: skewX(-25deg);
}
.hero-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.hero-text .chips { margin-top: auto; width: 100%; }
.hero-text .bubble { margin-bottom: 22px; }
.boom {
  position: absolute; z-index: 3; pointer-events: none;
  font: 400 2.6rem/1 var(--font-display); letter-spacing: .04em; color: var(--gold);
  -webkit-text-stroke: 2px var(--line); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--line); transform: rotate(-12deg);
  animation: boom .5s cubic-bezier(.2, 1.8, .5, 1) both;
}
@keyframes boom { from { transform: rotate(-12deg) scale(.2); opacity: 0; } }
.burst { position: relative; display: grid; place-items: center; width: min(78vw, 300px); aspect-ratio: 1; margin: -10px auto -20px; }
.burst svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.burst .avatar { position: relative; z-index: 1; }
.panel-num { font: 400 .95rem/1 var(--font-display); letter-spacing: .08em; color: var(--ink-soft); }

/* --- enfants regroupés par famille */
.family-jump .chip { text-decoration: none; }
.family { scroll-margin-top: 64px; }
.family + .family { margin-top: 18px; padding-top: 18px; border-top: var(--border) dashed var(--line); }
.family-head { display: grid; gap: 4px; }
.family-title {
  justify-self: start; background: var(--red); color: #fff; padding: 6px 12px 4px;
  border: var(--border) solid var(--line); box-shadow: 4px 4px 0 var(--line); transform: rotate(-1deg);
}
.family-row + .family-row { padding-top: 10px; border-top: 2px dashed color-mix(in srgb, var(--line) 25%, transparent); }
