/* ============ Police ============ */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url(../fonts/inter-latin.woff2) format('woff2');
}

/* ============ Jetons ============ */
/* Tailles de texte en rem : elles suivent le réglage de taille de police du téléphone */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-2xs: 0.625rem; /* 10px */
  --fs-xs: 0.6875rem; /* 11px */
  --fs-sm: 0.75rem; /* 12px */
  --fs: 0.8125rem; /* 13px */
  --fs-md: 0.875rem; /* 14px */
  --fs-lg: 1rem; /* 16px */
  --fs-xl: 1.125rem; /* 18px */
  --fs-2xl: 1.25rem; /* 20px */
  --title-fs: 1.5rem; /* 24px : titres des mois (en-tête et page) */

  --ink: #13161d;
  --ink-2: #4a5263;
  --ink-3: #8a93a6;
  --ink-4: #bcc3d0;
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #eceff5;
  --line: rgba(20, 30, 60, 0.07);
  --line-2: rgba(20, 30, 60, 0.13);
  --accent: #5b6bf5;
  --accent-2: #9aa5ff;
  --accent-soft: #eceeff;
  --danger: #e5484d;
  --danger-soft: #fdeeee;
  /* fond des jours fériés / vacances : modifiables dans les réglages */
  --ferie-bg: #ffe9df;
  --vac-bg: #e8efff;
  --empty-bg: #ffffff; /* zones du mois sans jour : modifiables dans les réglages */
  /* haut des dégradés (le bas = --ferie-bg, --vac-bg, --empty-bg) */
  --ferie-top: #ffffff;
  --vac-top: #ffffff;
  --empty-top: #ffffff;
  --ferie-ink: #c2552d;
  --vac-ink: #4659c8;

  --r-xs: 4px;
  --r-sm: 8px;
  --r: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --sh-1: 0 1px 2px rgba(17, 24, 52, 0.06), 0 1px 1px rgba(17, 24, 52, 0.03);
  --sh-2: 0 1px 2px rgba(17, 24, 52, 0.05), 0 8px 18px -8px rgba(28, 40, 90, 0.16), 0 22px 44px -22px rgba(28, 40, 90, 0.2);
  --sh-3: 0 2px 6px rgba(17, 24, 52, 0.05), 0 22px 44px -16px rgba(28, 40, 90, 0.24), 0 60px 110px -30px rgba(28, 40, 90, 0.34);
  --sh-card: 0 1px 2px rgba(17, 24, 52, 0.04), 0 6px 16px -10px rgba(30, 45, 100, 0.18);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* remplacées au démarrage par de vrais ressorts (linear()) */
  --spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --spring-ms: 520ms;
  --spring-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --spring-soft-ms: 420ms;
  --spring-snappy: cubic-bezier(0.3, 1.25, 0.6, 1);
  --spring-snappy-ms: 320ms;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --m-tb: rgba(255, 255, 255, 0.6); /* verre derrière le titre du mois (en-tête), sur son flou */
  --m-wd: rgba(0, 0, 0, 0.6); /* barre des jours de la semaine (en-tête) */
  --row-min: 94px; /* 3 événements sans agrandir la ligne */
  --lane: 20px; /* hauteur d'un événement (18px) + ses marges */
  --num-h: 28px; /* numéro du jour + marge avant le premier événement */
}

/* teinte du texte dérivée de la couleur de fond choisie */
@supports (color: oklch(from red l c h)) {
  :root {
    --ferie-ink: oklch(from var(--ferie-bg) calc(l - 0.42) calc(c + 0.13) h);
    --vac-ink: oklch(from var(--vac-bg) calc(l - 0.42) calc(c + 0.13) h);
  }
}

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

html {
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: 100%;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  /* rien ne déborde sur le côté (calendrier décalé vers la droite quand les réglages s'ouvrent) : sinon, sur
     Chrome Android, la page s'élargit et les pop-ups, le panneau et les messages sortent de l'écran.
     « clip » (et non « hidden ») : pas de zone de défilement en plus, le calendrier défile toujours avec la page */
  overflow-x: clip;
}

html.locked {
  overflow: hidden;
}

body {
  overflow-x: clip;
  margin: 0;
  min-height: 100dvh;
  background: transparent;
  font-size: var(--fs-md);
  line-height: 1.4;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* l'attribut hidden l'emporte toujours sur les display des composants */
[hidden] {
  display: none !important;
}

.i {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
}
.i.flip {
  transform: scaleX(-1);
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #fff;
}
/* grain très léger : bruit SVG généré (aucun fichier externe) */
.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
  mix-blend-mode: multiply;
  opacity: 0.05;
}

/* ============ Boutons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    transform var(--spring-snappy-ms) var(--spring-snappy),
    background-color 0.2s,
    box-shadow 0.2s,
    opacity 0.2s;
}
.btn .i {
  width: 16px;
  height: 16px;
}
.btn:active {
  transform: scale(0.96);
}
.btn:disabled {
  opacity: 0.55;
}
.btn.busy {
  pointer-events: none;
  opacity: 0.6;
}
.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 16px -9px rgba(19, 22, 29, 0.6);
}
.btn-soft {
  background: var(--surface-3);
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-outline {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-2), var(--sh-1);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 16px -9px rgba(229, 72, 77, 0.65);
}
.btn-danger-ghost {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  height: 32px;
  padding: 0 13px;
  font-size: var(--fs-sm);
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition:
    transform var(--spring-snappy-ms) var(--spring-snappy),
    background-color 0.2s;
}
.icon-btn .i {
  width: 19px;
  height: 19px;
}
.icon-btn:active {
  transform: scale(0.88);
  background: var(--surface-3);
}
.icon-btn.soft {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.icon-btn.soft .i {
  width: 15px;
  height: 15px;
}

/* ============ Champs ============ */
.input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 0;
  border-radius: var(--r);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs-md);
  font-weight: 500;
  outline: none;
  transition:
    box-shadow 0.2s,
    background-color 0.2s;
}
.input::placeholder {
  color: var(--ink-3);
}
.input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 3px rgba(91, 107, 245, 0.13);
}
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type='number'] {
  -moz-appearance: textfield;
}
/* champs « search » (utilisés pour éviter la barre de saisie automatique de Chrome) : aspect d'un champ normal */
input[type='search'] {
  -webkit-appearance: none;
  appearance: none;
}
/* la croix d'effacement, même invisible, garde sa place à droite et décentre le texte (heure, minutes) */
input[type='search']::-webkit-search-cancel-button,
input[type='search']::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

/* ============ Radios ============ */
.radio-group {
  display: flex;
  flex-direction: column;
}
.radio {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 0 -8px;
  padding: 3px 8px;
  border-radius: var(--r);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition: background-color 0.2s;
}
.radio:active {
  background: var(--surface-2);
}
/* choix impossible (ex. « N jours avant » d'un événement d'aujourd'hui) */
.radio.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.radio-dot {
  position: relative;
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.8px var(--ink-4);
  transition: box-shadow 0.25s;
}
.radio-dot::after {
  content: '';
  position: absolute;
  inset: 4.5px;
  border-radius: 50%;
  background: var(--ink);
  transform: scale(0);
  transition: transform var(--spring-ms) var(--spring);
}
.radio.on .radio-dot {
  box-shadow: inset 0 0 0 1.8px var(--ink);
}
.radio.on .radio-dot::after {
  transform: scale(1);
}
.radio-label {
  font-size: var(--fs-md);
  font-weight: 500;
}
.radio-label:empty {
  display: none;
}

/* ============ Stepper ============ */
.stepper {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 34px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.step-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--sh-1);
  cursor: pointer;
  transition: transform var(--spring-snappy-ms) var(--spring-snappy);
}
.step-btn .i {
  width: 13px;
  height: 13px;
  stroke-width: 2.5;
}
.step-btn:active {
  transform: scale(0.86);
}
.stepper input {
  width: 34px;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: var(--fs-md);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  outline: none;
}

/* ============ Champ heure (heure : minutes) ============ */
.timef {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.timef input {
  width: 36px;
  height: 32px;
  padding: 0 0 1px; /* les chiffres d'Inter tombent un peu sous le centre */
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: center;
  font-size: var(--fs-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition:
    box-shadow 0.2s,
    background-color 0.2s;
}
.timef input::placeholder {
  color: var(--ink-4);
}
.timef input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.timef-sep {
  font-weight: 650;
  color: var(--ink-3);
}

/* ============ Segmenté ============ */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  height: 34px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-3);
}
.seg-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--n));
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--sh-1), 0 3px 8px -3px rgba(17, 24, 52, 0.14);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform var(--spring-ms) var(--spring);
}
.seg button {
  position: relative;
  z-index: 1;
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: var(--fs);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s;
}
.seg button.on {
  color: var(--ink);
}
/* choix à la largeur de leur texte (segmented({ fit })) : le curseur est placé et dimensionné en JS */
.seg-fit {
  grid-template-columns: repeat(var(--n), auto);
}
.seg-fit .seg-thumb {
  transition:
    transform var(--spring-ms) var(--spring),
    width var(--spring-ms) var(--spring);
}

/* ============ Case à cocher / interrupteur ============ */
.cbx {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1.8px var(--ink-4);
  cursor: pointer;
  transition:
    background-color 0.25s,
    box-shadow 0.25s,
    transform var(--spring-snappy-ms) var(--spring-snappy);
}
.cbx .i {
  width: 13px;
  height: 13px;
  stroke-width: 3.2;
  opacity: 0;
  transform: scale(0.3) rotate(-12deg);
  transition:
    transform var(--spring-ms) var(--spring),
    opacity 0.18s;
}
.cbx.on {
  background: var(--ink);
  box-shadow: none;
}
.cbx.on .i {
  opacity: 1;
  transform: none;
}
.cbx:active {
  transform: scale(0.86);
}
.cbx:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.switch {
  position: relative;
  flex: none;
  width: 42px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--ink-4);
  cursor: pointer;
  transition: background-color 0.3s;
}
.switch-knob {
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform var(--spring-ms) var(--spring);
}
.switch.on {
  background: var(--ink);
}
.switch.on .switch-knob {
  transform: translateX(17px);
}

/* ============ Pastilles ============ */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0 6px;
}
.chip {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: var(--fs);
  font-weight: 650;
  cursor: pointer;
  transition:
    background-color 0.25s,
    color 0.25s,
    box-shadow 0.25s,
    transform var(--spring-snappy-ms) var(--spring-snappy);
}
.chip.on {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 5px 12px -6px rgba(19, 22, 29, 0.6);
}
.chip:active {
  transform: scale(0.88);
}
/* jours de la semaine : toujours sur une seule ligne */
.chips-days {
  flex-wrap: nowrap;
  gap: 4px;
}
.chips-days .chip {
  flex: 1 1 0;
  width: auto;
  max-width: 34px;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
}
.chip-wide {
  width: auto;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: var(--fs-sm);
}

/* ============ Dépliable ============ */
.collapse {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows var(--spring-soft-ms) var(--spring-soft),
    opacity 0.3s;
}
.collapse.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.collapse-inner {
  min-height: 0;
  /* rogne seulement en hauteur (animation) : les filets peuvent déborder sur les côtés */
  overflow-x: visible;
  overflow-y: clip;
}

/* ============ Toasts ============ */
.toast-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-b) + 16px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 14px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 440px;
  min-height: 44px;
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: rgba(19, 22, 29, 0.92);
  color: #fff;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 34px -14px rgba(19, 22, 29, 0.55);
  font-size: var(--fs);
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition:
    transform var(--spring-ms) var(--spring),
    opacity 0.25s;
}
.toast.in {
  opacity: 1;
  transform: none;
}
.toast.out {
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition-duration: 0.25s;
}
.toast:not(:has(.toast-action)) {
  padding-right: 18px;
}
.toast-icon .i {
  width: 16px;
  height: 16px;
  color: var(--accent-2);
}
.toast-msg {
  flex: 1;
  padding: 4px 2px 4px 0;
}
.toast-action {
  height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 650;
  cursor: pointer;
}

/* ============ Proposition d'installation (1re ouverture dans le navigateur) ============ */
.install-card {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 14px);
  z-index: 40; /* sous les panneaux et pop-ups */
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(440px, calc(100% - 28px));
  padding: 10px 6px 10px 10px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-3), 0 0 0 1px var(--line);
  opacity: 0;
  transform: translate(-50%, 24px) scale(0.96);
  transition:
    transform var(--spring-ms) var(--spring),
    opacity 0.25s;
}
.install-card.in {
  opacity: 1;
  transform: translate(-50%, 0);
}
.install-logo {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.install-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.install-text b {
  font-size: var(--fs-md);
  font-weight: 650;
}
.install-text small {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
/* les toasts passent au-dessus de la carte (sauf si un panneau la recouvre) */
body:has(.install-card.in):not(:has(.layer)) .toast-wrap {
  bottom: calc(var(--safe-b) + 92px);
}

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