/*
 * Child Space directory (/s/<space>/spaces)
 * HumHub's standard SpaceDirectoryCard widget is rendered unchanged.  The
 * regular /spaces page supplies additional card layout rules through its own
 * view/stylesheet; this route needs a self-contained equivalent.
 * All selectors are scoped to avoid affecting /spaces or Space profile cards.
 */
.ns-child-directory { width: 100%; min-width: 0; }
.ns-child-directory-hint { margin: 12px 0 0; }

.ns-child-directory .ns-child-directory-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin: 0 0 24px;
    padding: 0;
    width: 100%;
}
/* Override the native widget's Bootstrap column and .card wrappers only here. */
.ns-child-directory .ns-child-directory-grid > .card-space {
    float: none;
    display: block;
    position: relative;
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
.ns-child-directory .ns-child-directory-grid .card-panel {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 270px;
    padding: 0;
    overflow: hidden;
    background: var(--background-color-page, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 5px;
    box-sizing: border-box;
}
.ns-child-directory .ns-child-directory-grid .card-bg-image {
    display: block;
    flex: 0 0 108px;
    height: 108px;
    min-height: 108px;
    width: 100%;
    background-color: var(--background-color-secondary, #dedede);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}
/* Native profile thumbnail overlaps the cover but must not overlap card text. */
.ns-child-directory .ns-child-directory-grid .card-header {
    position: relative;
    display: block;
    flex: 0 0 64px;
    height: 64px;
    min-height: 64px;
    width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    box-sizing: border-box;
}
.ns-child-directory .ns-child-directory-grid .card-image-link {
    position: absolute;
    display: block;
    top: -48px;
    left: 14px;
    width: 94px;
    height: 94px;
    padding: 0;
    margin: 0;
    z-index: 1;
    line-height: 1;
}
.ns-child-directory .ns-child-directory-grid .card-image-link img {
    display: block;
    width: 94px;
    height: 94px;
    max-width: 94px;
    max-height: 94px;
    object-fit: cover;
}
.ns-child-directory .ns-child-directory-grid .card-icons {
    position: absolute;
    float: none;
    top: 10px;
    right: 12px;
    margin: 0;
    z-index: 2;
}
.ns-child-directory .ns-child-directory-grid .card-header > :not(.card-image-link):not(.card-icons) {
    /* Native SpaceDirectoryStatus elements keep their functionality. */
    z-index: 2;
}
.ns-child-directory .ns-child-directory-grid .card-body {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 14px 15px;
    margin: 0;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}
.ns-child-directory .ns-child-directory-grid .card-title {
    display: block;
    font-weight: 600;
    font-size: 17px;
    line-height: 1.35;
    margin: 0 0 7px;
    overflow-wrap: anywhere;
}
.ns-child-directory .ns-child-directory-grid .card-title a { text-decoration: none; }
.ns-child-directory .ns-child-directory-grid .card-details {
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 8px;
    overflow-wrap: anywhere;
    white-space: normal;
}
.ns-child-directory .ns-child-directory-grid .card-tags { margin-top: 8px; }
.ns-child-directory .ns-child-directory-grid .card-footer {
    display: block;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color, #eee);
    background: transparent;
    box-sizing: border-box;
}
@media (max-width: 1199px) {
    .ns-child-directory .ns-child-directory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
    .ns-child-directory .ns-child-directory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .ns-child-directory .ns-child-directory-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }
}
