/**
 * Communities index.
 *
 * From the Claude Design "Tunnyl Feed" project's Communities screen, with the
 * usual two corrections: its accent blue maps to the neutral ramp, and one of
 * its greys is replaced. The design used var(--text-faint) for the per-card activity
 * line, which measures 2.54:1 on the white card — well under AA. Gray 500 is
 * the documented value that is safe on white (4.83:1).
 */

.communities-main {
    min-width: 0;
}

.communities-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.communities-title {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.communities-count {
    font-size: 14px;
    /* --text-muted (Gray 600), NOT --text-secondary. This line sits on the
       page background, where Gray 500 measures 4.43:1. The card-internal greys
       below correctly use --text-secondary because they are on white.
       Fifth time this has come up; the token name does not carry the
       constraint, so it has to be remembered every time. */
    color: var(--text-muted);
    margin-top: 5px;
}

/* Inherited var(--text-secondary) from dashboard-common.css, on the page background. */
.communities-main .empty-state {
    color: var(--text-muted);
}

.communities-new {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-fg);
    background: var(--accent);
    border: 1px solid var(--accent);
    padding: 9px 20px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.communities-new:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ===== Category filters ===== */
.community-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.community-filter {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-body);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 7px 14px;
    border-radius: 16px;
    cursor: pointer;
}

.community-filter:hover { border-color: var(--accent-border); }

/* Selected state carries fill AND weight, never colour alone. */
.community-filter[aria-pressed="true"] {
    color: var(--accent-fg);
    background: var(--accent);
    border-color: var(--accent);
}

.community-filter:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== Card grid ===== */
.community-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.community-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.community-card:hover { border-color: var(--accent-border); }

.community-card-head {
    display: flex;
    align-items: flex-start;
    gap: 13px;
}

.community-mono {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent-fg);
    background: var(--accent);
}

.community-card-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
}

.community-card-title:hover { text-decoration: underline; }

.community-card-stat {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.community-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    padding: 3px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.community-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-body);
}

.community-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
}

/* The design used Gray 400 here — 2.54:1 on a white card. Gray 500 is the
   documented value that passes on white. */
.community-activity {
    font-size: 12px;
    color: var(--text-secondary);
}

.community-join {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-fg);
    background: var(--accent);
    border: 1px solid var(--accent);
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.community-join:hover { background: var(--accent-hover); }

.community-join[disabled] {
    color: var(--text-secondary);
    background: var(--card-bg);
    border-color: var(--card-border);
    cursor: default;
}

.community-join:focus-visible,
.communities-new:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* One column once two would be too narrow to read. */
@media (max-width: 900px) {
    .community-grid { grid-template-columns: 1fr; }
    .communities-head { flex-direction: column; align-items: flex-start; gap: 12px; }
}


/* ===== Search, Yours, Show more, Create (Sep 2026) ===== */
.communities-new { display: inline-flex; align-items: center; gap: 6px; }
.communities-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.communities-tools .community-filters { margin-bottom: 0; }
.communities-search {
    flex: 0 0 300px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: 6px; background: var(--card-bg); color: var(--text-secondary);
}
.communities-search input { flex: 1; min-width: 0; border: none; background: none; font: inherit; font-size: 14px; color: var(--text-primary); outline: none; }
.communities-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.communities-section-title { margin: 0 0 12px; font-size: var(--text-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.communities-yours { margin-bottom: 24px; }
.communities-yours[hidden] { display: none; }
.community-grid-compact .community-card { padding: 14px 16px; }
.community-joined {
    display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 7px 12px;
    border-radius: 6px; background: var(--surface-3); color: var(--text-body); text-decoration: none;
}
.community-role-tag { font-size: 11px; font-weight: 500; color: var(--text-secondary); border: 1px solid var(--card-border); border-radius: 9px; padding: 1px 6px; margin-left: 6px; }
.communities-more { display: flex; justify-content: center; margin-top: 18px; }
.communities-more[hidden] { display: none; }
.communities-more-btn { height: 36px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--card-bg); color: var(--text-primary); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.communities-more-btn:hover { background: var(--hover-bg); }
.communities-more-btn[disabled] { opacity: 0.6; cursor: default; }
.cc-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.cc-modal[hidden] { display: none; }
.cc-dialog { position: relative; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 24px 28px; }
.cc-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: none; background: none; font-size: 22px; color: var(--text-secondary); cursor: pointer; border-radius: 6px; }
.cc-close:hover { background: var(--hover-bg); color: var(--text-primary); }
.cc-title { margin: 0 0 18px; font-size: var(--text-lg); font-weight: 600; }
.cc-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.cc-field label { font-size: 14px; font-weight: 500; }
.cc-field input, .cc-field textarea, .cc-field select { width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit; font-size: 14px; background: var(--card-bg); color: var(--text-primary); }
.cc-field input:focus, .cc-field textarea:focus, .cc-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.cc-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cc-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.cc-error[hidden] { display: none; }
.cc-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.cc-btn { height: 38px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--card-bg); color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.cc-btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.cc-btn-primary:hover { background: var(--accent-hover); }
.cc-btn[disabled] { opacity: 0.6; cursor: default; }
