/* Presence on a record: the top-bar indicator (Components/LiveIndicator.razor) and the Live rail it toggles
   (Components/LiveRail.razor). The rail is a side rail, placed by css/side-rail.css. People's colours and
   avatars come from the shared people stylesheet. */

/* ---- Indicator ---- */

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    height: 32px;
    padding: 0 12px 0 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--neutral-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-secondary);
    white-space: nowrap;
    cursor: pointer;
}

/* With no avatars before it, the label takes the pill's own inset. */
.live-indicator.empty {
    padding-left: 12px;
}

.live-indicator:hover {
    border-color: var(--text-muted);
}

.live-indicator:focus-visible,
.live-icon-button:focus-visible,
.live-go:focus-visible,
.live-rail-title-row h2:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

.live-indicator.open {
    border-color: var(--brand-accent);
    background: var(--accent-bg);
}

/* Live updates are paused or interrupted: these are the people last seen, not the people here now. */
.live-indicator.paused {
    color: var(--text-muted);
}

.live-indicator.paused .person-stack {
    opacity: 0.55;
}

@media (max-width: 640px) {
    .live-indicator:not(.empty) .live-indicator-label {
        display: none;
    }

    .live-indicator:not(.empty) {
        padding-right: 3px;
    }
}

/* ---- Rail ---- */

.live-rail {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-subtle);
    background: var(--surface-app);
    color: var(--text-secondary);
    font-size: var(--fs-body);
    line-height: var(--lh-normal);
}

.live-rail-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 12px 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.live-rail-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.live-rail-title-row h2 {
    margin: 0;
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: var(--fs-section);
    font-weight: var(--fw-semibold);
    /* The base heading styles carry a display-size line height. */
    line-height: var(--lh-normal);
}

.live-rail-summary {
    color: var(--text-tertiary);
    font-size: var(--fs-secondary);
}

.live-icon-button {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.live-icon-button:hover {
    background: var(--neutral-bg);
    color: var(--text-primary);
}

.live-rail-body {
    flex: 1;
    min-height: 0;
    padding: 4px 18px 16px;
    overflow-x: hidden;
    overflow-y: auto;
}

.live-rail-heading {
    margin: 14px 0 2px;
    color: var(--text-muted);
    font-size: var(--fs-label);
    font-weight: var(--fw-bold);
    letter-spacing: var(--label-spacing-wide);
    line-height: var(--lh-normal);
    text-transform: uppercase;
}

.live-rail-empty {
    margin: 8px 0 0;
    color: var(--text-tertiary);
    font-size: var(--fs-secondary);
}

/* ---- People ---- */

.live-people {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.live-person {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 0;
}

.live-person + .live-person {
    border-top: 1px solid var(--border-subtle);
}

.live-person-text {
    flex: 1;
    min-width: 0;
}

.live-person-name {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 6px;
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
    overflow-wrap: anywhere;
}

.live-person-role {
    color: var(--text-muted);
    font-size: var(--fs-small);
    font-weight: 400;
}

.live-person-where {
    color: var(--text-tertiary);
    font-size: var(--fs-small);
    overflow-wrap: anywhere;
}

.live-go {
    flex: none;
    padding: 2px;
    border-radius: var(--radius-xs);
    color: var(--status-info);
    font-size: var(--fs-secondary);
    text-decoration: none;
}

.live-go:hover {
    text-decoration: underline;
}

/* The current user, in the accent that already means "you" and "selected". */
.person-you {
    --person-bg: var(--accent-bg);
    --person-fg: var(--brand-accent);
}

/* The changes that arrived while the rail was closed. */
.live-indicator-count {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand-accent);
    color: var(--surface-app);
    font-size: 11px;
    font-weight: var(--fw-bold);
    line-height: 1;
}

/* ---- Changes ---- */

.live-changes {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.live-change {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.live-change .person-avatar {
    margin-top: 1px;
}

.live-change-text {
    flex: 1;
    min-width: 0;
}

.live-change-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 4px;
    color: var(--text-secondary);
    font-size: var(--fs-secondary);
}

.live-change-subject {
    padding: 0;
    font-size: var(--fs-secondary);
    overflow-wrap: anywhere;
}

.live-change-when {
    margin-left: auto;
    color: var(--text-muted);
    font-size: var(--fs-small);
    white-space: nowrap;
}

/* One line each: a long value is cut, and the field itself shows the whole of it. */
.live-change-value,
.live-change-was {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-change-value {
    margin-top: 1px;
    color: var(--text-primary);
    font-size: var(--fs-secondary);
}

.live-change-was {
    color: var(--text-muted);
    font-size: var(--fs-small);
}

.live-rail-footer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: var(--fs-small);
}

/* ---- People in a place: record tabs, tree nodes, Settings pages (Components/PresenceAvatars.razor) ---- */

.presence-avatars {
    flex: none;
}

/* On the tab strip and the Settings rail the avatars sit on the app surface; in the tree, on the panel. */
.org-nav .presence-avatars,
.settings-rail .presence-avatars {
    --person-stack-edge: var(--surface-app);
}

.settings-nav-item.settings-nav-item-with-people {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-nav-item-with-people .settings-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "{name} is also here": presence for a whole page (Components/LiveAlsoHere.razor). */
.live-also-here {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 3px;
    border: 1px solid var(--person-accent, var(--border-strong));
    border-radius: 12px;
    background: color-mix(in srgb, var(--person-accent, transparent) 14%, transparent);
    color: var(--person-fg, var(--text-secondary));
    font-size: var(--fs-small);
    white-space: nowrap;
}

/* ---- Notices above the record's content ----
   The state of live updates, and what someone else did to the page on screen. One line of what happened,
   one of what it means, and at most two things to do about it. */
.live-notice {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    box-sizing: border-box;
    margin: 8px 12px 8px 16px;
    padding: 8px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--neutral-bg);
    color: var(--text-primary);
    font-size: var(--fs-secondary);
    line-height: var(--lh-normal);
}

.live-notice.warning {
    border-color: color-mix(in srgb, var(--warning-dot) 45%, transparent);
    background: var(--warning-bg);
}

.live-notice.info {
    border-color: color-mix(in srgb, var(--brand-accent) 50%, transparent);
    background: var(--info-bg);
}

.live-notice > svg,
.live-notice > .person-avatar {
    flex: none;
}

.live-notice-text {
    flex: 1 1 320px;
    min-width: 0;
}

.live-notice-title {
    font-weight: var(--fw-semibold);
}

.live-notice-detail {
    color: var(--text-secondary);
    font-size: var(--fs-small);
}

.live-notice-button {
    display: inline-flex;
    flex: none;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-small);
    text-decoration: none;
    cursor: pointer;
}

.live-notice-button:hover {
    background: var(--neutral-bg);
}

.live-notice-button:focus-visible,
.live-notice-link:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

.live-notice-link {
    flex: none;
    color: var(--brand-accent);
    font-size: var(--fs-small);
    text-decoration: none;
}

.live-notice-link:hover {
    text-decoration: underline;
}
