/* Site messages: header bell, inbox panel, pinned banner.
   Loaded by base.html only when INBOX_ENABLED is on. Tokens only (tokens.css),
   so light and dark come for free; the bell sits on the identity bar, which is
   black in both themes, and inherits .icon-btn's colours there. */

/* ---- bell -------------------------------------------------------------- */
.icon-btn.inbox-bell { position: relative; width: 34px; padding: 0; }
.icon-btn.inbox-bell.is-open { background: var(--surface-inset); color: var(--text); }
.inbox-bell-icon {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.inbox-badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: var(--action); color: var(--on-action);
  font: 600 10px/16px var(--font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-shadow: 0 0 0 2px #000;
  pointer-events: none;
}

/* ---- panel ------------------------------------------------------------- */
/* Stacking with other first-visit layers on the same page:
   #280 v2 retirement modal (antd, z 1000) > rc-guide tour > this panel > the
   in-flow banner. The banner is in normal flow under the nav bar, so it never
   covers anything; the panel stays under any modal, including a ?inbox= deep
   link that opens on load. */
.inbox-layer { position: fixed; inset: 0; z-index: 900; }
.inbox-panel {
  position: absolute;
  top: calc(var(--header-identity-height, 56px) + 4px);
  right: max(var(--page-gutter, 16px), calc((100vw - var(--header-rail, 1440px)) / 2 + var(--page-gutter, 16px)));
  width: min(400px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 96px));
  display: flex; flex-direction: column;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: inbox-pop var(--dur-fast, 120ms) var(--ease-out, ease-out);
}
@keyframes inbox-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.inbox-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.inbox-panel-head h2 { margin: 0; font: 600 var(--text-md, 16px) var(--font-display); letter-spacing: 0.02em; }
.inbox-panel-actions { display: inline-flex; align-items: center; gap: 4px; }
.inbox-panel-body { overflow-y: auto; overscroll-behavior: contain; }

.inbox-link-btn {
  border: 0; background: none; padding: 4px 6px; border-radius: var(--radius-control);
  color: var(--action-text, var(--action)); font: 500 var(--text-sm, 13px) var(--font); cursor: pointer;
}
.inbox-link-btn:hover { background: var(--action-soft); }
.inbox-close {
  width: 28px; height: 28px; border: 0; border-radius: var(--radius-control);
  background: none; color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.inbox-close:hover { background: var(--surface-inset); color: var(--text); }
.inbox-link-btn:focus-visible, .inbox-close:focus-visible, .inbox-item:focus-visible, .inbox-back:focus-visible {
  outline: 2px solid var(--focus-ring, var(--action)); outline-offset: -2px;
}

.inbox-list { list-style: none; margin: 0; padding: 0; }
.inbox-list li + li { border-top: 1px solid var(--border-muted, var(--border)); }
.inbox-item {
  display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 12px 16px 12px 12px;
  border: 0; background: none; color: inherit; cursor: pointer; font: inherit;
}
.inbox-item:hover { background: var(--surface-inset); }
.inbox-item-dot { flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: transparent; }
.inbox-item.is-unread .inbox-item-dot { background: var(--action); }
.inbox-item-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.inbox-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inbox-item-time { color: var(--text-subtle); font-size: var(--text-xs, 12px); white-space: nowrap; }
.inbox-item-title { font-weight: 500; color: var(--text-muted); overflow-wrap: anywhere; }
.inbox-item.is-unread .inbox-item-title { font-weight: 600; color: var(--text); }
.inbox-item-excerpt {
  color: var(--text-muted); font-size: var(--text-sm, 13px);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-line;
}

.inbox-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.inbox-tag {
  padding: 0 6px; border-radius: var(--radius-pill, 999px);
  font: 600 10px/18px var(--font); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface-inset); color: var(--text-muted);
}
.inbox-tag.is-direct { background: var(--action-soft); color: var(--action-text, var(--action)); }
.inbox-tag.is-pinned { color: var(--attention, var(--text)); }

.inbox-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 16px; color: var(--text-subtle); text-align: center;
}
.inbox-empty .inbox-bell-icon { width: 28px; height: 28px; opacity: 0.6; }

.inbox-detail { padding: 12px 16px 20px; }
.inbox-back {
  display: block; border: 0; background: none; padding: 4px 0; margin-bottom: 8px;
  color: var(--text-muted); font: 500 var(--text-sm, 13px) var(--font); cursor: pointer;
}
.inbox-back:hover { color: var(--text); }
/* The title is the sender's text, not chrome: no house uppercase (chrome.css
   uppercases every h1-h4) and no display tracking. */
.inbox-detail-title {
  margin: 8px 0 4px; font: 600 var(--text-lg, 18px)/1.3 var(--font);
  text-transform: none; letter-spacing: normal; overflow-wrap: anywhere;
}
.inbox-detail-meta { color: var(--text-subtle); font-size: var(--text-xs, 12px); margin-bottom: 12px; }
.inbox-detail-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--leading-normal, 1.6); }
.inbox-detail-body a, .inbox-banner a { color: var(--action-text, var(--action)); text-decoration: underline; text-underline-offset: 2px; }

/* ---- pinned banner ----------------------------------------------------- */
/* The banner sits inside the sticky .site-header; include its height in the
   token other sticky blocks and scroll-padding use (tokens.css defines it as
   identity + nav). */
:root:has(.site-header .inbox-banner) {
  --header-height: calc(var(--header-identity-height) + var(--header-nav-height) + var(--inbox-banner-height, 0px));
}
.inbox-banner {
  background: var(--action-soft);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.inbox-banner-inner {
  display: flex; align-items: center; gap: 12px;
  max-width: var(--header-rail, 1440px); margin: 0 auto;
  padding: 8px var(--page-gutter, 16px);
  font-size: var(--text-sm, 13px);
}
.inbox-banner-label {
  flex: 0 0 auto; padding: 0 6px; border-radius: var(--radius-pill, 999px);
  background: var(--action); color: var(--on-action);
  font: 600 10px/18px var(--font); letter-spacing: 0.04em; text-transform: uppercase;
}
.inbox-banner-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- phones: the panel becomes a sheet under the header ---------------- */
@media (max-width: 640px) {
  .inbox-panel {
    top: var(--header-identity-height, 56px); right: 0; left: 0; bottom: 0;
    width: auto; max-height: none;
    border-radius: 0; border-left: 0; border-right: 0;
  }
  .inbox-banner-inner { flex-wrap: wrap; gap: 6px 10px; }
  .inbox-banner-text { flex-basis: calc(100% - 80px); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .inbox-banner-body { display: none; }
}
@media (prefers-reduced-motion: reduce) { .inbox-panel { animation: none; } }
