/* ==================== Notifications ====================
   The bell's number and drop-down, the list (drop-down and page), the
   "turn on" card and the per-kind switches (notifications app,
   static/js/notifications.js). Three levels, one colour each: urgent in
   the alert red, important in petrol, info quiet. */

/* ---- Counts ---- */
.notif-badge {
  position: absolute; top: calc(var(--space-0-5) * -1); right: calc(var(--space-0-5) * -1);
  min-width: var(--space-4); height: var(--space-4); padding: 0 var(--space-1); border-radius: var(--radius-full);
  background: hsl(var(--accent)); color: hsl(var(--accent-foreground));
  font-size: var(--text-3xs); font-weight: 700; line-height: var(--space-4); text-align: center;
  font-variant-numeric: tabular-nums; box-shadow: 0 0 0 var(--space-0-5) hsl(var(--surface));
  pointer-events: none;
}
.bottom-nav-dot {
  position: absolute; top: var(--space-1); left: calc(50% + var(--space-1-5));
  width: var(--space-2); height: var(--space-2); border-radius: 50%;
  background: hsl(var(--accent)); box-shadow: 0 0 0 var(--space-0-5) hsl(var(--surface));
}
.cleaner-topbar__bell { color: inherit; }

/* ---- The list ---- */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); color: hsl(var(--fg)); text-decoration: none;
  border-bottom: 1px solid hsl(var(--border));
  transition: background-color var(--dur-fast) var(--ease-out);
}
.notif-list li:last-child .notif-item { border-bottom: 0; }
.notif-item:hover { background: hsl(var(--surface-sunken)); }
.notif-item, .notif-panel__read, .notif-panel__all { touch-action: manipulation; }
.notif-item:active { background: hsl(var(--primary-soft)); }
.notif-item:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: -2px; }
.notif-item__dot {
  width: var(--space-2); height: var(--space-2); border-radius: 50%; margin-top: var(--space-1-5);
  background: hsl(var(--border-strong));
}
.notif-item__dot--urgent { background: hsl(var(--destructive)); }
.notif-item__dot--important { background: hsl(var(--primary)); }
.notif-item__dot--info { background: hsl(var(--fg-subtle)); }
.notif-item:not(.is-unread) .notif-item__dot { opacity: 0.35; }
.notif-item__main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-0-5); }
.notif-item__title { font-size: var(--text-ui); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item.is-unread .notif-item__title { font-weight: 700; }
.notif-item__body {
  font-size: var(--text-sm); color: hsl(var(--fg-muted)); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.notif-item__time { font-size: var(--text-2xs); color: hsl(var(--fg-subtle)); white-space: nowrap; font-variant-numeric: tabular-nums; }
.notif-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-5); text-align: center; color: hsl(var(--fg-muted)); font-size: var(--text-sm); }
.notif-empty__icon svg { width: var(--space-6); height: var(--space-6); color: hsl(var(--fg-subtle)); }

/* ---- The bell's drop-down (wide screens) ----
   Scales in from the bell (its top-right corner), fast, like the account menu. */
.notif-panel {
  position: fixed; z-index: 60; width: min(var(--notif-panel-w), calc(100vw - var(--space-4)));
  max-height: min(var(--notif-panel-h), calc(100dvh - var(--topbar-h) - var(--space-6)));
  display: flex; flex-direction: column;
  background: hsl(var(--surface)); border: 1px solid hsl(var(--border)); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover); overflow: hidden;
  transform-origin: top right; transform: scale(0.96); opacity: 0;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
  overscroll-behavior: contain;
}
.notif-panel.is-open { transform: scale(1); opacity: 1; }
.notif-panel:focus { outline: none; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid hsl(var(--border)); }
.notif-panel__title { font-size: var(--text-ui); font-weight: 700; }
.notif-panel__read { font-size: var(--text-xs); font-weight: 600; color: hsl(var(--primary)); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.notif-panel__read:hover { background: hsl(var(--primary-soft)); }
.notif-panel__body { overflow-y: auto; flex: 1; min-height: 0; }
.notif-panel__loading { padding: var(--space-6); text-align: center; color: hsl(var(--fg-subtle)); font-size: var(--text-sm); }
.notif-panel__all {
  display: block; padding: var(--space-3) var(--space-4); border-top: 1px solid hsl(var(--border));
  text-align: center; font-size: var(--text-sm); font-weight: 600; color: hsl(var(--primary));
}
.notif-panel__all:hover { background: hsl(var(--surface-sunken)); }
@media (prefers-reduced-motion: reduce) {
  .notif-panel { transition: opacity var(--dur-fast) linear; transform: none; }
}

/* ---- "Turn on notifications" ---- */
.notif-enable { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }
.notif-enable__icon {
  flex-shrink: 0; width: var(--space-10); height: var(--space-10); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: hsl(var(--primary-soft)); color: hsl(var(--primary));
}
.notif-enable__icon svg { width: var(--space-5); height: var(--space-5); }
.notif-enable__text { flex: 1; min-width: 0; }
.notif-enable__title { font-size: var(--text-ui); font-weight: 700; }
.notif-enable__text p { margin-top: var(--space-0-5); font-size: var(--text-sm); color: hsl(var(--fg-muted)); line-height: 1.45; text-wrap: pretty; }
.notif-enable__actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.notif-enable[data-current="on"] .notif-enable__icon { background: hsl(var(--success-bg)); color: hsl(var(--success)); }
.notif-enable--compact { position: relative; border-color: hsl(var(--primary) / 0.25); padding-right: var(--space-12); }
/* "Not now" sits in the corner, out of the way of the text and the button. */
.notif-enable__close { position: absolute; top: var(--space-2); right: var(--space-2); }
@media (max-width: 600px) {
  .notif-enable { flex-wrap: wrap; align-items: flex-start; }
  .notif-enable__actions { width: 100%; justify-content: flex-start; padding-left: calc(var(--space-10) + var(--space-4)); }
  .notif-enable__actions:not(:has(> :not([hidden]))) { display: none; }
}

/* ---- The page ---- */
.notif-page-list { margin-bottom: var(--space-4); overflow: hidden; }
.notif-settings__title { font-size: var(--text-ui); font-weight: 700; }
.notif-settings .hint { margin: var(--space-1) 0 var(--space-3); font-size: var(--text-sm); color: hsl(var(--fg-muted)); line-height: 1.45; }
.notif-settings__list { list-style: none; margin: 0; padding: 0; }
.notif-setting {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0; border-top: 1px solid hsl(var(--border));
}
.notif-setting .notif-item__dot { margin-top: 0; align-self: start; margin-top: var(--space-1-5); }
.notif-setting__text { display: flex; flex-direction: column; gap: var(--space-0-5); min-width: 0; }
.notif-setting__label { font-size: var(--text-ui); font-weight: 600; }
.notif-setting__help { font-size: var(--text-sm); color: hsl(var(--fg-muted)); }

/* The switch: a real checkbox under a drawn track, so keyboard and screen
   readers get a checkbox. 44px of hit area on touch. */
.notif-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; touch-action: manipulation; }
.notif-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.notif-switch__track {
  position: relative; width: var(--space-9); height: var(--space-5); border-radius: var(--radius-full);
  background: hsl(var(--border-strong)); transition: background-color var(--dur-base) var(--ease-out);
}
.notif-switch__track::after {
  content: ""; position: absolute; top: var(--space-0-5); left: var(--space-0-5);
  width: var(--space-4); height: var(--space-4); border-radius: 50%; background: hsl(var(--surface));
  box-shadow: var(--shadow-xs); transition: transform var(--dur-base) var(--ease-out);
}
.notif-switch input:checked + .notif-switch__track { background: hsl(var(--success)); }
.notif-switch input:checked + .notif-switch__track::after { transform: translateX(var(--space-4)); }
.notif-switch input:focus-visible + .notif-switch__track { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
@media (pointer: coarse) { .notif-switch { min-height: var(--control-h); min-width: var(--control-h); justify-content: center; } }
@media (prefers-reduced-motion: reduce) { .notif-switch__track, .notif-switch__track::after { transition: none; } }
