/* Calendrier de résidence — feuille de style unique.
   Reprise de la maquette Claude Design « Copalendar » (canvas 1a → 1f).
   Trois écarts assumés par rapport à la maquette :
   — les polices sont auto-hébergées et sous-ensemble latin, aucune ressource
     distante n'est admise ; Material Symbols est remplacé par trois SVG inline ;
   — le gris des jours hors du mois est assombri (0.62 → 0.55) pour tenir
     4.5:1, l'écran se lit au soleil ;
   — les actions inventées par la maquette (« Attribuer ce jour », « Préciser la
     règle », « Modifier ce jour ») sont remplacées par les seules actions que
     le serveur expose réellement : la configuration est en lecture seule. */

@font-face {
  font-family: "Figtree";
  src: url("figtree.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("ibm-plex-mono.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Surfaces et encre — 1f « Surfaces et encre ». */
  --surface: oklch(0.985 0.004 80);
  --container: oklch(0.955 0.006 80);
  --outline: oklch(0.88 0.008 70);
  --outline-strong: oklch(0.50 0.01 70);
  --ink: oklch(0.18 0.01 60);
  --ink-2: oklch(0.35 0.01 60);
  --ink-3: oklch(0.45 0.01 60);
  --muted: oklch(0.55 0.01 70);

  /* États de jour — 1f « États de jour ». Même chroma perçu pour les deux
     parents : aucun n'est « le principal ». */
  --a: oklch(0.42 0.10 155);
  --b: oklch(0.50 0.13 50);
  --a-soft: oklch(0.88 0.03 155);
  --a-deep: oklch(0.25 0.08 155);
  --hatch: repeating-linear-gradient(135deg, oklch(0.30 0 0) 0 3px, oklch(0.50 0 0) 3px 6px);

  --tap: 46px;
  --pad: 20px;
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

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

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* ---- échelle typographique (1f) ----------------------------------------- */

.display   { font-size: 56px; line-height: 1; font-weight: 600; letter-spacing: -.03em; }
.display-m { font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; }
.title     { font-size: 22px; line-height: 1.2; font-weight: 600; }
.label     { font-size: 13px; line-height: 1.25; font-weight: 600; letter-spacing: .08em;
             text-transform: uppercase; color: var(--ink-3); }
.mono      { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.dim       { color: var(--ink-2); }
.dimmer    { color: var(--ink-3); }

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

#app { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#view-today, #view-vacations { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.vhead { flex: none; padding: 10px var(--pad) 0; display: flex; flex-direction: column; gap: 2px; }
.vfoot { flex: none; margin: 12px var(--pad) 8px; padding-top: 12px; border-top: 1px solid var(--outline);
         display: flex; flex-direction: column; gap: 6px; }

/* ---- 1a · calendrier ---------------------------------------------------- */

/* Le mois courant est encadré par les deux mois voisins : le libellé est
   l'affordance de navigation, comme dans la maquette. Le glissement fait la
   même chose. */
.months { display: flex; gap: 6px; align-items: baseline; font-size: 13px;
          font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.mlink { color: var(--ink-3); min-height: 30px; padding: 0 2px; }
.mcur { color: var(--ink); }
.mlink:first-child::after { content: " ·"; }
.mlink:last-child::before { content: "· "; }

.key { flex: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 14px var(--pad) 0;
       font-size: 13px; font-weight: 500; color: var(--ink-2); }
.key span { display: flex; gap: 6px; align-items: center; }
.key i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.key i.k-a { background: var(--a); }
.key i.k-b { background: var(--b); }
.key i.k-i { background: var(--hatch); }
.key i.k-n { box-shadow: inset 0 0 0 1.5px var(--outline-strong); }

.grid-head { flex: none; display: grid; grid-template-columns: repeat(7, 1fr);
             padding: 16px 12px 0; text-align: center;
             font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--ink-3); }

.grid { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 12px 0;
        display: flex; flex-direction: column; touch-action: pan-y; }
.wrow { flex: 1 1 0; min-height: 56px; display: grid; grid-template-columns: repeat(7, 1fr); align-items: center; }
.cellbox { height: 52px; }

.cell {
  position: relative; width: 100%; height: 52px;
  border: 1.5px solid transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.cell.s-a { background: var(--a); color: #fff; }
.cell.s-b { background: var(--b); color: #fff; }
.cell.s-i { background: var(--hatch); color: #fff; font-weight: 600; }
.cell.s-n { color: var(--ink); border-color: var(--outline-strong); }
.cell.s-o { color: var(--muted); font-weight: 400; cursor: default; }
.cell.today { outline: 2px solid var(--ink); outline-offset: 2px; z-index: 1; }

.cell .ferie { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%);
               width: 14px; height: 2px; background: currentColor; }
.cell .note { position: absolute; top: 7px; right: 9px; width: 5px; height: 5px;
              border-radius: 50%; background: currentColor; }

.tally { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; font-variant-numeric: tabular-nums; }
.tally b { font-weight: 600; }
.tally b.t-a { color: var(--a); }
.tally b.t-b { color: var(--b); }

.marks { display: flex; gap: 14px; font-size: 13px; color: var(--ink-3); }
.marks span { display: flex; gap: 6px; align-items: center; }
.marks i.m-ferie { width: 12px; height: 2px; background: var(--ink-2); }
.marks i.m-note { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-2); }

/* ---- 1c / 1d · aujourd'hui ---------------------------------------------- */

.hero { flex: none; padding: 24px var(--pad) 0; display: flex; flex-direction: column; gap: 10px; }
.hero .display .who-a { color: var(--a); }
.hero .display .who-b { color: var(--b); }
.hero .display .who-n { color: oklch(0.30 0 0); }

.hatchtag { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: oklch(0.30 0 0); }
.hatchtag i { width: 14px; height: 14px; border-radius: 4px; background: var(--hatch); flex: none; }

/* Les avertissements sont dans le flux, jamais derrière un tap : la
   spécification l'impose. */
.callout { background: var(--container); border-radius: 8px; padding: 16px 18px;
           display: flex; flex-direction: column; gap: 10px; }
.callout p { font-size: 15px; line-height: 1.4; }
.callout .label { color: var(--ink-3); }
.callout + .callout { margin-top: 8px; }

.block { margin: 0 var(--pad); padding-top: 16px; border-top: 1px solid var(--outline);
         display: flex; flex-direction: column; gap: 6px; }
.block.plain { border-top: 0; padding-top: 0; }
.spaced { margin-top: 24px; }

.deadline { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.deadline .mono { flex: none; white-space: nowrap; font-size: 22px; }

.days { display: flex; flex-direction: column; }
.days .drow { display: grid; grid-template-columns: 14px 1fr auto; gap: 16px; align-items: center; height: 44px; }
.days .drow i { width: 14px; height: 44px; flex: none; }
.days .drow i.s-a { background: var(--a); }
.days .drow i.s-b { background: var(--b); }
.days .drow i.s-i { background: var(--hatch); }
.days .drow i.s-n { box-shadow: inset 0 0 0 1.5px var(--outline-strong); }
.days .drow .when { font-size: 16px; font-variant-numeric: tabular-nums; }
.days .drow .when b { font-weight: 600; display: inline-block; width: 44px; }
.days .drow .who { font-size: 15px; font-weight: 600; }
.days .drow .who.s-a { color: var(--a); }
.days .drow .who.s-b { color: var(--b); }
.days .drow .who.s-i, .days .drow .who.s-n { color: oklch(0.30 0 0); }

/* ---- 1e · vacances ------------------------------------------------------ */

.vac { padding: 14px var(--pad); border-top: 1px solid var(--outline);
       display: flex; flex-direction: column; gap: 8px; }
.vac-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.vac-h .title { line-height: 1.2; font-size: 20px; }
.vac-n { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.vac .dates { font-size: 14px; color: var(--ink-2); }
.bar { display: flex; height: 12px; gap: 2px; border-radius: 4px; overflow: hidden; }
.bar.void { box-shadow: inset 0 0 0 1.5px var(--outline-strong); }
.bar i.s-a { background: var(--a); }
.bar i.s-b { background: var(--b); }
.bar i.s-i { background: var(--hatch); }
.split { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.split .p-a { color: var(--a); font-weight: 600; }
.split .p-b { color: var(--b); font-weight: 600; }
.split .p-m { color: var(--ink-2); text-align: center; }
.swap { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.3; }
.swap svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--ink-3); }

.chip { display: inline-flex; align-items: center; font-size: 13px; font-weight: 600;
        padding: 3px 10px; border-radius: 20px; box-shadow: inset 0 0 0 1px var(--outline-strong);
        color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- actions ------------------------------------------------------------ */

.act { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
       min-height: var(--tap); padding: 0 20px; border-radius: 22px;
       font-size: 14px; font-weight: 600; text-decoration: none; }
.act.filled { background: var(--ink); color: var(--surface); }
.act.outlined { box-shadow: inset 0 0 0 1px var(--outline-strong); color: var(--ink); }
.act.text { color: var(--ink-2); padding: 0 8px; }
.act:disabled { opacity: .45; cursor: default; }
.act.wide { width: 100%; }
.row-act { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---- barre de navigation ------------------------------------------------ */

.nav {
  flex: none; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--container);
  padding: 10px 8px calc(14px + env(safe-area-inset-bottom));
  max-width: 430px; margin: 0 auto; width: 100%;
}
.nav-i { display: flex; flex-direction: column; align-items: center; gap: 4px;
         font-size: 12px; font-weight: 500; color: var(--ink-2); min-height: var(--tap); }
.nav-i .ico { display: flex; align-items: center; justify-content: center;
              padding: 4px 20px; border-radius: 16px; }
.nav-i svg { width: 24px; height: 24px; fill: none; stroke: currentColor;
             stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-i[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.nav-i[aria-selected="true"] .ico { background: var(--a-soft); color: var(--a-deep); }
.nav-i[aria-selected="true"] svg { stroke-width: 2; }

/* ---- 1b · panneau de détail --------------------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; }
.scrim { position: absolute; inset: 0; background: oklch(0.18 0.01 60 / .32); }
.sheet-in {
  position: relative; width: 100%; max-width: 430px; margin: 0 auto;
  max-height: 88dvh; overflow-y: auto; background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 10px 24px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
#sheet-body { display: flex; flex-direction: column; gap: 22px; }
/* La poignée est le bouton de fermeture : cible de 44 px, trait de 4 px. */
.grip { align-self: center; flex: none; width: 88px; height: 24px; display: flex;
        align-items: center; justify-content: center; }
.grip::before { content: ""; width: 32px; height: 4px; border-radius: 2px; background: oklch(0.75 0.01 70); }
.sheet-h { display: flex; flex-direction: column; gap: 6px; }
.sheet-who { display: flex; align-items: center; gap: 12px; }
.sheet-who i { width: 18px; height: 18px; border-radius: 5px; flex: none; }
.sheet-who i.s-a { background: var(--a); }
.sheet-who i.s-b { background: var(--b); }
.sheet-who i.s-i { background: var(--hatch); }
.sheet-who i.s-n { box-shadow: inset 0 0 0 1.5px var(--outline-strong); }
.sheet-who span { font-size: 32px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; }

.facts { display: grid; grid-template-columns: 96px 1fr; row-gap: 16px; column-gap: 16px;
         font-size: 15px; line-height: 1.4; }
.facts dt { color: var(--ink-3); font-weight: 500; }
.facts dd { margin: 0; }
.facts dd b { font-weight: 600; font-variant-numeric: tabular-nums; }
.facts dd small { display: block; font-size: 15px; color: var(--ink-2); }

.field { width: 100%; border: 1px solid var(--outline-strong); border-radius: 6px;
         padding: 12px 14px; min-height: 76px; font: 400 15px/1.45 var(--sans);
         color: var(--ink); background: var(--surface); resize: vertical; }
.field:focus-visible { outline: 2px solid var(--a); outline-offset: 1px; }
.readonly { border: 1px solid var(--outline); border-radius: 6px; padding: 12px 14px;
            min-height: 76px; font-size: 15px; line-height: 1.45; color: var(--ink-2); }

.alt2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.alt2 .alt { box-shadow: inset 0 0 0 1.5px var(--outline-strong); border-radius: 8px; padding: 12px; }
.alt2 .alt h4 { font-size: 13px; font-weight: 600; letter-spacing: .04em; margin-bottom: 8px; }
.alt2 .alt div { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 2px 0; }
.alt2 .alt i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.alt2 .alt i.s-a { background: var(--a); }
.alt2 .alt i.s-b { background: var(--b); }
.alt2 .alt i.s-i { background: var(--hatch); }

/* ---- divers ------------------------------------------------------------- */

.toast {
  position: fixed; left: 20px; right: 20px; bottom: 108px; z-index: 80;
  max-width: 390px; margin: 0 auto;
  padding: 13px 16px; border-radius: 8px;
  background: var(--ink); color: var(--surface); font-size: 14px; font-weight: 500;
}

.empty { padding: 32px var(--pad); color: var(--ink-2); font-size: 15px; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
