/* =====================================================================
   Components. Only var(--token) colors: they work in light and dark.
   No inline styles anywhere (the CSP forbids them); dynamic values come
   from data-* attributes applied by assets/js/ui.js.
   ===================================================================== */

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: 72rem; margin: 0 auto; padding-left: var(--s-4); padding-right: var(--s-4); }
.container--narrow { max-width: 42rem; }
.stack > * + * { margin-top: var(--s-4); }
.stack--lg > * + * { margin-top: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.grid-auto { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.muted { color: var(--c-ink-2); }
.faint { color: var(--c-ink-3); }
.text-accent { color: var(--c-accent-text); }
.eyebrow { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-accent-text); margin-bottom: var(--s-2); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--c-ink); text-decoration: none; font-weight: 800; font-size: var(--fs-lg); letter-spacing: -.02em; }
.brand__mark { width: 34px; height: 34px; flex: none; }
.brand__mark .m-bg { fill: var(--c-accent); }
.brand__mark .m-fg { fill: none; stroke: var(--c-accent-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding-top: var(--s-4); padding-bottom: var(--s-4); }

/* ---------- Icons ---------- */
.icon { width: 1.5rem; height: 1.5rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 1.125rem; height: 1.125rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--touch); padding: 0 1.4rem;
  font: inherit; font-weight: 700; line-height: 1; text-decoration: none; white-space: nowrap;
  border: 1.5px solid transparent; border-radius: var(--radius-pill);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--c-accent); color: var(--c-accent-ink); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--c-accent-hover); }
.btn--secondary { background: var(--c-surface); color: var(--c-ink); border-color: var(--c-border-strong); }
.btn--secondary:hover { background: var(--c-surface-2); }
.btn--ghost { background: transparent; color: var(--c-ink); }
.btn--ghost:hover { background: var(--c-surface-2); }
.btn--danger { background: var(--c-urgent); color: var(--c-on-urgent); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 56px; font-size: var(--fs-lg); padding: 0 1.8rem; }
.btn--icon { width: var(--touch); padding: 0; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: var(--radius-pill); font-size: .8125rem; font-weight: 700; line-height: 1.2; background: var(--c-surface-2); color: var(--c-ink-2); }
.badge--accent { background: var(--c-accent-soft); color: var(--c-accent-text); }
.badge--read { background: var(--c-read-soft); color: var(--c-read); }
.badge--urgent { background: var(--c-urgent-soft); color: var(--c-urgent); }
.badge--info { background: var(--c-info-soft); color: var(--c-info); }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 1rem; border-radius: var(--radius-pill); border: 1.5px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-ink); font: inherit; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--c-ink); color: var(--c-bg); border-color: var(--c-ink); }
.unread-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); flex: none; }

/* ---------- Cards ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--s-5); }
.card--flat { box-shadow: none; }
.card__title { margin-bottom: var(--s-2); }

/* Communication card in the feed */
.feed-card { display: block; position: relative; overflow: hidden; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: inherit; text-decoration: none; }
.feed-card__cover { height: 9rem; background: var(--c-surface-2); }
.feed-card__cover--warm { background: linear-gradient(135deg, var(--c-accent-soft), var(--c-surface-2)); }
.feed-card__body { padding: var(--s-4) var(--s-5) var(--s-4); }
.feed-card__meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-2); color: var(--c-ink-3); font-size: var(--fs-sm); }
.feed-card__title { font-size: var(--fs-lg); margin-bottom: var(--s-2); }
.feed-card__excerpt { color: var(--c-ink-2); margin-bottom: var(--s-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed-card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); color: var(--c-ink-3); font-size: var(--fs-sm); }
.feed-card.is-unread { border-color: var(--c-accent); }
.feed-card.is-unread .feed-card__title { font-weight: 800; }
.feed-card.is-read .feed-card__title { font-weight: 600; color: var(--c-ink-2); }
.feed-card--urgent { border-color: var(--c-urgent); }
.feed-card--urgent::before { content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 6px; background: var(--c-urgent); }

.banner { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-radius: var(--radius-md); background: var(--c-surface-2); }
.banner--urgent { background: var(--c-urgent-soft); color: var(--c-urgent); font-weight: 650; }
.banner--info { background: var(--c-info-soft); color: var(--c-info); }

/* ---------- Reading indicators ---------- */
.ring { --p: 0; --size: 4.5rem; position: relative; display: grid; place-items: center; width: var(--size); height: var(--size); border-radius: 50%; background: conic-gradient(var(--c-read) calc(var(--p) * 1%), var(--c-surface-2) 0 100%); font-weight: 800; font-variant-numeric: tabular-nums; }
.ring::before { content: ""; position: absolute; top: 7px; right: 7px; bottom: 7px; left: 7px; border-radius: 50%; background: var(--c-surface); }
.ring > span { position: relative; font-size: .95rem; }
.progress { --p: 0; height: .625rem; border-radius: var(--radius-pill); background: var(--c-surface-2); overflow: hidden; }
.progress::before { content: ""; display: block; height: 100%; width: calc(var(--p) * 1%); background: var(--c-accent); border-radius: inherit; transition: width .4s ease; }
.progress--read::before { background: var(--c-read); }
.stat { display: flex; align-items: center; gap: var(--s-4); }
.stat__value { font-size: var(--fs-2xl); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--c-ink-2); font-size: var(--fs-sm); }

/* ---------- Segmented control (theme switch) ---------- */
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius-pill); }
.segmented button { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: 0 .9rem; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--c-ink-2); font: inherit; font-size: var(--fs-sm); font-weight: 700; cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--c-surface); color: var(--c-ink); box-shadow: var(--shadow-sm); }
.segmented .icon { width: 1.1rem; height: 1.1rem; }

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; justify-content: space-around; padding: var(--s-2) var(--s-2) calc(var(--s-2) + var(--safe-bottom)); background: var(--c-surface); border-top: 1px solid var(--c-border); }
.bottom-nav--static { position: static; border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding-bottom: var(--s-2); }
.bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 64px; min-height: var(--touch); padding: var(--s-1) var(--s-2); color: var(--c-ink-3); font-size: .75rem; font-weight: 700; text-decoration: none; border-radius: var(--radius-md); }
.bottom-nav a[aria-current="page"] { color: var(--c-ink); }
.bottom-nav a[aria-current="page"] .icon { color: var(--c-accent-text); }
.nav-badge { position: absolute; top: 0; right: 10px; min-width: 1.2rem; height: 1.2rem; padding: 0 .3rem; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--c-urgent); color: var(--c-on-urgent); font-size: .7rem; font-weight: 800; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: 0 var(--s-4); pointer-events: none; }
.toast { display: flex; align-items: center; gap: var(--s-3); max-width: 28rem; padding: var(--s-3) var(--s-4); border-radius: var(--radius-md); background: var(--c-ink); color: var(--c-bg); box-shadow: var(--shadow-md); font-weight: 650; animation: toast-in .25s ease both; pointer-events: auto; }
.toast--success .icon { color: var(--c-read); }
.toast--error .icon { color: var(--c-urgent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state / skeleton ---------- */
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--c-ink-2); }
.empty__art { width: 5rem; height: 5rem; margin: 0 auto var(--s-4); display: grid; place-items: center; border-radius: 50%; background: var(--c-accent-soft); color: var(--c-accent-text); }
.empty__art .icon { width: 2.25rem; height: 2.25rem; }
.empty h3 { color: var(--c-ink); }
.skeleton { border-radius: var(--radius-md); background: linear-gradient(90deg, var(--c-surface-2), var(--c-border), var(--c-surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Home ---------- */
.hero { padding: var(--s-7) 0 var(--s-8); background: radial-gradient(60rem 28rem at 85% -10%, var(--c-accent-soft), transparent 70%); }
.hero__title { font-size: var(--fs-hero); line-height: 1.08; letter-spacing: -.03em; margin-bottom: var(--s-4); max-width: 18ch; }
.hero__lead { font-size: var(--fs-lg); color: var(--c-ink-2); max-width: 36rem; margin-bottom: var(--s-5); }
.pillar__icon { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: var(--radius-md); background: var(--c-accent-soft); color: var(--c-accent-text); margin-bottom: var(--s-3); }
.site-footer { padding: var(--s-6) 0; color: var(--c-ink-3); font-size: var(--fs-sm); }

/* ---------- Design system page ---------- */
.ds-section { padding: var(--s-6) 0; border-top: 1px solid var(--c-border); }
.swatches { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.swatch { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-sm); }
.swatch i { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); border: 1px solid var(--c-border-strong); flex: none; }
.sw-bg { background: var(--c-bg); } .sw-surface { background: var(--c-surface); } .sw-surface-2 { background: var(--c-surface-2); }
.sw-border { background: var(--c-border-strong); } .sw-ink { background: var(--c-ink); } .sw-ink-2 { background: var(--c-ink-2); }
.sw-accent { background: var(--c-accent); } .sw-accent-soft { background: var(--c-accent-soft); } .sw-accent-text { background: var(--c-accent-text); }
.sw-read { background: var(--c-read); } .sw-urgent { background: var(--c-urgent); } .sw-info { background: var(--c-info); }

@media (min-width: 48em) {
  .feed-card__cover { height: 11rem; }
  .toasts { bottom: var(--s-5); }
}

/* Home hero grid */
.hero__grid { display: grid; gap: var(--s-6); align-items: center; }
@media (min-width: 52em) { .hero__grid { grid-template-columns: 1.1fr .9fr; } }
