/*
 * Glossary hub (/glossary/), Figma "Glossary / Index" (file TtcElVBB8zSMtMk2WR2VFf, 24451:13431).
 * Text styles come from the global sd-type-* classes; the search field and the no-results
 * state are the global components in template-parts/components/search/. This file only holds
 * layout, colours and the parts with no global equivalent (A-Z list, term rows).
 * --gh-header is the measured height of the fixed site header (js/glossary-hub.js);
 * the fallbacks match the Figma header (80 desktop, 64 below 1100px).
 */

.gh-page {
    --gh-header: 80px;
    --gh-text: #262626;
    --gh-muted: rgba(0, 0, 0, .55);
    --gh-letter: rgba(0, 0, 0, .4);
    --gh-disabled: #d4d4d4;
    --gh-border: #e5e5e5;
    --gh-divider: rgba(0, 0, 0, .1);
    /* UI Kit Shadow/xs */
    --gh-shadow-xs: 0 2px 6px rgba(0, 0, 0, .02), 0 1px 1px rgba(0, 0, 0, .05);
    background: #fff;
    color: var(--gh-text);
}

.gh-page,
.gh-page * {
    font-family: 'Google Sans Flex', sans-serif;
}

.gh-sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Hero */

.gh-hero {
    padding: 24px 64px;
}

.gh-hero__card {
    position: relative;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    max-width: 1200px;
    min-height: 480px;
    margin: 0 auto;
    padding: 48px;
    overflow: hidden;
    border-radius: 12px;
    background: #1a1a1a;
}

.gh-hero__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gh-hero__card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(233.1deg, rgba(26, 26, 26, 0) 38.452%, rgba(26, 26, 26, .8) 100%);
    pointer-events: none;
}

.gh-hero__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 760px;
}

.gh-hero__title.gh-hero__title {
    margin: 0;
    color: #fff;
}

.gh-hero__text.gh-hero__text {
    max-width: 502px;
    margin: 0;
    color: #e5e5e5;
}

/* Catalog: A-Z column + search and groups (desktop) */

.gh-catalog {
    padding: 0 64px 80px;
}

.gh-layout {
    position: relative;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    grid-template-areas:
        "alpha search"
        "alpha results";
    /* The A-Z column is taller than a short filtered list: without this the extra
       height was split between both rows, so the sticky search grew into a tall
       white block and the results sat in the middle of the page. */
    grid-template-rows: auto 1fr;
    align-items: start;
    column-gap: 96px;
    max-width: 1200px;
    margin: 0 auto;
}

.gh-controls {
    display: contents;
}

.gh-search {
    grid-area: search;
    position: sticky;
    top: calc(var(--gh-header) - 24px);
    z-index: 3;
    padding-top: 48px;
    background: #fff;
}

.gh-alpha {
    grid-area: alpha;
    align-self: start;
    position: sticky;
    top: calc(var(--gh-header) + 24px);
    z-index: 2;
    margin-top: 48px;
}

.gh-alpha__list {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 42px;
    max-height: calc(100vh - var(--gh-header) - 48px);
    padding: 4px;
    overflow-y: auto;
    border: 1px solid var(--gh-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--gh-shadow-xs);
    scrollbar-width: none;
}

.gh-alpha__list::-webkit-scrollbar {
    display: none;
}

/* Type comes from the global sd-type-static-sm class in the markup (Figma
   glossary-alphabet-letter 24499:2066 = Static/SM Regular in every state). */
.gh-alpha__letter.gh-alpha__letter {
    display: inline-flex;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--gh-muted);
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.gh-alpha__letter.gh-alpha__letter[aria-current="true"] {
    background: #f5f5f5;
    color: var(--gh-text);
}

/* Hover only with a real pointer: on touch screens :hover sticks to the last tapped
   letter and looked like a second active letter. */
@media (hover: hover) {
    .gh-alpha__letter.gh-alpha__letter:hover {
        background: #f5f5f5;
        color: var(--gh-text);
    }
}

.gh-alpha__letter.gh-alpha__letter:disabled {
    background: transparent;
    color: var(--gh-disabled);
    cursor: default;
}

.gh-results {
    grid-area: results;
    min-width: 0;
}

.gh-group {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 48px;
    /* Full shorthand: the global `section { padding: 80px 0 }` would add 80px below each group. */
    padding: 48px 0 0;
    scroll-margin-top: calc(var(--gh-header) + 72px);
}

.gh-group[hidden] {
    display: none;
}

.gh-group__letter.gh-group__letter {
    box-sizing: border-box;
    height: 56px;
    margin: 0;
    padding: 9px 0 15px;
    color: var(--gh-letter);
    text-align: center;
}

.gh-group__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gh-term {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gh-term[hidden] {
    display: none;
}

.gh-term::before,
.gh-term::marker {
    content: none;
}

.gh-term__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gh-divider);
    color: var(--gh-text);
    text-decoration: none;
    transition: background-color .2s ease;
}

.gh-term__title.gh-term__title {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--gh-text);
}

.gh-term__arrow {
    flex: 0 0 16px;
    margin-top: 5px;
    color: var(--gh-muted);
    transition: color .2s ease;
}

@media (hover: hover) {
    a.gh-term__row:hover {
        background: #fafafa;
        color: var(--gh-text);
    }

    a.gh-term__row:hover .gh-term__arrow {
        color: rgba(0, 0, 0, .75);
    }
}

.gh-term__row:focus-visible,
.gh-alpha__letter:focus-visible {
    outline: 2px solid #3e9d69;
    outline-offset: 2px;
}

/* Tablet: same layout, narrower gutters */

@media (max-width: 1100px) {
    .gh-page {
        --gh-header: 64px;
    }

    .gh-hero {
        padding: 24px 32px;
    }

    .gh-hero__card {
        padding: 40px;
    }

    .gh-catalog {
        padding: 0 32px 80px;
    }

    .gh-layout {
        column-gap: 48px;
    }
}

/* Mobile: full-bleed hero, pinned search + scrolling A-Z row, stacked groups */

@media (max-width: 767px) {
    .gh-hero {
        padding: 0;
    }

    .gh-hero__card {
        min-height: 512px;
        padding: 32px 20px;
        border-radius: 0;
    }

    .gh-hero__card::after {
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .8));
    }

    .gh-hero__content {
        gap: 16px;
    }

    .gh-catalog {
        padding: 0 0 32px;
    }

    .gh-layout {
        display: block;
    }

    .gh-controls {
        display: flex;
        flex-direction: column;
        gap: 16px;
        position: sticky;
        top: var(--gh-header);
        z-index: 3;
        padding: 20px 20px 12px;
        background: #fff;
        transition: box-shadow .2s ease;
    }

    .gh-controls.is-stuck {
        box-shadow: var(--gh-shadow-xs);
    }

    .gh-search {
        position: static;
        padding-top: 0;
    }

    /* align-self: stretch resets the desktop `start`, which let the row grow to all 26 letters. */
    .gh-alpha {
        position: relative;
        top: auto;
        align-self: stretch;
        min-width: 0;
        /* Inside the 20px gutters like the search field (Figma): the row shows exactly
           7 whole letters and they hide at the container edges, not the screen edges. */
        margin: 0;
    }

    .gh-alpha__list {
        flex-direction: row;
        width: auto;
        max-height: none;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overscroll-behavior-x: contain;
        /* Figma 24521:19635: the scroll viewport ends 24px early so the last letter clears the fade. */
        padding-right: 24px;
    }

    /* Fixed 44px touch target around the 32px Figma letter, no stretching (Figma 24521:19636),
       so about 8 letters show at 390px. No transition: the highlight moves with the row. */
    .gh-alpha__letter.gh-alpha__letter {
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        background: transparent;
        box-shadow: inset 0 0 0 6px #fff;
        transition: none;
    }

    .gh-alpha__letter.gh-alpha__letter[aria-current="true"] {
        background: #f5f5f5;
        box-shadow: inset 0 0 0 6px #fff;
        border-radius: 10px;
    }

    @media (hover: hover) {
        .gh-alpha__letter.gh-alpha__letter:hover {
            background: #f5f5f5;
            box-shadow: inset 0 0 0 6px #fff;
            border-radius: 10px;
        }
    }

    .gh-alpha::before,
    .gh-alpha::after {
        content: '';
        position: absolute;
        top: 0;
        z-index: 1;
        width: 32px;
        height: 44px;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .gh-alpha::before {
        left: 0;
        background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
    }

    .gh-alpha::after {
        right: 0;
        background: linear-gradient(to left, #fff, rgba(255, 255, 255, 0));
    }

    .gh-alpha[data-left-overflow="true"]::before,
    .gh-alpha[data-right-overflow="true"]::after {
        opacity: 1;
    }

    .gh-results {
        display: flex;
        flex-direction: column;
        padding: 20px 20px 0;
    }

    .gh-groups {
        display: flex;
        flex-direction: column;
        gap: 28px;
    }

    .gh-group {
        display: block;
        padding: 0;
        scroll-margin-top: calc(var(--gh-header) + 152px);
    }

    .gh-group__letter.gh-group__letter {
        height: auto;
        padding: 0;
        text-align: left;
    }

    .gh-term__arrow {
        margin-top: 4px;
    }
}
