/* ============================================
   serenity-ext.css — v1.0.0
   Card + Sheet détail du Score Sérénité
   Wrapper additif, n'écrase aucun style core.
   Typo : utilise les vars CSS prod (pas de switch Unbounded/DM Sans).
   ============================================ */

/* ============================================
   Variables locales défensives
   ============================================ */
:root {
  --serenity-bg-start: #1A2845;
  --serenity-bg-end: #233153;
  --serenity-ivoire: #F5EFE0;
  --serenity-sable: #ECDDCB;
  --serenity-ok: #b8d975;
  --serenity-ok-soft: rgba(164, 199, 93, 0.22);
  --serenity-warn: #f5d680;
  --serenity-warn-soft: rgba(245, 214, 128, 0.22);
  --serenity-todo: #f5a4a6;
  --serenity-todo-soft: rgba(248, 85, 88, 0.22);
  --serenity-idle: rgba(245, 239, 224, 0.7);
  --serenity-idle-soft: rgba(245, 239, 224, 0.1);
  --serenity-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================
   Card — affichée dans #dashboard-content
   ============================================ */
.serenity-card {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px 12px;
  padding: 18px 20px 14px;
  background: linear-gradient(155deg, var(--serenity-bg-start) 0%, var(--serenity-bg-end) 100%);
  color: var(--serenity-ivoire);
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 2px 12px rgba(26, 40, 69, 0.10),
    0 1px 3px rgba(26, 40, 69, 0.08);
  transition:
    transform 0.18s var(--serenity-ease),
    box-shadow 0.18s var(--serenity-ease);
  -webkit-tap-highlight-color: transparent;
  /* v2.47.4 — animation d'entrée désactivée par sécurité, au cas où elle se
     re-déclenche en boucle à cause d'un selector prod */
  animation: none;
}

@keyframes serenitySlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.serenity-card:hover {
  transform: translateY(-1px);
  box-shadow:
    0 6px 20px rgba(26, 40, 69, 0.18),
    0 2px 6px rgba(26, 40, 69, 0.12);
}

.serenity-card:active {
  transform: scale(0.99);
}

.serenity-card:focus-visible {
  outline: 2px solid rgba(245, 239, 224, 0.6);
  outline-offset: 2px;
}

/* Head */
.serenity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.serenity-lbl {
  font-family: ui-monospace, "Geist Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  margin-bottom: 4px;
}

.serenity-score {
  font-family: var(--font-display), "Unbounded", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--serenity-ivoire);
}

.serenity-total {
  font-size: 15px;
  opacity: 0.55;
  margin-left: 4px;
  letter-spacing: 0;
  font-weight: 400;
}

.serenity-ring {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Checks */
.serenity-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.serenity-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.92;
}

.serenity-check-label {
  flex: 1;
  min-width: 0;
}

.serenity-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.serenity-check.ok .serenity-dot {
  background: var(--serenity-ok-soft);
  color: var(--serenity-ok);
}

.serenity-check.todo .serenity-dot {
  background: var(--serenity-todo-soft);
  color: var(--serenity-todo);
}

.serenity-check.idle .serenity-dot {
  background: var(--serenity-idle-soft);
  color: var(--serenity-idle);
}

/* CTA */
.serenity-cta {
  padding-top: 12px;
  border-top: 1px solid rgba(245, 239, 224, 0.12);
  font-family: ui-monospace, "Geist Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.18s var(--serenity-ease);
}

.serenity-card:hover .serenity-cta {
  opacity: 1;
}

.serenity-cta svg {
  display: block;
  flex-shrink: 0;
  transition: transform 0.18s var(--serenity-ease);
}

.serenity-card:hover .serenity-cta svg {
  transform: translateX(2px);
}

/* ============================================
   Sheet detail (full-screen overlay)
   ============================================ */
.serenity-sheet-overlay {
  position: fixed;
  inset: 0;
  /* v2.47.3 — backdrop-filter supprimé par cohérence (préventif Sprint 1+2) */
  background: rgba(20, 32, 56, 0.92);
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.28s var(--serenity-ease);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.serenity-sheet-overlay.is-open {
  opacity: 1;
}

.serenity-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--serenity-ivoire, #F5EFE0);
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* v2.47.4 — sheet statique, animations bloquées (cohérence Sprint 1+2) */
  opacity: 1;
  animation: none !important;
  box-shadow: 0 -10px 40px rgba(26, 40, 69, 0.25);
  position: relative;
}

.serenity-sheet-overlay.is-open .serenity-sheet {
  animation: none !important;
}

/* Desktop : sheet centrée modal */
@media (min-width: 768px) {
  .serenity-sheet-overlay {
    align-items: center;
  }
  .serenity-sheet {
    border-radius: 22px;
    max-height: 86vh;
  }
}

/* Head sheet */
.serenity-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--serenity-sable);
  flex-shrink: 0;
  background: var(--serenity-ivoire, #F5EFE0);
}

.serenity-sheet-title {
  font-family: var(--font-display), "Unbounded", system-ui, sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: #1A2845;
}

.serenity-sheet-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--serenity-sable);
  background: transparent;
  color: #1A2845;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s var(--serenity-ease);
}

.serenity-sheet-close:hover {
  background: var(--serenity-sable);
}

/* Body sheet */
.serenity-sheet-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.serenity-detail-section {
  padding: 16px 20px 8px;
}

.serenity-detail-eyebrow {
  font-family: ui-monospace, "Geist Mono", monospace;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1A2845;
  opacity: 0.55;
}

.serenity-section-head {
  padding: 16px 20px 0;
}

.serenity-detail-score {
  font-family: var(--font-display), "Unbounded", system-ui, sans-serif;
  font-weight: 600;
  font-size: 64px;
  line-height: 1;
  letter-spacing: -0.035em;
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.serenity-detail-score-total {
  font-family: ui-monospace, "Geist Mono", monospace;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.55;
  font-weight: 400;
}

.serenity-detail-prose {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: #1A2845;
  opacity: 0.75;
  max-width: 36ch;
}

.serenity-rule {
  border: 0;
  height: 1px;
  background: var(--serenity-sable);
  margin: 0;
}

/* Checks détaillées */
.serenity-detail-checks {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.serenity-detail-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  border: 1px solid var(--serenity-sable);
  border-radius: 12px;
  background: transparent;
}

.serenity-detail-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
}

.serenity-detail-check.ok .serenity-detail-dot {
  background: var(--serenity-ok-soft);
  color: #5a8d2e;
}

.serenity-detail-check.todo .serenity-detail-dot {
  background: var(--serenity-todo-soft);
  color: #c43a3d;
}

.serenity-detail-check.idle .serenity-detail-dot {
  background: var(--serenity-sable);
  color: #1A2845;
}

.serenity-detail-text {
  flex: 1;
  min-width: 0;
}

.serenity-detail-label {
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #1A2845;
}

.serenity-detail-sub {
  margin-top: 4px;
  font-size: 13px;
  opacity: 0.65;
  line-height: 1.4;
  color: #1A2845;
}

.serenity-detail-foot {
  padding: 0 20px 30px;
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  opacity: 0.55;
  color: #1A2845;
}

/* ============================================
   Réduit l'animation pour les utilisateurs prefers-reduced-motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .serenity-card,
  .serenity-sheet-overlay,
  .serenity-sheet,
  .serenity-ring svg circle {
    animation: none !important;
    transition: none !important;
  }
}
