/* ============================================================
   CALENDRIER « Almanach des dates » — éditorial joy (CALENDRIER.md)
   Couleurs 100% depuis les tokens. Les chips reçoivent leur teinte
   joy en inline (--joy-<hue>-*). Animations en cascade.
   ============================================================ */

/* ── Barre de navigation mois ── */
.cal-monthnav {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0 18px;
  flex-wrap: wrap;
}
.cal-nav {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: transform .15s ease, color .15s ease, border-color .15s ease, background .15s ease;
}
.cal-nav:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 30%, transparent); transform: scale(1.08); }
.cal-monthlabel {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--ink);
  min-width: 200px;
  text-align: center;
  letter-spacing: -0.01em;
  animation: cal-label-in .4s cubic-bezier(0.16,1,0.3,1) both;
}
.cal-monthlabel em { font-style: italic; color: var(--accent); }
.cal-today-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 12px; color: var(--muted);
  transition: color .15s ease;
}
.cal-today-btn:hover { color: var(--accent); }
.cal-today-btn .cal-today-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-spacer { flex: 1; }
.cal-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cal-legend-item {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Plateau ── */
.cal-board {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}
.cal-weekhead {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-tinted) 45%, transparent);
}
.cal-weekhead-cell {
  padding: 13px 0; text-align: center;
  font-family: var(--sans); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  border-right: 1px solid var(--line-soft);
}
.cal-weekhead-cell:last-child { border-right: none; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 124px;
}

/* ── Cellule jour ── */
.cal-cell {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 8px 6px;
  display: flex; flex-direction: column; gap: 5px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  animation: cal-cell-in .42s cubic-bezier(0.16,1,0.3,1) both;
  transition: background .16s ease;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: color-mix(in srgb, var(--surface-tinted) 40%, transparent); }
.cal-cell:hover .cal-daynum:not(.cal-today) { color: var(--accent); }
.cal-out { cursor: default; background: color-mix(in srgb, var(--surface-tinted) 22%, transparent); }
.cal-out:hover { background: color-mix(in srgb, var(--surface-tinted) 22%, transparent); }
.cal-sel { background: color-mix(in srgb, var(--accent) 8%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }

.cal-cell-head { display: flex; align-items: center; justify-content: space-between; }
.cal-daynum {
  font-family: var(--serif); font-size: 15px;
  color: var(--ink-soft);
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease;
}
.cal-out .cal-daynum { color: var(--muted-soft); }
.cal-today {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-style: italic;
  animation: cal-today-glow 2.6s ease-in-out infinite;
}
.cal-count { font-family: var(--sans); font-size: 11px; color: var(--muted); }

.cal-chips { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.cal-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--sans); font-size: 10.5px;
  background: var(--joy-tint);
  color: var(--joy-ink);
  border: 1px solid color-mix(in srgb, var(--joy-ink) 30%, transparent);
  animation: cal-chip-in .4s ease both;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.cal-cell:hover .cal-chip { box-shadow: 0 2px 6px color-mix(in srgb, var(--ink) 10%, transparent); }
.cal-chip:hover { transform: translateX(2px); }
.cal-chip-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--joy-ink); flex-shrink: 0; }
.cal-chip-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-family: var(--serif); font-style: italic; font-size: 11px; color: var(--muted); padding-left: 2px; }

/* ── Agenda (30 jours) ── */
.cal-agenda { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 8px 24px; }
.cal-agrow { display: flex; gap: 22px; padding: 18px 0; align-items: flex-start; animation: cal-ag-in .45s cubic-bezier(0.16,1,0.3,1) both; }
.cal-agrow + .cal-agrow { border-top: 1px solid var(--line-soft); }
.cal-agdate { width: 72px; flex-shrink: 0; cursor: pointer; text-align: left; }
.cal-agdate-dow { font-family: var(--sans); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.cal-agdate.is-first .cal-agdate-dow, .cal-agdate.is-first .cal-agdate-num { color: var(--accent); }
.cal-agdate-num { font-family: var(--serif); font-size: 42px; line-height: 0.95; color: var(--ink); font-feature-settings: "lnum"; }
.cal-agdate-mon { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--muted); }
.cal-agcol { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cal-agev {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-left: 2px solid var(--joy-ink);
  border-radius: 4px; padding: 10px 12px;
  transition: background .15s ease;
}
.cal-agev:hover { background: var(--joy-tint); }
.cal-agev-time { font-family: var(--mono); font-size: 12px; color: var(--joy-ink); width: 46px; flex-shrink: 0; }
.cal-agev-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--joy-ink); flex-shrink: 0; }
.cal-agev-title { font-family: var(--serif); font-size: 17px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-agev-couple { font-family: var(--sans); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); flex-shrink: 0; }
.cal-agev-cat { font-family: var(--sans); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--joy-ink); padding: 4px 9px; background: var(--joy-tint); border-radius: 999px; flex-shrink: 0; }
.cal-agenda-empty { padding: 48px 12px; text-align: center; font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--muted); }

/* ── Drawer détail du jour ── */
.cal-backdrop {
  position: fixed; inset: 0; z-index: 1200;
  background: color-mix(in srgb, var(--ink) 28%, transparent);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.cal-backdrop.on { opacity: 1; pointer-events: auto; }
.cal-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1201;
  width: 420px; max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(0.16,1,0.3,1);
  box-shadow: -18px 0 50px color-mix(in srgb, var(--ink) 18%, transparent);
}
.cal-drawer.on { transform: translateX(0); }
.cal-drawer-head {
  padding: 26px 26px 20px; position: relative;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--joy-rose-tint), color-mix(in srgb, var(--joy-gold-tint) 70%, transparent));
}
.cal-drawer-eyebrow { font-family: var(--sans); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.cal-drawer-date { font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--ink); margin: 8px 0 0; letter-spacing: -0.01em; }
.cal-drawer-sub { margin-top: 8px; font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--muted); }
.cal-x {
  position: absolute; top: 20px; right: 20px;
  width: 34px; height: 34px; border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s ease, color .15s ease;
}
.cal-x:hover { color: var(--ink); transform: rotate(90deg); }
.cal-drawer-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; flex: 1; }
.cal-ev {
  background: var(--bg); border: 1px solid var(--line-soft);
  border-left: 2px solid var(--joy-ink);
  border-radius: 6px; padding: 14px 16px;
  animation: cal-ev-in .4s cubic-bezier(0.16,1,0.3,1) both;
}
.cal-ev-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cal-ev-cat { display: inline-flex; align-items: center; gap: 6px; font-family: var(--sans); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--joy-ink); padding: 4px 9px; background: var(--joy-tint); border-radius: 999px; }
.cal-ev-cat-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--joy-ink); }
.cal-ev-time { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: auto; }
.cal-ev-title { font-family: var(--serif); font-size: 19px; color: var(--ink); line-height: 1.2; cursor: pointer; }
.cal-ev-title:hover { color: var(--accent); }
.cal-ev-couple { margin-top: 6px; font-family: var(--sans); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cal-ev-task { cursor: pointer; transition: background .15s ease, transform .12s ease; }
.cal-ev-task:hover { background: var(--joy-tint); transform: translateX(2px); }
.cal-ev-task .cal-ev-title { cursor: pointer; }
.cal-ev-hint { margin-top: 8px; font-family: var(--sans); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--joy-ink); opacity: .75; }
.cal-empty { text-align: center; padding: 48px 12px; }
.cal-empty-medallion { display: inline-flex; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); align-items: center; justify-content: center; margin-bottom: 16px; color: var(--accent); }
.cal-empty-text { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); line-height: 1.5; }
.cal-drawer-foot { padding: 16px 24px; border-top: 1px solid var(--line); }
.cal-add {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--primary); color: #fff;
  font-family: var(--sans); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  transition: filter .15s ease;
}
.cal-add:hover { filter: brightness(1.06); }

/* ── Keyframes ── */
@keyframes cal-cell-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cal-chip-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
@keyframes cal-label-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cal-ag-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cal-ev-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes cal-today-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 0%, transparent); }
}

/* ── Responsive ── */
@media (max-width: 1100px) { .cal-grid { grid-auto-rows: 100px; } }
@media (max-width: 760px) {
  .cal-grid { grid-auto-rows: 84px; }
  .cal-daynum { font-size: 13px; width: 22px; height: 22px; }
  .cal-chip { font-size: 9.5px; padding: 2px 5px; }
  .cal-monthlabel { font-size: 22px; min-width: 0; }
  .cal-legend { display: none; }
  .cal-agrow { gap: 14px; }
  .cal-agev-couple { display: none; }
}
@media (max-width: 640px) {
  .cal-drawer { width: 100%; max-width: 100%; }
}
@media (max-width: 420px) {
  .cal-grid { grid-auto-rows: 76px; }
  .cal-chips .cal-chip:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cal-cell, .cal-chip, .cal-monthlabel, .cal-agrow, .cal-ev { animation: none !important; }
  .cal-today { animation: none !important; }
  .cal-drawer { transition: none; }
}
