/* Layered mobile nav shell.
 *
 * Three layers slide in from the right (high motion) or cross-fade
 * (reduced motion). The CSS reads --motion-multiplier off the layout
 * root: a multiplier of 0 produces 0 horizontal travel and the
 * transition becomes a pure opacity change.
 *
 * The max-depth rule (layer 3 only when nav hierarchy depth == 3) is
 * enforced in the template — when depths ≥4 are present the template
 * emits a flat list inside the layer-2 panel rather than further
 * layer-3 surfaces. The CSS here renders whatever the template emits.
 */

.nav-mobile-shell {
    position: fixed;
    inset: 0;
    z-index: 100;
    visibility: hidden;
    pointer-events: none;
}

.nav-mobile-shell[data-open="true"] {
    visibility: visible;
    pointer-events: auto;
}

.nav-mobile-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity var(--anim-normal, 200ms) ease;
}

.nav-mobile-shell[data-open="true"] .nav-mobile-backdrop {
    opacity: 1;
}

.nav-mobile-panels {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(92vw, 360px);
    background: var(--header-bg, var(--color-surface, #ffffff));
    color: var(--header-text, var(--color-text, inherit));
    box-shadow: var(--elevation-lg, -8px 0 24px rgba(0, 0, 0, 0.18));
    overflow: hidden;
}

.nav-mobile-panel {
    position: absolute;
    inset: 0;
    padding: var(--spacing-lg, 1.5rem);
    overflow-y: auto;
    /* Shell reveal: slide from the right when motion is high; fade
     * when motion is reduced or zeroed. The translate distance is
     * scaled by --motion-multiplier so the reduced-motion path stays
     * in place.
     */
    transform: translateX(calc(100% * var(--motion-multiplier, 1)));
    opacity: 0;
    transition: transform var(--anim-normal, 200ms) ease,
                opacity var(--anim-normal, 200ms) ease,
                visibility var(--anim-normal, 200ms) ease;
    visibility: hidden;
}

.nav-mobile-panel[data-active="true"] {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.nav-mobile-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs, 0.5rem);
}

.nav-mobile-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm, 0.75rem);
    padding: var(--spacing-sm, 0.75rem) 0;
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
}

.nav-mobile-link {
    flex: 1 1 auto;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.nav-mobile-expand {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: var(--spacing-xs, 0.5rem);
    font-size: 1.25rem;
    line-height: 1;
}

.nav-mobile-back {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs, 0.5rem);
    margin-bottom: var(--spacing-md, 1rem);
    padding: var(--spacing-xs, 0.5rem) 0;
    font-weight: 600;
}

.nav-mobile-back-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* Rich list — thumbnails + content summaries inside layer 2 and the
 * grandchildren panels that survive the max-depth rule.
 */
.nav-mobile-list--rich {
    gap: var(--spacing-sm, 0.75rem);
}

.nav-mobile-item--rich {
    display: block;
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    padding-bottom: var(--spacing-sm, 0.75rem);
}

.nav-mobile-rich-link {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: var(--spacing-sm, 0.75rem);
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.nav-mobile-rich-link:has(> :not(.nav-thumbnail):first-child) {
    /* When NavImageURL was empty the template did not render an
     * <img>; collapse the grid to a single column so the label
     * occupies the full width and the layout stays clean (no broken
     * placeholder where an image should have been).
     */
    grid-template-columns: 1fr;
}

.nav-mobile-rich-link .nav-thumbnail {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--corner-subtle, 4px);
}

.nav-mobile-rich-label {
    font-weight: 600;
}

.nav-mobile-rich-summary {
    display: block;
    font-size: 0.875rem;
    color: var(--color-text-muted, rgba(0, 0, 0, 0.65));
    line-height: 1.4;
    grid-column: 1 / -1;
}

/* Flat list inside layer 2 — the max-depth fallback for taxonomies
 * deeper than 3.
 */
.nav-mobile-flat-list {
    list-style: none;
    margin: var(--spacing-xs, 0.5rem) 0 0;
    padding: 0 0 0 var(--spacing-md, 1rem);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    grid-column: 1 / -1;
}

.nav-mobile-flat-link {
    color: var(--color-text-muted, rgba(0, 0, 0, 0.7));
    text-decoration: none;
    font-size: 0.875rem;
}

/* Desktop hides the shell entirely — the megamenu / standard nav
 * surfaces handle desktop interactions.
 */
@media (min-width: 1024px) {
    .nav-mobile-shell {
        display: none;
    }
}
