/* Calendrier de l'avent Glooob : couleurs de glooob.eu + une touche de Noël */
:root {
  --bg: #f1f7f9;
  --bg2: #f6f9fb;
  --card: #ffffff;
  --card2: #f1f5f9;
  --border: #cbd5e1;
  --line: #e2e8f0;
  --seg: #e5edf3;
  --text: #0f172a;
  --muted: #5b6b80;
  --primary: #1c5468;
  --primary-hover: #154253;
  --teal: #2b7a90;
  --tint: #e0eef3;
  --red: #c0392b;
  --red2: #e74c3c;
  --green: #15803d;
  --gold: #d4a017;
  --tint-green: #dcfce7;
  --tint-red: #fee2e2;
  --tint-gold: #fef3c7;
  --door: linear-gradient(160deg, #1c5468 0%, #2b7a90 100%);
  --door-alt: linear-gradient(160deg, #b03a2e 0%, #d9534f 100%);
  --door-alt2: linear-gradient(160deg, #1f6f4a 0%, #2e9a66 100%);
  --hero: radial-gradient(600px at 10% 10%, rgba(107, 184, 204, .45), transparent 60%),
          radial-gradient(500px at 95% 90%, rgba(192, 57, 43, .14), transparent 60%),
          linear-gradient(135deg, #dff0f6 0%, #ffffff 100%);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 14px 36px rgba(15, 23, 42, .14);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --bg2: #0f1829;
  --card: #111827;
  --card2: #172033;
  --border: #243044;
  --line: #1f2937;
  --seg: #0b1220;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #2b7a90;
  --primary-hover: #236579;
  --tint: rgba(107, 184, 204, .14);
  --green: #34d399;
  --tint-green: rgba(52, 211, 153, .14);
  --tint-red: rgba(248, 113, 113, .14);
  --tint-gold: rgba(251, 191, 36, .14);
  --hero: radial-gradient(600px at 10% 10%, rgba(61, 148, 173, .35), transparent 60%),
          radial-gradient(500px at 95% 90%, rgba(192, 57, 43, .25), transparent 60%),
          linear-gradient(135deg, #0f2a35 0%, #1c3d4c 100%);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 14px 36px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 500 15px/1.55 Quicksand, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 700; }
.brand-name, .door-num, .hero h1, .login-box h1, .modal h2 { font-family: Fredoka, Quicksand, sans-serif; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.ico { stroke: none; }
img.twemoji { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin: 0 .04em; }

/* ---------- Neige ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flake { position: absolute; top: -12px; border-radius: 50%; background: #fff; opacity: .85; box-shadow: 0 0 4px rgba(43, 122, 144, .35); animation: fall linear infinite; }
:root[data-theme="light"] .flake { background: #b9d9e4; box-shadow: none; }
@keyframes fall { to { transform: translate3d(var(--drift, 30px), 105vh, 0); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); padding: 9px 16px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 700; text-decoration: none; box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--teal); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.block { width: 100%; padding: 12px 18px; font-size: 15px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 10px; cursor: pointer; box-shadow: var(--shadow-sm); padding: 0; }
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
#theme-toggle [data-sun] { display: none; }
:root[data-theme="dark"] #theme-toggle [data-sun] { display: block; }
:root[data-theme="dark"] #theme-toggle [data-moon] { display: none; }

/* ---------- Connexion ---------- */
.login-page { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px 16px; }
.login-top { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.login-top img { width: 46px; height: 46px; object-fit: contain; }
.login-top .brand-name { font-size: 28px; }
.login-box { width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 32px 30px; box-shadow: var(--shadow-sm); }
.login-box h1 { font-size: 26px; margin-bottom: 6px; }
.login-box > p { margin: 0 0 22px; }
.login-gift { font-size: 44px; line-height: 1; margin-bottom: 10px; animation: wiggle 2.4s ease-in-out infinite; display: inline-block; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-10deg); } 90% { transform: rotate(10deg); } 95% { transform: rotate(-6deg); } }
.login-points { list-style: none; padding: 18px 0 0; margin: 22px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 14px; }
.login-back { color: var(--teal); font-weight: 700; text-decoration: none; background: var(--seg); padding: 6px 12px; border-radius: 8px; font-size: 13px; }

/* ---------- En-tête ---------- */
#app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand-name { font-size: 22px; font-weight: 600; }
.brand-name span { color: var(--red); font-size: 15px; margin-left: 5px; }
.seg-nav { margin: 0 auto; display: flex; gap: 2px; background: var(--seg); padding: 4px; border-radius: 12px; }
.seg-nav button { border: 0; background: none; padding: 7px 16px; border-radius: 9px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg-nav button.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .seg-nav button.on { color: #6bb8cc; }
.tools { display: flex; align-items: center; gap: 8px; }
.me-avatar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--card); box-shadow: var(--shadow-sm); background: var(--card2); }
#page { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 20px 40px; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }

/* ---------- Bandeau ---------- */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; background: var(--hero); border: 1px solid var(--border); border-radius: 20px; padding: 26px 28px; margin-bottom: 22px; position: relative; overflow: hidden; }
.hero h1 { font-size: 30px; line-height: 1.15; }
.hero p { margin: 0; max-width: 620px; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.pill-stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 10px 16px; text-align: center; min-width: 96px; box-shadow: var(--shadow-sm); }
.pill-stat b { display: block; font-family: Fredoka, sans-serif; font-size: 24px; line-height: 1.1; }
.pill-stat span { font-size: 12px; color: var(--muted); font-weight: 700; }
.countdown { margin-top: 14px; display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); padding: 6px 12px; border-radius: 99px; font-weight: 700; font-size: 13px; }
.test-banner { background: var(--tint-gold); color: #92400e; border: 1px solid #f59e0b; border-radius: 12px; padding: 8px 14px; margin-bottom: 16px; font-weight: 700; }
:root[data-theme="dark"] .test-banner { color: #fbbf24; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero h1 { font-size: 24px; } }

/* ---------- Portes ---------- */
/* 6 colonnes : 24 cases + la grande (2×2) + 3 larges = 30 places, sans trou (4 colonnes : 28 ; 3 colonnes : 27) */
.doors { display: grid; gap: 14px; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 132px; grid-auto-flow: dense; }
.door { position: relative; perspective: 900px; border: 0; padding: 0; background: none; cursor: pointer; font: inherit; color: inherit; }
.door.big { grid-row: span 2; grid-column: span 2; }
.door.w6 { grid-column: span 2; }
@media (max-width: 900px) { .doors { grid-template-columns: repeat(4, 1fr); } .door.w6 { grid-column: auto; } .door.w4 { grid-column: span 2; } }
@media (max-width: 560px) { .doors { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 112px; gap: 10px; } .door.w4 { grid-column: auto; } }
.door-inside { position: absolute; inset: 0; border-radius: 16px; background: var(--card); border: 2px dashed var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; text-align: center; }
.door-inside .em { font-size: 30px; line-height: 1; }
.door-inside .t { font-size: 12px; font-weight: 700; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.door-front { position: absolute; inset: 0; border-radius: 16px; background: var(--door); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow-sm), inset 0 0 0 3px rgba(255, 255, 255, .14); transform-origin: left center; transition: transform .7s cubic-bezier(.3, .9, .3, 1), box-shadow .2s; backface-visibility: hidden; overflow: hidden; }
.door:nth-child(3n+1) .door-front { background: var(--door-alt); }
.door:nth-child(4n+2) .door-front { background: var(--door-alt2); }
.door-front::before { content: ""; position: absolute; inset: 8px; border: 2px dashed rgba(255, 255, 255, .28); border-radius: 11px; }
.door-front::after { content: ""; position: absolute; right: 12px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .7); }
.door-num { font-size: 40px; font-weight: 700; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.door.big .door-num { font-size: 58px; }
.door-sub { font-size: 11px; font-weight: 700; opacity: .9; margin-top: 4px; }
.door.locked { cursor: default; }
.door.locked .door-front { filter: saturate(.35) brightness(.95); }
.door.locked .door-front .lock { position: absolute; top: 8px; left: 10px; font-size: 13px; opacity: .85; }
.door.ready .door-front { animation: glow 2s ease-in-out infinite; }
.door.ready:hover .door-front { transform: rotateY(-22deg); }
.door.today .door-front { outline: 3px solid var(--gold); outline-offset: 3px; }
@keyframes glow { 0%, 100% { box-shadow: var(--shadow-sm), 0 0 0 0 rgba(212, 160, 23, .5); } 50% { box-shadow: var(--shadow-sm), 0 0 0 7px rgba(212, 160, 23, 0); } }
.door.opened .door-front { transform: rotateY(-105deg); pointer-events: none; }
.door.opened .door-inside { border-style: solid; border-color: var(--line); background: var(--card); }
.door.opened:hover .door-inside { border-color: var(--teal); }
.door.opening .door-front { transform: rotateY(-105deg); }
.door.soon .door-sub::after { content: " · bientôt"; }
.door .ribbon { position: absolute; top: -6px; right: -6px; z-index: 3; background: var(--gold); color: #1c1917; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; box-shadow: var(--shadow-sm); }

/* ---------- Fenêtre d'une case ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.modal-head { background: var(--hero); padding: 22px 24px 18px; border-bottom: 1px solid var(--line); position: relative; }
.modal-head .day-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--red); color: #fff; font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 99px; }
.modal-head .type-badge { display: inline-block; background: var(--card); border: 1px solid var(--border); font-weight: 700; font-size: 12px; padding: 2px 10px; border-radius: 99px; margin-left: 6px; }
.modal-head h2 { font-size: 26px; margin: 10px 0 0; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal-body { padding: 20px 24px 24px; }
.content-text { white-space: pre-wrap; word-break: break-word; }
.content-img { width: 100%; max-height: 360px; object-fit: cover; border-radius: 14px; margin: 14px 0 0; border: 1px solid var(--line); }
.video { position: relative; padding-top: 56.25%; margin-top: 14px; border-radius: 14px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.quiz { margin-top: 16px; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.quiz h3 { font-size: 16px; }
.choices { display: grid; gap: 8px; margin-top: 10px; }
.choice { text-align: left; border: 2px solid var(--border); background: var(--card); border-radius: 12px; padding: 10px 14px; font: inherit; font-weight: 700; cursor: pointer; color: var(--text); }
.choice:hover:not(:disabled) { border-color: var(--teal); background: var(--tint); }
.choice:disabled { cursor: default; }
.choice.good { border-color: var(--green); background: var(--tint-green); }
.choice.bad { border-color: var(--red2); background: var(--tint-red); }
.gift { margin-top: 16px; background: var(--tint-gold); border: 1px solid #f5d36b; border-radius: 14px; padding: 16px; text-align: center; }
:root[data-theme="dark"] .gift { border-color: rgba(251, 191, 36, .4); }
.gift .prize { font-family: Fredoka, sans-serif; font-size: 20px; font-weight: 600; margin: 4px 0 12px; }
.code-box { display: inline-flex; align-items: center; gap: 10px; background: var(--card); border: 2px dashed var(--gold); border-radius: 12px; padding: 8px 8px 8px 16px; font: 700 18px ui-monospace, Consolas, monospace; letter-spacing: .06em; }
.gained { display: inline-block; background: var(--tint-green); color: var(--green); font-weight: 700; padding: 3px 10px; border-radius: 99px; font-size: 13px; margin-top: 12px; }

/* ---------- Classement ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow-sm); }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: end; margin-bottom: 18px; }
.podium .p { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 16px 10px; text-align: center; box-shadow: var(--shadow-sm); }
.podium .p img { width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--card); box-shadow: var(--shadow-sm); background: var(--card2); }
.podium .p.first { padding-top: 24px; background: var(--tint-gold); }
.podium .medal { font-size: 26px; display: block; }
.podium .name { font-weight: 700; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .pts { font-family: Fredoka, sans-serif; font-size: 20px; color: var(--primary); }
:root[data-theme="dark"] .podium .pts { color: #6bb8cc; }
.rank-row { display: grid; grid-template-columns: 44px 36px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row.me { background: var(--tint); border-radius: 12px; }
.rank-row .r { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 18px; text-align: center; color: var(--muted); }
.rank-row img { width: 36px; height: 36px; border-radius: 50%; background: var(--card2); }
.rank-row .pts { font-weight: 700; }
@media (max-width: 560px) { .podium { grid-template-columns: 1fr; } }

/* ---------- Notifications ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(400px, calc(100vw - 32px)); }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--teal); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-weight: 600; animation: pop .3s; }
.toast.err { border-left-color: var(--red2); }
.toast.ok { border-left-color: var(--green); }

/* ---------- Confettis ---------- */
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 200; pointer-events: none; animation: confetti 1.8s ease-in forwards; }
@keyframes confetti { to { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); opacity: .9; } }

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .brand-name { font-size: 18px; }
  .seg-nav { order: 3; width: 100%; }
  .seg-nav button { flex: 1; }
  .tools { margin-left: auto; }
  #page { padding: 16px 12px 32px; }
}
