/* =============================================================================
   The social drawer
   -----------------------------------------------------------------------------
   Friends and invitations, over the page rather than in place of it. It is not
   a modal: the backdrop is there to catch a click, not to dim the page away.
   ============================================================================= */

/* ── The navbar trigger ──────────────────────────────────────────────────── */

.social-open {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast),
                border-color var(--transition-fast);
}

.social-open:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.social-open:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

/* The whole reason the drawer gets noticed at all. */
.social-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--accent-primary);
    color: var(--on-accent);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── The drawer ──────────────────────────────────────────────────────────── */

.social-backdrop {
    position: fixed;
    inset: 0;
    z-index: 190;
    background: transparent;
}

.social {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    width: min(380px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.social.is-open { transform: none; }

@media (prefers-reduced-motion: reduce) {
    .social { transition: none; }
}

.social-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--border-secondary);
}

.social-title {
    margin: 0;
    font-family: "EB Garamond", Georgia, serif;
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -0.4px;
    color: var(--text-primary);
}

.social-close {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.social-close:hover { color: var(--text-primary); border-color: var(--accent-hover); }

.social-close:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.social-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 16px 22px 0;
    padding: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-md);
}

.social-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.social-tabs.is-three { grid-template-columns: repeat(3, 1fr); }

.social-tab.is-on { background: var(--bg-elevated); color: var(--text-primary); }

.social-tab:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: -2px;
}

.social-count {
    min-width: 17px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--accent-primary);
    color: var(--on-accent);
    font-size: 10px;
    line-height: 17px;
    font-variant-numeric: tabular-nums;
}

/* ── The list ────────────────────────────────────────────────────────────── */

.social-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 22px 24px;
}

.social-heading {
    margin: 20px 0 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.social-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.social-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

.social-row:last-child { border-bottom: none; }

.social-avatar {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--bg-elevated);
}

.social-name {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
}

.social-sub {
    flex-basis: 100%;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-muted);
}

.social-tag {
    font-style: normal;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.social-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.social-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast),
                background var(--transition-fast);
}

.social-btn:hover { color: var(--text-primary); border-color: var(--accent-hover); }

.social-btn:disabled { opacity: 0.5; cursor: default; }

.social-btn.is-primary {
    border-color: transparent;
    background: var(--accent-primary);
    color: var(--on-accent);
}

.social-btn.is-primary:hover { background: var(--accent-secondary); }

.social-btn:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

.social-muted {
    font-size: 11.5px;
    color: var(--text-muted);
}

.social-empty {
    margin: 16px 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-muted);
}

.social-error {
    margin: 12px 0;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-subtle);
    border: 1px solid var(--danger-border);
    font-size: 12.5px;
    color: var(--danger);
}

/* An invitation is about a session, so the name leads and the avatar goes. */
.social-row.is-invite { align-items: flex-start; }

/* ── Chat ────────────────────────────────────────────────────────────────── */

/* A conversation row is the whole hit target, not just a button in it. */
.social-row.is-chat {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding-left: 8px;
    padding-right: 8px;
    margin: 0 -8px;
    transition: background var(--transition-fast);
}

.social-row.is-chat:hover { background: var(--bg-tertiary); }

.social-row.is-chat:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: -2px;
}

/* The thread fills the drawer: the log scrolls, the form stays put. */
.chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-secondary);
}

.chat-with {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 0;
}

.chat-line {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-start;
    max-width: 85%;
}

.chat-line.is-mine {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-bubble {
    padding: 9px 13px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--hairline);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* Yours is the one that carries the brand; theirs stays neutral. */
.chat-line.is-mine .chat-bubble {
    background: var(--accent-subtle);
    border-color: var(--accent-hover);
}

.chat-when {
    font-size: 10.5px;
    color: var(--text-muted);
}

.chat-form {
    display: flex;
    gap: 8px;
    padding: 12px 0 0;
    border-top: 1px solid var(--border-secondary);
}

.chat-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13.5px;
}

.chat-form input:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: 1px;
}

/* The thread needs the drawer's whole height, so the body stops scrolling. */
.social-body:has(.chat) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Finding someone ─────────────────────────────────────────────────────── */

/* On an empty friends list this is the only control that does anything, so
   it sits at the top of the tab rather than under the list it would fill. */
.social-search {
    display: flex;
    gap: 8px;
    margin: 16px 0 4px;
}

.social-search input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}

.social-search input::placeholder { color: var(--text-muted); }

.social-search input:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: 1px;
}

.social-search .social-btn { flex: none; }

/* ── Inviting ────────────────────────────────────────────────────────────── */

/* Already asked. Still a button - they might have declined and you might
   want to ask again - but it stops competing for the eye. */
.social-btn.is-done {
    border-color: transparent;
    color: var(--text-muted);
}

.social-note {
    margin: 12px 0;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-hover);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-secondary);
}
