/* =========================================================
   THE DIRECTORY

   Loaded only by member/index.php, so none of this can
   reach any other page. Every class starts dir- for the
   same reason.

   The layout is the phone-directory one: a search box you
   cannot miss, a sticky filter rail, and rows built on a
   grid so the columns line up down the page.

   Colours are the app's own - indigo and orange - rather
   than the navy and red the layout was drawn in.
========================================================= */

.dir-page {
    --dir-ink:      #1d2433;
    --dir-ink-2:    #3b4453;
    --dir-muted:    #6b7382;
    --dir-faint:    #939aa8;
    --dir-line:     #e4e7ef;
    --dir-line-2:   #ccd2de;
    --dir-surface:  #ffffff;
    --dir-surface-2:#f6f7fc;

    --dir-accent:   #525fe1;   /* buttons, links, focus */
    --dir-soft:     #eef0ff;   /* chips, selected */
    --dir-brand:    #eb6834;   /* the stripe, counts */
    --dir-key:      #f4f5fa;   /* badge fill */
    --dir-key-edge: #cfd4e2;
    --dir-mark:     #fff1b8;   /* search highlight */

    --dir-radius:   10px;
    --dir-shadow:   0 1px 2px rgba(29,36,51,.05), 0 6px 20px rgba(29,36,51,.06);

    padding: 0 0 70px;
    background: #ffffff;
}

.dir-wrap {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
}


/* =========================================================
   SEARCH
========================================================= */

.dir-head { padding: 30px 0 22px; }

.dir-head h1 {
    margin: 0 0 16px;
    font-size: 26px;
    font-weight: 600;
    color: var(--dir-ink);
}

.dir-search { position: relative; }

.dir-search > i {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    color: var(--dir-faint);
    font-size: 16px;
    pointer-events: none;
}

.dir-search input {
    width: 100%;
    height: 58px;
    padding: 0 60px 0 52px;

    background: #ffffff;
    border: 1px solid var(--dir-line-2);
    border-radius: var(--dir-radius);
    box-shadow: var(--dir-shadow);

    font-family: inherit;
    font-size: 17px;
    color: var(--dir-ink);
}

.dir-search input::placeholder { color: var(--dir-faint); }

.dir-search input:focus {
    outline: none;
    border-color: var(--dir-accent);
    box-shadow: 0 0 0 3px var(--dir-soft), var(--dir-shadow);
}

/* The keyboard hint. Goes away the moment there is
   something in the box, where it would be clutter. */
.dir-key {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);

    min-width: 22px;
    padding: 2px 7px;

    background: var(--dir-surface-2);
    border: 1px solid var(--dir-line);
    border-radius: 5px;

    color: var(--dir-faint);
    font-size: 12px;
    text-align: center;
}

.dir-search input:not(:placeholder-shown) ~ .dir-key { display: none; }

.dir-clear {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);

    width: 32px;
    height: 32px;

    background: none;
    border: 0;
    border-radius: 50%;

    color: var(--dir-muted);
    cursor: pointer;
}

.dir-clear:hover { background: var(--dir-surface-2); color: var(--dir-ink); }


/* =========================================================
   LAYOUT
========================================================= */

.dir-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}


/* =========================================================
   FILTERS
========================================================= */

.dir-filters {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.dir-filters-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

/* Only in the sidebar header does this get pushed to the
   right-hand edge. In the chips row it belongs next to the
   chips it clears, not marooned across the page. */
.dir-filters-head .dir-link { margin-left: auto; }

.dir-filters-head h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--dir-muted);
}

.dir-link {
    padding: 0;
    background: none;
    border: 0;
    color: var(--dir-accent);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.dir-link:hover { text-decoration: underline; }

.dir-drawer-close { display: none; }


/* ---- the status toggle ---- */

.dir-seg {
    display: flex;
    margin-bottom: 22px;
    padding: 3px;
    background: var(--dir-surface-2);
    border: 1px solid var(--dir-line);
    border-radius: 9px;
}

.dir-seg button {
    flex: 1;
    min-width: 0;
    padding: 7px 4px;

    background: none;
    border: 0;
    border-radius: 6px;

    color: var(--dir-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.dir-seg button.on {
    background: #ffffff;
    color: var(--dir-accent);
    box-shadow: 0 1px 2px rgba(29,36,51,.10);
}

.dir-seg button:not(.on):hover { color: var(--dir-ink); }


/* ---- checkbox groups ---- */

.dir-facet { margin-bottom: 22px; }

.dir-facet h3 {
    margin: 0 0 7px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--dir-muted);
}

.dir-opt {
    display: flex;
    align-items: center;
    gap: 9px;

    margin: 0 -8px;
    padding: 5px 8px;
    border-radius: 6px;

    font-size: 14px;
    color: var(--dir-ink-2);
    cursor: pointer;
}

.dir-opt:hover { background: var(--dir-surface-2); }

.dir-opt input { flex: none; accent-color: var(--dir-accent); cursor: pointer; }

.dir-opt-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-count {
    margin-left: auto;
    padding-left: 8px;
    color: var(--dir-faint);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Nothing matches, but still clickable - a zero is
   information. Never faded while ticked. */
.dir-opt.is-empty { opacity: .45; }


/* ---- the congregation dots ---- */

.dir-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--dir-faint);
}

.dir-dot.c0 { background: #525fe1; }
.dir-dot.c1 { background: #eb6834; }
.dir-dot.c2 { background: #1f9d63; }
.dir-dot.c3 { background: #a855c7; }
.dir-dot.c4 { background: #0ea5b7; }
.dir-dot.c5 { background: #c9a018; }


/* =========================================================
   TOOLBAR
========================================================= */

.dir-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.dir-tally {
    margin: 0;
    color: var(--dir-muted);
    font-size: 14px;
}

.dir-tally strong {
    margin-right: 3px;
    color: var(--dir-ink);
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dir-of { color: var(--dir-faint); }

.dir-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.dir-select {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--dir-muted);
}

.dir-select select {
    height: 38px;
    padding: 0 10px;

    background: #ffffff;
    border: 1px solid var(--dir-line-2);
    border-radius: 6px;

    font: inherit;
    font-size: 13.5px;
    color: var(--dir-ink);
    cursor: pointer;
}

.dir-select select:focus {
    outline: 2px solid var(--dir-accent);
    outline-offset: 1px;
}


/* ---- buttons ---- */

.dir-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    height: 38px;
    padding: 0 14px;

    background: #ffffff;
    color: var(--dir-ink-2);
    border: 1px solid var(--dir-line-2);
    border-radius: 6px;

    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.dir-btn:hover { background: var(--dir-surface-2); color: var(--dir-ink); }

.dir-btn-primary {
    background: var(--dir-accent);
    color: #ffffff;
    border-color: var(--dir-accent);
}

.dir-btn-primary:hover { background: #414dcc; color: #ffffff; }

.dir-btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }

.dir-btn-ghost { background: none; border-color: transparent; color: var(--dir-muted); }
.dir-btn-ghost:hover { background: var(--dir-surface-2); }

.dir-pill {
    min-width: 18px;
    padding: 1px 5px;
    background: var(--dir-brand);
    border-radius: 20px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}


/* ---- the export menu ---- */

.dir-menu { position: relative; }

.dir-menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;

    display: none;
    min-width: 210px;
    padding: 6px;

    background: #ffffff;
    border: 1px solid var(--dir-line);
    border-radius: 9px;
    box-shadow: 0 10px 30px rgba(29,36,51,.14);
}

.dir-menu.open .dir-menu-list { display: block; }

.dir-menu-list a {
    display: flex;
    align-items: center;
    gap: 9px;

    padding: 9px 11px;
    border-radius: 6px;

    color: var(--dir-ink-2);
    font-size: 13.5px;
    text-decoration: none;
}

.dir-menu-list a:hover { background: var(--dir-surface-2); color: var(--dir-accent); }
.dir-menu-list i { width: 15px; color: var(--dir-faint); }


/* =========================================================
   CHIPS
========================================================= */

.dir-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
}

.dir-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    height: 28px;
    padding: 0 8px 0 11px;

    background: var(--dir-soft);
    border: 0;
    border-radius: 14px;

    color: var(--dir-accent);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.dir-chip:hover { background: #e2e5ff; }
.dir-chip i { font-size: 11px; opacity: .7; }


/* =========================================================
   ROWS
========================================================= */

.dir-panel {
    margin-bottom: 16px;
    background: var(--dir-surface);
    border: 1px solid var(--dir-line);
    border-radius: var(--dir-radius);
    overflow: hidden;
}

.dir-group-head {
    display: flex;
    align-items: center;
    padding: 11px 18px;
    background: var(--dir-surface-2);
    border-bottom: 1px solid var(--dir-line);
}

.dir-group-head h3 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--dir-ink);
}

.dir-group-head span {
    margin-left: auto;
    color: var(--dir-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.dir-row {
    display: grid;
    align-items: center;
    gap: 18px;

    padding: 13px 18px;
    border-top: 1px solid var(--dir-line);

    grid-template-columns: 62px minmax(0, 1.05fr) minmax(0, .9fr) minmax(0, 1.45fr) auto;
}

.dir-row:first-child { border-top: 0; }
.dir-group-head + .dir-row { border-top: 0; }
.dir-row:hover { background: var(--dir-surface-2); }


/* ---- the badge ----

   Built like a key on a phone: a thicker bottom border that
   collapses when pressed, so it feels like a button rather
   than a picture. */

.dir-badge {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 54px;
    height: 54px;
    overflow: hidden;

    background: var(--dir-key);
    border: 1px solid var(--dir-key-edge);
    border-bottom-width: 3px;
    border-radius: 8px;

    color: var(--dir-ink);
    font-size: 19px;
    font-weight: 600;
    text-decoration: none;
}

.dir-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dir-badge.has-photo { padding: 0; background: var(--dir-surface-2); }

.dir-badge:active { border-bottom-width: 1px; transform: translateY(2px); }


/* ---- who ---- */

.dir-who { min-width: 0; }

.dir-name {
    display: block;
    color: var(--dir-ink);
    font-size: 15.5px;
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-name:hover { color: var(--dir-accent); }

.dir-role {
    display: block;
    color: var(--dir-muted);
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-tag {
    display: inline-block;
    margin-top: 3px;
    padding: 1px 7px;

    border: 1px solid var(--dir-line-2);
    border-radius: 20px;

    color: var(--dir-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}


/* ---- where ---- */

.dir-where { min-width: 0; font-size: 13.5px; }

.dir-place {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--dir-ink-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-num {
    display: block;
    margin-top: 2px;
    color: var(--dir-faint);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}


/* ---- reach ---- */

.dir-reach { min-width: 0; }

.dir-reach-line {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 26px;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
}

.dir-reach-label {
    color: var(--dir-faint);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.dir-reach-value {
    display: flex;
    align-items: center;
    gap: 7px;

    min-width: 0;
    color: var(--dir-ink-2);
    font-size: 13.5px;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.dir-reach-value span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dir-reach-value:hover { color: var(--dir-accent); }
.dir-reach-value i { flex: none; width: 13px; color: var(--dir-faint); font-size: 12px; }

.dir-copy {
    width: 26px;
    height: 26px;
    background: none;
    border: 0;
    border-radius: 5px;
    color: var(--dir-faint);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
}

.dir-row:hover .dir-copy { opacity: 1; }
.dir-copy:hover { background: var(--dir-soft); color: var(--dir-accent); }
.dir-copy:focus { opacity: 1; }

.dir-none { color: var(--dir-faint); font-size: 13px; font-style: italic; }


/* ---- action ---- */

.dir-act { display: flex; gap: 6px; justify-content: flex-end; }


/* ---- the search highlight ---- */

.dir-row mark {
    padding: 0 1px;
    background: var(--dir-mark);
    border-radius: 2px;
    color: inherit;
}


/* =========================================================
   NOTHING FOUND
========================================================= */

.dir-empty {
    padding: 48px 24px;
    background: #ffffff;
    border: 1px dashed var(--dir-line-2);
    border-radius: var(--dir-radius);
    text-align: center;
}

.dir-empty i { color: var(--dir-line-2); font-size: 30px; }

.dir-empty p { margin: 14px 0 0; color: var(--dir-ink-2); font-size: 15px; }

.dir-empty-hint { color: var(--dir-muted) !important; font-size: 13.5px !important; }

.dir-empty .dir-btn { margin-top: 18px; }


/* =========================================================
   COPIED
========================================================= */

.dir-toast {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;

    padding: 10px 18px;

    background: #1d2433;
    border-radius: 8px;
    box-shadow: 0 8px 26px rgba(29,36,51,.28);

    color: #ffffff;
    font-size: 13.5px;
}


/* =========================================================
   THE DRAWER, AND NARROWER SCREENS
========================================================= */

.dir-drawer-open { display: none; }
.dir-drawer-foot { display: none; }

.dir-overlay {
    position: fixed;
    inset: 0;
    z-index: 10040;
    background: rgba(20, 25, 38, .45);
}


/* Tablet: four columns. Congregation moves under the name,
   contact details take the right-hand side. */
@media (max-width: 1080px) {

    .dir-row {
        grid-template-columns: 62px minmax(0, 1fr) minmax(0, 1.3fr) auto;
        align-items: start;
    }

    .dir-where {
        grid-column: 2;
        grid-row: 2;
        margin-top: 4px;
    }

    .dir-who   { grid-column: 2; grid-row: 1; }
    .dir-badge { grid-row: 1 / span 2; }
    .dir-reach { grid-column: 3; grid-row: 1 / span 2; }
    .dir-act   { grid-column: 4; grid-row: 1 / span 2; }

    .dir-copy { opacity: 1; }
}


@media (max-width: 860px) {

    .dir-wrap { padding: 0 16px; }

    .dir-layout { grid-template-columns: minmax(0, 1fr); }

    /* The sidebar becomes a drawer. */
    .dir-filters {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;

        /* Above the app's mobile header, which sits at
           9998. Anything lower and the drawer's own title
           and close button hide behind it. */
        z-index: 10050;

        display: flex;
        flex-direction: column;

        width: 300px;
        max-width: 86vw;
        max-height: none;
        padding: 18px 18px 0;

        background: #ffffff;
        box-shadow: 0 0 40px rgba(29,36,51,.22);

        transform: translateX(-100%);
        transition: transform .22s ease;
    }

    .dir-filters.open { transform: translateX(0); }

    .dir-filters-inner { flex: 1; overflow: auto; }

    .dir-drawer-close {
        display: block;
        width: 32px;
        height: 32px;
        margin-left: 6px;
        background: none;
        border: 0;
        color: var(--dir-muted);
        font-size: 16px;
        cursor: pointer;
    }

    .dir-drawer-foot {
        display: block;
        padding: 14px 0;
        border-top: 1px solid var(--dir-line);
    }

    .dir-drawer-foot .dir-btn { width: 100%; justify-content: center; }

    .dir-drawer-open { display: inline-flex; }

    body.dir-locked { overflow: hidden; }

    /* The toolbar wraps: count and filter button on one
       line, the tools below. */
    .dir-toolbar { flex-wrap: wrap; }
    .dir-tools { width: 100%; margin-left: 0; flex-wrap: wrap; }
    .dir-select { flex: 1 1 140px; }
    .dir-select select { flex: 1; min-width: 0; }
}


@media (max-width: 620px) {

    .dir-head h1 { font-size: 22px; }

    .dir-search input { height: 52px; font-size: 16px; padding-right: 48px; }

    /* Phone: badge on the left with name, role and
       congregation stacked beside it. Contact details drop
       below a dashed line, then the buttons. */
    .dir-row {
        grid-template-columns: 54px minmax(0, 1fr);
        gap: 12px;
        padding: 14px;
    }

    .dir-badge { width: 48px; height: 48px; font-size: 17px; grid-row: 1; }
    .dir-who   { grid-column: 2; grid-row: 1; }

    .dir-where {
        grid-column: 1 / -1;
        grid-row: 2;
        margin-top: 8px;
    }

    .dir-reach {
        grid-column: 1 / -1;
        grid-row: 3;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px dashed var(--dir-line);
    }

    .dir-reach-line { grid-template-columns: 50px minmax(0, 1fr) 28px; }

    .dir-act {
        grid-column: 1 / -1;
        grid-row: 4;
        margin-top: 10px;
        justify-content: flex-start;
    }

    .dir-act .dir-btn { flex: 1; justify-content: center; }

    /* Stretched to half the row, a borderless button reads
       as a stray word rather than something to press. Give
       it an outline back at this size. */
    .dir-act .dir-btn-ghost { border-color: var(--dir-line-2); }
}


/* Somebody who has asked their computer to stop animating
   things means it. */
@media (prefers-reduced-motion: reduce) {
    .dir-filters { transition: none; }
    .dir-badge:active { transform: none; }
}


/* =========================================================
   PAGING

   25 a page, the same as the reports. The bar says where you
   are in words as well as numbers, because "Showing 26-50 of
   123" answers the question that a row of numbered buttons
   on its own does not.
========================================================= */

.dir-pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;

    margin-top: 18px;
    padding: 14px 16px;

    background: var(--dir-surface);
    border: 1px solid var(--dir-line);
    border-radius: var(--dir-radius);
}

.dir-showing {
    margin: 0;
    color: var(--dir-muted);
    font-size: 13.5px;
}

.dir-showing strong {
    color: var(--dir-ink);
    font-variant-numeric: tabular-nums;
}

.dir-pages {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.dir-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    height: 34px;
    padding: 0 12px;

    background: var(--dir-surface);
    border: 1px solid var(--dir-line-2);
    border-radius: 8px;

    color: var(--dir-ink-2);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;

    cursor: pointer;
}

.dir-page-btn:hover:not(:disabled) {
    border-color: var(--dir-accent);
    color: var(--dir-accent);
}

.dir-page-btn:disabled {
    color: var(--dir-faint);
    border-color: var(--dir-line);
    cursor: default;
}

.dir-page-btn i { font-size: 11px; }

/* The numbers are square; Previous and Next carry words. */
.dir-page-num {
    min-width: 34px;
    justify-content: center;
    padding: 0 9px;
    font-variant-numeric: tabular-nums;
}

.dir-page-btn.is-on {
    background: var(--dir-accent);
    border-color: var(--dir-accent);
    color: #ffffff;
}

.dir-page-gap {
    padding: 0 4px;
    color: var(--dir-faint);
}

.dir-per { margin: 0; }


/* The list is scrolled to on every page change, and the menu
   bar is fixed, so it needs room to land under. */
#dirList { scroll-margin-top: 105px; }


@media (max-width: 720px) {

    .dir-pager {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .dir-pages {
        margin: 0;
        justify-content: center;
    }

    /* On a phone the numbers are the first thing to go -
       Previous and Next are what get used. */
    .dir-page-num,
    .dir-page-gap { display: none; }

    .dir-pages { gap: 8px; }

    .dir-page-btn { flex: 1; justify-content: center; }

    .dir-per { justify-content: center; }
}

/* Selectable columns shared by CSV and Print / Save as PDF. */
.dir-menu-list.dir-export-picker { width: 330px; max-width: calc(100vw - 32px); max-height: 70vh; overflow-y: auto; padding: 14px; }
.dir-export-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.dir-export-columns { display:grid; grid-template-columns:1fr 1fr; gap:10px 12px; }
.dir-export-option { display:flex; align-items:center; gap:8px; font-size:13px; margin:0; cursor:pointer; }
.dir-export-option input { width:16px; height:16px; accent-color:var(--site-accent,#5659e8); flex:0 0 16px; }
.dir-export-note { font-size:12px; color:var(--dir-muted); margin:12px 0 8px; padding-bottom:10px; border-bottom:1px solid var(--dir-line); }
@media(max-width:400px) { .dir-export-columns { grid-template-columns:1fr; } }
