/*
 * FAQ accordion, shared by the home page and the Resources page.
 * Markup: .faq-list > .faq-item > button.faq-question[aria-expanded] + .faq-answer
 * Toggling is in js/faq.js.
 */

.faq-list {
    display: flex;
    flex-direction: column;
    gap: calc(18 * var(--px));
}

.faq-item {
    padding: calc(24 * var(--px));
    border-radius: var(--radius-md);
    background: var(--card-grey-bg-color);
}

.faq-question {
    width: 100%;
    padding: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: calc(9 * var(--px));
    border-radius: 0;
    background: none;
    color: var(--blue-color);
    font-size: var(--font-subheading);
    font-weight: 600;
    line-height: var(--lh-subheading);
    text-align: left;
    cursor: pointer;
    transition: color var(--dur-fast);
}

.faq-question:hover,
.faq-question:focus {
    background: none;
    color: var(--blue-color);
}

@media (hover: hover) {
    .faq-question:hover {
        color: var(--navy-text-color);
    }
}

.faq-question:focus-visible {
    outline: 2px solid var(--btn-orange-color);
    outline-offset: 6px;
    border-radius: var(--radius-2xs);
}

/*
 * Answers open by animating grid-template-rows (0fr -> 1fr), so the browser works out the height.
 * aria-expanded on the question is the only state. Answers only collapse once js/faq.js has
 * loaded (it adds .faq-ready), so if the script fails every answer stays open.
 */
.faq-arrow {
    flex-shrink: 0;
    width: calc(24 * var(--px));
    height: calc(24 * var(--px));
    margin-top: 1px;
    transform: rotate(-90deg);
    transition: transform var(--dur-toggle) var(--ease-out);
}

.faq-answer {
    display: grid;
    grid-template-rows: 1fr;
    transition:
        grid-template-rows var(--dur-toggle) var(--ease-out),
        visibility 0s;
}

.faq-ready .faq-question[aria-expanded="false"] .faq-arrow {
    transform: rotate(90deg);
}

/* Closed answers are also hidden from keyboard and screen readers once the close finishes */
.faq-ready .faq-question[aria-expanded="false"] + .faq-answer {
    grid-template-rows: 0fr;
    visibility: hidden;
    transition:
        grid-template-rows var(--dur-toggle) var(--ease-out),
        visibility 0s var(--dur-toggle);
}

.faq-answer-inner {
    min-height: 0;
    overflow: hidden;
}

.faq-answer-content {
    padding-top: calc(12 * var(--px));
    display: flex;
    flex-direction: column;
    gap: calc(14 * var(--px));
    color: var(--muted-text-color);
    font-size: var(--font-body);
    line-height: calc(21 * var(--px));
}

.faq-item {
    --reveal-y: 16px;
}

.faq-answer a {
    color: var(--blue-color);
    text-decoration: underline;
}

@media (hover: hover) {
    .faq-answer a:hover {
        color: var(--btn-orange-color);
    }
}

@media (width < 500px) {
    .faq-item {
        padding: calc(18 * var(--px));
        border-radius: var(--radius-sm);
    }

    .faq-question {
        font-size: var(--font-item-title);
        line-height: var(--lh-item-title);
    }

    .faq-arrow {
        width: calc(22 * var(--px));
        height: calc(22 * var(--px));
        margin-top: 1px;
    }
}
