/* Calendrier de l'avent LaboIT : Noël × terminal */
:root {
  --bg: #070b10;
  --bg2: #0b1118;
  --panel: #0e151e;
  --panel2: #121b26;
  --line: #1c2834;
  --line2: #2a3a4a;
  --fg: #d9e4ee;
  --dim: #6f8296;
  --green: #5af78e;
  --green-d: #1f8a4c;
  --red: #ff4d5e;
  --red-d: #8f1d2c;
  --gold: #ffcf5c;
  --ice: #8be9fd;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --pixel: 'VT323', var(--mono);
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 77, 94, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(90, 247, 142, .07), transparent 60%),
    var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
::selection { background: var(--green); color: var(--bg); }
a { color: var(--ice); text-underline-offset: 3px; }
a:hover { color: #fff; }
code { font-family: var(--mono); background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: .05em .35em; font-size: .92em; color: var(--gold); }
.dim { color: var(--dim); }
[hidden] { display: none !important; }

/* Fond animé */
#snow { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.crt {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.45));
  mix-blend-mode: overlay;
}

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px max(16px, calc((100vw - 1180px) / 2));
  background: rgba(7, 11, 16, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; color: var(--fg); font-weight: 800; letter-spacing: .02em; }
.brand .host { color: var(--green); }
.cursor { display: inline-block; margin-left: 2px; color: var(--green); animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#nav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; font-size: 14px; }
#nav a, .linkbtn { color: var(--dim); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 4px 0; }
#nav a:hover, .linkbtn:hover { color: var(--fg); }
#nav a.on { color: var(--gold); }
#nav .who { color: var(--green); }

main { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 16px 64px; outline: none; }
.boot { color: var(--dim); }
.foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap;
  padding: 18px max(16px, calc((100vw - 1180px) / 2));
  border-top: 1px solid var(--line); color: var(--fg); font-size: 13px;
}

/* Titres et textes communs */
.cmd { margin: 0 0 6px; color: var(--dim); font-size: 14px; }
.ps { color: var(--green); font-weight: 800; }
.h1 { font-family: var(--pixel); font-weight: 400; font-size: clamp(40px, 6vw, 64px); line-height: .95; margin: 0 0 10px; letter-spacing: .01em; }
.h2 { font-size: 15px; color: var(--gold); margin: 34px 0 12px; font-weight: 800; }
.lead { color: #b8c6d3; max-width: 68ch; margin: 0 0 14px; }
.hint { color: var(--dim); font-size: 13px; margin: 6px 0 0; }
.err { color: var(--red); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.back { display: inline-block; margin-bottom: 18px; color: var(--dim); text-decoration: none; }
.back:hover { color: var(--green); }
.page-head { margin-bottom: 26px; }

/* Héros */
.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 34px; }
.title {
  font-family: var(--pixel); font-weight: 400;
  font-size: clamp(54px, 9.5vw, 116px); line-height: .82; margin: 8px 0 18px;
  text-shadow: 0 0 22px rgba(217, 228, 238, .18);
  animation: flicker 6s infinite;
}
.title .accent { color: var(--red); text-shadow: 0 0 24px rgba(255, 77, 94, .55); }
@keyframes flicker { 0%, 96%, 100% { opacity: 1; } 97% { opacity: .82; } 98% { opacity: 1; } 99% { opacity: .9; } }
.status-line { font-size: 15px; color: var(--fg); margin: 16px 0 10px; min-height: 1.6em; }
.status-line b { color: var(--gold); font-weight: 600; }
.clock { color: var(--green); font-variant-numeric: tabular-nums; }
.progress { margin: 10px 0 0; color: var(--fg); }
.progress .bar { color: var(--green); letter-spacing: -.5px; }
.tree {
  margin: 0; justify-self: center;
  font: 20px/1.05 var(--mono); color: var(--green-d);
  text-shadow: 0 0 10px rgba(31, 138, 76, .35);
  user-select: none;
}
.tree .star { color: var(--gold); text-shadow: 0 0 16px var(--gold); animation: pulse 2.4s ease-in-out infinite; }
.tree .trunk { color: #8a5a2b; }
.tree .base { color: var(--dim); font-size: 14px; }
.tree i { font-style: normal; animation: twinkle 3s ease-in-out infinite; animation-delay: var(--d, 0s); }
.tree .l1 { color: var(--red); } .tree .l2 { color: var(--gold); } .tree .l3 { color: var(--ice); }
@keyframes twinkle { 0%, 100% { opacity: 1; text-shadow: 0 0 10px currentColor; } 50% { opacity: .25; text-shadow: none; } }
@keyframes pulse { 50% { opacity: .55; } }

/* Grille du calendrier */
.cal { display: grid; grid-template-columns: 38px repeat(5, minmax(0, 1fr)); gap: 12px; }
.cal-row { display: contents; }
.cal-head span { color: var(--dim); font-size: 13px; text-align: center; text-transform: uppercase; letter-spacing: .15em; }
.wk { color: var(--line2); font-size: 12px; writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; align-self: center; letter-spacing: .2em; }

.door {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  min-height: 158px; padding: 12px 14px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--fg); text-decoration: none; overflow: hidden;
  perspective: 900px;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.door .num { font-family: var(--pixel); font-size: 58px; line-height: .8; }
.door .mon { font-size: 12px; color: var(--dim); margin-left: 4px; }
.door .meta { font-size: 12px; color: var(--dim); }
.door .t { font-weight: 600; font-size: 14px; line-height: 1.35; }
.door .by { margin-top: auto; font-size: 12px; color: var(--dim); }
.door .ok { position: absolute; top: 12px; right: 12px; color: var(--green); font-size: 12px; font-weight: 800; }

.door.empty { background: transparent; border-style: dashed; border-color: rgba(28, 40, 52, .6); }
.door.empty .num { color: var(--line2); }
.door.locked {
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.018) 0 10px, transparent 10px 20px), var(--panel);
}
.door.locked .num { color: var(--line2); }
.door.locked .lock { margin-top: auto; font-size: 12px; color: var(--dim); }
.door.nochal { border-style: dashed; }
.door.nochal .num { color: var(--dim); }
.door.xmas { border-color: rgba(255, 77, 94, .35); background: linear-gradient(160deg, rgba(255,77,94,.12), transparent 60%), var(--panel); }
.door.xmas .num { color: var(--red); }

a.door:hover, a.door:focus-visible { border-color: var(--green); transform: translateY(-3px); box-shadow: 0 10px 30px -12px rgba(90, 247, 142, .35); outline: none; }
.door.solved { border-color: rgba(90, 247, 142, .45); background: linear-gradient(160deg, rgba(90,247,142,.08), transparent 55%), var(--panel); }
.door.solved .num { color: var(--green); }
.door.today { box-shadow: 0 0 0 1px var(--gold), 0 0 28px -6px rgba(255, 207, 92, .6); animation: glow 2.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 1px var(--gold), 0 0 10px -6px rgba(255, 207, 92, .3); } }

/* Porte fermée (case ouverte mais pas encore visitée) */
.door .panel {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: space-between; padding: 12px 14px 14px;
  background:
    linear-gradient(90deg, transparent calc(50% - 7px), var(--gold) calc(50% - 7px) calc(50% + 7px), transparent calc(50% + 7px)),
    linear-gradient(0deg, transparent calc(50% - 7px), var(--gold) calc(50% - 7px) calc(50% + 7px), transparent calc(50% + 7px)),
    repeating-linear-gradient(45deg, #a3192b 0 12px, #8f1d2c 12px 24px);
  border-radius: inherit;
  transform-origin: left center;
  transition: transform .55s cubic-bezier(.2, .8, .2, 1), opacity .55s;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.door .panel .num { color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.door .panel .cta { align-self: flex-start; white-space: nowrap; background: var(--bg); color: var(--gold); font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 4px; }
a.door:hover .panel, a.door:focus-visible .panel { transform: rotateY(-24deg); }
.door.opening .panel { transform: rotateY(-108deg); opacity: .2; }

/* Fenêtre terminal */
.term { background: rgba(14, 21, 30, .92); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: 0 30px 80px -40px rgba(0,0,0,.8); }
.term-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel2); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--dim); }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--red); }
.dots i:nth-child(2) { background: var(--gold); }
.dots i:nth-child(3) { background: var(--green); }
.term-body { padding: clamp(16px, 3vw, 30px); }

.day-title { font-family: var(--pixel); font-weight: 400; font-size: clamp(38px, 6vw, 62px); line-height: .95; margin: 6px 0 14px; }
.day-title .daynum { color: var(--red); margin-right: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px; }
.chips li { border: 1px solid var(--line2); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: #b8c6d3; }
.chips li.th { border-color: var(--green-d); color: var(--green); }

/* Contenu Markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3 { color: var(--gold); font-size: 16px; margin: 1.6em 0 .6em; }
.md h1::before { content: '# '; color: var(--dim); }
.md h2::before { content: '## '; color: var(--dim); }
.md h3::before { content: '### '; color: var(--dim); }
.md pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 14px; overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; color: var(--fg); }
.md blockquote { margin: 1em 0; padding: 4px 14px; border-left: 3px solid var(--gold); color: #b8c6d3; background: rgba(255, 207, 92, .05); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; }
.md img { max-width: 100%; border-radius: 6px; }
.md ul, .md ol { padding-left: 1.4em; }
.md li::marker { color: var(--green); }

.res { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.res a { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--fg); background: var(--bg2); transition: border-color .2s, background .2s; }
.res a:hover { border-color: var(--ice); background: rgba(139, 233, 253, .05); }
.res .arrow { color: var(--ice); }
.res .host { margin-left: auto; color: var(--dim); font-size: 12px; }

/* Validation du flag */
.flagbox { margin-top: 10px; }
.flagform { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; transition: border-color .2s; }
.flagform:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(90, 247, 142, .12); }
.flagform input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--fg); font: inherit; font-size: 16px; }
.flagform.ok { border-color: var(--green); }
.flagform.shake {animation: shake .4s; border-color: var(--red); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.flagmsg { min-height: 1.6em; margin: 10px 0 0; }
.granted { font-family: var(--pixel); font-size: 34px; line-height: 1; color: var(--green); text-shadow: 0 0 18px rgba(90, 247, 142, .6); margin: 0 0 10px; }
.denied { font-family: var(--pixel); font-size: 34px; line-height: 1; color: var(--red); text-shadow: 0 0 18px rgba(255, 77, 94, .5); }
.spark { position: fixed; z-index: 100; pointer-events: none; font-size: 18px; animation: spark 1s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }

.solution details { border: 1px dashed var(--line2); border-radius: 6px; padding: 12px 14px; }
.solution summary { cursor: pointer; color: var(--gold); }
.solution details[open] summary { margin-bottom: 14px; }

/* Formulaires */
.field { display: grid; gap: 6px; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend, .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); padding: 0; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 10px 12px; width: 100%; transition: border-color .2s, box-shadow .2s; }
textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(90, 247, 142, .12); }
.flagform input:focus { box-shadow: none; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 0 16px; }
.grid2 .wide { grid-column: 1 / -1; }
.stars-input { display: flex; gap: 8px; flex-wrap: wrap; }
.stars-input label { cursor: pointer; }
.stars-input input { position: absolute; opacity: 0; width: 1px; }
.stars-input span { display: inline-block; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 6px; color: var(--dim); }
.stars-input input:checked + span { border-color: var(--gold); color: var(--gold); }
.stars-input input:focus-visible + span { box-shadow: 0 0 0 3px rgba(255, 207, 92, .25); }

.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--green); color: var(--green); background: transparent; cursor: pointer; text-decoration: none; transition: background .15s, color .15s, transform .1s; white-space: nowrap; }
.btn:hover { background: var(--green); color: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--green); color: var(--bg); }
.btn.primary:hover { background: #8dffb0; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: var(--bg); }
.btn.ghost { border-color: var(--line2); color: var(--fg); }
.btn.ghost:hover { border-color: var(--fg); background: transparent; color: #fff; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.code { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.code span { font-family: var(--pixel); font-size: 54px; line-height: 1; width: 52px; padding: 8px 0 4px; text-align: center; color: var(--gold); background: var(--bg); border: 1px solid var(--gold); border-radius: 6px; text-shadow: 0 0 14px rgba(255, 207, 92, .5); }

/* Éditeur de défi */
.md-field textarea { min-height: 220px; }
.md-tabs { display: flex; align-items: center; gap: 6px; }
.md-tabs .lbl { margin-right: auto; }
.tab { font: inherit; font-size: 12px; background: none; border: 1px solid transparent; color: var(--dim); padding: 3px 10px; border-radius: 4px; cursor: pointer; }
.tab.on { border-color: var(--line2); color: var(--fg); }
.preview { min-height: 220px; padding: 14px; border: 1px dashed var(--line2); border-radius: 6px; background: var(--bg2); }
.res-rows { display: grid; gap: 8px; }
.res-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; }
.icon { font: inherit; background: none; border: 1px solid var(--line2); color: var(--dim); border-radius: 6px; width: 40px; cursor: pointer; }
.icon:hover { color: var(--red); border-color: var(--red); }
.adminbox { border: 1px solid rgba(255, 207, 92, .35); background: rgba(255, 207, 92, .04); border-radius: var(--radius); padding: 16px 16px 2px; margin-bottom: 24px; }
.adminbox .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.note { border-left: 3px solid var(--gold); padding: 6px 12px; background: rgba(255, 207, 92, .06); color: #e8dcc0; }

/* Cartes, badges, tableaux */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--fg); text-decoration: none; transition: border-color .2s; }
a.card:hover { border-color: var(--green); }
.card .t { font-weight: 600; }
.card .meta { font-size: 12px; color: var(--dim); }
.badge { display: inline-block; justify-self: start; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 4px; border: 1px solid currentColor; }
.badge.brouillon { color: var(--dim); }
.badge.soumis { color: var(--gold); }
.badge.valide { color: var(--green); }
.badge.refuse { color: var(--red); }
.badge.role-admin { color: var(--red); }
.badge.role-createur { color: var(--gold); }
.badge.role-apprenti { color: var(--ice); }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(14, 21, 30, .85); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; background: var(--panel2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
.tbl tbody tr:hover { background: rgba(255,255,255,.02); }
.tbl select { padding: 4px 8px; width: auto; }
.tbl .c { text-align: center; }
.tbl .yes { color: var(--green); font-weight: 800; }
.tbl .no { color: var(--line2); }
.tbl tfoot td { color: var(--gold); border-top: 1px solid var(--line2); }
.free { color: var(--dim); font-style: italic; }

.tabs { display: flex; gap: 6px; margin: 10px 0 22px; flex-wrap: wrap; }
.tabs button { font: inherit; background: none; border: 1px solid var(--line2); color: var(--dim); padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.tabs button[aria-selected="true"] { border-color: var(--gold); color: var(--gold); background: rgba(255, 207, 92, .06); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.kpi b { display: block; font-family: var(--pixel); font-weight: 400; font-size: 46px; line-height: 1; color: var(--green); }
.kpi span { font-size: 12px; color: var(--dim); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--dim); font-size: 14px; }
.check input { width: auto; accent-color: var(--gold); }

.empty-state { padding: 40px 20px; text-align: center; border: 1px dashed var(--line2); border-radius: var(--radius); color: var(--dim); }
.empty-state .big { font-family: var(--pixel); font-size: 48px; color: var(--red); display: block; line-height: 1; margin-bottom: 8px; }

/* Toast et dialogue */
#toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--green); color: var(--fg); font-size: 14px; transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: var(--red); }
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--gold); border-radius: 10px; padding: 24px; max-width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); }

/* Responsive */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .tree { display: none; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { position: static; }
  .cal { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cal-head, .wk, .door.empty { display: none; }
  .door { min-height: 132px; }
  .door .num { font-size: 48px; }
  .grid2, .adminbox .grid3 { grid-template-columns: 1fr; }
  .res-row { grid-template-columns: 1fr auto; }
  .res-row .r-label { grid-column: 1 / -1; }
  .code span { width: 42px; font-size: 44px; }
  .res .host { display: none; }
}

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