////
///
/// Drilldown Menu Component Mixins
/// ===========================================================================
///
/// Foundation-style drilldown navigation mixins for creating multi-level
/// navigational menus that slide horizontally through nested levels.
///
/// @group Mixins.BodyMolecules.Navigation
/// @author Scape Agency
/// @link https://scape.style
/// @since 0.1.0 initial release
/// @access public
///
////

// ============================================================================
// Use
// ============================================================================

@use "../../../dev" as *;
@use "../../../variables" as *;
@use "../../head_layout" as *;

// ============================================================================
// Drilldown Container Mixins
// ============================================================================

/// Base drilldown container - clips overflow for slide animation
/// @group Drilldown
@mixin drilldown--container {
    position: relative;
    overflow: hidden;
    width: 100%;
    background-color: var(--color_fill_primary);
}

/// Drilldown wrapper - holds all menu levels and slides
/// @group Drilldown
@mixin drilldown--wrapper {
    display: flex;
    flex-direction: row;
    transition: transform 0.3s ease-in-out;
    will-change: transform;
}

/// Individual drilldown level (each submenu)
/// @group Drilldown
@mixin drilldown--level {
    min-width: 100%;
    flex-shrink: 0;
    list-style: none;
    padding: 0;
    margin: 0;
}

// ============================================================================
// Drilldown Item Mixins
// ============================================================================

/// Base drilldown menu item
/// @group Drilldown
@mixin drilldown--item {
    display: block;
    margin: 0;

    > a,
    > button {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: q(12) q(16);
        color: var(--color_text_primary);
        background-color: var(--color_fill_primary);
        border: none;
        border-bottom: q(1) solid var(--color_line_secondary);
        text-align: left;
        text-decoration: none;
        cursor: pointer;
        transition:
            background-color 0.15s ease,
            color 0.15s ease;

        &:hover,
        &:focus {
            background-color: var(--color_fill_secondary);
            color: var(--color_text_primary);
            outline: none;
        }

        &:focus-visible {
            outline: q(2) solid var(--color_accent_primary);
            outline-offset: q(-2);
        }
    }
}

/// Item with submenu - shows forward indicator
/// @group Drilldown
@mixin drilldown--has-submenu {
    > a,
    > button {
        &::after {
            content: "";
            display: inline-block;
            width: q(8);
            height: q(8);
            border-right: q(2) solid var(--color_text_secondary);
            border-bottom: q(2) solid var(--color_text_secondary);
            transform: rotate(-45deg);
            margin-left: q(8);
            transition:
                transform 0.15s ease,
                border-color 0.15s ease;
        }

        &:hover::after {
            border-color: var(--color_accent_primary);
        }
    }
}

/// Drilldown back button styling
/// @group Drilldown
@mixin drilldown--back {
    > a,
    > button {
        display: flex;
        align-items: center;
        gap: q(8);
        width: 100%;
        padding: q(12) q(16);
        font-weight: 600;
        color: var(--color_accent_primary);
        background-color: var(--color_fill_secondary);
        border: none;
        border-bottom: q(1) solid var(--color_line_primary);
        text-align: left;
        text-decoration: none;
        cursor: pointer;
        transition: background-color 0.15s ease;

        &::before {
            content: "";
            display: inline-block;
            width: q(8);
            height: q(8);
            border-left: q(2) solid currentColor;
            border-bottom: q(2) solid currentColor;
            transform: rotate(45deg);
        }

        &:hover,
        &:focus {
            background-color: var(--color_fill_tertiary);
            outline: none;
        }
    }
}

/// Submenu title in back button area
/// @group Drilldown
@mixin drilldown--submenu-title {
    display: block;
    padding: q(8) q(16);
    font-size: calc(var(--typescale-base) * 0.75);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color_text_secondary);
    background-color: var(--color_fill_secondary);
    border-bottom: q(1) solid var(--color_line_primary);
}

// ============================================================================
// Drilldown State Mixins
// ============================================================================

/// Active item highlight
/// @group Drilldown
@mixin drilldown--item-active {
    > a,
    > button {
        color: var(--color_accent_primary);
        background-color: var(--color_fill_secondary);
        font-weight: 600;
    }
}

/// Disabled item
/// @group Drilldown
@mixin drilldown--item-disabled {
    > a,
    > button {
        color: var(--color_text_tertiary);
        pointer-events: none;
        cursor: not-allowed;

        &::after {
            border-color: var(--color_text_tertiary);
        }
    }
}

// ============================================================================
// Drilldown Animation Helpers
// ============================================================================

/// Animate to specific level (use with JS)
/// @param {Number} $depth - Level depth (0 = root)
/// @group Drilldown
@mixin drilldown--go-to-level($depth) {
    transform: translateX(calc(-100% * #{$depth}));
}

/// Auto-height transition support
/// @group Drilldown
@mixin drilldown--auto-height {
    transition:
        transform 0.3s ease-in-out,
        height 0.3s ease-in-out;
}

// ============================================================================
// Drilldown Variant Mixins
// ============================================================================

/// Compact drilldown with smaller padding
/// @group Drilldown
@mixin drilldown--compact {
    .drilldown__item {
        > a,
        > button {
            padding: q(8) q(12);
            font-size: calc(var(--typescale-base) * 0.875);
        }
    }

    .drilldown__back {
        > a,
        > button {
            padding: q(8) q(12);
        }
    }
}

/// Bordered drilldown items
/// @group Drilldown
@mixin drilldown--bordered {
    border: q(1) solid var(--color_line_primary);
    border-radius: var(--primitive-corner-radius-04);

    .drilldown__item:last-child {
        > a,
        > button {
            border-bottom: none;
        }
    }
}

/// Dark drilldown variant
/// @group Drilldown
@mixin drilldown--dark {
    background-color: var(--color_fill_04);

    .drilldown__item {
        > a,
        > button {
            color: var(--color_fill_01);
            background-color: var(--color_fill_04);
            border-color: var(--color_fill_03);

            &:hover,
            &:focus {
                background-color: var(--color_fill_03);
            }

            &::after {
                border-color: var(--color_fill_02);
            }
        }
    }

    .drilldown__back {
        > a,
        > button {
            background-color: var(--color_fill_03);
            border-color: var(--color_fill_02);
        }
    }
}

// ============================================================================
// Utility Classes are defined in:
// src/scss/classes/body_molecules/navigation/_drilldown.scss
// ============================================================================
