/* Répertoire — feuille de style unique.
 *
 * Direction : un carnet de recettes de famille dont les quantités sont la
 * matière vivante. Fraunces pour les titres, comme un vieux livre de cuisine ;
 * IBM Plex Mono pour les nombres, parce que l'app fait de l'arithmétique sur
 * la recette de ta grand-mère. Les ingrédients sont tenus en registre : les
 * quantités alignées à droite, les aliments à gauche.
 */

:root {
  --ink:        #14201c;
  --ink-soft:   #5a6b62;
  --paper:      #edf0e9;
  --card:       #fafbf7;
  --line:       #cfd8c9;
  --accent:     #2f5d4a;
  --accent-ink: #fafbf7;
  --amount:     #a06a07;
  --alert:      #9c3b2e;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --figure: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: 20px;
  --radius: 3px;
  --measure: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:        #e7ede5;
    --ink-soft:   #93a399;
    --paper:      #101714;
    --card:       #18221e;
    --line:       #2b3931;
    --accent:     #82b89a;
    --accent-ink: #0d1411;
    --amount:     #e2b75c;
    --alert:      #e08374;
  }
}

/* Le même jeu de jetons, hors de toute requête média : c'est ce qui permet
   de forcer le sombre alors que le système est en clair. Le sélecteur de
   thème écrit data-theme sur <html> ; sans JavaScript, l'app suit le
   système, ce qui est le bon défaut. */
:root[data-theme="dark"] {
  --ink:        #e7ede5;
  --ink-soft:   #93a399;
  --paper:      #101714;
  --card:       #18221e;
  --line:       #2b3931;
  --accent:     #82b89a;
  --accent-ink: #0d1411;
  --amount:     #e2b75c;
  --alert:      #e08374;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

/* --- charpente ------------------------------------------------------- */

.masthead { border-bottom: 1px solid var(--line); background: var(--card); }
.masthead .inner {
  max-width: var(--measure); margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex; align-items: baseline; gap: 20px;
}
.wordmark {
  font-family: var(--display);
  font-variation-settings: "opsz" 120;
  font-weight: 600; font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.masthead nav { margin-left: auto; display: flex; gap: 18px; align-items: baseline; }
.masthead nav a, .masthead nav button {
  font-size: 0.85rem; color: var(--ink-soft);
  background: none; border: none; padding: 0; cursor: pointer;
  text-decoration: none; font-family: var(--body);
  white-space: nowrap;
}
.masthead nav a:hover, .masthead nav button:hover { color: var(--accent); }
/* Le bouton n'existe que si le JavaScript tourne : sinon il ne ferait rien
   et l'app suit le système, ce qui est le bon défaut. */
.themetoggle { display: none; }
:root.js .themetoggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; border: 1px solid var(--line);
  border-radius: 50%; color: var(--ink-soft); cursor: pointer;
}
.themetoggle:hover { color: var(--accent); border-color: var(--accent); }
.themetoggle svg {
  width: 15px; height: 15px; display: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.themetoggle .moon { fill: currentColor; stroke: none; }

/* L'icône montre le thème vers lequel on va, jamais celui où l'on est. */
.themetoggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .themetoggle .moon { display: none; }
  :root:not([data-theme="light"]) .themetoggle .sun { display: block; }
}
:root[data-theme="dark"] .themetoggle .moon { display: none; }
:root[data-theme="dark"] .themetoggle .sun { display: block; }
:root[data-theme="light"] .themetoggle .moon { display: block; }
:root[data-theme="light"] .themetoggle .sun { display: none; }

@media (max-width: 620px) {
  .masthead .inner { flex-wrap: wrap; gap: 8px 14px; padding: 12px var(--gutter); }
  .masthead nav { margin-left: 0; width: 100%; gap: 14px; flex-wrap: wrap; }
  .masthead nav a, .masthead nav button { font-size: 0.78rem; }
}

main { max-width: var(--measure); margin: 0 auto; padding: 28px var(--gutter) 72px; }
/* Un calendrier de sept jours a besoin de plus que la largeur d'un texte. */
main.wide { max-width: 76rem; }

h1 {
  font-family: var(--display);
  font-variation-settings: "opsz" 144;
  font-weight: 600; font-size: clamp(1.7rem, 5vw, 2.3rem);
  line-height: 1.12; letter-spacing: -0.02em;
  margin: 0 0 6px; text-wrap: balance;
}

/* Une capitale d'imprimerie : l'intitulé de section, pas un titre. */
h2 {
  font-family: var(--body);
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-soft);
  margin: 34px 0 12px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}

a { color: var(--accent); text-underline-offset: 2px; }

.standfirst { color: var(--ink-soft); font-size: 0.92rem; margin: 0 0 22px; max-width: 34rem; }
.hint { color: var(--ink-soft); font-size: 0.82rem; margin: 6px 0 0; }
.empty { color: var(--ink-soft); padding: 44px 0; text-align: center; font-style: italic; }

/* --- le registre des quantités : l'élément signature ------------------ */

/* Une seule grille pour toute la liste : des grilles par ligne ne
   partagent pas leurs colonnes, et les quantités ne s'aligneraient pas. */
.ledger {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: max-content 1fr;
}
.ledger li { display: contents; }
/* Pas de column-gap : la gouttière couperait le filet entre les deux
   colonnes. L'écart vient du padding, le filet reste continu. */
.ledger li > * { padding: 9px 0; border-bottom: 1px solid var(--line); }
.ledger .food { padding-left: 18px; }
.ledger .amount {
  font-family: var(--figure);
  font-weight: 500; font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--amount); text-align: right;
  white-space: nowrap;
}
.ledger .amount.none { color: var(--ink-soft); opacity: 0.5; }
.ledger .food { min-width: 0; }
.ledger .food .note {
  display: block; color: var(--ink-soft); font-size: 0.78rem; font-style: italic;
}

@media (prefers-reduced-motion: no-preference) {
  .ledger .amount { animation: settle 420ms cubic-bezier(.2,.7,.3,1) backwards; }
  .ledger li:nth-child(1) .amount { animation-delay: 20ms; }
  .ledger li:nth-child(2) .amount { animation-delay: 45ms; }
  .ledger li:nth-child(3) .amount { animation-delay: 70ms; }
  .ledger li:nth-child(4) .amount { animation-delay: 95ms; }
  .ledger li:nth-child(5) .amount { animation-delay: 120ms; }
  .ledger li:nth-child(n+6) .amount { animation-delay: 145ms; }
}
@keyframes settle {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

/* --- le cadran des convives ------------------------------------------ */

.dial {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); overflow: hidden; margin: 2px 0 14px;
}
.dial a, .dial .value {
  display: flex; align-items: center; justify-content: center;
  padding: 7px 13px; text-decoration: none; color: var(--ink-soft);
  font-size: 0.95rem;
}
.dial a:hover { background: var(--accent); color: var(--accent-ink); }
.dial .value {
  font-family: var(--figure); font-weight: 500; color: var(--ink);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  min-width: 5.4rem; gap: 6px;
}
.dial .value small { font-family: var(--body); color: var(--ink-soft); font-size: 0.72rem; }
.dial a[aria-disabled="true"] { opacity: 0.32; pointer-events: none; }
.shortcuts { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 4px; }
.shortcuts a { margin-right: 14px; }

/* --- fiches du répertoire -------------------------------------------- */

.shelf { list-style: none; padding: 0; margin: 0; }
.shelf li { border-bottom: 1px solid var(--line); }
.shelf a {
  display: grid; grid-template-columns: 1fr max-content;
  gap: 4px 16px; align-items: baseline;
  padding: 14px 4px; text-decoration: none; color: var(--ink);
}
.shelf a:hover { background: var(--card); }
.shelf .title {
  font-family: var(--display); font-variation-settings: "opsz" 40;
  font-weight: 600; font-size: 1.08rem; letter-spacing: -0.01em;
}
.shelf .tally {
  font-family: var(--figure); font-size: 0.78rem;
  color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.shelf .under { grid-column: 1 / -1; color: var(--ink-soft); font-size: 0.82rem; }

/* --- étapes ----------------------------------------------------------- */

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li {
  counter-increment: step; position: relative;
  padding: 0 0 14px 2.4rem; margin-bottom: 2px;
}
.steps li::before {
  content: counter(step) ".";
  position: absolute; left: 0; top: 0.1rem;
  font-family: var(--figure); font-size: 0.78rem; font-weight: 500;
  color: var(--amount);
}

/* --- formulaires ------------------------------------------------------ */

label { display: block; margin: 16px 0 5px; font-size: 0.78rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
input, textarea, select {
  font: inherit; color: var(--ink); width: 100%;
  padding: 9px 11px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea { min-height: 170px; resize: vertical; line-height: 1.55; font-family: var(--figure); font-size: 0.88rem; }
input[type="number"] { font-family: var(--figure); font-variant-numeric: tabular-nums; }

button, .button {
  font: inherit; font-weight: 500; cursor: pointer;
  display: inline-block; width: auto; text-align: center; text-decoration: none;
  padding: 9px 18px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
}
button:hover, .button:hover { filter: brightness(1.08); }
button.quiet, .button.quiet {
  background: transparent; color: var(--ink-soft); border-color: var(--line);
}
button.danger { background: transparent; color: var(--alert); border-color: var(--line); }
button.danger:hover { background: var(--alert); color: var(--card); border-color: var(--alert); }

.actions { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 130px; }
.pair { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.pair input { flex: 1 1 8rem; min-width: 0; }
.pair button, .pair select { flex: 0 0 auto; width: auto; }

@media (max-width: 560px) {
  /* Cinq champs sur une ligne de téléphone ne sont plus des champs. */
  .pair.stack { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .pair.stack > :first-child, .pair.stack > button { grid-column: 1 / -1; }
  .pair.stack select, .pair.stack button { width: 100%; }
}

.alert {
  border-left: 3px solid var(--alert); background: var(--card);
  color: var(--alert); padding: 11px 14px; margin-bottom: 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

h3.part {
  font-family: var(--body); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--amount);
  margin: 20px 0 6px;
}
.ledger + h3.part { margin-top: 26px; }

/* --- relecture -------------------------------------------------------- */

.proof { list-style: none; padding: 0; margin: 0 0 10px; }
.proof li {
  padding: 10px 12px; margin: 0 -12px;
  border-left: 3px solid transparent; border-radius: var(--radius);
}
.proof li.doubt { border-left-color: var(--alert); background: var(--card); }
.proof li.part { border-left-color: var(--amount); margin-top: 14px; }
.proof li.part input {
  font-family: var(--body); font-weight: 600; letter-spacing: 0.04em;
}
.reading.part { color: var(--amount); font-style: italic; }
.proof input { font-family: var(--figure); font-size: 0.88rem; }
.reading {
  display: block; margin-top: 6px; font-size: 0.82rem; color: var(--ink-soft);
}
.reading b {
  font-family: var(--figure); font-weight: 500;
  color: var(--amount); font-variant-numeric: tabular-nums;
}
.reading i { font-style: italic; }
.reading.doubt { color: var(--alert); }
.reading.doubt b { color: var(--alert); }

/* --- qui mange -------------------------------------------------------- */

.table { list-style: none; padding: 0; margin: 0 0 22px; }
.table li {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.table .seat { flex: 1; min-width: 0; }
.table button { padding: 5px 11px; font-size: 0.8rem; }
.table .meals { display: flex; gap: 12px; align-items: center; }
.table .meals label {
  display: flex; align-items: center; gap: 5px; margin: 0;
  font-size: 0.78rem; text-transform: none; letter-spacing: 0;
  color: var(--ink-soft); cursor: pointer;
}
.table .meals input { width: auto; margin: 0; accent-color: var(--accent); }
.table .meals label:has(input:checked) { color: var(--accent); }
.table .meals select { font-size: 0.8rem; padding: 5px 9px; width: auto; }

.stock { list-style: none; padding: 0; margin: 0 0 24px; }
.stock li {
  display: grid; gap: 4px 12px; align-items: center;
  grid-template-columns: 1fr max-content max-content;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.stock .what { grid-column: 1 / -1; }
.stock .name { font-weight: 500; }
.stock .tally {
  font-family: var(--figure); font-size: 0.8rem; color: var(--amount);
  margin-left: 9px; font-variant-numeric: tabular-nums;
}
.stock .under { display: block; font-size: 0.76rem; color: var(--ink-soft); }
.stock .under .due { color: var(--amount); }
.stock select { width: auto; font-size: 0.8rem; padding: 6px 9px; }
.stock button { padding: 6px 12px; font-size: 0.8rem; }
.stock form { margin: 0; }

/* Une ligne de récurrent porte un bouton : trois colonnes, pas deux. Le
   formulaire est la cellule — en display:contents, c'est le bouton qui
   devient l'élément de grille et le filet disparaît. */
.ledger:has(.took) { grid-template-columns: max-content 1fr max-content; }
.ledger .took {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 9px 0 9px 14px; border-bottom: 1px solid var(--line); margin: 0;
}
.ledger .took button { padding: 5px 13px; font-size: 0.78rem; }

/* --- la semaine, en agenda -------------------------------------------- */
/*
 * Les jours en lignes, les repas en colonnes. Sept colonnes de jours
 * donneraient des noms de plats français sur quatre lignes : ici chaque
 * plat a la largeur de s'écrire.
 */

.agenda { margin-bottom: 10px; }

.head, .row {
  display: grid;
  grid-template-columns: 6.5rem repeat(var(--slots), 1fr);
  gap: 10px;
}
.head { padding-bottom: 6px; }
.slothead {
  font-family: var(--figure); font-size: 0.7rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-soft); padding-left: 2px;
}

.row { align-items: stretch; padding: 7px 0; border-top: 1px solid var(--line); }
.row:last-of-type { border-bottom: 1px solid var(--line); }
.row.weekend { background: color-mix(in srgb, var(--card) 70%, transparent); }

.daycell { align-self: center; padding-left: 2px; min-width: 0; }
.dayname {
  display: block; font-size: 0.74rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft);
}
.row.weekend .dayname { color: var(--accent); }
.daynum {
  font-family: var(--figure); font-size: 0.78rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.row.today .daynum { color: var(--amount); font-weight: 500; }

.cell {
  display: block; min-width: 0; text-decoration: none; color: var(--ink);
  padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card);
}
.cell:hover { border-color: var(--accent); }
.cell .slotmark { display: none; }
.cell .dish {
  display: block; font-family: var(--display);
  font-variation-settings: "opsz" 34; font-weight: 600;
  font-size: 0.97rem; line-height: 1.25; letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.cell .dish.empty {
  font-family: var(--body); font-weight: 400; font-size: 0.85rem;
  color: var(--ink-soft);
}
.cell .tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; margin-top: 5px;
}
.pips { display: inline-flex; gap: 2px; }
.pips i { width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.pips i.on { background: var(--amount); }
.cell .heads {
  font-family: var(--figure); font-size: 0.72rem; color: var(--ink-soft);
}
.cell .heads::before { content: "×"; }
.cell .asked { font-family: var(--figure); font-size: 0.7rem; color: var(--accent); }

@media (max-width: 700px) {
  /* Sur un téléphone, une journée est un bloc : le jour, puis ses repas. */
  .head { display: none; }
  .row { grid-template-columns: 1fr; gap: 7px; padding: 12px 0; }
  .daycell { display: flex; align-items: baseline; gap: 9px; }
  .dayname { display: inline; }
  .cell .slotmark {
    display: block; font-family: var(--figure); font-size: 0.68rem;
    color: var(--ink-soft); margin-bottom: 2px;
  }
}

/* --- un repas --------------------------------------------------------- */

.seats { list-style: none; padding: 0; margin: 0 0 6px;
  display: flex; flex-wrap: wrap; gap: 8px; }
.seats label {
  display: flex; align-items: center; gap: 7px; margin: 0;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--card); cursor: pointer;
  font-size: 0.9rem; text-transform: none; letter-spacing: 0; color: var(--ink);
}
.seats input { width: auto; margin: 0; accent-color: var(--accent); }
.seats label:has(input:checked) { border-color: var(--accent); color: var(--accent); }

.picks { list-style: none; padding: 0; margin: 0; }
.picks li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.picks label {
  display: flex; align-items: baseline; gap: 10px; margin: 0;
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.picks input { width: auto; margin: 0; accent-color: var(--accent); }
.pick-name {
  font-family: var(--display); font-variation-settings: "opsz" 40;
  font-weight: 600; font-size: 1.02rem; color: var(--ink);
}
.pick-why {
  display: block; margin-left: 26px; font-size: 0.8rem; color: var(--ink-soft);
}
.picks .chosen .pick-name { color: var(--accent); }

/* --- aversions -------------------------------------------------------- */

.table .seat { text-decoration: none; color: var(--ink); }
.table a.seat:hover { color: var(--accent); }
.level {
  font-family: var(--figure); font-size: 0.75rem;
  padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line);
  color: var(--ink-soft); white-space: nowrap;
}
.level.never { color: var(--alert); border-color: var(--alert); }
.pair select { flex: 0 0 auto; width: auto; }

.agenda .dish.beside {
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-soft);
}
.agenda .dish.beside::before { content: "+ "; opacity: 0.6; }
.seats.beside { max-height: 15rem; overflow-y: auto; }

/* --- partage ------------------------------------------------------- */
.agenda span.cell { cursor: default; }
.visibility { margin: 26px 0 0; }
.visibility .hint { margin: 0 0 8px; max-width: 34rem; }
.shelf .tally {
  font-family: var(--figure);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* --- comptes et foyers -------------------------------------------- */
.table .seat small {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-soft);
  font-weight: 400;
}
.table .tally {
  font-family: var(--figure);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.alert.keep { background: var(--card); border-color: var(--accent); color: var(--ink); }
.token {
  display: block;
  margin-top: 6px;
  font-family: var(--figure);
  font-size: 0.8rem;
  word-break: break-all;
  user-select: all;
}
.house {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 18px 4px;
  margin-bottom: 20px;
}
.house .pair { margin-bottom: 6px; }
.house .tally { display: block; margin: 0 0 8px; }
.house .table li:last-child > * { border-bottom: none; }
.house .vacant { color: var(--ink-soft); font-style: italic; }
/* Both slots keep their width whether or not the row shows a button, so
   the selects line up down the column. */
.table .roleset { flex: 0 0 9.5rem; margin: 0; }
.table .roleset select { width: 100%; font-size: 0.8rem; padding: 5px 9px; }
.table .pull { flex: 0 0 5.4rem; display: flex; justify-content: flex-end; }
.table .pull form { margin: 0; }
