/* Sous Le Sapin : ambiance catalogue de jouets d'autrefois. */
:root {
  --paper: #fbf5e6;
  --paper-2: #f4ead3;
  --card: #fffdf7;
  --ink: #2b1d14;
  --ink-soft: #5e4a3a;
  --muted: #8a7764;
  --red: #b3202a;
  --red-deep: #7a1018;
  --green: #1f5e3b;
  --green-ok: #2f8a4f;
  --orange: #d9700f;
  --gold: #c9972a;
  --line: #e3d5b8;
  --shadow: 0 1px 0 rgba(122, 16, 24, .06), 0 6px 18px -8px rgba(60, 30, 10, .35);
  --radius: 14px;
  --title: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --hand: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;
  --body: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 17px/1.5 var(--body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(201, 151, 42, .07) 1px, transparent 1.2px),
    radial-gradient(rgba(122, 16, 24, .05) 1px, transparent 1.2px);
  background-size: 22px 22px, 31px 31px;
  background-position: 0 0, 11px 7px;
}
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
main, .topbar, #toast { position: relative; z-index: 1; }

a { color: var(--red-deep); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--title); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(30px, 7vw, 46px); font-weight: 900; }
h2 { font-size: clamp(22px, 4.6vw, 28px); font-weight: 900; color: var(--red-deep); }
h3 { font-size: 19px; }
.hand { font-family: var(--hand); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ------------------------------------------------ barre du haut */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--red);
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 12px, transparent 12px 24px);
  color: #fff;
  box-shadow: 0 3px 0 var(--gold), 0 5px 14px rgba(0,0,0,.18);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-family: var(--title); font-weight: 700; font-size: 19px; white-space: nowrap; }
.brand em { font-style: italic; font-weight: 900; }
.brand img { background: var(--paper); border-radius: 50%; padding: 2px; }
#nav { display: flex; gap: 6px; }
#nav a { color: #fff; text-decoration: none; font-weight: 800; font-size: 15px; padding: 8px 12px;
  border-radius: 999px; background: rgba(255,255,255,.14); white-space: nowrap; }
#nav a:hover, #nav a:focus-visible { background: rgba(255,255,255,.26); }
@media (max-width: 420px) { .brand span { display: none; } }

main { max-width: 1100px; margin: 0 auto; padding: 22px 16px 80px; outline: none; }
.loading { text-align: center; font-family: var(--hand); font-size: 26px; color: var(--muted); margin-top: 18vh; }

/* ------------------------------------------------ éléments communs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border: 0; border-radius: 999px; cursor: pointer;
  font: 800 16px/1.1 var(--body); text-decoration: none; text-align: center;
  background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-deep);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-deep); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.green { background: var(--green-ok); box-shadow: 0 3px 0 #1d5c33; }
.btn.orange { background: var(--orange); box-shadow: 0 3px 0 #9a4e08; }
.btn.ghost { background: transparent; color: var(--red-deep); box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn.block { display: flex; width: 100%; }
.btn.danger { background: #fff; color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 14px; }

.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid var(--line);
}
.panel.narrow { max-width: 480px; margin: 0 auto; }
.panel + .panel { margin-top: 18px; }

label.field { display: block; font-weight: 800; font-size: 15px; color: var(--ink-soft); }
label.field > span.hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=email], textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: 17px var(--body); color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,151,42,.2); }
textarea { min-height: 90px; resize: vertical; }
.error { color: var(--red); font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(30px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50; max-width: calc(100% - 32px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--red); }

/* ------------------------------------------------ couverture (en-tête de page) */
.cover { text-align: center; margin: 6px 0 26px; }
.cover .kicker { font: 800 13px var(--body); letter-spacing: .22em; text-transform: uppercase; color: var(--green); }
.cover h1 { margin: 4px 0 0; }
.cover h1 .hand { display: block; font-size: .72em; color: var(--red); font-weight: 700; margin-bottom: -4px; }
.cover .rule { display: flex; align-items: center; gap: 12px; max-width: 420px; margin: 12px auto 0; color: var(--gold); }
.cover .rule::before, .cover .rule::after { content: ''; flex: 1; border-top: 2px dotted var(--gold); }
.seal {
  display: inline-grid; place-items: center; width: 76px; height: 76px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8bf55, var(--gold) 60%, #9e7419);
  color: #fff; font: 900 15px/1 var(--title); text-align: center; box-shadow: 0 3px 8px rgba(0,0,0,.2);
  border: 3px dashed rgba(255,255,255,.55); transform: rotate(-8deg);
}
.seal b { display: block; font-size: 21px; }

/* ------------------------------------------------ accueil */
.greet { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.greet h1 { margin: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 30px 0 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.person {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 18px 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform .12s ease;
}
.person:hover { transform: translateY(-3px) rotate(-.4deg); }
.person .avatar { width: 64px; height: 64px; font-size: 28px; }
.person .name { font: 900 19px var(--title); }
.person .count { font-size: 14px; color: var(--muted); }
.avatar {
  display: grid; place-items: center; border-radius: 50%; color: #fff; font-family: var(--title); font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.15), 0 0 0 3px var(--paper), 0 0 0 5px var(--gold);
}
.badge {
  position: absolute; top: -8px; right: -6px; background: var(--red); color: #fff; font-weight: 800; font-size: 13px;
  padding: 4px 10px; border-radius: 999px; box-shadow: 0 2px 0 var(--red-deep); transform: rotate(6deg);
}
.mine-card {
  display: flex; align-items: center; gap: 18px; padding: 18px 20px; text-decoration: none; color: var(--ink);
  background: linear-gradient(120deg, var(--green) 0%, #2a7a4e 100%); color: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 2px solid rgba(255,255,255,.25); outline: 3px dashed rgba(255,255,255,.22);
  outline-offset: -9px;
}
.mine-card .avatar { width: 58px; height: 58px; font-size: 26px; flex: none; }
.mine-card .t { font: 900 22px var(--title); }
.mine-card .s { opacity: .88; font-size: 15px; }
.mine-card .go { margin-left: auto; font-size: 30px; }
.alerts { border: 2px solid var(--orange); background: #fff7ec; }
.alerts h3 { color: var(--orange); margin: 0 0 8px; }
.alert-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.alert-row:first-of-type { border-top: 0; }
.banner {
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #fff; border: 2px dashed var(--gold); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px;
}
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .big { font-size: 46px; display: block; }

/* ------------------------------------------------ catalogue */
.cat-tools { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.years { display: flex; gap: 6px; flex-wrap: wrap; }
.years a { padding: 6px 14px; border-radius: 999px; text-decoration: none; font-weight: 800; font-size: 14px;
  color: var(--ink-soft); background: var(--paper-2); }
.years a.on { background: var(--green); color: #fff; }
.note-secret { background: #fff; border-left: 5px solid var(--green); padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; }

.catalog { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 560px) { .catalog { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .catalog { grid-template-columns: repeat(3, 1fr); } }

.item {
  position: relative; display: flex; flex-direction: column; background: var(--card); border-radius: 6px;
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: visible;
}
.item .pic {
  position: relative; aspect-ratio: 1 / 1; background: #fff; border-radius: 6px 6px 0 0; overflow: hidden;
  display: grid; place-items: center; border-bottom: 1px solid var(--line);
}
.item .pic img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.item .pic .noimg { font-size: 70px; opacity: .6; }
.item .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.item .ref { font: 700 12px var(--body); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.item h3 { font-size: 21px; margin: 0; }
.item .details { color: var(--ink-soft); font-size: 15px; white-space: pre-line; }
.stars { color: var(--gold); font-size: 18px; letter-spacing: 2px; }
.stars .off { color: #e3d5b8; }
.stars .lbl { font: 700 13px var(--body); color: var(--muted); letter-spacing: 0; margin-left: 6px; }

.price-tag {
  position: absolute; top: 14px; right: -8px; z-index: 2; padding: 7px 14px 7px 20px;
  background: var(--red); color: #fff; font: 900 18px var(--title);
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
  box-shadow: 0 2px 0 var(--red-deep); filter: drop-shadow(0 2px 2px rgba(0,0,0,.2));
}
.price-tag::before { content: ''; position: absolute; left: 9px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--paper); }
.price-tag small { font: 700 11px var(--body); opacity: .9; margin-right: 3px; }

.sticker-new {
  position: absolute; top: 10px; left: 10px; z-index: 2; width: 66px; height: 66px; display: grid; place-items: center;
  background: #ffd84d; color: var(--red-deep); font: 900 14px/1 var(--title); transform: rotate(-12deg);
  clip-path: polygon(50% 0, 61% 18%, 80% 8%, 79% 30%, 100% 33%, 86% 50%, 100% 67%, 79% 70%, 80% 92%, 61% 82%,
    50% 100%, 39% 82%, 20% 92%, 21% 70%, 0 67%, 14% 50%, 0 33%, 21% 30%, 20% 8%, 39% 18%);
}

.ribbon {
  position: absolute; top: 26px; left: -44px; z-index: 2; width: 190px; transform: rotate(-38deg);
  text-align: center; font: 900 13px/1 var(--body); letter-spacing: .14em; text-transform: uppercase; color: #fff;
  padding: 8px 0; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.ribbon.full { background: var(--green-ok); }
.ribbon.partial { background: var(--orange); }
.item.taken .pic img { opacity: .55; filter: saturate(.6); }

.links { display: flex; flex-wrap: wrap; gap: 6px; }
.link-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 6px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 14px;
  border: 1px solid var(--line); max-width: 100%;
}
.link-chip:hover { background: #fff; border-color: var(--gold); }
.link-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag { width: 24px; height: 18px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); flex: none; object-fit: cover; }

.res-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.res-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; background: #fff; border-radius: 10px;
  padding: 8px 10px; border: 1px solid var(--line); }
.dot { flex: none; width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; }
.dot.full { background: var(--green-ok); }
.dot.partial { background: var(--orange); }
.res-list .who { font-weight: 800; }
.res-list .changed { display: block; color: var(--orange); font-weight: 800; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.actions .btn { flex: 1 1 auto; }

.item.secret { border: 2px dashed var(--green); }
.secret-stamp {
  display: inline-block; align-self: flex-start; font: 700 22px var(--hand); color: var(--green);
  border: 2px solid var(--green); border-radius: 6px; padding: 0 10px; transform: rotate(-3deg);
}
.owner-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.owner-tools .btn { flex: 1 1 auto; }
.icon-btn { min-width: 44px; padding: 6px 10px; }

/* ------------------------------------------------ fiche d'édition */
.editor { max-width: 720px; margin: 0 auto; }
.editor .grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 560px) { .editor .grid2 { grid-template-columns: 2fr 1fr; } }
.link-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.link-row input { margin-top: 0; }
.flag-btn { flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 10px; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; cursor: pointer; font: 800 13px var(--body); color: var(--ink-soft); }
.flag-menu { position: absolute; z-index: 20; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: var(--shadow); display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 4px; }
.flag-menu button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; border-radius: 8px;
  cursor: pointer; font: 600 15px var(--body); text-align: left; color: var(--ink); }
.flag-menu button:hover, .flag-menu button:focus-visible { background: var(--paper-2); }
.visual { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: start; }
@media (max-width: 420px) { .visual { grid-template-columns: 1fr; } }
.visual .preview { aspect-ratio: 1; background: #fff; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
.visual .preview img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.candidates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.candidates button { aspect-ratio: 1; padding: 4px; background: #fff; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; overflow: hidden; }
.candidates button:hover, .candidates button:focus-visible { border-color: var(--gold); }
.candidates button.on { border-color: var(--green-ok); box-shadow: 0 0 0 3px rgba(47,138,79,.25); }
.candidates img { width: 100%; height: 100%; object-fit: contain; }
.desire-pick { display: flex; gap: 6px; margin-top: 6px; }
.desire-pick button { flex: 1; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer;
  font: 800 14px var(--body); color: var(--ink-soft); }
.desire-pick button.on { border-color: var(--gold); background: #fff8e4; color: var(--ink); }
.desire-pick .st { display: block; color: var(--gold); font-size: 17px; letter-spacing: 1px; }
.price-row { display: flex; gap: 8px; }
.price-row input { flex: 1; }
.price-row select { width: 96px; flex: none; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--red);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ fenêtre (coche) */
.modal-back { position: fixed; inset: 0; background: rgba(43,29,20,.5); z-index: 40; display: grid; place-items: end center; padding: 16px; }
@media (min-width: 600px) { .modal-back { place-items: center; } }
.modal { width: 100%; max-width: 460px; background: var(--card); border-radius: 18px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
  border-top: 6px solid var(--red); max-height: 90vh; overflow: auto; }
.modal.green { border-top-color: var(--green-ok); }
.modal.orange { border-top-color: var(--orange); }

/* ------------------------------------------------ groupes, admin */
.members { list-style: none; padding: 0; margin: 0; }
.members li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); }
.members li:first-child { border-top: 0; }
.members .avatar { width: 38px; height: 38px; font-size: 17px; flex: none; }
.members .grow { flex: 1; min-width: 0; }
.invite-box { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .invite-box { grid-template-columns: 1fr 170px; align-items: center; } }
.qr { width: 170px; height: 170px; justify-self: center; border-radius: 12px; border: 6px solid #fff; box-shadow: var(--shadow); }
.copy-field { display: flex; gap: 8px; }
.copy-field input { margin-top: 0; font-size: 15px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; font-weight: 700; }
.toggle input { width: 24px; height: 24px; accent-color: var(--green-ok); }
.accounts { width: 100%; border-collapse: collapse; }
.accounts td { padding: 12px 6px; border-top: 1px dashed var(--line); vertical-align: top; }
.accounts .tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); margin: 2px 2px 0 0; }
.accounts .tag.admin { background: var(--gold); color: #fff; }
.accounts .tag.warn { background: #ffe3c2; color: #8a4300; }
@media (max-width: 640px) { .accounts td { display: block; border-top: 0; padding: 4px 0; } .accounts tr { display: block; border-top: 1px dashed var(--line); padding: 10px 0; } }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--paper-2); padding: 5px; border-radius: 999px; }
.tabs button { flex: 1; min-height: 42px; border: 0; border-radius: 999px; background: none; font: 800 15px var(--body); color: var(--ink-soft); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--red-deep); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

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