/* =============================================================================
   Communities Module — communities.css
   Covers: admin/show, managers/edit, managers/dashboard, managers/members,
           site/index, site/details, site/courses
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Banner header
----------------------------------------------------------------------------- */
.community-banner {
    position: relative;
    overflow: hidden;
}

.community-banner--admin {
    min-height: 160px;
}

.community-banner--detail {
    min-height: clamp(360px, 50vh, 620px);
    border-radius: 8px;
}

.community-banner__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.community-banner__overlay--light {
    background: rgba(0, 0, 0, 0.45);
}

.community-banner__content {
    position: relative;
    z-index: 1;
}

.community-banner__content--fill {
    min-height: 160px;
}

/* Detail page: absolutely fills the banner so it never drives banner height */
.community-banner__content--detail {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0 1rem 1.25rem;
}

/* Semi-transparent About card overlaid on the banner */
.community-banner__about {
    background: rgba(0, 0, 0, 0.52);
    border-radius: 6px;
    color: #fff;
    padding: 0.75rem 1rem;
}

.community-banner__about p {
    margin-bottom: 0.3rem;
    opacity: 0.9;
    font-size: 0.9rem;
}

.community-banner__about a {
    color: rgba(255, 255, 255, 0.85);
    word-break: break-all;
}

.community-banner__about a:hover {
    color: #fff;
    text-decoration: underline;
}

/* About body text — clamped to 3 lines; overflow reveals Read More button via JS */
.community-about__body {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Announcement card body — clamped to 5 lines; overflow reveals Read More button via JS */
.announcement-card__body {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -----------------------------------------------------------------------------
   Logo (circular image)
----------------------------------------------------------------------------- */
.community-logo {
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #fff;
}

/* Used inline in card title (index page, no banner) */
.community-logo--xs {
    width: 28px;
    height: 28px;
    vertical-align: middle;
    margin-right: 5px;
}

/* Card overlay logo (index page, with banner) */
.community-logo--sm {
    width: 58px;
    height: 58px;
}

/* Admin banner header */
.community-logo--md {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

/* Detail page banner header */
.community-logo--lg {
    width: 80px;
    height: 80px;
}

/* Logo overlap on the card browse page.
   Lives at the top of card-body; negative margin pulls it up over the banner.
   Logo is 58px tall — half (29px) sits on the banner, half in the card body.
   z-index: 0 keeps it visually above the banner image but below stretched-link::after (z-index: 1). */
.community-card__logo-overlap {
    margin-top: -29px;
    margin-bottom: 8px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 0;
    flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   Logo placeholder (no logo uploaded)
----------------------------------------------------------------------------- */
.community-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Admin banner header placeholder — fixed rgba colours, no dynamic value */
.community-logo-placeholder--admin {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.6);
}

/* Detail page placeholder — background comes from inline primary_color */
.community-logo-placeholder--detail {
    width: 80px;
    height: 80px;
    border: 3px solid #fff;
}

/* -----------------------------------------------------------------------------
   Community card (browse index page)
----------------------------------------------------------------------------- */

/* Wrapper for the banner <img> — needed so the logo overlay can be positioned */
.community-card__banner-wrap {
    position: relative;
}

/* Banner image on the browse/index card — fixed height so cards stay uniform.*/
.community-card__banner-img {
    display: block;
    width: 100%;
    height: 160px;
    object-fit: cover;
    object-position: center top;
    border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}

/* Coloured top border when no banner image is set (border-top-color stays inline) */
.community-card--branded {
    border-top-width: 4px;
    border-top-style: solid;
}

/* Interactive hover state for browse cards */
.community-card--interactive {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.community-card--interactive:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

/* -----------------------------------------------------------------------------
   Header badges (admin show — banner area)
----------------------------------------------------------------------------- */
.community-header-badges {
    gap: 6px;
}

.community-header-badge {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    font-size: 0.8em;
    padding: 4px 8px;
}

/* Private badge uses dark text on yellow background */
.community-header-badge--dark-text {
    color: #212529;
}

/* -----------------------------------------------------------------------------
   Colour swatch (details card, admin show)
----------------------------------------------------------------------------- */
.community-color-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* -----------------------------------------------------------------------------
   Admin sidebar card images
----------------------------------------------------------------------------- */
.community-admin-logo {
    height: 80px;
    width: 80px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #dee2e6;
}

.community-admin-banner {
    width: 100%;
    height: 112px;
    object-fit: cover;
    object-position: center;
    border-radius: 0 0 4px 4px;
    display: block;
}

/* -----------------------------------------------------------------------------
   Form controls (edit / create)
----------------------------------------------------------------------------- */
.community-color-input {
    height: 38px;
    width: 60px;
}

.community-logo-preview {
    height: 60px;
    width: 60px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #dee2e6;
}

.community-banner-preview {
    height: 300px;
    width: 100%;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid #dee2e6;
}

/* -----------------------------------------------------------------------------
   Upload drop zone (edit form)
----------------------------------------------------------------------------- */
.upload-zone {
    position: relative;
    border: 2px dashed #dee2e6;
    border-radius: 6px;
    padding: 1.5rem 1rem;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    overflow: hidden;
}

.upload-zone:hover,
.upload-zone--over {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.04);
}

.upload-zone--selected {
    border-color: #28a745;
    background-color: rgba(40, 167, 69, 0.04);
}

/* Invisible full-size input sits on top so the whole zone is clickable */
.upload-zone__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* -----------------------------------------------------------------------------
   Members management
----------------------------------------------------------------------------- */
.community-role-select {
    width: auto;
}

/* -----------------------------------------------------------------------------
   Announcements — unread highlight (pulsing yellow)
   Uses opacity on a ::before overlay so the animation runs on the compositor
   (no Paint on every frame).
----------------------------------------------------------------------------- */
.announcement--new {
    border-left: 3px solid #ffc107 !important;
    position: relative;
}

.announcement--new::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 193, 7, 0.18);
    opacity: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
    animation: ann-pulse 2.4s ease-in-out infinite;
}

@keyframes ann-pulse {
    0%,  100% { opacity: 0; }
    50%        { opacity: 1; }
}
