/* KEEBOARD, proto : mise en page fonctionnelle et responsive, design à venir.
   Toutes les couleurs et tailles passent par les variables ci-dessous pour faciliter le futur habillage. */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1b1b1f;
  --muted: #62626b;
  --line: #e2e2dd;
  --primary: #2b3a67;
  --primary-text: #ffffff;
  --accent: #b4532a;
  --ok: #1f7a4d;
  --ok-bg: #e4f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf1d6;
  --bad: #a3262a;
  --bad-bg: #fbe4e4;
  --radius: 10px;
  --sidebar-w: 248px;
  --gutter: 16px;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--line); margin: .75rem 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; font-size: .85rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 40rem; }
.lead-sm { color: var(--muted); }
ul.plain { list-style: none; margin: 0 0 .75rem; padding: 0; }
ul.plain li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }

/* ---- Barre du haut ---- */
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { font-weight: 800; letter-spacing: .08em; text-decoration: none; color: var(--text); }
.brand-group { display: inline-flex; align-items: center; gap: .5rem; }
.badge-beta {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px;
  background: var(--warn-bg); border: 1px solid #ecd59a; color: var(--warn);
  font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.topbar-band { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-public { justify-content: space-between; }
.public-nav { display: flex; align-items: center; gap: 1rem; }

.burger { display: inline-flex; flex-direction: column; gap: 4px; padding: 10px; margin: -6px 0 -6px -10px; cursor: pointer; }
.burger span { display: block; width: 22px; height: 2px; background: var(--text); }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

/* ---- Structure : tiroir sur mobile, colonne fixe sur grand écran ---- */
.shell { flex: 1; display: block; }
.main { padding: var(--gutter); max-width: 1100px; width: 100%; margin: 0 auto; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(82vw, var(--sidebar-w)); z-index: 50;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 1rem; overflow-y: auto;
  transform: translateX(-100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
.nav-toggle:checked ~ .shell .sidebar { transform: none; }
.nav-toggle:checked ~ .shell .nav-backdrop { display: block; }
.nav-toggle:focus-visible ~ .topbar .burger { outline: 2px solid var(--primary); }

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .75rem; border-radius: 8px; text-decoration: none; color: var(--text);
  min-height: 44px;
}
.sidebar a:hover { background: var(--bg); }
.sidebar a[aria-current="page"] { background: var(--primary); color: var(--primary-text); }
.nav-band { font-weight: 700; margin: 0 .75rem .5rem; }
.nav-user { margin: 0 .75rem .5rem; color: var(--muted); }
.logout { margin-top: auto; padding-top: 1rem; }
.pill { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 .55rem; font-size: .8rem; font-weight: 700; }

@media (min-width: 900px) {
  .burger, .nav-backdrop { display: none !important; }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start; }
  .shell-public { display: block; }
  .sidebar { position: sticky; top: 53px; height: calc(100vh - 53px); transform: none; width: auto; z-index: 1; }
  .main { padding: 1.5rem 2rem; margin: 0; }
  .shell-public .main { margin: 0 auto; }
}

/* ---- Composants ---- */
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem var(--gutter); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .5rem; }
.page-head h1 { margin: 0; }
.rule { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: .6rem .9rem; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.narrow { max-width: 26rem; margin: 1rem auto; }
.narrow-left { max-width: 34rem; }
.hero { padding: 1.5rem 0 1rem; max-width: 46rem; }
.hero h1 { font-size: 2rem; }

.grid { display: grid; gap: var(--gutter); margin-bottom: var(--gutter); grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: var(--gutter); }
.grid > .card { margin-bottom: 0; }
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover { border-color: var(--primary); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gutter); margin-bottom: var(--gutter); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; text-align: center; text-decoration: none; color: var(--text); }
.stat strong { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-block { width: 100%; }
.link, .link-danger { background: none; border: 0; padding: .25rem 0; font: inherit; cursor: pointer; text-decoration: underline; color: var(--primary); }
.link-danger { color: var(--bad); }
form.inline { display: inline; }

.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; }
.form-inline { grid-template-columns: 1fr auto; align-items: end; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea {
  width: 100%; min-height: 44px; padding: .55rem .7rem; font: inherit; font-weight: 400;
  border: 1px solid #b9b9b2; border-radius: 8px; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.subhead { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.voices { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: 0; display: grid; gap: .5rem; }
.voices legend { font-weight: 600; padding: 0 .3rem; }
.form label.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400; min-height: 32px; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--primary); }
.copy-row { display: flex; gap: .5rem; margin-bottom: .75rem; }
.copy-row input { flex: 1; min-width: 0; }

.alert { border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: var(--gutter); border: 1px solid; }
.alert-success { background: var(--ok-bg); border-color: #b5dfc5; color: #14532f; }
.alert-info { background: #e8edf7; border-color: #c3cde6; color: #1f2c52; }
.alert-error { background: var(--bad-bg); border-color: #f0b8b9; color: #7a1a1d; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--bg); border: 1px solid var(--line); }
.badge-accent { background: #fbe9df; border-color: #efc8b3; color: #7a3413; }
.status-voting { background: var(--warn-bg); border-color: #ecd59a; color: var(--warn); }
.status-validated { background: var(--ok-bg); border-color: #b5dfc5; color: var(--ok); }
.status-rejected { background: var(--bad-bg); border-color: #f0b8b9; color: var(--bad); }
.todo { color: var(--accent); font-weight: 700; font-size: .85rem; }

/* ---- Tableaux ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { min-width: 9rem; }
.table .actions > * { margin-right: .75rem; }
tr:target { background: #fffbe8; }

@media (max-width: 719px) {
  .table.responsive thead { position: absolute; left: -9999px; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
  .table.responsive tr:last-child { border-bottom: 0; }
  .table.responsive td { border: 0; padding: .3rem 0; text-align: left; }
  .table.responsive td::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .table.responsive td.actions { display: flex; flex-wrap: wrap; gap: .25rem .9rem; padding-top: .5rem; }
  .table.responsive td.actions::before { content: none; }
  .table-wrap { border: 0; background: transparent; }
  .table.responsive tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; }
  .table.responsive tr:last-child { border-bottom: 1px solid var(--line); }
}

/* ---- Vote ---- */
.vote-form { display: flex; gap: .3rem; flex-wrap: nowrap; }
@media (max-width: 399px) { .vote-form { flex-wrap: wrap; } }
.score-btn {
  width: 42px; height: 44px; border-radius: 8px; cursor: pointer;
  border: 1px solid #b9b9b2; background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: 1.05rem;
}
.score-btn:hover { border-color: var(--primary); }
.score-final { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 44px; border-radius: 8px; background: var(--primary); color: var(--primary-text); font-weight: 700; font-size: 1.05rem; }
.score-btn.is-veto { border-color: var(--bad); color: var(--bad); }
.row-validated td, .row-rejected td { opacity: .92; }
.notes summary { cursor: pointer; color: var(--primary); font-size: .85rem; }
.notes ul { margin-top: .4rem; }

/* ---- Commentaires ---- */
.comments { list-style: none; margin: 0 0 1rem; padding: 0; }
.comments li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.comment-meta { margin: 0 0 .2rem; }

/* ---- Tutoriel d'accueil : fenêtre flottante, ne bloque pas la page ---- */
.tour {
  position: fixed; right: var(--gutter); bottom: var(--gutter); z-index: 30;
  width: min(25rem, calc(100vw - 2 * var(--gutter))); max-height: calc(100vh - 2 * var(--gutter)); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--primary); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 1rem 1.1rem;
}
.tour summary { display: flex; justify-content: space-between; gap: 1rem; cursor: pointer; list-style: none; font-size: .8rem; color: var(--muted); }
.tour summary::-webkit-details-marker { display: none; }
.tour summary::after { content: "Réduire"; text-decoration: underline; }
.tour details:not([open]) summary::after { content: "Afficher"; }
.tour details[open] summary { margin-bottom: .25rem; }
.tour h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.tour p { margin: 0 0 .6rem; }
.tour ul { margin: 0 0 .75rem; padding-left: 1.2rem; }
.tour li { margin-bottom: .3rem; }
.tour-note { background: var(--warn-bg); border-radius: 8px; padding: .5rem .7rem; }
.tour-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tour-bar { padding: .7rem .9rem; }
.tour-bar p { margin: 0 0 .5rem; }
@media (max-width: 719px) { .tour { left: var(--gutter); width: auto; max-height: 60vh; } }

@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
