/* Notifications: header bell + dropdown, pop-ups, the Notifications page and the panel pages.
   Colours come from the app tokens (app.css / appearance.css), so light and dark themes both work. */

/* ---------- Header bell ---------- */
.notif { position: relative; display: flex; }
.notif-bell {
  position: relative; display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: color .15s, background-color .15s, border-color .15s;
}
.notif-bell:hover, .notif.is-open .notif-bell { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.notif-bell:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.site-header .notif-bell svg { width: 21px; height: 21px; }
.notif-bell.is-ringing svg { animation: notif-ring .9s ease-in-out; transform-origin: 50% 2px; }
.notif-badge {
  position: absolute; top: -3px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; letter-spacing: 0;
  box-shadow: 0 0 0 2px var(--surface); font-variant-numeric: tabular-nums;
}
.notif-badge[hidden] { display: none; }
.notif-badge.is-bumped { animation: notif-pop .45s cubic-bezier(.3, 1.6, .5, 1); }
html[data-theme] .notif-bell {
  background: linear-gradient(135deg, var(--glass-sheen), transparent), var(--glass-fill);
  border-color: var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 0 1px var(--glass-rim), var(--glass-shadow);
}
html[data-theme] .notif-bell:hover, html[data-theme] .notif.is-open .notif-bell { color: var(--primary); }

/* ---------- Dropdown ---------- */
.notif-panel {
  position: absolute; top: calc(100% + 12px); right: -8px; z-index: 60;
  width: 400px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: notif-in .16s ease-out;
}
.notif-panel[hidden] { display: none; }
/* Solid glass: the header's own blur is a backdrop root, so a see-through panel would show the page text. */
html[data-theme] .notif-panel {
  background: linear-gradient(135deg, var(--glass-sheen), transparent 55%), var(--glass-solid);
  border-color: var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 0 1px var(--glass-rim), var(--glass-shadow-raised);
}
.notif-panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.notif-panel__head strong { font-size: 15px; letter-spacing: -.2px; }
.notif-link {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px; margin: -4px -6px;
  border: 0; border-radius: 6px; background: none; color: var(--primary);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.notif-link:hover { background: var(--primary-soft); }
.notif-link[hidden] { display: none; }
.notif-link svg { width: 15px; height: 15px; }
.notif-panel__list { max-height: min(460px, calc(100vh - 230px)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.notif-panel__foot {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px;
  border-top: 1px solid var(--border); color: var(--primary); font-size: 13.5px; font-weight: 600; text-decoration: none !important;
}
.notif-panel__foot:hover { background: var(--surface-2); }
.notif-panel__foot svg { width: 15px; height: 15px; }

.notif-items { list-style: none; margin: 0; padding: 4px 0; }
.notif-items > li + li { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.notif-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 10px; gap: 12px; align-items: start;
  padding: 12px 16px; color: var(--text); text-decoration: none !important; transition: background-color .12s;
}
a.notif-item:hover { background: var(--surface-2); }
a.notif-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 8px; }
.notif-item.is-unread { background: color-mix(in srgb, var(--primary) 5%, transparent); }
a.notif-item.is-unread:hover { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.notif-item__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-item__title { font-size: 14px; font-weight: 550; line-height: 1.35; color: var(--text-2); overflow-wrap: anywhere; }
.notif-item.is-unread .notif-item__title { font-weight: 650; color: var(--text); }
.notif-item__body {
  font-size: 13px; line-height: 1.45; color: var(--text-2); overflow-wrap: anywhere; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-item__body--full { display: block; -webkit-line-clamp: unset; white-space: normal; }
.notif-item__body[hidden] { display: none; }
.notif-item__meta { font-size: 12px; color: var(--muted); }
.notif-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }

.notif-icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--primary-soft); color: var(--primary);
}
.notif-icon svg { width: 18px; height: 18px; }
.notif-icon--test { background: var(--info-soft); color: var(--info); }
.notif-icon--standard { background: var(--warning-soft); color: var(--warning); }

.notif-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 24px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.55; }
.notif-empty svg { width: 34px; height: 34px; color: var(--border-strong); margin-bottom: 4px; }
.notif-empty strong { color: var(--text); font-size: 14.5px; }
.notif-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 34px 16px; color: var(--muted); font-size: 13px; }
.notif-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: notif-spin .7s linear infinite; }
.notif-error { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .notif-bell { width: 44px; height: 44px; }
  .site-header .notif-bell svg { width: 20px; height: 20px; }
}
/* Phones: the dropdown spans the screen under the header. */
@media (max-width: 560px) {
  .notif-panel { position: fixed; top: calc(var(--sh-height, 72px) + 6px); left: 10px; right: 10px; width: auto; max-width: none; }
  .notif-panel__list { max-height: calc(100vh - var(--sh-height, 72px) - 140px); max-height: calc(100dvh - var(--sh-height, 72px) - 140px); }
}

/* ---------- Pop-up for a notification that just arrived ---------- */
.toast.notif-toast {
  align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--primary);
}
.notif-toast.notif-toast--test { border-left-color: var(--info); }
.notif-toast.notif-toast--standard { border-left-color: var(--warning); }
.notif-toast__link { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; color: inherit; text-decoration: none !important; }
.notif-toast__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-toast__label { font-size: 11px; font-weight: 650; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.notif-toast__title { font-size: 14px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.notif-toast__body { font-size: 12.5px; color: var(--text-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.notif-toast .toast-close { align-self: flex-start; }

/* ---------- Notifications page ---------- */
.notif-page { max-width: 860px; margin-inline: auto; }
.notif-feed { list-style: none; margin: 0; padding: 0; }
.notif-entry {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px;
  padding: 20px 24px; scroll-margin-top: 120px;
}
.notif-entry + .notif-entry { border-top: 1px solid var(--border); }
.notif-entry.is-unread { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.notif-entry:first-child { border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.notif-entry:target { animation: notif-flash 2.4s ease-out; }
.notif-entry .notif-icon { width: 40px; height: 40px; }
.notif-entry__main { min-width: 0; }
.notif-entry__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.notif-entry__title { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.4; letter-spacing: -.2px; overflow-wrap: anywhere; }
.notif-entry__title a { color: var(--text); }
.notif-entry__title .badge { margin-left: 6px; vertical-align: 2px; }
.notif-entry__top .btn-icon { margin: -6px -8px 0 0; color: var(--muted); }
.notif-entry__body { margin-top: 6px; color: var(--text-2); font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; }
.notif-entry__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.notif-entry__go { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-weight: 600; color: var(--primary); }
.notif-entry__go svg { width: 14px; height: 14px; }
@media (max-width: 560px) {
  .notif-entry { grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 16px; }
  .notif-entry .notif-icon { width: 34px; height: 34px; }
  .notif-entry__go { margin-left: 0; flex-basis: 100%; }
}

/* ---------- Panel: list, detail, compose ---------- */
.notif-admin-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.notif-admin-bar .pick-search { width: min(280px, 100%); }
.cell-notif { min-width: 260px; }
.notif-cell { display: flex; align-items: flex-start; gap: 12px; }
.notif-cell .notif-icon { width: 34px; height: 34px; }
.notif-cell__body { max-width: 52ch; }
.read-meter { display: flex; align-items: center; gap: 8px; }
.read-meter .progress { width: 90px; }
.read-summary { display: flex; align-items: center; gap: 18px; }
.read-summary .score-ring strong { font-size: 1.15rem; }

.compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.compose-side { position: sticky; top: calc(var(--topbar-h, 60px) + 16px); }
@media (max-width: 1100px) {
  .compose-grid { grid-template-columns: minmax(0, 1fr); }
  .compose-side { position: static; }
}
.compose-audience { display: flex; width: 100%; }
.compose-audience label { flex: 1 1 0; min-width: 0; }
.compose-audience span { justify-content: center; width: 100%; white-space: nowrap; }
.compose-audience svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 520px) {
  .compose-audience { flex-direction: column; }
}
.compose-note { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); }
.compose-note svg { width: 18px; height: 18px; color: var(--primary); flex: none; }
.compose-groups { max-height: 320px; overflow-y: auto; }
.compose-chips {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 46px; padding: 7px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.compose-chips [data-chips-empty] { padding: 0 6px; }
.person-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 3px 3px 3px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 600;
}
.person-chip > span:not(.avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-chip .avatar { --size: 24px; font-size: 10px; }
.person-chip button {
  display: grid; place-items: center; width: 22px; height: 22px; padding: 0; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
}
.person-chip button:hover { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.person-chip button svg { width: 13px; height: 13px; }
[data-people-results]:empty { display: none; }
.notif-preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.compose-reach { margin: 14px 0 0; font-size: 14px; color: var(--text-2); }
.compose-reach strong { color: var(--text); }
.compose-tips p { margin-top: 6px; line-height: 1.6; }
.field .help.row-between { gap: 12px; }
[data-count-for] { flex: none; font-variant-numeric: tabular-nums; }
[data-count-for].is-near { color: var(--warning); font-weight: 600; }

/* ---------- Motion ---------- */
@keyframes notif-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes notif-pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }
@keyframes notif-spin { to { transform: rotate(360deg); } }
@keyframes notif-ring {
  0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); }
  45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); }
}
@keyframes notif-flash { 0%, 30% { background: color-mix(in srgb, var(--primary) 14%, transparent); } }
@media (prefers-reduced-motion: reduce) {
  .notif-panel, .notif-badge.is-bumped, .notif-bell.is-ringing svg, .notif-entry:target { animation: none; }
}
