/* ============================================================
   NOTIFICATIONS — la cloche et son panneau
   modules/notifications/notifications.css · codia-modules (paquet « notifications »)
   ============================================================
   Apparence de la cloche du CAP, aux tokens du projet (aucune couleur en
   dur hors des replis). Un site ajuste par notifications.project.css :
   taille de la cloche, couleurs des tons (--notif-tone-*), largeur du panneau.
   Panneau en position fixe calée sous la cloche par le script (jamais coupé
   par un conteneur qui défile) ; ≤ 720 px : feuille en bas d'écran.
   ============================================================ */

.notif {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* `hidden` respecté même sans la remise à zéro du socle (core/css) : un site qui ne la charge pas
   (Maison Vénus) voyait le fond de la feuille (`.notif-backdrop`, display:block ≤ 720 px) couvrir l'écran. */
.notif[hidden],
.notif [hidden] {
  display: none;
}

.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid var(--c-line, rgba(10, 31, 56, 0.12));
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease, ease), border-color 0.2s var(--ease, ease);
}
.notif-bell:hover {
  background: var(--c-soft, rgba(10, 31, 56, 0.05));
  border-color: var(--c-accent, #236FA8);
}
.notif-bell:focus-visible {
  outline: 2px solid var(--c-focus, #32BCEC);
  outline-offset: 2px;
}
.notif-bell-icon {
  display: inline-flex;
}
.notif-bell-icon svg {
  width: 17px;
  height: 17px;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: var(--f-body, system-ui, sans-serif);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--c-paper, #FDFCFA);
  background: var(--c-danger, #A32D2D);
  border: 2px solid var(--c-paper, #FDFCFA);
  border-radius: 9px;
}

/* ── Panneau ── */
.notif-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 1000;
  width: 380px;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  color: var(--c-ink, #1A1A1A);
  text-align: left;
  background: var(--c-paper, #FDFCFA);
  border: 1px solid var(--c-line, rgba(10, 31, 56, 0.12));
  border-radius: var(--r-md, 4px);
  box-shadow: 0 20px 60px var(--notif-shadow, rgba(1, 21, 45, 0.25));
  animation: notif-panel-in 0.18s var(--ease, ease-out);
}
@keyframes notif-panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.notif-backdrop {
  display: none;
}

.notif-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--c-line, rgba(10, 31, 56, 0.12));
}
.notif-panel-title {
  margin: 0;
  font-family: var(--f-display, Georgia, serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--c-primary, #0A1F38);
}
.notif-panel-count {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-accent, #236FA8);
}
.notif-all-read {
  margin-left: auto;
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  color: var(--c-accent, #236FA8);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: 0;
  cursor: pointer;
}
.notif-all-read:hover {
  color: var(--c-primary, #0A1F38);
}
/* Fermer (1.3.1) : téléphone seulement — sur ordinateur, Échap et le clic extérieur suffisent. */
.notif-close {
  display: none;
}

.notif-panel-list {
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.notif-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ── Une ligne ── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 15px 18px;
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--c-line, rgba(10, 31, 56, 0.12));
  cursor: pointer;
  transition: background 0.15s var(--ease, ease);
}
.notif-row:last-child .notif-item {
  border-bottom: 0;
}
.notif-item:hover {
  background: var(--c-soft, rgba(10, 31, 56, 0.04));
}
.notif-item:focus-visible {
  outline: 2px solid var(--c-focus, #32BCEC);
  outline-offset: -2px;
}
.notif-item.is-unread {
  background: var(--notif-unread-bg, color-mix(in srgb, var(--c-accent, #236FA8) 7%, transparent));
}
.notif-item.is-unread:hover {
  background: var(--notif-unread-hover, color-mix(in srgb, var(--c-accent, #236FA8) 12%, transparent));
}

.notif-item-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.notif-item-icon svg {
  width: 16px;
  height: 16px;
}
.notif-tone-neutral {
  color: var(--notif-tone-neutral, var(--c-primary, #0A1F38));
  background: var(--notif-tone-neutral-bg, color-mix(in srgb, var(--c-primary, #0A1F38) 8%, transparent));
}
.notif-tone-positive {
  color: var(--notif-tone-positive, var(--c-success, #0F6E56));
  background: var(--notif-tone-positive-bg, var(--c-success-soft, color-mix(in srgb, var(--c-success, #0F6E56) 14%, transparent)));
}
.notif-tone-negative {
  color: var(--notif-tone-negative, var(--c-danger, #A32D2D));
  background: var(--notif-tone-negative-bg, var(--c-danger-soft, color-mix(in srgb, var(--c-danger, #A32D2D) 14%, transparent)));
}
.notif-tone-team {
  color: var(--notif-tone-team, var(--c-highlight, #D4A24A));
  background: var(--notif-tone-team-bg, var(--c-primary, #0A1F38));
}

.notif-item-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.notif-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--c-primary, #0A1F38);
}
.notif-item-subtitle {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--c-mute, rgba(10, 31, 56, 0.6));
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notif-item-time {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-accent, #236FA8);
}
.notif-item-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 0.55rem;
  background: var(--c-accent, #236FA8);
  border-radius: 50%;
}

.notif-more {
  display: block;
  width: 100%;
  padding: 12px 18px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--c-accent, #236FA8);
  background: transparent;
  border: 0;
  border-top: 1px solid var(--c-line, rgba(10, 31, 56, 0.12));
  cursor: pointer;
}
.notif-more:hover {
  background: var(--c-soft, rgba(10, 31, 56, 0.04));
}

.notif-empty {
  padding: 32px 20px;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
  color: var(--c-mute, rgba(10, 31, 56, 0.6));
}
.notif-empty p {
  margin: 0;
}
.notif-empty-icon {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--c-line, rgba(10, 31, 56, 0.3));
}
.notif-empty-icon svg {
  width: 32px;
  height: 32px;
}
.notif-error .btn {
  margin-top: 12px;
}
.notif-loading {
  padding: 16px;
}

/* ── Téléphone : feuille en bas d'écran, fond assombri ── */
@media (max-width: 720px) {
  .notif-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--r-md, 4px) var(--r-md, 4px) 0 0;
    box-shadow: 0 -10px 40px var(--notif-shadow, rgba(1, 21, 45, 0.3));
  }
  /* La feuille ne prend jamais tout l'écran (1.3.1) : une bande du fond reste visible en haut
     pour fermer d'un geste ; la feuille défile d'un bloc (liste puis « Sur cet appareil »),
     son en-tête et le bouton Fermer restent en vue. */
  .notif-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .notif-panel > * {
    flex: none;
  }
  .notif-panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: grid;                          /* titre et compteur, puis « Tout marquer lu » sous le titre (1.5.1) */
    grid-template-columns: auto 1fr;
    flex: none;
    padding-right: 62px;   /* la place du bouton Fermer, hors du flux : toujours en haut à droite (1.5.0) */
    background: var(--c-paper, #FDFCFA);
  }
  .notif-all-read {
    grid-column: 1 / -1;
    justify-self: start;
    margin-left: 0;
    padding: 6px 0;
  }
  .notif-panel-list {
    max-height: none;
    overflow: visible;
  }
  .notif-close {
    position: absolute;
    top: 8px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    color: var(--c-primary, #0A1F38);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
  }
  .notif-close:focus-visible {
    outline: 2px solid var(--c-accent, #236FA8);
    outline-offset: 2px;
  }
  .notif-close-icon,
  .notif-close-icon svg {
    display: block;
    width: 22px;
    height: 22px;
  }
  .notif-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: block;
    background: var(--notif-backdrop, rgba(1, 21, 45, 0.5));
  }
}

@media (prefers-reduced-motion: reduce) {
  .notif-panel {
    animation: none;
  }
}
