/* =====================================================================
   Applications page (page_applications.xml): the application types as the
   shared card (components.css .dc-card, photo only), three across. Under each
   photo a row: the application's icon, its name, and its NCC building class
   at the end. Hovering, focusing or tapping the class opens a small pop-up
   with what the class covers (applications.js).
   Headings and colours: components.css.
   ===================================================================== */

.apps {
    padding: 40px 0 64px;
    overflow-x: clip;       /* closed pop-ups of the right-hand cards don't widen the page */
    background: #fff;
    font-family: var(--dc-font);
}
.apps-breadcrumbs {
    margin-bottom: 20px;
}

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

.apps-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px 20px;
    margin: 32px 0 0;
    padding: 0;
    list-style: none;
}
.apps-item {
    position: relative;
}
/* ---------- icon, name, NCC class ---------- */

.apps-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}
.apps-ncc-icon {
    flex: none;
    width: 40px;
    height: 40px;
    margin: -6px 0;         /* the icons have space around them: keep the row 28px tall */
    object-fit: contain;
}
.apps .apps-name {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 28px;
    color: var(--dc-ink);
    font-family: var(--dc-font-head);
    font-size: 1.1875rem;
    font-weight: bold;
    line-height: 1.2;
    text-decoration: none;
}
.apps .apps-name:hover,
.apps-item:hover .apps-name {
    color: var(--dc-red);
    text-decoration: none;
}
.apps-name:focus-visible {
    outline: 2px solid var(--dc-red);
    outline-offset: 2px;
}
/* the class sits at the end of the row */
.apps-ncc {
    position: relative;
    display: flex;
    flex: none;
    align-items: center;
    margin-left: auto;
}
.apps-ncc-label {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--dc-muted);
    font-family: var(--dc-font);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: help;
}
.apps-ncc-label:hover,
.apps-ncc-label[aria-expanded="true"] {
    color: var(--dc-red);
}
.apps-ncc-label:focus-visible {
    outline: 2px solid var(--dc-red);
    outline-offset: 2px;
}

.apps-ncc-pop {
    position: absolute;
    bottom: calc(100% + 10px);
    right: -12px;
    z-index: 20;
    width: 340px;
    max-width: calc(100vw - 32px);
    padding: 16px 18px;
    border: 1px solid var(--dc-line);
    background: #fff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    visibility: hidden;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0s linear 0.15s;
    pointer-events: none;
}
/* the little arrow pointing at the class */
.apps-ncc-pop::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 24px;
    translate: var(--apps-arrow-shift, 0px) 0;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border-right: 1px solid var(--dc-line);
    border-bottom: 1px solid var(--dc-line);
    background: #fff;
    transform: rotate(45deg);
}
/* covers the gap between the class and the pop-up, so moving the pointer up
   into the pop-up doesn't close it */
.apps-ncc-pop::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 12px;
}
.apps-ncc:hover .apps-ncc-pop,
.apps-ncc-label:focus-visible + .apps-ncc-pop,
.apps-ncc-label[aria-expanded="true"] + .apps-ncc-pop {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity 0.15s, transform 0.15s, visibility 0s;
    pointer-events: auto;
}
.apps-ncc-pop .apps-ncc-title {
    margin: 0 0 6px;
    color: var(--dc-red);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.apps-ncc-pop p:not(.apps-ncc-title) {
    margin: 0 0 6px;
    color: var(--dc-text);
    font-size: 0.8125rem;
    line-height: 1.5;
}
.apps-ncc-pop p:last-child {
    margin-bottom: 0;
}
.apps-ncc-pop strong {
    color: var(--dc-ink);
    font-weight: 500;
}

/* ---------- tablets and phones ---------- */

@media (max-width: 991.98px) {
    .apps-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .apps {
        padding: 24px 0 48px;
    }
    .apps-grid {
        gap: 20px 12px;
        margin-top: 24px;
    }
    .apps-meta {
        flex-wrap: wrap;
        gap: 6px 8px;
        margin-top: 10px;
    }
    .apps-ncc-icon {
        width: 32px;
        height: 32px;
    }
    .apps .apps-name {
        flex: 1;
        font-size: 1rem;
    }
    .apps-ncc {
        flex-basis: calc(100% - 40px);
        margin-left: 40px;      /* icon (32px) + gap (8px): in line with the name */
    }
    .apps-ncc-label {
        min-height: 20px;
    }
    .apps-ncc-label {
        font-size: 0.6875rem;
    }
    .apps-ncc-pop {
        right: auto;
        left: -12px;
    }
    .apps-ncc-pop::after {
        right: auto;
        left: 24px;
    }
    .apps-ncc-pop {
        width: 300px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apps-ncc-pop {
        transition: none;
    }
}

/* a class with no definition entered: just the label */
.apps-ncc-label--plain,
.apps-ncc-label--plain:hover {
    color: var(--dc-muted);
    cursor: default;
}
