/* =============================================
   COMMUNITIES — Screen Styles
   Built entirely on the tokens defined in base.css.
   Standalone screen: no navbar/footer chrome here.
   ============================================= */

.comm-screen {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

/* =============================================
   TOPBAR — search + create
   ============================================= */
.comm-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.comm-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    border-radius: var(--r-md);
    padding: 11px 14px;
    color: var(--text-3);
    transition: border-color 0.15s ease;
}

.comm-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.comm-search svg {
    flex-shrink: 0;
}

.comm-search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-1);
}

.comm-search input::placeholder {
    color: var(--text-3);
}

.comm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 18px;
    border-radius: var(--r-md);
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.15s ease;
}

.comm-btn[hidden] {
    display: none;
}

.comm-btn:active {
    transform: scale(0.97);
}

.comm-btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.comm-btn-primary:hover {
    background: #2f6fe8;
}

.comm-btn-ghost {
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    color: var(--text-1);
}

.comm-btn-ghost:hover {
    background: var(--bg-hover);
}

.comm-btn-block {
    width: 100%;
    margin-top: 22px;
}

/* Icon-only back button, pinned to the left of the search field. */
.comm-back-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
}

/* =============================================
   LIST
   ============================================= */
.comm-list {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.comm-list.comm-list-visible {
    opacity: 1;
    transform: translateY(0);
}

.comm-list[hidden] {
    display: none;
}

.comm-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.comm-row[hidden] {
    display: none;
}

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

.comm-row:hover {
    background: var(--bg-hover);
}

.comm-row:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.comm-row-enter {
    animation: comm-row-enter 0.24s ease both;
}

@keyframes comm-row-enter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comm-row-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}

.comm-row-info {
    flex: 1;
    min-width: 0;
}

.comm-row-name-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.comm-row-name {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.comm-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2.5px 7px;
    border-radius: 100px;
    white-space: nowrap;
}

.comm-badge-admin {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.comm-badge-joined {
    background: var(--green-soft);
    color: var(--green);
}

.comm-badge-type {
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    color: var(--text-2);
    text-transform: none;
    font-weight: 600;
    letter-spacing: normal;
}

/* =============================================
   JOIN BUTTON — new
   Sits between comm-row-info and the unread badge/chevron. Deliberately
   small/compact so it doesn't compete visually with the row's primary
   "tap to open chat" affordance.
   ============================================= */
.comm-join-btn {
    flex-shrink: 0;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 100px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.comm-join-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.comm-join-btn-action {
    background: var(--accent);
    color: #fff;
}

.comm-join-btn-action:hover {
    background: #2f6fe8;
}

.comm-join-btn-pending {
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    color: var(--text-2);
    cursor: default;
}

.comm-join-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

.comm-row-unread {
    flex-shrink: 0;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--accent);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comm-row-unread[hidden] {
    display: none;
}

.comm-row-stats {
    display: flex;
    align-items: center;
    gap: 14px;
}

.comm-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--text-2);
}

.comm-stat svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.comm-row-chevron {
    flex-shrink: 0;
    color: var(--text-3);
}

/* =============================================
   SKELETON / SHIMMER LOADING STATE
   ============================================= */
.comm-list-skeleton {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.comm-list-skeleton[hidden] {
    display: none;
}

.comm-skel-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

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

.comm-skel-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
}

.comm-skel-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.comm-skel-line {
    height: 11px;
    border-radius: 5px;
}

.comm-skel-line--name {
    width: 42%;
    height: 13px;
}

.comm-skel-line--meta {
    width: 68%;
}

.comm-skel-avatar,
.comm-skel-line {
    position: relative;
    overflow: hidden;
    background: var(--bg-elevated);
}

.comm-skel-avatar::after,
.comm-skel-line::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
            transparent,
            var(--bg-hover) 45%,
            var(--bg-hover) 55%,
            transparent);
    animation: comm-shimmer 1.6s ease-in-out infinite;
    will-change: transform;
}

@keyframes comm-shimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {

    .comm-skel-avatar::after,
    .comm-skel-line::after {
        animation: none;
    }

    .comm-row-enter {
        animation: none;
    }

    .comm-list,
    .comm-list-skeleton {
        transition: none;
    }
}

/* =============================================
   EMPTY / NO RESULTS
   ============================================= */
.comm-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-2);
    font-size: 14px;
}

.comm-empty[hidden] {
    display: none;
}

.comm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =============================================
   CREATE MODAL
   ============================================= */
.comm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 10, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

.comm-modal-overlay[hidden] {
    display: none;
}

.comm-modal {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border-md);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 28px 24px 24px;
}

.comm-modal h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 6px;
}

.comm-modal-sub {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 22px;
}

.comm-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-2);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.comm-modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-1);
}

.comm-field {
    display: block;
    margin-bottom: 16px;
}

.comm-field span {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 7px;
}

.comm-field span em {
    font-style: normal;
    font-weight: 400;
    color: var(--text-3);
}

.comm-field input,
.comm-field textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    resize: none;
    transition: border-color 0.15s ease;
}

.comm-field input::placeholder,
.comm-field textarea::placeholder {
    color: var(--text-3);
}

.comm-field input:focus-visible,
.comm-field textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* =============================================
   PRIVACY TOGGLE — new
   Two equal-width chips acting as a radiogroup (see communities.html).
   ============================================= */
.comm-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.comm-type-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border-md);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.comm-type-option:hover {
    background: var(--bg-hover);
}

.comm-type-option.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.comm-type-option small {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-3);
}

.comm-modal-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 10px 12px;
}

.comm-modal-note svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--accent);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 480px) {
    .comm-screen {
        padding: 20px 14px 40px;
    }

    .comm-topbar {
        flex-wrap: wrap;
    }

    .comm-search {
        flex-basis: 100%;
    }

    .comm-btn:not(.comm-btn-block):not(.comm-back-btn) {
        flex: 1;
    }

    .comm-row-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }
}