/**
 * Custom Mobile Carts: FAQ page
 *
 * Lays out templates/template-faq.php: the topic list beside the
 * questions on wide screens and above them on phones, the search box,
 * the group headers and the closing band. The accordions themselves are
 * the native details/summary pattern from style.css (.accordion); this
 * file only sizes the summaries for touch, adds the permalink and the
 * highlight for a question reached by its link. Cards, chips, buttons,
 * form controls and the page hero are global. Mobile first.
 *
 * @package CustomMobileCarts
 */

/* ==========================================================================
   Editor content under the hero
   ========================================================================== */

.faq-content {
    padding-bottom: 0;
}

.faq-prose {
    max-width: 46rem;
}

.faq-prose > :first-child {
    margin-top: 0;
}

/* ==========================================================================
   Layout: topics beside the questions from 1024px
   ========================================================================== */

.faq-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-2xl);
    align-items: start;
}

.faq-layout__main {
    width: 100%;
    max-width: 72ch;
    min-width: 0;
}

@media (min-width: 1024px) {
    .faq-layout {
        grid-template-columns: minmax(0, 17rem) minmax(0, 1fr);
        column-gap: var(--spacing-3xl);
    }

    .faq-nav {
        position: sticky;
        top: calc(var(--header-height) + var(--spacing-xl));
        max-height: calc(100vh - var(--header-height) - var(--spacing-2xl));
        overflow-y: auto;
    }
}

/* ==========================================================================
   Topic list
   ========================================================================== */

.faq-nav {
    padding: var(--spacing-lg);
}

/* A list of links, never a link itself: the card stays still under the pointer */
@media (hover: hover) {
    .faq-nav:hover {
        transform: none;
        box-shadow: var(--shadow-xs);
    }
}

.faq-nav__title {
    margin-bottom: var(--spacing-sm);
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: var(--font-weight-bold);
    line-height: 1.3;
    letter-spacing: var(--letter-spacing-eyebrow);
    text-transform: uppercase;
    color: var(--color-eyebrow);
}

.faq-nav__list {
    display: grid;
    gap: 0.125rem;
}

.faq-nav__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.625rem;
    min-height: 44px;
    margin-inline: calc(-1 * var(--spacing-sm));
    padding: 0.375rem var(--spacing-sm);
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--color-text-light);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.faq-nav__link:hover {
    color: var(--color-heading);
    background-color: var(--color-surface-hover);
}

/* How many questions the topic holds; the script updates it while filtering */
.faq-nav__count {
    flex: none;
    min-width: 1.75rem;
    padding: 0.125rem 0.5rem;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.4;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--color-chip-fg);
    background-color: var(--color-chip-bg);
    border-radius: var(--radius-full);
}

/* A topic with no matching questions stays listed but steps back */
.faq-nav__list li.is-empty .faq-nav__link {
    color: var(--color-text-muted);
}

.faq-nav__list li.is-empty .faq-nav__count {
    color: var(--color-text-muted);
    background-color: var(--color-bg-subtle);
}

/* ==========================================================================
   Search box (shown by faq.js)
   ========================================================================== */

.faq-search {
    margin-bottom: var(--spacing-2xl);
}

.faq-search__label {
    margin-bottom: 0.375rem;
}

.faq-search__row {
    position: relative;
    display: flex;
    align-items: center;
}

.faq-search__icon {
    position: absolute;
    left: 0.875rem;
    display: inline-flex;
    color: var(--color-text-muted);
    pointer-events: none;
}

.faq-search__input {
    padding-left: 2.75rem;
}

/* Room for the clear button once the field has text */
.faq-search__input.has-value {
    padding-right: 4.5rem;
}

/* The browser's own clear control would double up with ours */
.faq-search__input::-webkit-search-cancel-button,
.faq-search__input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.faq-search__clear {
    position: absolute;
    right: 0.375rem;
}

.faq-search__status {
    min-height: 1.5rem;
    margin: 0.5rem 0 0;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    color: var(--color-text-light);
}

/* ==========================================================================
   Groups
   ========================================================================== */

.faq-group + .faq-group {
    margin-top: var(--spacing-3xl);
}

.faq-group__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--spacing-md) var(--spacing-md);
    align-items: start;
    margin-bottom: var(--spacing-lg);
}

.faq-group__chip {
    width: 44px;
    height: 44px;
}

.faq-group__heading {
    min-width: 0;
}

.faq-group__title {
    margin-bottom: 0.25rem;
    font-size: var(--font-size-2xl);
    scroll-margin-top: calc(var(--header-height) + var(--spacing-md));
}

.faq-group__intro {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--color-text-light);
}

/* Open all and Close all, under the heading on phones and to its right from 640px */
.faq-group__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--spacing-md);
    grid-column: 1 / -1;
}

.faq-group__tool {
    min-height: 44px;
    padding: 0.5rem 0;
    font-family: var(--font-body);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-link);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.faq-group__tool:hover {
    color: var(--color-link-hover);
}

@media (min-width: 640px) {
    .faq-group__header {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .faq-group__tools {
        grid-column: auto;
        align-self: center;
    }
}

/* The group anchor lands below the fixed header */
.faq-group {
    scroll-margin-top: calc(var(--header-height) + var(--spacing-md));
}

/* ==========================================================================
   Questions: the global accordion with touch sized summaries
   ========================================================================== */

.faq-item {
    scroll-margin-top: calc(var(--header-height) + var(--spacing-md));
}

.faq-item__summary {
    align-items: center;
    min-height: 44px;
    padding-block: 1rem;
}

/* The ring the global rule draws would be clipped by the item above and
   below, so it moves inside the summary where it can be seen whole. The
   transparent outline from style.css stays for forced colours mode. */
.faq-item__summary:focus-visible {
    box-shadow: inset 0 0 0 2px var(--color-link);
}

.faq-item__question {
    min-width: 0;
}

.faq-item__content {
    padding-right: 0;
}

@media (min-width: 640px) {
    .faq-item__content {
        padding-right: 2.25rem;
    }
}

.faq-item__content p {
    color: var(--color-text);
}

.faq-item__permalink {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 44px;
    margin-top: 0.25rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
}

.faq-item__permalink:hover {
    color: var(--color-link);
}

/* A question reached by its link gets a gold edge so the eye lands on it */
.faq-item:target,
.faq-item.is-targeted {
    box-shadow: inset 3px 0 0 var(--color-secondary);
}

.faq-item:target > .faq-item__summary,
.faq-item.is-targeted > .faq-item__summary,
.faq-item:target > .faq-item__content,
.faq-item.is-targeted > .faq-item__content {
    padding-left: var(--spacing-md);
}

/* Nothing matched the search */
.faq-empty {
    margin: 0;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg-tint);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-secondary);
    border-radius: var(--radius-md);
}

/* ==========================================================================
   Closing call to action (same pattern as the Start Here page)
   ========================================================================== */

.faq-cta__inner {
    display: grid;
    gap: var(--spacing-xl);
}

@media (min-width: 1024px) {
    .faq-cta__inner {
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: var(--spacing-3xl);
        align-items: center;
    }
}

.faq-cta__copy > :last-child {
    margin-bottom: 0;
}

.faq-cta__title {
    max-width: 24ch;
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-4xl);
}

.faq-cta__text {
    max-width: 40rem;
    font-size: var(--font-size-lg);
    line-height: 1.6;
}

.faq-cta__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 480px) {
    .faq-cta__actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   Reduced motion and print
   ========================================================================== */

/* style.css already zeroes the motion tokens, which stops the chevron
   turning and the details height animating. This covers the sticky topic
   list, which can jump while the page scrolls. */
@media (prefers-reduced-motion: reduce) {
    .faq-nav {
        position: static;
    }

    .faq-nav__link,
    .faq-group__tool {
        transition: none;
    }
}

@media print {
    .page-hero .breadcrumbs,
    .faq-nav,
    .faq-search,
    .faq-group__tools,
    .faq-item__permalink,
    .faq-cta {
        display: none !important;
    }

    .faq-layout {
        display: block;
    }

    .faq-layout__main {
        max-width: none;
    }

    /* Every answer prints, open or not */
    .faq-item:not([open]) > .faq-item__content {
        display: block;
    }

    .faq-item__summary::after {
        display: none;
    }

    .faq-item,
    .faq-group__header {
        break-inside: avoid;
    }
}
