/* ==========================================================================
   IRONITT v2 — notifications panel
   --------------------------------------------------------------------------
   The activity log that opens from the bell: a header, a search field, one
   row with the All / Unread / Mentions switch and the type filter, the
   active filter chips, then the feed grouped into Today and Earlier.

   The panel itself is the shared .popup-panel (style.css, shell.css place
   it); it floats, so it keeps its shadow. Inside, everything is flat: an
   entry is a row (who, the sentence, the quote, when + what to do), never a
   card in a card. Unread is a dot and a stronger sentence, nothing louder.
   ========================================================================== */

.notif-panel {
  width: min(420px, calc(100vw - 24px));
  max-height: min(680px, calc(100dvh - 24px));
}

/* ---- Header ------------------------------------------------------------ */
.notif-panel-header {
  padding: var(--space-md) var(--space-md) var(--space-sm) var(--space-lg);
  border-bottom: 0;
}
.notif-panel-header h2 {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
}
.notif-panel-header-actions { display: flex; align-items: center; gap: var(--space-xs); }
.notif-panel-action-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.notif-panel-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Search ------------------------------------------------------------ */
.notif-search-wrap { padding: 0 var(--space-md) var(--space-sm); }
.notif-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: 40px;
  padding: 0 var(--space-sm) 0 var(--space-md);
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  transition: border-color 150ms ease;
}
.notif-search:focus-within { border-color: var(--accent-color); }
.notif-search-icon { color: var(--text-muted); font-size: var(--font-size-xs); }
.notif-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}
.notif-search-input::placeholder { color: var(--text-muted); }
.notif-search-clear {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: var(--font-size-2xs);
  cursor: pointer;
}
.notif-search-clear[hidden] { display: none; }
/* The "press S" hint only means something with a keyboard. */
.notif-search-kbd {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--font-size-2xs);
}
.notif-search:focus-within .notif-search-kbd,
.notif-search-clear:not([hidden]) ~ .notif-search-kbd { display: none; }
@media (hover: none) { .notif-search-kbd { display: none; } }

/* ---- Switch + filter row ----------------------------------------------- */
.notif-panel-tabs-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-md) var(--space-sm);
}
.notif-panel-tabs {
  position: relative;
  flex: 1;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
}
.notif-tab-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  opacity: 0;
  pointer-events: none;
}
.notif-tab-indicator.visible { opacity: 1; }
.notif-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: color 150ms ease;
}
.notif-tab:hover { color: var(--text-primary); }
.notif-tab.active { color: var(--text-primary); }
.notif-tab-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent-color);
  color: var(--accent-text);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-bold);
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.notif-tab-count[hidden] { display: none; }

.notif-filter-wrap { position: relative; }
.notif-filter-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.notif-filter-btn:hover,
.notif-filter-btn.open { background: var(--bg-hover); color: var(--text-primary); }
/* Filters on: a dot, since the button is only an icon. */
.notif-filter-btn.has-filters { color: var(--accent-color); border-color: var(--accent-light); }
.notif-filter-btn.has-filters::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-round);
  background: var(--accent-color);
}

/* The filter menu floats over the feed, so it carries a shadow. */
.notif-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 3;
  width: 230px;
  padding: var(--space-xs);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.notif-filter-menu[hidden] { display: none; }
.notif-filter-menu-label {
  padding: var(--space-sm) var(--space-sm) var(--space-xs);
  color: var(--text-muted);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.notif-filter-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
}
.notif-filter-option:hover { background: var(--bg-hover); }
.notif-filter-check {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: transparent;
  font-size: 10px;
}
.notif-filter-option.active .notif-filter-check { background: var(--accent-color); border-color: var(--accent-color); color: var(--accent-text); }
.notif-filter-option-icon { width: 16px; color: var(--text-muted); text-align: center; }
.notif-filter-option-label { flex: 1; }
.notif-filter-option-count { color: var(--text-muted); font-size: var(--font-size-xs); font-variant-numeric: tabular-nums; }

/* ---- Active filter chips ----------------------------------------------- */
.notif-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 var(--space-md) var(--space-sm);
}
.notif-filter-chips[hidden] { display: none; }
.notif-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-subtle);
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
}
.notif-chip > i:first-child { color: var(--accent-color); }
.notif-chip-x { color: var(--text-muted); font-size: 10px; }
.notif-chip--clear { background: transparent; color: var(--text-muted); }
.notif-chip--clear:hover { color: var(--text-primary); }

/* ---- Feed -------------------------------------------------------------- */
.notif-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--space-xs) var(--space-sm);
  border-top: 1px solid var(--border-color);
}
.notif-group-label {
  padding: var(--space-md) var(--space-md) var(--space-xs);
  color: var(--text-muted);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.notif-feed { display: grid; }

.notif-entry { position: relative; border-radius: var(--radius-md); }
.notif-entry-main {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: var(--space-sm) 12px;
  align-items: start;
  padding: 10px var(--space-md) 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: 0;
  transition: background-color 150ms ease;
}
.notif-entry-main:hover,
.notif-entry-main:focus-visible { background: var(--bg-hover); }
.notif-entry-main:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-color); }

/* Who: their avatar with the kind of event as a badge on its corner. */
.notif-entry-who { position: relative; width: 40px; height: 40px; }
.notif-entry-avatar { width: 40px; height: 40px; font-size: var(--font-size-sm); }
.notif-entry-node,
.notif-entry-sys {
  display: grid;
  place-items: center;
  border-radius: var(--radius-round);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.notif-entry-node {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  font-size: 9px;
  box-shadow: 0 0 0 2px var(--bg-secondary);
}
.notif-entry-sys { width: 40px; height: 40px; font-size: var(--font-size-sm); }
.notif-entry-node--accent { background: var(--accent-color); color: var(--accent-text); }
.notif-entry-node--iron { background: var(--iron-gold); color: var(--text-inverse); }

.notif-entry-copy { display: grid; gap: 6px; min-width: 0; }
.notif-entry-line {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.4;
}
.notif-entry-line strong { color: var(--text-primary); font-weight: var(--font-weight-semibold); }
.notif-entry.unread .notif-entry-line { color: var(--text-primary); }

/* What was said: a quiet quote under the sentence, marked by a hairline on
   its left rather than boxed. A gift or an item reads as a small record. */
.notif-entry-card {
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.notif-entry-card--iron { border-left-color: var(--iron-gold); }
.notif-card-head { display: flex; align-items: center; gap: 6px; }
.notif-card-diamond { display: inline-grid; width: 14px; height: 14px; color: var(--iron-gold); }
.notif-card-diamond svg { width: 100%; height: 100%; }
.notif-card-title { color: var(--text-primary); font-weight: var(--font-weight-semibold); }
.notif-card-rarity {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--iron-gold-soft);
  color: var(--iron-gold);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
}
.notif-card-note { margin-top: 2px; color: var(--text-muted); font-style: italic; }

.notif-entry-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
}
.notif-entry-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.notif-entry-action { color: var(--accent-color); font-weight: var(--font-weight-semibold); }
.notif-entry-action::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 var(--space-sm) 2px 0;
  border-radius: var(--radius-round);
  background: var(--text-muted);
  vertical-align: middle;
}

.notif-entry-unread-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: var(--radius-round);
  background: var(--accent-color);
}

/* Dismiss: shown on hover/focus with a pointer; always reachable on touch. */
.notif-entry-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: var(--font-size-2xs);
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, color 150ms ease;
}
.notif-entry:hover .notif-entry-dismiss,
.notif-entry:focus-within .notif-entry-dismiss { opacity: 1; }
.notif-entry-dismiss:hover { color: var(--text-primary); }
.notif-entry:hover .notif-entry-unread-dot { visibility: hidden; }
@media (hover: none) {
  .notif-entry-dismiss { opacity: 1; background: transparent; }
  .notif-entry-main { padding-right: 40px; }
  .notif-entry-unread-dot { position: absolute; top: 14px; right: 36px; margin: 0; }
}

/* ---- Empty state: an icon and a sentence ------------------------------- */
.notif-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
}
.notif-empty-icon { color: var(--text-muted); font-size: var(--font-size-lg); margin-bottom: var(--space-xs); }
.notif-empty-title { color: var(--text-primary); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); }
.notif-empty-desc { max-width: 30ch; color: var(--text-muted); font-size: var(--font-size-xs); line-height: 1.5; }

/* ---- Phones: the panel is a sheet that uses the height it is given ----- */
@media (max-width: 768px) {
  .notif-panel { width: auto; max-height: none; }
  .notif-panel.active, .notif-panel.closing {
    bottom: calc(var(--mobile-nav-h, 64px) + env(safe-area-inset-bottom, 0px) + 20px);
  }
}

/* ---- Toasts (#notif-toasts, js/island.js _toast) ----------------------- */
/* Small cards in the bottom-right corner, newest on top, at most three.
   They float, so they carry the shadow; they never touch the navigation. */
#notif-toasts {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  z-index: calc(var(--z-tooltip) + 10);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: min(360px, calc(100vw - 2 * var(--space-md)));
  pointer-events: none;
}
#notif-toasts:empty { display: none; }

.notif-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: auto;
  transition: opacity 200ms ease, transform 200ms var(--island-ease);
}
.notif-toast--in { opacity: 1; transform: none; }
.notif-toast--out { opacity: 0; transform: none; transition-duration: 150ms; pointer-events: none; }
.notif-toast--link { cursor: pointer; }
.notif-toast--link:hover { border-color: var(--text-muted); }

.notif-toast__icon { flex-shrink: 0; width: 18px; text-align: center; font-size: 15px; color: var(--text-muted); }
.notif-toast--accent .notif-toast__icon { color: var(--accent-color); }
.notif-toast--success .notif-toast__icon { color: var(--color-success); }
.notif-toast--danger .notif-toast__icon { color: var(--color-danger); }
.notif-toast--gold .notif-toast__icon { color: var(--iron-gold); }

.notif-toast__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.notif-toast__title {
  overflow: hidden;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.notif-toast__line {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-toast__action {
  flex-shrink: 0;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--accent-color);
  color: var(--accent-text);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background-color 150ms ease;
}
.notif-toast__action:hover { background: var(--accent-hover); }
.notif-toast__close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.notif-toast__close:hover { background: var(--bg-hover); color: var(--text-primary); }
.notif-toast__action:focus-visible,
.notif-toast__close:focus-visible { outline: 0; box-shadow: var(--focus-ring); }

/* Phones: full width above the dock (and above the call badge when it shows). */
@media (max-width: 768px) {
  #notif-toasts {
    left: var(--space-md);
    right: var(--space-md);
    width: auto;
    bottom: calc(var(--mobile-nav-h, 64px) + env(safe-area-inset-bottom, 0px) + 28px);
  }
  body:has(#notif-badge.notif-badge--visible) #notif-toasts {
    bottom: calc(var(--mobile-nav-h, 64px) + env(safe-area-inset-bottom, 0px) + 84px);
  }
  html.kb-open #notif-toasts { bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .notif-toast, .notif-toast--in { transform: none; transition: opacity 120ms ease; }
}
