/* GSL Mega Menus — Structural CSS.
 * Desktop layout uses Tailwind utilities in walker output.
 * This file handles stateful transitions and structural rules that require
 * class-toggling or pseudo-elements beyond utility scope.
 */

/* ─── Desktop ─────────────────────────────────────────────────────── */

.sub-menu-container {
    background: var(--wp--custom--color--surface, #f3f0eb);
    border-top: 1px solid var(--wp--custom--color--on-surface, #3a3a38);
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
}

.gsl-mega-menu__item:hover > .sub-menu-container,
.gsl-mega-menu__item:focus-within > .sub-menu-container,
.gsl-mega-menu__item.is-open > .sub-menu-container {
    opacity: 1;
    visibility: visible;
}

.sub-menu-wrapper::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 25%;
    height: 100%;
    background: var(--wp--custom--color--surface-alt, #fdfcfb);
    z-index: -1;
}

.sub-menu-container::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: calc(50% - ((var(--wp--custom--layout--site-width, 1644px) + (clamp(1rem, 4vw, 2.5rem) * 2)) * 0.25));
    height: 100%;
    background: var(--wp--custom--color--surface-alt, #fdfcfb);
}

.gsl-mega-menu__sidebar-link {
    border-bottom: 1px solid transparent;
    transition: border-color 200ms ease;
}

.group\/item:hover .gsl-mega-menu__sidebar-link,
.group\/item:focus-within .gsl-mega-menu__sidebar-link {
    border-bottom-color: var(--wp--custom--color--on-surface, #3a3a38);
}

.group\/item:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
}

/* ─── Mobile: Burger Button ───────────────────────────────────────── */

.gsl-mobile-menu__trigger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 28px;
    height: 28px;
}

.gsl-mobile-menu__bar {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 300ms ease, opacity 200ms ease;
    transform-origin: center;
}

.gsl-mobile-menu__trigger.is-open .gsl-mobile-menu__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.gsl-mobile-menu__trigger.is-open .gsl-mobile-menu__bar:nth-child(2) {
    opacity: 0;
}

.gsl-mobile-menu__trigger.is-open .gsl-mobile-menu__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ─── Mobile: Drawer ──────────────────────────────────────────────── */

.gsl-mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 40;
    visibility: hidden;
    pointer-events: none;
}

.gsl-mobile-menu.is-open {
    visibility: visible;
    pointer-events: auto;
}

.gsl-mobile-menu__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 300ms ease;
}

.gsl-mobile-menu.is-open .gsl-mobile-menu__backdrop {
    opacity: 1;
}

.gsl-mobile-menu__panel {
    position: absolute;
    top: var(--wp--custom--layout--header-height, 70px);
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 402px;
    display: flex;
    flex-direction: column;
    background: var(--wp--custom--color--primary, #3a3a38);
    color: var(--wp--custom--color--on-primary, #f3f0eb);
    transform: translateX(-100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.gsl-mobile-menu.is-open .gsl-mobile-menu__panel {
    transform: translateX(0);
}

/* ─── Mobile: Navigation Content ──────────────────────────────────── */

.gsl-mobile-menu__nav {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.gsl-mobile-menu__scroll {
    height: 100%;
    overflow-y: auto;
    padding: var(--wp--custom--spacing--xl, 2.5rem) var(--wp--custom--spacing--lg, 1.875rem);
}

.gsl-mobile-menu__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--wp--custom--spacing--s, 1.25rem);
}

.gsl-mobile-menu__list > .menu-item > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: var(--wp--preset--font-family--body);
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.4;
    text-transform: capitalize;
    color: inherit;
    text-decoration: none;
    padding-block: 0.625rem;
    border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.gsl-mobile-menu__list > .menu-item:last-child > a {
    border-bottom: none;
}

/* Chevron for items with children */
.gsl-mobile-menu__list > .menu-item-has-children > a::after {
    content: '';
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    background: currentColor;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z'/%3E%3C/svg%3E");
    mask-size: contain;
    mask-repeat: no-repeat;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
}

/* ─── Mobile: Slide-Panel Submenu ─────────────────────────────────── */

.gsl-mega-menu__sub-menu--mobile {
    position: absolute;
    top: 0;
    left: 100%;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: var(--wp--custom--color--primary, #3a3a38);
    color: var(--wp--custom--color--on-primary, #f3f0eb);
    display: flex;
    flex-direction: column;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

.gsl-mega-menu__item--mobile.open > .gsl-mega-menu__sub-menu--mobile {
    transform: translateX(-100%);
}

.gsl-mega-menu__mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: var(--wp--custom--spacing--md, 1.25rem) var(--wp--custom--spacing--lg, 1.875rem);
    border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    flex-shrink: 0;
}

.gsl-mega-menu__mobile-back {
    appearance: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    color: inherit;
    display: flex;
    align-items: center;
}

.gsl-mega-menu__mobile-title {
    font-family: var(--wp--preset--font-family--body);
    font-size: 1.125rem;
    font-weight: 500;
    text-transform: capitalize;
}

.gsl-mega-menu__mobile-view-all {
    margin-left: auto;
    font-size: 0.875rem;
    text-decoration: none;
    color: inherit;
    opacity: 0.7;
    transition: opacity 200ms;
}

.gsl-mega-menu__mobile-view-all:hover {
    opacity: 1;
}

.gsl-mega-menu__mobile-scroll {
    flex: 1;
    overflow-y: auto;
    padding: var(--wp--custom--spacing--lg, 1.875rem);
}

.gsl-mega-menu__mobile-scroll .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--wp--custom--spacing--sm, 0.9375rem);
}

.gsl-mega-menu__mobile-scroll .sub-menu a {
    display: block;
    font-family: var(--wp--preset--font-family--body);
    font-size: 1rem;
    font-weight: 400;
    color: inherit;
    text-decoration: none;
    text-transform: capitalize;
    padding-block: 0.375rem;
    transition: opacity 200ms;
}

/* Items with children inside panels get chevron + flex layout */
.gsl-mega-menu__mobile-scroll .menu-item-has-children > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gsl-mega-menu__mobile-scroll .menu-item-has-children > a::after {
    content: '';
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    background: currentColor;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z'/%3E%3C/svg%3E");
    mask-size: contain;
    mask-repeat: no-repeat;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
}

.gsl-mega-menu__mobile-scroll .sub-menu a:hover {
    opacity: 0.7;
}

/* ─── Mobile: Footer ──────────────────────────────────────────────── */

.gsl-mobile-menu__footer {
    flex-shrink: 0;
    padding: var(--wp--custom--spacing--md, 1.25rem) var(--wp--custom--spacing--lg, 1.875rem) var(--wp--custom--spacing--xl, 2.5rem);
}

.gsl-mobile-menu__footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--wp--custom--spacing--xl, 2.5rem);
}

.gsl-mobile-menu__footer-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    text-decoration: none;
    font-family: var(--wp--preset--font-family--body);
    font-size: 1rem;
    text-transform: capitalize;
    transition: opacity 200ms;
}

.gsl-mobile-menu__footer-link:hover {
    opacity: 0.7;
}

.gsl-mobile-menu__footer-link svg {
    flex-shrink: 0;
}
