/* myH Directory front end. Scoped under `.myh-directory`; typography and body
   colour are inherited, so every size is in `em`. */

.myh-directory {

    /* Palette: the myHealth@myHands colour sheet, unmodified. Teal (1.88:1)
       and cyan (2.87:1) are decorative only; the deep secondaries are all
       above 7:1. Measured by tests/contrast-audit.php. */
    --myh-brand: #2937db;          /* primary blue */
    --myh-brand-purple: #8f38d5;   /* primary purple, the other gradient end */
    --myh-brand-soft: #00d4bf;     /* primary teal, tints and fills only */
    --myh-brand-cyan: #0ca6c9;     /* primary cyan, tints only */

    --myh-brand-deep-teal: #075f73;    /* secondary, 7.26:1 */
    --myh-brand-deep-purple: #783ba8;  /* secondary, 7.02:1 */
    --myh-brand-deep-blue: #404d8e;    /* secondary, 7.86:1 */

    --myh-ink-muted: #5c6478;
    --myh-surface: #ffffff;
    --myh-surface-raised: #f6f8fb;

    /* --myh-line is decorative. --myh-line-strong identifies a form control,
       where WCAG 1.4.11 demands 3:1 against both surfaces; #888fa3 is the
       lightest value that clears it on white and on the raised surface. */
    --myh-line: #e2e6ef;
    --myh-line-strong: #888fa3;

    /* One secondary colour per area. The alphas are solved for, not chosen:
       each is where that colour over white reaches 5.5:1 against body text. */
    --myh-chip-patients-citizens: rgba(120, 59, 168, .28);
    --myh-chip-strategy-value: rgba(64, 77, 142, .27);
    --myh-chip-services-workflows: rgba(7, 95, 115, .27);
    --myh-chip-design-usability: rgba(215, 165, 255, .68);
    --myh-chip-technology-data-systems: rgba(114, 166, 228, .51);
    --myh-chip-governance-security-ethics: rgba(12, 166, 201, .43);

    --myh-chip-bg: rgba(114, 166, 228, .30);

    /* One 4px-based scale. No ad-hoc values below. */
    --myh-space-1: .25rem;
    --myh-space-2: .5rem;
    --myh-space-3: .75rem;
    --myh-space-4: 1rem;
    --myh-space-5: 1.5rem;
    --myh-space-6: 2rem;

    --myh-radius-sm: 6px;
    --myh-radius: 10px;
    --myh-radius-pill: 999px;

    /* --myh-font is left UNDEFINED so the rule below falls back to `inherit`.
       Defining it as `inherit` would not work: as a custom property value that
       is a CSS-wide keyword, so font-family would resolve to `unset`. */

    --myh-text-xs: .75em;
    --myh-text-sm: .85em;
    --myh-text-md: .92em;
    --myh-text-lg: 1.05em;
    --myh-text-xl: 1.25em;

    /* WCAG 2.4.7. */
    --myh-focus-color: var(--myh-brand);
    --myh-focus-width: 2px;
    --myh-focus-offset: 2px;

    /* Width belongs to the theme; set this only if a page template turns out
       not to constrain the content. */
    --myh-max-width: none;

    --myh-sidebar-width: 260px;

    /* Search field, results bar and controls share one height, which is what
       keeps the cards aligned with the first facet. */
    --myh-control-height: 2.75rem;

    /* Two resource cards per row inside the theme's 1400px grid. */
    --myh-card-min: 420px;
}

.myh-directory {
    font-family: var(--myh-font, inherit);
}

/* `hidden` has to actually hide: a theme's `display` on a matching selector
   would otherwise win on specificity. */
.myh-directory [hidden] {
    display: none !important;
}

.myh-directory :focus-visible {
    outline: var(--myh-focus-width) solid var(--myh-focus-color);
    outline-offset: var(--myh-focus-offset);
    border-radius: var(--myh-radius-sm);
}

.myh-directory__inner {
    max-width: var(--myh-max-width);
    margin: 0 auto;
    padding: var(--myh-space-4) 0 calc(var(--myh-space-6) * 2);
}

.myh-directory__title {
    margin: 0 0 var(--myh-space-2);
}

.myh-directory__intro {
    margin: 0 0 var(--myh-space-6);
    color: var(--myh-ink-muted);
    max-width: 60ch;
}

.myh-directory__body {
    display: grid;
    grid-template-columns: var(--myh-sidebar-width) minmax(0, 1fr);
    gap: var(--myh-space-5);
    align-items: start;
}

@media (max-width: 860px) {
    .myh-directory__body {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ------------------------------------------------------------- filters -- */

.myh-filters {
    position: sticky;
    top: var(--myh-space-4);
}

@media (max-width: 860px) {
    .myh-filters {
        position: static;
    }
}

.myh-search {
    margin-bottom: var(--myh-space-5);
}

/* Phone only; the script reveals it. */
.myh-directory .myh-filters__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--myh-space-2);
    width: 100%;
    height: var(--myh-control-height);
    margin-bottom: var(--myh-space-5);
    padding: 0 var(--myh-space-3);
    border: 1px solid var(--myh-line-strong);
    border-radius: var(--myh-radius);
    background: var(--myh-surface);
    color: inherit;
    font: inherit;
    cursor: pointer;
}

/* The chevron turns to point at what the button will do next. */
.myh-directory .myh-filters__toggle::after {
    content: "";
    width: .7em;
    height: .7em;
    background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235c6478' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    transition: transform .15s ease;
}

.myh-directory .myh-filters__toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
    .myh-directory .myh-filters__toggle::after {
        transition: none;
    }
}

/* The one place a selector carries the `.myh-directory` scope: themes style
   `input` through a container ID, which a bare class cannot outrank. */
.myh-directory .myh-search__input {
    width: 100%;
    height: var(--myh-control-height);
    padding: var(--myh-space-2) var(--myh-space-3);
    border: 1px solid var(--myh-line-strong);
    border-radius: var(--myh-radius);
    background: var(--myh-surface);
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
}

.myh-facet {
    border: 0;
    padding: 0;
    margin: 0 0 var(--myh-space-5);
}

.myh-facet__legend {
    font-size: var(--myh-text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: var(--myh-space-2);
    padding: 0;
}

.myh-facet__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* min-height keeps the row a 24px target (WCAG 2.5.8) at any inherited size. */
.myh-facet__label {
    display: flex;
    align-items: center;
    gap: var(--myh-space-2);
    padding: 2px 0;
    min-height: 24px;
    cursor: pointer;
}

/* A facet that would return nothing. Not disabled: it still deselects. */
.myh-facet__label.is-empty {
    opacity: .6;
    cursor: default;
}

.myh-facet__text {
    flex: 1 1 auto;
    font-size: var(--myh-text-md);
}

/* A number, not a pill. */
.myh-facet__count {
    flex: 0 0 auto;
    font-size: var(--myh-text-sm);
    color: var(--myh-ink-muted);
    font-variant-numeric: tabular-nums;
}

.myh-filters__submit {
    width: 100%;
    padding: var(--myh-space-2);
    border: 0;
    border-radius: var(--myh-radius-sm);
    background: var(--myh-brand);
    color: #fff;
    cursor: pointer;
    font: inherit;
}

/* ------------------------------------------------------------- results -- */

.myh-results__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--myh-space-2) var(--myh-space-4);
    min-height: var(--myh-control-height);
    margin-bottom: var(--myh-space-5);
}

/* One type size across the whole band, inherited. The count is the only thing
   here that is not grey. */
.myh-results__count {
    margin: 0;
}

/* The count hides itself when there is nothing to count; without this the sort
   control would jump to the left of an empty row. */
.myh-results__bar .myh-results__count[hidden] + .myh-sort {
    margin-left: auto;
}

.myh-sort {
    display: flex;
    align-items: center;
}

/* Matches the search field opposite it. */
/* The frame is on .myh-sort, so the select must not draw a second one. */
.myh-directory .myh-sort__select {
    font: inherit;
    color: inherit;
    height: var(--myh-control-height);
    padding: 0 calc(var(--myh-space-3) + 1.1em) 0 var(--myh-space-3);
    /* 1.4.11: a control's boundary needs 3:1 against what surrounds it. Same
       frame and same height as the search field opposite it, so the row reads
       as one pair of controls with the count between them. */
    border: 1px solid var(--myh-line-strong);
    border-radius: var(--myh-radius);
    background-color: var(--myh-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%235c6478' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--myh-space-3) center;
    background-size: .7em auto;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.myh-directory .myh-sort__select:hover {
    border-color: var(--myh-brand);
}

/* ------------------------------------------------------ active filters -- */

/* Full width above both columns, so showing it moves the whole listing down
   rather than knocking the results column out of step with the sidebar. */
.myh-active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--myh-space-2);
    margin-bottom: var(--myh-space-5);
}

.myh-active__label {
    font-size: var(--myh-text-sm);
    color: var(--myh-ink-muted);
}

.myh-active__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--myh-space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

/* A chip you can take off again: the whole thing is the remove control. */
.myh-active__chip {
    display: inline-flex;
    align-items: center;
    gap: var(--myh-space-1);
    min-height: 24px;
    padding: 2px var(--myh-space-2);
    border: 1px solid var(--myh-line-strong);
    border-radius: var(--myh-radius-pill);
    background: none;
    color: inherit;
    font: inherit;
    font-size: var(--myh-text-xs);
    cursor: pointer;
}

.myh-active__chip:hover {
    border-color: var(--myh-brand);
    color: var(--myh-brand);
}

.myh-active__remove {
    font-size: 1.1em;
    line-height: 1;
}

.myh-active__reset {
    background: none;
    border: 0;
    padding: var(--myh-space-1) 0;
    min-height: 24px;
    color: var(--myh-brand);
    font: inherit;
    font-size: var(--myh-text-sm);
    text-decoration: underline;
    cursor: pointer;
}

/* Set by enableClamping() on any description that is not actually clipped. */
.myh-card__more.is-inert {
    display: none;
}

/* Side by side the box stays and only the button goes, so the meta rule under
   it sits level across the row. `visibility` also drops it from the tab order. */
@container myh-grid (min-width: 864px) {
    .myh-card__more.is-inert {
        display: inline-block;
        visibility: hidden;
    }
}

/* -------------------------------------------------------------- pager -- */

.myh-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--myh-space-2);
    margin-top: var(--myh-space-6);
}

.myh-pager__pages {
    display: flex;
    gap: var(--myh-space-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

.myh-pager__page,
.myh-pager__step {
    min-width: 32px;
    min-height: 32px;
    padding: 0 var(--myh-space-2);
    border: 1px solid var(--myh-line);
    border-radius: var(--myh-radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    font-size: var(--myh-text-sm);
    cursor: pointer;
}

.myh-pager__page:hover:not(.is-current),
.myh-pager__step:hover:not(:disabled) {
    border-color: var(--myh-brand);
    color: var(--myh-brand);
}

.myh-pager__page.is-current {
    background: var(--myh-brand);
    border-color: var(--myh-brand);
    color: #fff;
    cursor: default;
}

.myh-pager__step:disabled {
    opacity: .4;
    cursor: default;
}

.myh-notice {
    margin: 0 0 var(--myh-space-5);
    padding: var(--myh-space-3) var(--myh-space-4);
    border-left: 3px solid var(--myh-line-strong);
    background: var(--myh-surface-raised);
    color: var(--myh-ink-muted);
    font-size: .9em;
}

/* Plain text, not a box. An empty state is an absence, not an object. */
.myh-results__empty {
    padding: var(--myh-space-6) 0;
    color: var(--myh-ink-muted);
}

/* Resources: grid. Projects: list. Fixed per module, there is no view toggle. */
/* The footer is NOT pinned: that put up to 184px of spare space in the middle
   of the card. Unpinned it falls below the footer and reads as padding. */
.myh-grid {
    display: grid;

    /* Container query, not media: the grid is one column on a phone and on a
       1000px laptop too. 864px is 2 x --myh-card-min plus the gap. */
    container: myh-grid / inline-size;
    /* min() lets the track collapse below --myh-card-min. Without it a 375px
       phone scrolled sideways by 76px. */
    grid-template-columns: repeat(auto-fill, minmax(min(var(--myh-card-min), 100%), 1fr));
    gap: var(--myh-space-5);
}

.myh-list {
    display: flex;
    flex-direction: column;
    gap: var(--myh-space-5);
}

/* --------------------------------------------------------------- cards -- */

.myh-card {
    background: var(--myh-surface);
    border: 1px solid var(--myh-line);
    border-radius: var(--myh-radius);
    padding: var(--myh-space-6);
    display: flex;
    flex-direction: column;
    gap: var(--myh-space-4);
    /* `anywhere`, not `break-word`: only `anywhere` shrinks the intrinsic
       minimum width, which is what stops a pasted URL widening the track. */
    overflow-wrap: anywhere;
}

/* Cards hidden by the filter are covered by the [hidden] rule near the top. */

/* Tighter than a resource card, because a project card stacks more short lines:
   acronym, full name, meta, chips. */
.myh-card--project {
    gap: var(--myh-space-3);
}

/* Clamp but no reservation: 54 of 67 titles take one line, so a reserved
   second line would be empty on 81% of the cards. */
.myh-card__title {
    margin: 0;
    font-size: 1.2em;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* The acronym is the project's name and the thing people scan the list for, so
   it carries more weight than a resource title, which sits next to five others
   in a grid. */
.myh-card--project .myh-card__title {
    font-size: 1.45em;
}

.myh-card__title a {
    color: var(--myh-brand);
    text-decoration: none;
}

.myh-card__title a:hover,
.myh-card__title a:focus {
    text-decoration: underline;
}

.myh-card__subtitle {
    margin: 0;
    color: var(--myh-ink-muted);
}

.myh-card__description {
    line-height: 1.5;
}

/* Two lines reserved, but only where cards stand side by side. */
@container myh-grid (min-width: 864px) {
    .myh-card__description {
        min-height: 3em;
    }
}

/* The stacked list reserves too, and unconditionally: nothing stands beside a
   card in a list at any width, so this is rhythm rather than alignment. */
.myh-list .myh-card__description {
    min-height: 3em;
}


.myh-card__description p {
    margin: 0;
}

/* Two lines, expanded inline by "Show more"; there are no detail pages. */
.myh-card__description.is-clamped p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* A standalone control, so it does not get the inline-link exception from
   WCAG 2.5.8; padding brings it to a 24px target. */
.myh-card__more {
    align-self: flex-start;
    background: none;
    border: 0;
    padding: var(--myh-space-1) 0;
    min-height: 24px;
    color: var(--myh-brand);
    font: inherit;
    font-size: var(--myh-text-sm);
    text-decoration: underline;
    cursor: pointer;
}

/* Not pinned to the bottom: see .myh-grid above for why the spare space belongs
   below the footer rather than above it. */
.myh-card__meta {
    display: flex;
    flex-direction: column;
    gap: var(--myh-space-1);
    padding-top: var(--myh-space-3);
    border-top: 1px solid var(--myh-line);
}

/* ------------------------------------------------------------ meta ------ */

.myh-meta {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--myh-space-3);
    row-gap: var(--myh-space-1);
    margin: 0;
    padding: 0;
    font-size: var(--myh-text-sm);
    color: var(--myh-ink-muted);
}

/* A border, not a "|" character: generated content is announced, and "vertical
   line" between every pair of values is noise. */
.myh-meta__item:not(:last-child) {
    padding-right: var(--myh-space-3);
    border-right: 1px solid var(--myh-line);
}

/* --------------------------------------------------------- provenance -- */

.myh-provenance {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--myh-space-1);
    font-size: var(--myh-text-sm);
}

.myh-provenance__row {
    display: flex;
    align-items: baseline;
    gap: var(--myh-space-2);
}

.myh-provenance__label {
    flex: 0 0 auto;
    min-width: 7em;
    color: var(--myh-ink-muted);
}

/* Two lines. One author list carries eleven names and made its card 199px
   taller. Full text stays in the DOM and on the title attribute. */
.myh-provenance__value {
    margin: 0;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* On a phone the 7em label column leaves the value half a line. */
@media (max-width: 860px) {
    .myh-provenance__row {
        display: block;
    }

    .myh-provenance__label {
        min-width: 0;
    }
}

/* ------------------------------------------------------------ chips ----- */

.myh-chips {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--myh-space-1);
    margin: 0;
    padding: 0;
}

/* Flat, not a gradient: a gradient behind six different chips reads as six
   different components. */
.myh-chip {
    display: inline-block;
    font-size: var(--myh-text-xs);
    padding: 2px var(--myh-space-2);
    border-radius: var(--myh-radius-pill);
    background: var(--myh-chip-bg);
    color: inherit;
}

.myh-chip--patients-citizens { background: var(--myh-chip-patients-citizens); }
.myh-chip--strategy-value { background: var(--myh-chip-strategy-value); }
.myh-chip--services-workflows { background: var(--myh-chip-services-workflows); }
.myh-chip--design-usability { background: var(--myh-chip-design-usability); }
.myh-chip--technology-data-systems { background: var(--myh-chip-technology-data-systems); }
.myh-chip--governance-security-ethics { background: var(--myh-chip-governance-security-ethics); }

/* ------------------------------------------------------------- actions -- */

.myh-card__actions {
    display: flex;
    align-items: center;
    gap: var(--myh-space-3);
    margin-top: var(--myh-space-1);
}

.myh-button {
    display: inline-block;
    padding: var(--myh-space-1) var(--myh-space-4);
    border-radius: var(--myh-radius-pill);
    background: var(--myh-brand);
    color: #fff;
    text-decoration: none;
    font-size: var(--myh-text-sm);
}

.myh-button:hover,
.myh-button:focus {
    background: #1f2aa8;
    color: #fff;
}

/* Social icons sit flush right, and only the filled ones render. */
/* Left-aligned now that no button shares the row: flush right made sense
   opposite the "Website" button and looks stranded on its own. */
.myh-social {
    list-style: none;
    display: flex;
    gap: var(--myh-space-1);
    margin: 0;
    padding: 0;
}

/* Brand colour on hover only, as the site's own header and footer do. */
.myh-social__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--myh-brand);
    text-decoration: none;
}

.myh-social__link:hover {
    color: var(--myh-brand-soft);
}

/* Inline SVG: Dashicons has no Bluesky mark, and an icon font would be a
   second font request for six glyphs. */
.myh-social__glyph {
    display: block;
    width: 20px;
    height: 20px;
}

/* WordPress' own class name, redefined because not every theme ships it and a
   visually-hidden label that is not hidden is worse than no label. Scoped, so a
   theme that does ship it keeps its own version everywhere else. */
.myh-directory .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
