/*
 * Citizen Connect agency directory (index/index2.php only).
 * Everything is scoped to .ccd-page / .ccd so shared pages are unaffected.
 */

.ccd-page {
    --ccd-ink:          #14213d;  /* body text          ~15:1 on white */
    --ccd-ink-muted:    #4a5568;  /* secondary text     ~7.5:1 on white */
    --ccd-primary:      #1e4e8c;  /* links, buttons     ~8:1 with white */
    --ccd-primary-dark: #163c6e;
    --ccd-primary-tint: #e9eff8;
    --ccd-navy:         #10284a;  /* header bar */
    --ccd-accent:       #b8913a;  /* a thin rule, decorative only */
    --ccd-bg:           #f4f6f9;
    --ccd-surface:      #ffffff;
    --ccd-tile:         #f3f5f8;
    --ccd-line:         #dde3ea;
    --ccd-line-strong:  #8592a6;  /* form/control borders, >=3:1 */
    --ccd-alert:        #b42318;  /* ~6.5:1 with white */
    --ccd-alert-dark:   #8f1b13;
    --ccd-alert-tint:   #fdf3f2;
    --ccd-alert-line:   #f1c4c0;
    --ccd-radius:       12px;
    --ccd-radius-sm:    8px;
    --ccd-shadow:       0 1px 2px rgba(16, 40, 74, .06);
    --ccd-shadow-hover: 0 8px 20px rgba(16, 40, 74, .09);
    background-color: var(--ccd-bg);
}

/* Calm the saturated blue bar on this page only (shared theme left alone). */
.ccd-page .ccthemenavbar,
.ccd-page .bottom-navbar.ccthemenavbar {
    background-color: var(--ccd-navy);
}

/* Below 992px the theme pins the header, which is taller than the page offset
   and hides the top of the content. On this page, let it scroll with the page. */
@media (max-width: 991px) {
    .ccd-page .horizontal-menu { position: relative; }
    .ccd-page .page-body-wrapper { padding-top: 0; }
}

/* ---- Layout ---------------------------------------------------------- */
.ccd.content-wrapper {
    background-color: var(--ccd-bg);
    color: var(--ccd-ink);
    padding: 1.5rem 1rem 3rem;
}
.ccd > * {
    max-width: 74rem;
    margin-left: auto;
    margin-right: auto;
}
.ccd [hidden] { display: none !important; }

.ccd-sr {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ccd a:focus-visible,
.ccd button:focus-visible {
    outline: 3px solid var(--ccd-primary);
    outline-offset: 2px;
}

/* ---- Hero ------------------------------------------------------------ */
.ccd-hero { padding: .5rem 0 1.75rem; }
.ccd-hero__title::before {
    content: "";
    display: block;
    width: 2rem;
    height: 3px;
    margin-bottom: .75rem;
    border-radius: 2px;
    background: var(--ccd-accent);
}
.ccd-hero__title {
    margin: 0 0 .625rem;
    color: var(--ccd-ink);
    font-size: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.01em;
}
.ccd-hero__lead {
    max-width: 40rem;
    margin: 0;
    color: var(--ccd-ink-muted);
    font-size: 1.0625rem;
    line-height: 1.55;
}

/* ---- Active incidents ------------------------------------------------ */
.ccd-alerts { margin-bottom: 2rem; }
.ccd-alerts__title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .75rem;
    color: var(--ccd-alert);
    font-size: 1.125rem;
    font-weight: 700;
}
.ccd-alerts__list {
    display: grid;
    gap: .75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.ccd-alert {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--ccd-alert-tint);
    border: 1px solid var(--ccd-alert-line);
    border-left: 4px solid var(--ccd-alert);
    border-radius: var(--ccd-radius-sm);
}
.ccd-alert__name {
    margin: 0 0 .25rem;
    color: var(--ccd-ink);
    font-size: 1rem;
    font-weight: 600;
}
.ccd-alert__place {
    margin: 0;
    color: var(--ccd-ink-muted);
    font-size: .9375rem;
}

/* ---- Directory head + filters ---------------------------------------- */
.ccd-directory__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .25rem 1rem;
    margin-bottom: .75rem;
}
.ccd-directory__title {
    margin: 0;
    color: var(--ccd-ink);
    font-size: 1.25rem;
    font-weight: 700;
}
.ccd-count {
    margin: 0;
    color: var(--ccd-ink-muted);
    font-size: .875rem;
    font-variant-numeric: tabular-nums;
}

.ccd-filters {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--ccd-surface);
    border: 1px solid var(--ccd-line);
    border-radius: var(--ccd-radius);
    box-shadow: var(--ccd-shadow);
}
.ccd-label {
    display: block;
    margin: 0 0 .375rem;
    color: var(--ccd-ink);
    font-size: .875rem;
    font-weight: 600;
}
.ccd-search {
    position: relative;
    max-width: 36rem;
}
.ccd-search__icon {
    position: absolute;
    top: 50%;
    left: .875rem;
    transform: translateY(-50%);
    color: var(--ccd-ink-muted);
    font-size: 1.25rem;
    line-height: 1;
    pointer-events: none;
}
.ccd-search__input {
    width: 100%;
    height: 3rem;
    padding: 0 3rem 0 2.75rem;
    color: var(--ccd-ink);
    background: var(--ccd-surface);
    border: 1px solid var(--ccd-line-strong);
    border-radius: 10px;
    font: inherit;
    font-size: 1rem; /* 16px keeps iOS from zooming */
    -webkit-appearance: none;
    appearance: none;
}
.ccd-search__input::placeholder { color: #6b7686; opacity: 1; }
.ccd-search__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.ccd-search__input:focus {
    border-color: var(--ccd-primary);
    outline: 2px solid transparent; /* forced-colors fallback */
    box-shadow: 0 0 0 3px rgba(30, 78, 140, .28);
}
.ccd-search__clear {
    position: absolute;
    top: 50%;
    right: .375rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    color: var(--ccd-ink-muted);
    background: transparent;
    border: 0;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
}
.ccd-search__clear:hover { color: var(--ccd-ink); background: var(--ccd-tile); }

.ccd-states {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .875rem;
}
.ccd-chip {
    min-height: 2.25rem;
    padding: 0 .875rem;
    color: var(--ccd-ink);
    background: var(--ccd-surface);
    border: 1px solid var(--ccd-line-strong);
    border-radius: 999px;
    font: inherit;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}
.ccd-chip:hover { background: var(--ccd-tile); }
.ccd-chip[aria-pressed="true"] {
    color: #fff;
    background: var(--ccd-navy);
    border-color: var(--ccd-navy);
}

/* ---- Grid + cards ---------------------------------------------------- */
.ccd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.ccd-card { display: flex; }
.ccd-card__inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    padding: 1.25rem;
    background: var(--ccd-surface);
    border: 1px solid var(--ccd-line);
    border-radius: var(--ccd-radius);
    box-shadow: var(--ccd-shadow);
    transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
.ccd-card__inner:hover {
    border-color: #c6d0dc;
    box-shadow: var(--ccd-shadow-hover);
    transform: translateY(-2px);
}

.ccd-card__head {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    align-items: center;
    gap: 1rem;
}
.ccd-card__name {
    margin: 0;
    color: var(--ccd-ink);
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* Fixed logo box: every patch gets the same footprint, whatever its shape. */
.ccd-logo {
    position: relative;
    display: grid;
    place-items: center;
    width: 5.5rem;
    height: 5.5rem;
    overflow: hidden;
    background: var(--ccd-tile);
    border: 1px solid var(--ccd-line);
    border-radius: 10px;
}
.ccd-logo__img {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    padding: .375rem;
    box-sizing: border-box;
    object-fit: contain;
}
.ccd-logo__initials {
    display: none;
    color: var(--ccd-primary);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1;
}
.ccd-logo.is-fallback {
    background: var(--ccd-primary-tint);
    border-color: #c9d6ea;
}
.ccd-logo.is-fallback .ccd-logo__initials { display: block; }

.ccd-card__contact {
    display: grid;
    gap: .5rem;
    color: var(--ccd-ink-muted);
    font-size: .9375rem;
    line-height: 1.45;
}
.ccd-contact {
    display: grid;
    grid-template-columns: 1.25rem 1fr;
    gap: .5rem;
    align-items: start;
    margin: 0;
}
.ccd-contact__icon {
    color: var(--ccd-ink-muted);
    font-size: 1.125rem;
    line-height: 1.3;
}
.ccd .ccd-contact__phone {
    color: var(--ccd-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
}
.ccd .ccd-contact__phone:hover { text-decoration: underline; }

.ccd-card__actions {
    display: grid;
    gap: .5rem;
    margin-top: auto; /* pins actions to the bottom so rows line up */
}
.ccd-modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.25rem, 1fr));
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ---- Buttons --------------------------------------------------------- */
.ccd .ccd-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-height: 2.75rem;
    padding: .5rem .875rem;
    border: 1px solid transparent;
    border-radius: var(--ccd-radius-sm);
    font: inherit;
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.ccd .ccd-btn .mdi { font-size: 1.125rem; line-height: 1; }

.ccd .ccd-btn--primary {
    justify-content: space-between;
    width: 100%;
    color: #fff;
    background: var(--ccd-primary);
}
.ccd .ccd-btn--primary:hover { color: #fff; background: var(--ccd-primary-dark); }

.ccd .ccd-btn--module {
    width: 100%;
    color: var(--ccd-primary);
    background: var(--ccd-surface);
    border-color: var(--ccd-line);
    font-size: .875rem;
    font-weight: 500;
}
.ccd .ccd-btn--module:hover {
    color: var(--ccd-primary-dark);
    background: var(--ccd-primary-tint);
    border-color: #b9c9e2;
}

.ccd .ccd-btn--alert {
    flex-shrink: 0;
    color: #fff;
    background: var(--ccd-alert);
}
.ccd .ccd-btn--alert:hover { color: #fff; background: var(--ccd-alert-dark); }

.ccd .ccd-btn--ghost {
    color: var(--ccd-primary);
    background: var(--ccd-surface);
    border-color: var(--ccd-primary);
}
.ccd .ccd-btn--ghost:hover { background: var(--ccd-primary-tint); }

.ccd .ccd-btn:active { transform: translateY(1px); }

/* ---- Empty state ----------------------------------------------------- */
.ccd-empty {
    padding: 2.5rem 1.25rem;
    text-align: center;
    background: var(--ccd-surface);
    border: 1px dashed var(--ccd-line-strong);
    border-radius: var(--ccd-radius);
}
.ccd-empty__icon {
    display: block;
    margin-bottom: .5rem;
    color: var(--ccd-primary);
    font-size: 2.5rem;
    line-height: 1;
}
.ccd-empty__title {
    margin: 0 0 .375rem;
    color: var(--ccd-ink);
    font-size: 1.125rem;
    font-weight: 600;
}
.ccd-empty__text {
    max-width: 30rem;
    margin: 0 auto 1.25rem;
    color: var(--ccd-ink-muted);
    font-size: .9375rem;
    line-height: 1.5;
}

/* ---- Larger screens -------------------------------------------------- */
@media (min-width: 768px) {
    .ccd.content-wrapper { padding: 2.5rem 1.5rem 4rem; }
    .ccd-hero { padding-bottom: 2.25rem; }
    .ccd-filters { padding: 1.25rem; }
    .ccd-grid { gap: 1.25rem; }
}

/* ---- Motion + contrast preferences ----------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .ccd-card__inner,
    .ccd .ccd-btn { transition: none; }
    .ccd-card__inner:hover,
    .ccd .ccd-btn:active { transform: none; }
}

@media (forced-colors: active) {
    .ccd-chip[aria-pressed="true"] { border-width: 3px; }
}
