/* ── What's New ──────────────────────────────────────────────────────────────
   The top-bar sparkle launcher, its slide-in panel, the story cards (shared by
   the panel and Settings → What's New), the once-per-session pop-up and the
   archive's filter bar. Theme-aware through the layout's --crm-* variables.   */

/* launcher */
.crm-wn-launcher { position: relative; }
.crm-wn-launcher.has-unread { color: var(--crm-primary); border-color: var(--crm-primary); background: var(--crm-primary-soft); }
.crm-wn-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: #e0245e; border: 2px solid var(--crm-surface, #fff); box-sizing: content-box; }
.crm-wn-dot-ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid #e0245e; opacity: .75; animation: crm-wn-pulse 1.6s ease-out infinite; }
@keyframes crm-wn-pulse { 0% { transform: scale(.5); opacity: .85; } 100% { transform: scale(1.5); opacity: 0; } }

/* panel */
.crm-wn-panel { width: min(500px, 100vw); background: var(--crm-bg, #F3F2F7); color: inherit; border-left: 1px solid var(--crm-border, #e8eaef); }
.crm-wn-head { align-items: flex-start; background: var(--crm-surface, #fff); border-bottom: 1px solid var(--crm-border, #e8eaef); padding: 14px 18px; }
.crm-wn-head-text { min-width: 0; }
.crm-wn-head .offcanvas-title { font-weight: 800; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.crm-wn-head .offcanvas-title i { color: var(--crm-primary); }
.crm-wn-sub { font-size: .78rem; color: #777; margin-top: 2px; }
.crm-wn-body { padding: 14px 16px; }
.crm-wn-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; padding: 10px 16px; border-top: 1px solid var(--crm-border, #e8eaef); background: var(--crm-surface, #fff); }
.crm-wn-link { background: none; border: 0; padding: 0; color: var(--crm-primary); font-weight: 700; font-size: .8rem; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.crm-wn-link:hover { text-decoration: underline; color: var(--crm-primary); }
.crm-wn-loading, .crm-wn-empty { text-align: center; color: #888; padding: 32px 14px; font-size: .84rem; }
.crm-wn-empty i { font-size: 2rem; display: block; margin-bottom: 8px; opacity: .45; }

/* cards — ONE type scale for every surface: title .92 · summary/body .84 ·
   section label .7 · chips .68. Nothing in a story is set outside these. */
.crm-wn-list { display: flex; flex-direction: column; gap: 12px; }
.crm-wn-card { background: var(--crm-surface, #fff); border: 1px solid var(--crm-border, #e8eaef); border-radius: 16px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); transition: box-shadow .15s, border-color .15s; }
.crm-wn-card.is-unread { border-color: rgba(var(--crm-primary-rgb, 83,3,131), .45); box-shadow: 0 0 0 3px rgba(var(--crm-primary-rgb, 83,3,131), .08); }
.crm-wn-card.is-open { box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.crm-wn-card-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "meta caret" "title caret"; column-gap: 10px; row-gap: 6px; align-items: start; width: 100%; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; min-width: 0; font-family: inherit; }
.crm-wn-card-meta { grid-area: meta; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.crm-wn-card-title { grid-area: title; font-weight: 700; font-size: .92rem; min-width: 0; line-height: 1.35; overflow-wrap: anywhere; }
.crm-wn-caret { grid-area: caret; align-self: center; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--crm-bg, #F3F2F7); color: #6f6f7a; font-size: .95rem; transition: transform .15s; }
.crm-wn-card-head[aria-expanded="true"] .crm-wn-caret { transform: rotate(180deg); }
.crm-wn-chip { font-size: .68rem; line-height: 1; padding: 5px 9px; border-radius: 999px; background: var(--crm-primary-soft, rgba(83,3,131,.08)); color: var(--crm-primary); font-weight: 700; white-space: nowrap; }
.crm-wn-date { font-size: .68rem; color: #8a8a8a; white-space: nowrap; }
.crm-wn-badge { font-size: .62rem; line-height: 1; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; white-space: nowrap; }
.crm-wn-badge-feature { background: #e6f6ec; color: #157347; }
.crm-wn-badge-improvement { background: #fff3df; color: #a85a00; }
.crm-wn-card-summary { font-size: .84rem; color: #5c5c66; margin-top: 8px; line-height: 1.55; }
.crm-wn-card-body { margin-top: 12px; }

/* the story body — one rounded box per section */
.crm-wn-prose { font-size: .84rem; line-height: 1.55; display: flex; flex-direction: column; gap: 10px; }
.crm-wn-sec { border: 1px solid var(--crm-border, #e8eaef); border-radius: 12px; padding: 11px 13px 9px; background: var(--crm-bg, #F3F2F7); }
.crm-wn-sec-where { background: rgba(var(--crm-primary-rgb, 83,3,131), .06); border-color: rgba(var(--crm-primary-rgb, 83,3,131), .22); }
.crm-wn-sec-improves { background: #f0faf4; border-color: #cfeadb; }
.crm-wn-sec-head { display: flex; align-items: center; gap: 7px; font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--crm-primary); margin-bottom: 7px; line-height: 1.2; }
.crm-wn-sec-head i { font-size: 1rem; line-height: 1; }
.crm-wn-sec-improves .crm-wn-sec-head { color: #157347; }
.crm-wn-sec-body { font-size: .84rem; line-height: 1.55; }
.crm-wn-sec-body > :last-child { margin-bottom: 0; }
.crm-wn-prose p { margin: 0 0 8px; }
.crm-wn-prose ul { list-style: none; padding: 0; margin: 0 0 6px; }
.crm-wn-prose ul li { position: relative; padding-left: 16px; margin-bottom: 5px; }
.crm-wn-prose ul li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--crm-primary); opacity: .75; }
.crm-wn-prose ol { list-style: none; counter-reset: crm-wn-step; padding: 0; margin: 0 0 6px; }
.crm-wn-prose ol li { counter-increment: crm-wn-step; position: relative; padding-left: 30px; margin-bottom: 7px; min-height: 22px; }
.crm-wn-prose ol li::before { content: counter(crm-wn-step); position: absolute; left: 0; top: .05em; width: 22px; height: 22px; border-radius: 50%; background: var(--crm-primary); color: #fff; font-size: .7rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.crm-wn-prose li > p { margin: 0; }
.crm-wn-prose strong { font-weight: 700; color: inherit; }
.crm-wn-prose img { max-width: 100%; height: auto; border-radius: 8px; }
.crm-wn-prose code { font-size: .8em; background: var(--crm-primary-soft, rgba(83,3,131,.08)); padding: 1px 5px; border-radius: 4px; }
.crm-wn-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.crm-wn-card-actions .btn { font-size: .8rem; border-radius: 10px; padding: 6px 12px; }
.crm-wn-cta { display: inline-flex; align-items: center; gap: 5px; }
.crm-wn-read-stamp { font-size: .76rem; color: #157347; display: inline-flex; gap: 4px; align-items: center; }

/* the once-per-session pop-up */
.crm-wn-toast { position: fixed; right: 18px; bottom: 18px; z-index: 1085; display: flex; align-items: center; gap: 10px; background: var(--crm-surface, #fff); color: inherit; border: 1px solid rgba(var(--crm-primary-rgb, 83,3,131), .35); box-shadow: 0 10px 30px rgba(0,0,0,.18); border-radius: 14px; padding: 10px 10px 10px 14px; max-width: calc(100vw - 36px); font-size: .82rem; transform: translateY(20px); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.crm-wn-toast.show { transform: none; opacity: 1; }
.crm-wn-toast-icon { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--crm-primary); color: #fff; display: flex; align-items: center; justify-content: center; animation: crm-wn-blink 1.3s ease-in-out infinite; }
@keyframes crm-wn-blink { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--crm-primary-rgb, 83,3,131), .55); } 50% { box-shadow: 0 0 0 9px rgba(var(--crm-primary-rgb, 83,3,131), 0); } }
.crm-wn-toast-text { min-width: 0; }
.crm-wn-toast-cta { background: var(--crm-primary); color: #fff; border: 0; border-radius: 9px; padding: 6px 12px; font-weight: 700; font-size: .78rem; cursor: pointer; white-space: nowrap; font-family: inherit; }
.crm-wn-toast-cta:hover { filter: brightness(1.08); }
.crm-wn-toast-close { background: none; border: 0; font-size: 1.15rem; line-height: 1; color: #999; cursor: pointer; padding: 0 4px; font-family: inherit; }
.crm-wn-toast-close:hover { color: #444; }

/* archive (Settings → What's New) */
.crm-wn-archive-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 38px; margin-bottom: 14px; }
.crm-wn-archive-count { font-size: .82rem; color: #666; white-space: nowrap; }
.crm-wn-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.crm-wn-filters .form-select, .crm-wn-filters .form-control { width: auto; min-width: 128px; }
.crm-wn-search { position: relative; }
.crm-wn-search i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: #999; pointer-events: none; }
.crm-wn-search input { padding-left: 28px; min-width: 190px; }
.crm-wn-list-archive .crm-wn-card { border-radius: 16px; }
.crm-wn-empty-filter { padding: 22px 14px; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
    .crm-wn-dot-ring, .crm-wn-toast-icon { animation: none; }
    .crm-wn-toast { transition: none; }
}

/* dark mode */
html[data-bs-theme="dark"] .crm-wn-sub,
html[data-bs-theme="dark"] .crm-wn-card-summary,
html[data-bs-theme="dark"] .crm-wn-date,
html[data-bs-theme="dark"] .crm-wn-archive-count,
html[data-bs-theme="dark"] .crm-wn-loading,
html[data-bs-theme="dark"] .crm-wn-empty { color: #a9adbb; }
html[data-bs-theme="dark"] .crm-wn-badge-feature { background: rgba(21,115,71,.28); color: #7fe0a7; }
html[data-bs-theme="dark"] .crm-wn-badge-improvement { background: rgba(168,90,0,.28); color: #ffc46b; }
html[data-bs-theme="dark"] .crm-wn-read-stamp { color: #7fe0a7; }
html[data-bs-theme="dark"] .crm-wn-sec { background: rgba(255,255,255,.04); }
html[data-bs-theme="dark"] .crm-wn-sec-where { background: rgba(var(--crm-primary-rgb, 83,3,131), .18); }
html[data-bs-theme="dark"] .crm-wn-sec-improves { background: rgba(21,115,71,.16); border-color: rgba(21,115,71,.4); }
html[data-bs-theme="dark"] .crm-wn-sec-improves .crm-wn-sec-head { color: #7fe0a7; }
html[data-bs-theme="dark"] .crm-wn-caret { background: rgba(255,255,255,.08); color: #c5c8d3; }
html[data-bs-theme="dark"] .crm-wn-toast-close:hover { color: #eee; }
