/* ==========================================================================
   Organisations index page
   Scoped under .orgs-list so styles can't leak. Reuses existing lf-page
   tokens — no new colour or font is introduced.
   ========================================================================== */

.orgs-list {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

/* ---- Header ---------------------------------------------------------- */
.orgs-list__header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.orgs-list__title {
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    margin: 0;
    font-weight: 700;
}

.orgs-list__search-label {
    display: block;
}

.orgs-list__search-label-text {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 6px;
    color: var(--lf-text-muted, #555);
}

.orgs-list__search-wrap {
    position: relative;
    display: block;
}

.orgs-list__search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--lf-text-muted, #777);
    pointer-events: none;
}

.orgs-list__search {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px 10px 40px;
    font-size: 1rem;
    border: 1px solid var(--lf-border, #ddd);
    border-radius: 10px;
    background: #fff;
    transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.orgs-list__search:focus-visible {
    outline: none;
    border-color: var(--lf-accent, #2a7ae2);
    box-shadow: 0 0 0 3px rgba(42, 122, 226, 0.25);
}

.orgs-list__count {
    margin: 0;
    font-size: 0.875rem;
    color: var(--lf-text-muted, #555);
}

/* ---- Groups ---------------------------------------------------------- */
.orgs-list__groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.orgs-group {
    background: #fff;
    border: 1px solid var(--lf-border, #e5e5e5);
    border-radius: 14px;
    overflow: hidden;
}

/* Hide the default disclosure triangle */
.orgs-group > summary {
    list-style: none;
    cursor: pointer;
}
.orgs-group > summary::-webkit-details-marker { display: none; }

.orgs-group__header {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    grid-template-areas: "title count register chevron";
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    min-height: 64px;
}

.orgs-group__title-link {
    grid-area: title;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.orgs-group__logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 0 0 2px var(--lf-primary, #4a7c59);
    flex-shrink: 0;
}

.orgs-group__logo--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--lf-primary, #4a7c59);
}

.orgs-group__name {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.orgs-group__count {
    grid-area: count;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: #fff;
    color: var(--lf-primary, #4a7c59);
    box-shadow: inset 0 0 0 2px var(--lf-primary, #4a7c59);
    font-size: 0.8125rem;
    font-weight: 600;
}

.orgs-group__register {
    grid-area: register;
    min-height: 44px;
}

.orgs-group__chevron {
    grid-area: chevron;
    width: 16px;
    text-align: center;
    transition: transform 180ms ease-out;
    color: var(--lf-text-muted, #666);
}

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

.orgs-group[open] > summary .orgs-group__chevron {
    transform: rotate(180deg);
}

.orgs-group__title-link:hover .orgs-group__name,
.orgs-group__title-link:focus-visible .orgs-group__name {
    text-decoration: underline;
}

.orgs-group__title-link:focus-visible,
.orgs-group__register:focus-visible,
.orgs-group__child-link:focus-visible {
    outline: 2px solid var(--lf-accent, #2a7ae2);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ---- Children grid --------------------------------------------------- */
.orgs-group__children {
    list-style: none;
    margin: 0;
    padding: 0 18px 18px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.orgs-group__child-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 14px;
    border: 1px solid var(--lf-border, #eee);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    background: #fff;
    transition: background 150ms ease-out, border-color 150ms ease-out;
}

.orgs-group__child-link:hover {
    background: var(--lf-muted, #fafafa);
    border-color: var(--lf-border-hover, #ccc);
}

.orgs-group__child-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #fff;
    box-shadow: 0 0 0 2px var(--lf-primary, #4a7c59);
}

.orgs-group__child-logo--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--lf-primary, #4a7c59);
}

.orgs-group__child-name {
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ---- Hidden-by-search states ---------------------------------------- */
.orgs-group[hidden],
.orgs-group__child[hidden] {
    display: none !important;
}

/* ---- Empty state ---------------------------------------------------- */
.orgs-list__empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--lf-text-muted, #666);
}

.orgs-list__empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.orgs-list__empty-text {
    font-size: 1rem;
    max-width: 40ch;
    margin: 0 auto;
}

/* ---- Mobile ---------------------------------------------------------- */
@media (max-width: 600px) {
    .orgs-list { padding: 16px 12px 64px; }

    .orgs-group__header {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "logo   title    chevron"
            "logo   count    chevron"
            "register register register";
        gap: 6px 10px;
        padding: 12px 14px;
    }
    .orgs-group__title-link {
        grid-area: title;
        gap: 10px;
    }
    .orgs-group__title-link .orgs-group__logo { grid-area: logo; }
    .orgs-group__count { grid-area: count; justify-self: start; }
    .orgs-group__register {
        grid-area: register;
        width: 100%;
        margin-top: 6px;
    }
    .orgs-group__chevron { grid-area: chevron; }

    .orgs-group__children {
        grid-template-columns: 1fr;
    }
}

/* ---------------------------------------------------------------
   Following-since indicator (logged-in users only)
   --------------------------------------------------------------- */

.orgs-group__title-text,
.orgs-group__child-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.orgs-group__following {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--lf-text-muted, #666);
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.orgs-group__child-following {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--lf-text-muted, #666);
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
