/* ---------- Identité Deyrolle (reprise de deyrolle.com) ---------- */
@font-face { font-family: Deyrolle; src: url(brand/DEYROLLE-BoldCaps.otf) format("opentype"); font-display: swap; }
@font-face { font-family: Venturis; src: url(brand/VenturisADF-Regular.otf) format("opentype"); font-display: swap; }
@font-face { font-family: Venturis; src: url(brand/VenturisADF-Bold.otf) format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: Venturis; src: url(brand/VenturisADF-Italic.otf) format("opentype"); font-style: italic; font-display: swap; }

:root {
  --mint: #b8e2dc;
  --mint-dark: #9bc4bd;
  --navy: #182438;
  --cream: #f4f1eb;

  --ink: #121212;
  --muted: #55534f;
  --ground: var(--cream);
  --surface: #ffffff;
  --line: #d9d3c7;
  --weekend: #ebe6da;
  --brand: var(--navy);
  --brand-ink: #ffffff;
  --focus: #564987;

  /* Code couleur du planning */
  --status-taxidermie: #7a4a21;
  --status-lpj: #2b7a4b;
  --status-entomo: #f2c94c;
  --status-conge: #2a68ad;
  --status-inventaire: #c9a9ee;
  --status-autre: #b23a2e;

  --text: Venturis, "Times New Roman", serif;
  --title: Deyrolle, Venturis, "Times New Roman", serif;
}

.status-taxidermie   { --status: var(--status-taxidermie);   --status-ink: #fff; }
.status-lpj          { --status: var(--status-lpj);          --status-ink: #fff; }
.status-entomo       { --status: var(--status-entomo);       --status-ink: #2b1f00; }
.status-conge        { --status: var(--status-conge);        --status-ink: #fff; }
.status-inventaire   { --status: var(--status-inventaire);   --status-ink: #2a1245; }
.status-autre        { --status: var(--status-autre);        --status-ink: #fff; }
/* Une forme par statut, partout où il apparaît : aide aussi à les distinguer sans la couleur. */
.status-taxidermie, .status-lpj, .status-entomo { border-radius: 999px; } /* galet : présent dans une zone */
.status-conge        { border-radius: 14px 3px 14px 3px; }  /* feuille */
.status-inventaire   { border-radius: 14px 14px 4px 4px; }  /* cloche de verre */
.status-autre        { border-radius: 5px; }                /* étiquette */
[class*="status-"]:not(body) { background: var(--status); color: var(--status-ink); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 17px/1.5 var(--text); letter-spacing: 0.03em; }
h1, h2 { margin: 0; line-height: 1.2; text-wrap: balance; }
/* La police Deyrolle dessine les minuscules en capitales, accents compris. */
h1 { font: 400 2rem/1.15 var(--title); text-transform: lowercase; }
h2 { font-size: 1.25rem; font-weight: 700; }
h1 small { font: italic 1rem var(--text); color: var(--muted); }
a { color: var(--brand); }
small { font-size: 0.8125rem; }
.muted { color: var(--muted); font-size: 0.875rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

main { max-width: 1000px; margin: 0 auto; padding: 24px 16px 48px; }
main.wide { max-width: 1500px; }
main.narrow { max-width: 560px; }
main.narrow h1 { margin-bottom: 20px; }

/* ---------- Bandeau ---------- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px 20px; padding: 10px 24px; border-top: 5px solid var(--mint-dark); border-bottom: 3px solid var(--mint-dark); background: var(--mint); }
.topbar a, .topbar .link { color: var(--ink); text-decoration: none; }
.topbar a:hover, .topbar .link:hover { text-decoration: underline; }
.app-name { font-style: italic; }
.logo img { display: block; width: 190px; height: auto; }
.account { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; gap: 2px 20px; }
.mainnav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 36px; padding: 0 16px; background: var(--navy); }
.mainnav a { padding: 9px 0 6px; border-bottom: 3px solid transparent; color: #fff; text-decoration: none; letter-spacing: 0.06em; }
.mainnav a:hover, .mainnav a[aria-current] { border-bottom-color: var(--mint); }
.mainnav a:focus-visible { outline-color: var(--mint); outline-offset: -3px; }

/* ---------- Boutons et formulaires ---------- */
.button { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 16px; border: 1px solid var(--brand); background: var(--surface); color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
button, input, select { letter-spacing: inherit; }
.button, input:not([type=checkbox], [type=radio]), select, fieldset, .menu div { border-radius: 10px; }
.button { transition: transform 0.15s, background-color 0.15s, box-shadow 0.15s; }
.button:hover { background: var(--mint); transform: translateY(-2px); box-shadow: 0 3px 0 rgb(24 36 56 / 0.18); }
.button:active { transform: none; box-shadow: none; }
.button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.button.primary:hover { background: #2b3c5a; border-color: #2b3c5a; }
.link { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; text-decoration: underline; cursor: pointer; }
.danger { border-color: #8c2319; color: #8c2319; }
.button.danger:hover { background: #8c2319; color: #fff; }
.stack { display: grid; gap: 18px; }
.stack .button.primary { justify-self: start; }
.stack label:not(.check) { display: grid; gap: 4px; font-weight: 700; }
input:not([type=checkbox], [type=radio]), select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid #8a9992; background: var(--surface); color: var(--ink); font: inherit; font-weight: 400; }
fieldset { margin: 0; padding: 12px 16px; border: 1px solid var(--line); background: var(--surface); }
/* float : garde le titre à l'intérieur du cadre. */
legend { float: left; width: 100%; margin-bottom: 6px; padding: 0; font-weight: 700; }
legend + * { clear: both; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
.check { display: flex; align-items: baseline; gap: 10px; padding: 5px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.separate { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.flash { margin: 0 0 20px; padding: 10px 14px; border: 1px solid; background: var(--surface); }
.flash.error { border-color: #b23a2e; color: #8c2319; }
.flash.success { border-color: var(--status-lpj); }
.credentials { padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.credentials dt { color: var(--muted); font-size: 0.875rem; }
.credentials dd { margin: 0 0 10px; overflow-wrap: anywhere; }
.credentials code { font-size: 1.25rem; }

/* ---------- Connexion ---------- */
.login-page { display: grid; align-items: center; min-height: 100vh; padding: 24px 16px; background: linear-gradient(rgb(12 18 28 / 0.45), rgb(12 18 28 / 0.45)), #3a2415 url(brand/boutique.jpg) center / cover; }
main.login { width: 100%; max-width: 420px; padding: 0 32px 28px; background: var(--cream); }
.login-logo { margin: 0 -32px 28px; padding: 22px 32px; border-top: 5px solid var(--mint-dark); border-bottom: 3px solid var(--mint-dark); background: var(--mint); }
.login-logo img { display: block; width: 240px; max-width: 100%; height: auto; margin: 0 auto; }
.login h1 { margin-bottom: 20px; font-size: 1.5rem; text-align: center; }
.login .button.primary { justify-self: stretch; justify-content: center; }

/* ---------- Listes ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.cards { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cards li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); }
.cards li :last-child:not(:first-child, .muted) { margin-left: auto; }
.list { width: 100%; border-collapse: collapse; background: var(--surface); }
.list th, .list td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.list td.actions { display: table-cell; }
.list td.actions > * { display: inline-block; margin-right: 14px; }
.inactive td:not(.actions) { color: var(--muted); }

/* ---------- Navigation par mois, légende, palette ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h2 { min-width: 9.5em; text-align: center; }
.view-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; margin-bottom: 20px; }
.view-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.view-form label { display: flex; align-items: center; gap: 8px; }
.view-form input, .view-form select { width: auto; min-height: 40px; padding: 4px 8px; }
.view-form input[type=number] { width: 4.5em; }
.date-field { position: relative; display: inline-flex; gap: 4px; }
.date-field input { width: 7.5em; }
.date-field .button { padding: 4px 10px; }
/* Invisible : ne sert qu'à ancrer le calendrier du navigateur. */
.date-field input[type=date] { position: absolute; inset: 0; width: 100%; opacity: 0; pointer-events: none; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: "▾"; margin-left: 8px; }
.menu div { position: absolute; right: 0; z-index: 5; min-width: 100%; border: 1px solid var(--brand); background: var(--surface); }
.menu div a { display: block; padding: 10px 16px; color: var(--ink); text-decoration: none; }
.menu div a:hover, .menu div a:focus-visible { background: var(--mint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0 0 16px; padding: 0; list-style: none; }
.chip { display: inline-block; min-width: 34px; padding: 3px 5px; border: 1px solid transparent; font-size: 0.75rem; font-weight: 700; text-align: center; }
.palette { display: flex; clear: both; flex-wrap: wrap; gap: 6px 10px; }
.palette label { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border: 2px solid transparent; cursor: pointer; }
.palette label:has(:checked) { border-color: var(--brand); background: var(--mint); }
.palette input { margin: 0; }
.palette label { border-radius: 10px; transition: background-color 0.15s; }
.palette .chip { transition: transform 0.2s; }
.palette label:hover .chip { transform: rotate(-5deg); }
.palette label:has(:checked) .chip { transform: scale(1.12); }
.palette label .chip:not([class*="status-"]) { border-color: var(--line); border-radius: 8px; }
.save-state { min-height: 1.5em; margin: 6px 0; color: var(--muted); font-size: 0.875rem; }
/* Un papillon bat des ailes quand c'est enregistré. */
.save-state.saved::after { content: ""; display: inline-block; width: 22px; height: 18px; margin-left: 8px; vertical-align: -4px; background: url(papillon.svg) center / contain no-repeat; animation: flutter 0.28s ease-in-out 4 alternate; }
@keyframes flutter { to { transform: scaleX(0.3) translateY(-3px); } }
.save-state.error { color: #8c2319; font-weight: 700; }

/* ---------- Grille mensuelle (admin, directeur) ---------- */
.grid-scroll { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.grid th, .grid td { min-width: 38px; padding: 2px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); text-align: center; }
.grid th { font-weight: 700; font-size: 0.875rem; }
.grid th small { display: block; color: var(--muted); font-weight: 400; }
.grid .name { position: sticky; left: 0; z-index: 1; min-width: 150px; max-width: 200px; padding: 4px 12px; border-left: 0; background: var(--surface); text-align: left; overflow-wrap: anywhere; }
.grid .name a { color: inherit; text-decoration: none; }
.grid .name a:hover { text-decoration: underline; }
.grid .months th { padding: 4px 8px; text-align: left; }
.grid .months span { position: sticky; left: 160px; }
.grid.roomy th:not(.name), .grid.roomy td { min-width: 92px; }
.grid .weekend { background: var(--weekend); }
.grid th.today { background: var(--brand); color: var(--brand-ink); }
.grid th.today small { color: inherit; }
.grid tbody tr:hover .name { background: var(--ground); }
.grid tfoot td, .grid tfoot th { color: var(--muted); font-size: 0.875rem; }
.grid tfoot tr:last-child > * { border-bottom: 0; }
.grid tfoot .total > * { color: var(--ink); font-weight: 700; }

.dot { display: inline-block; width: 11px; height: 11px; margin-right: 8px; }
/* Repère d'un changement exceptionnel de zone. */
.moved::after { content: ""; position: absolute; top: -1px; right: -1px; width: 11px; height: 11px; border: 2px solid var(--surface); border-radius: 50%; background: var(--focus); }
.badge.moved { position: relative; }

/* ---------- Emploi du temps de base (fiche utilisateur) ---------- */
.schedule > * + * { margin-top: 14px; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; }
.stack .weekdays label { display: block; font-weight: 400; cursor: pointer; }
.weekdays input { position: absolute; opacity: 0; }
.weekdays span { display: block; min-width: 52px; padding: 8px 6px; border: 1px solid #8a9992; border-radius: 10px; text-align: center; transition: background-color 0.15s; }
.weekdays span:hover { background: var(--ground); }
.weekdays input:checked + span { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.weekdays input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.since { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.stack .since label { display: inline; }

/* ---------- Écarts (notes du jour) ---------- */
.note { display: flex; align-items: center; justify-content: center; width: 100%; height: 34px; padding: 0; border: 0; background: transparent; color: var(--ink); font: 700 0.875rem var(--text); }
.note:not([data-note=""]) { background: var(--mint); }
.note:not([data-note=""])::before { content: "✎"; }
button.note { cursor: pointer; }
.note { border-radius: 10px; }
.note::before { transition: transform 0.2s; }
button.note:hover { box-shadow: inset 0 0 0 2px var(--mint-dark); }
button.note:hover::before { transform: rotate(-15deg) scale(1.25); }
button.note[data-note=""]:is(:hover, :focus-visible)::before { content: "+"; }
.notes { margin-top: 24px; }
.notes ul { margin: 8px 0 0; padding: 0; list-style: none; }
.notes li { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.notes strong { display: inline-block; min-width: 12em; }
dialog { width: min(480px, calc(100vw - 32px)); padding: 24px; border: 0; border-top: 5px solid var(--mint-dark); background: var(--cream); color: var(--ink); }
dialog::backdrop { background: rgb(12 18 28 / 0.55); }
dialog .save-state { margin: 0; }
dialog .save-state:empty { display: none; }
[hidden] { display: none !important; }
.cell { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 36px; padding: 0; border: 0; font: 700 0.75rem var(--text); }
.cell:not([class*="status-"]) { background: transparent; }
/* Un long motif est raccourci et n'élargit pas la colonne ; un clic l'affiche en entier. */
.roomy .cell.status-autre { display: block; overflow: hidden; contain: inline-size; padding: 0 6px; line-height: 36px; text-overflow: ellipsis; white-space: nowrap; }
button.cell { cursor: pointer; user-select: none; }
button.cell { transition: transform 0.15s, box-shadow 0.15s; }
button.cell:hover { transform: translateY(-2px); box-shadow: 0 3px 5px rgb(24 36 56 / 0.3); }
button.cell:not([class*="status-"]):hover { transform: none; border-radius: 10px; box-shadow: inset 0 0 0 2px var(--mint-dark); }
button.cell:active { transform: scale(0.92); }

/* ---------- Calendrier personnel ---------- */
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--surface); }
.calendar th { padding: 8px 4px; color: var(--muted); font-size: 0.875rem; font-weight: 700; }
.calendar td { height: 92px; padding: 6px; border: 1px solid var(--line); vertical-align: top; }
.calendar .outside { background: var(--ground); }
.calendar .outside > :not([popover]) { opacity: 0.55; }
.calendar .date { display: inline-block; min-width: 26px; font-variant-numeric: tabular-nums; text-align: center; }
.calendar .date { border-radius: 8px; }
.calendar .today .date { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.badge { display: block; margin-top: 4px; padding: 4px 10px; font-size: 0.875rem; font-weight: 700; overflow-wrap: anywhere; }
.badge small { display: block; font-weight: 400; }
.badge .short { display: none; }
button.badge { width: 100%; border: 0; font: 700 0.875rem var(--text); text-align: left; cursor: pointer; }
.reason { max-width: min(420px, calc(100vw - 32px)); padding: 16px 20px; border: 0; border-top: 5px solid var(--mint-dark); background: var(--cream); color: var(--ink); box-shadow: 0 6px 24px rgb(24 36 56 / 0.35); text-align: left; overflow-wrap: anywhere; }
.reason p { margin: 6px 0 0; }

@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr; justify-items: center; padding: 10px 16px; }
  .app-name { display: none; }
  .account { justify-content: center; }
  .mainnav { gap: 0 24px; }
  .month-nav { flex-wrap: wrap; }
  .menu div { right: auto; left: 0; }
  .grid .months span { left: 118px; }
  .month-nav h2 { min-width: 7.5em; font-size: 1.125rem; }
  .calendar td { height: 64px; padding: 3px; }
  .badge { padding: 3px; font-size: 0.75rem; text-align: center; }
  .badge .short { display: inline; }
  /* Le libellé complet reste lu par les lecteurs d'écran. */
  .badge .long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .badge small { display: none; }
  .grid .name { min-width: 110px; max-width: 110px; padding: 4px 8px; }
}

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

@media print {
  .topbar, .mainnav, .view-bar, .palette, .save-state, .button { display: none; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .grid th, .grid td { min-width: 0; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
