/* =============================================
   UTOPIA — ACTIVITY ("The Pulse")
   Live, site-wide timeline of completed trades.
   Mobile-first, theme-aware (light & dark), reuses
   the shared design tokens from styles.css.
   ============================================= */

:root {
    --act-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --act-green: var(--accent-green, #10b981);
    --act-card-bg: var(--bg-secondary);
    --act-spine: var(--border-primary);
}
[data-theme="light"] {
    --act-card-bg: #ffffff;
}

/* ---------- Top header (back · title · bell) ---------- */
.top-header.act-top-header {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
}
.act-back-btn {
    width: 44px; height: 44px;
    border: 0; padding: 0;
    background: transparent;
    border-radius: 50%;
    color: var(--blue-500);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.act-back-btn:active { transform: scale(0.92); }
.act-back-btn:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.act-back-btn .material-symbols-outlined { font-size: 24px; }
.act-title {
    margin: 0;
    text-align: center;
    font-family: 'Manrope', 'Inter', -apple-system, sans-serif;
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ---------- Content shell ---------- */
.act-content {
    padding-top: calc(var(--home-header-height, 64px) + 14px);
    padding-bottom: calc(var(--home-pill-height, 64px) + var(--home-pill-offset, 16px) + 36px + env(safe-area-inset-bottom, 0px));
    padding-left: 20px;
    padding-right: 20px;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- Hero ---------- */
.act-hero { padding: 6px 0 4px; }
.act-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Manrope', 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.act-live-dot {
    position: relative;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--act-green);
    flex-shrink: 0;
}
.act-live-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--act-green);
    animation: actRadar 2.2s ease-out infinite;
}
@keyframes actRadar {
    0%   { transform: scale(1);   opacity: 0.6; }
    100% { transform: scale(3.4); opacity: 0; }
}
.act-hero-sub {
    margin: 10px 0 18px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.4;
}

.act-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 26px;
}
.act-stat {
    flex: 1;
    min-width: 0;
    background: var(--act-card-bg);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: 14px 8px;
    text-align: center;
}
.act-stat-num {
    display: block;
    font-family: 'Manrope', 'Inter', sans-serif;
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.05;
}
.act-stat-label {
    display: block;
    margin-top: 5px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

/* ---------- "N new" jump pill ---------- */
.act-newpill {
    position: fixed;
    left: 50%;
    top: calc(var(--home-header-height, 64px) + 12px);
    transform: translateX(-50%) translateY(-10px);
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 0;
    border-radius: 9999px;
    background: var(--blue-500);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 700;
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.38);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--act-ease), transform 0.25s var(--act-ease);
}
.act-newpill.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.act-newpill:active { transform: translateX(-50%) translateY(0) scale(0.96); }
.act-newpill .material-symbols-outlined { font-size: 18px; }

/* These set their own display, so the UA `[hidden]{display:none}` loses the
   cascade — re-assert it here (the attribute selector adds the specificity). */
.act-newpill[hidden],
.act-loadmore[hidden],
.act-empty[hidden] { display: none; }

/* ---------- Timeline ---------- */
.act-feed { position: relative; }

/* Continuous spine: each row/header draws its own segment so they stack
   seamlessly even across group dividers. */
.act-item,
.act-group-title { position: relative; padding-left: 36px; }
.act-item::before,
.act-group-title::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--act-spine);
}
.act-feed > .act-item:first-child::before,
.act-feed > .act-group-title:first-child::before { top: 8px; }
.act-feed > .act-item:last-child::before { bottom: auto; height: 26px; }

.act-group-title {
    padding-top: 16px;
    padding-bottom: 10px;
    font-family: 'Manrope', 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}
.act-feed > .act-group-title:first-child { padding-top: 4px; }

.act-item { padding-bottom: 12px; }
.act-dot {
    position: absolute;
    left: 7px; top: 22px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--blue-500);
    border: 3px solid var(--bg-primary);
    box-sizing: border-box;
    z-index: 1;
}

/* The newest trade gets a green "live" heartbeat. */
.act-item.newest .act-dot {
    background: var(--act-green);
    animation: actHeartbeat 2.4s ease-in-out infinite;
}
@keyframes actHeartbeat {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
    50%      { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.18); }
}

/* ---------- Trade card ---------- */
.act-card {
    background: var(--act-card-bg);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.20);
    padding: 12px 14px;
    transition: transform 0.2s var(--act-ease), border-color 0.2s ease;
}
[data-theme="light"] .act-card { box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06); }
.act-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.act-avatars {
    position: relative;
    flex: 0 0 auto;
    width: 52px; height: 34px;
}
.act-avatar {
    position: absolute;
    top: 0;
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
    border: 2px solid var(--act-card-bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-tertiary);
}
.act-avatar.first { left: 0; z-index: 2; }
.act-avatar.second { left: 18px; z-index: 1; }
.act-avatar .material-symbols-outlined { font-size: 20px; }

.act-parties {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}
.act-name {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.act-you { color: var(--blue-500); flex-shrink: 0; }
.act-swap {
    font-size: 16px;
    color: var(--blue-500);
    flex-shrink: 0;
}

.act-value {
    flex: 0 0 auto;
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.14);
    color: var(--act-green);
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 9999px;
    letter-spacing: 0.01em;
}
[data-theme="light"] .act-value { background: rgba(16, 185, 129, 0.10); }

.act-time {
    margin-top: 8px;
    padding-left: 62px;   /* align under the parties text, past the avatars */
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Fresh trades fade/slide in as they arrive. */
@keyframes actFreshIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: none; }
}
.act-item.fresh .act-card { animation: actFreshIn 0.5s var(--act-ease) both; }

/* ---------- Skeleton (initial load) ---------- */
.act-card.act-skel { pointer-events: none; }
.act-skel-line {
    height: 12px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    position: relative;
    overflow: hidden;
}
.act-skel-line.w60 { width: 60%; }
.act-skel-line.w30 { width: 30%; margin-top: 10px; }
.act-skel-line::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.14), transparent);
    animation: actShimmer 1.3s infinite;
}
@keyframes actShimmer { 100% { transform: translateX(100%); } }

/* ---------- Load-more / error ---------- */
.act-loadmore {
    display: flex;
    justify-content: center;
    padding: 18px 0 6px;
}
.act-spinner {
    width: 22px; height: 22px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--blue-500);
    border-radius: 50%;
    animation: actSpin 0.8s linear infinite;
}
@keyframes actSpin { to { transform: rotate(360deg); } }

.act-error {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    padding: 24px 0;
}
.act-error button {
    margin-left: 6px;
    color: var(--blue-500);
    font-weight: 700;
    background: none; border: 0; cursor: pointer;
}
.act-sentinel { width: 100%; height: 1px; }

/* ---------- Empty state ---------- */
.act-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}
.act-empty .material-symbols-outlined {
    font-size: 44px;
    color: var(--text-tertiary);
    opacity: 0.55;
    margin-bottom: 10px;
    display: block;
}
.act-empty-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0 0 4px;
}
.act-empty-sub { margin: 0 0 18px; font-size: 0.875rem; }
.act-empty-cta {
    display: inline-flex;
    align-items: center;
    padding: 12px 22px;
    background: var(--blue-500);
    color: #fff;
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: 0.9375rem;
    transition: background 0.2s ease;
}
.act-empty-cta:hover { background: var(--blue-600); }

/* ---------- Desktop ---------- */
@media (min-width: 768px) {
    .act-title { font-size: 1.25rem; }
    .act-hero-sub { font-size: 1rem; }
    .act-stat-num { font-size: 1.625rem; }
    .act-stat-label { font-size: 0.6875rem; }
    .act-parties { font-size: 0.9375rem; }
    .act-value { font-size: 0.875rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .act-live-dot::after,
    .act-item.newest .act-dot,
    .act-item.fresh .act-card,
    .act-skel-line::after,
    .act-spinner { animation: none !important; }
    .act-newpill { transition: opacity 0.01s linear; }
}
