/*
 * Storefront shell: the top strip, the header row (logo, search, cart box), the menu row with the
 * category menu, its fly-outs and the mega menu, the sticky state, the drawer below 992px, and the footer.
 *
 * KuteShop positions its panels from script. Here every panel is laid out by CSS and opens on hover and
 * on focus-within, so the menus work from the keyboard and with script off; the shop's module only adds
 * click and touch toggling, aria-expanded, Escape and outside-click (js/store-theme.js).
 */

/* ---------------------------------------------------------------- top strip */

/* The strip is a stacking context of its own, so its language panel can rise no higher than the strip
   itself. The panel hangs down over the header row, which is opaque and comes later in the document;
   the strip must therefore stack above the header (.sf-header), or the panel opens unseen behind it. */
.sf-topbar {
    min-height: var(--sf-height-strip);
    background: var(--sf-surface);
    box-shadow: var(--sf-shadow-strip);
    font-size: var(--sf-text-small);
    color: var(--sf-ink-secondary);
    position: relative;
    z-index: 45;
}

.sf-topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1.5rem;
    min-height: var(--sf-height-strip);
}

/* The language selector keeps to the end of the strip at every width. Below 992px the links are hidden
   and the selector is the strip's only item, which space-between would put at the start; its panel,
   anchored to the trigger's end edge, would then open outward past the screen's edge with its labels cut off. */
.sf-topbar-end {
    margin-inline-start: auto;
}

.sf-topbar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.25rem;
}

.sf-topbar-links a {
    display: inline-block;
    padding-block: 0.375rem;
}

/* A navigation entry that has no page yet is text, not a link that goes nowhere. */
.sf-shell .store-link-pending {
    color: var(--sf-ink-muted);
    cursor: default;
}

.sf-shell .store-link-pending:hover {
    color: var(--sf-ink-muted);
}

/* ---------------------------------------------------------------- drop-downs (language, account) */

.sf-dropdown {
    position: relative;
}

.sf-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
    border: 0;
    background: none;
    color: inherit;
    font-size: inherit;
}

.sf-dropdown-trigger:hover {
    color: var(--sf-accent-ink);
}

.sf-dropdown-panel {
    display: none;
    position: absolute;
    inset-block-start: 100%;
    inset-inline-end: 0;
    z-index: 60;
    min-width: 11rem;
    padding-block: 0.375rem;
    background: var(--sf-surface);
    border: 1px solid var(--sf-line);
    box-shadow: var(--sf-shadow-panel);
}

:root:not([data-store-enhanced]) .sf-dropdown:focus-within > .sf-dropdown-panel,
[aria-expanded="true"] + .sf-dropdown-panel {
    display: block;
}

.sf-dropdown-panel a,
.sf-dropdown-panel button {
    display: block;
    width: 100%;
    padding: 0.4375rem 1rem;
    border: 0;
    background: none;
    color: var(--sf-ink);
    font-size: var(--sf-text-small);
    text-align: start;
    white-space: nowrap;
}

.sf-dropdown-panel a:hover,
.sf-dropdown-panel button:hover,
.sf-dropdown-panel .active {
    background: var(--sf-surface-alt);
    color: var(--sf-accent-ink);
}

.sf-dropdown-panel form {
    margin: 0;
}

/* ---------------------------------------------------------------- header row */

/* Stacks below the top strip (.sf-topbar), whose drop-down panels hang over this row. */
.sf-header {
    position: relative;
    z-index: 40;
    background: var(--sf-surface);
}

.sf-header-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.875rem;
    padding-block: 1.25rem;
}

.sf-header-logo {
    flex: 0 0 auto;
}

/* The two language links of the page shown while the site is closed for setup (docs/architecture/site-setup-mode.md). */
.sf-site-setup-languages {
    display: flex;
    gap: 1rem;
    margin-inline-start: auto;
}

.sf-site-setup-languages a {
    color: var(--sf-ink);
    text-decoration: underline;
}

.sf-site-setup-languages a[aria-current="true"] {
    color: var(--sf-accent-ink);
    font-weight: 700;
    text-decoration: none;
}

.sf-header-logo img {
    display: block;
    width: auto;
    height: 3.25rem;
}

.sf-header-search {
    flex: 1 1 22rem;
    min-width: 0;
}

.sf-search-form {
    display: flex;
    align-items: stretch;
    min-height: var(--sf-height-control);
    border: 1px solid var(--sf-accent-edge);
    background: var(--sf-surface);
}

.sf-search-category {
    flex: 0 1 11rem;
    min-width: 0;
    padding-inline: 0.75rem;
    border: 0;
    border-inline-end: 1px solid var(--sf-line);
    background: var(--sf-surface);
    color: var(--sf-ink);
    font-size: var(--sf-text-small);
}

.sf-search-term {
    flex: 1 1 auto;
    min-width: 0;
    padding-inline: 0.875rem;
    border: 0;
    background: var(--sf-surface);
    color: var(--sf-ink);
    font-size: var(--sf-text-small);
}

.sf-search-term::placeholder {
    color: var(--sf-ink-muted);
    opacity: 1;
}

.sf-search-submit {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-width: var(--sf-height-control);
    border: 0;
    background: var(--sf-accent);
    color: var(--sf-on-accent);
}

.sf-search-submit:hover {
    background: var(--sf-accent-hover);
}

/* The field's own outline sits inside the amber frame, which is already the frame of the control. */
.sf-search-form :is(select, input):focus-visible {
    outline-offset: -3px;
}

.sf-header-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.sf-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--sf-height-control);
    padding-inline: 0.5rem;
    border: 0;
    background: none;
    color: var(--sf-ink);
    font-size: var(--sf-text-small);
}

.sf-action .sf-icon {
    width: 1.375rem;
    height: 1.375rem;
}

.sf-action-cart {
    padding-inline: 0.875rem;
    border: 1px solid var(--sf-line);
}

.sf-action-cart:hover {
    border-color: var(--sf-accent);
}

.sf-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding-inline: 0.25rem;
    border-radius: 0.625rem;
    background: var(--sf-bar);
    color: var(--sf-on-bar);
    font-size: var(--sf-text-smallest);
    font-weight: 700;
    line-height: 1;
}

/* ---------------------------------------------------------------- menu row */

.sf-menu-row {
    position: relative;
    background: var(--sf-surface);
    border-block-end: 1px solid var(--sf-line);
}

/* The row is the box the mega menu is positioned against, so the panel spans the row. */
.sf-menu-row-inner {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 1.875rem;
    min-height: var(--sf-height-bar);
}

/* The sticky state: after the visitor scrolls past the header the menu row stays at the top. The
   header keeps the row's height so the page does not jump when it leaves the flow. */
.sf-header.sf-is-stuck {
    padding-block-end: var(--sf-height-bar);
}

.sf-header.sf-is-stuck .sf-menu-row {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: 50;
    box-shadow: var(--sf-shadow-panel);
}

/* -- the category menu */

.sf-categories {
    position: relative;
    flex: 0 0 var(--sf-sidebar-width);
}

.sf-categories-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    height: 100%;
    min-height: var(--sf-height-bar);
    padding-inline: 1.25rem;
    border: 0;
    background: var(--sf-bar);
    color: var(--sf-on-bar);
    font-size: var(--sf-text-body);
    font-weight: 700;
    text-align: start;
}

.sf-categories-list {
    display: none;
    position: absolute;
    inset-block-start: 100%;
    inset-inline-start: 0;
    z-index: 55;
    width: 100%;
    border: 1px solid var(--sf-line);
    border-block-start: 0;
    background: var(--sf-surface);
    box-shadow: var(--sf-shadow-panel);
}

.sf-categories:hover > .sf-categories-list,
:root:not([data-store-enhanced]) .sf-categories:focus-within > .sf-categories-list,
[aria-expanded="true"] + .sf-categories-list {
    display: block;
}

.sf-categories-item {
    position: static;
}

.sf-categories-item + .sf-categories-item {
    border-block-start: 1px solid var(--sf-line);
}

.sf-categories-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.5rem 1.25rem;
    color: var(--sf-ink);
}

.sf-categories-link .sf-icon {
    width: 0.875rem;
    height: 0.875rem;
    color: var(--sf-ink-muted);
}

.sf-flyout {
    display: none;
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 100%;
    z-index: 56;
    width: min(43.75rem, calc(100vw - var(--sf-sidebar-width) - 4rem));
    min-height: 100%;
    padding: 1.25rem 1.875rem;
    background: var(--sf-surface);
    border: 1px solid var(--sf-line);
    box-shadow: var(--sf-shadow-panel);
}

.sf-categories-item:hover > .sf-flyout,
.sf-categories-item:focus-within > .sf-flyout {
    display: block;
}

.sf-flyout-heading {
    margin: 0 0 0.75rem;
    padding-block-end: 0.5rem;
    border-block-end: 1px solid var(--sf-line);
    font-size: var(--sf-text-block-title);
    font-weight: 700;
}

.sf-link-columns {
    columns: 3 10rem;
    column-gap: 1.875rem;
}

.sf-link-columns li {
    break-inside: avoid;
}

.sf-link-columns a {
    display: inline-block;
    padding-block: 0.3125rem;
    color: var(--sf-ink-secondary);
    font-size: var(--sf-text-small);
}

.sf-link-columns a:hover {
    color: var(--sf-accent-ink);
}

/* -- the main menu */

.sf-main-menu {
    flex: 1 1 auto;
    min-width: 0;
}

.sf-main-menu-list {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    height: 100%;
}

.sf-main-menu-item {
    position: static;
    display: flex;
}

.sf-main-menu-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: var(--sf-height-bar);
    padding-inline: 0.9375rem;
    border: 0;
    background: none;
    color: var(--sf-ink);
    font-size: var(--sf-text-body);
}

.sf-main-menu-link::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0.9375rem;
    height: 3px;
    background: var(--sf-accent);
    transform: scaleX(0);
    transition: transform var(--sf-transition);
}

.sf-main-menu-link:hover::before,
.sf-main-menu-link[aria-current="page"]::before,
.sf-main-menu-item:focus-within > .sf-main-menu-link::before,
.sf-main-menu-link[aria-expanded="true"]::before {
    transform: scaleX(1);
}

.sf-main-menu-link[aria-current="page"] {
    font-weight: 700;
}

.sf-main-menu-link .sf-icon {
    width: 0.75rem;
    height: 0.75rem;
}

/* The mega menu spans the menu row beside the category menu, as KuteShop's does. */
.sf-mega {
    display: none;
    position: absolute;
    inset-block-start: 100%;
    inset-inline-start: calc(var(--sf-sidebar-width) + 1.875rem + var(--sf-gutter));
    inset-inline-end: var(--sf-gutter);
    z-index: 54;
    padding: 1.25rem 1.875rem;
    background: var(--sf-surface);
    border: 1px solid var(--sf-line);
    box-shadow: var(--sf-shadow-panel);
}

.sf-main-menu-item:hover > .sf-mega,
:root:not([data-store-enhanced]) .sf-main-menu-item:focus-within > .sf-mega,
[aria-expanded="true"] + .sf-mega {
    display: block;
}

.sf-mega .sf-link-columns {
    columns: 4 10rem;
}

/* -- the drawer button, shown below 992px instead of the two menus */

.sf-drawer-toggle {
    display: none;
    align-items: center;
    gap: 0.625rem;
    min-height: var(--sf-height-bar);
    padding-inline: 1.25rem;
    border: 0;
    background: var(--sf-bar);
    color: var(--sf-on-bar);
    font-weight: 700;
}

@media (max-width: 991.98px) {
    .sf-categories,
    .sf-main-menu {
        display: none;
    }

    .sf-drawer-toggle {
        display: inline-flex;
    }

    .sf-menu-row {
        border-block-end: 0;
    }

    .sf-header-main {
        gap: 0.75rem 1rem;
        padding-block: 0.875rem;
    }

    .sf-header-search {
        order: 3;
        flex-basis: 100%;
    }

    .sf-search-category {
        flex-basis: 7.5rem;
    }

    .sf-header-logo img {
        height: 2.5rem;
    }

    .sf-header-actions {
        margin-inline-start: auto;
        gap: 0.25rem;
    }

    .sf-action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

/* ---------------------------------------------------------------- drawer */

.sf-drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1050;
    width: min(20rem, 88vw);
    overflow-y: auto;
    background: var(--sf-surface);
    box-shadow: var(--sf-shadow-panel);
    transform: translateX(-105%);
    transition: transform var(--sf-transition);
    visibility: hidden;
}

[dir="rtl"] .sf-drawer {
    transform: translateX(105%);
}

.sf-drawer.is-open {
    transform: none;
    visibility: visible;
}

.sf-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-block-end: 1px solid var(--sf-line);
}

.sf-drawer-head img {
    display: block;
    width: auto;
    height: 2.25rem;
}

.sf-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    background: none;
    color: var(--sf-ink);
}

.sf-drawer-section {
    padding: 0.75rem 1.25rem;
    border-block-end: 1px solid var(--sf-line);
}

.sf-drawer-heading {
    margin: 0.25rem 0 0.5rem;
    font-size: var(--sf-text-block-title);
    font-weight: 700;
}

.sf-drawer-menu > li + li {
    border-block-start: 1px solid var(--sf-line);
}

.sf-drawer-menu a,
.sf-drawer-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 2.75rem;
    padding-block: 0.5rem;
    border: 0;
    background: none;
    color: var(--sf-ink);
    font-size: var(--sf-text-body);
    text-align: start;
}

.sf-drawer-menu a.active {
    font-weight: 700;
    color: var(--sf-accent-ink);
}

.sf-drawer-submenu {
    display: none;
    padding-inline-start: 1rem;
    padding-block-end: 0.5rem;
}

[aria-expanded="true"] + .sf-drawer-submenu {
    display: block;
}

.sf-drawer-menu button[aria-expanded="true"] .sf-icon {
    transform: rotate(180deg);
}

.sf-drawer-submenu a {
    min-height: 2.5rem;
    color: var(--sf-ink-secondary);
    font-size: var(--sf-text-small);
}

.sf-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.45);
}

.sf-drawer-open .sf-drawer-overlay {
    display: block;
}

.sf-drawer-open {
    overflow: hidden;
}

/* ---------------------------------------------------------------- footer */

.sf-footer {
    margin-block-start: 3rem;
    border-block-start: 1px solid var(--sf-line);
    background: var(--sf-surface);
    color: var(--sf-ink-secondary);
    font-size: var(--sf-text-small);
}

.sf-footer-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 2rem 1.875rem;
    padding-block: 2.5rem 2rem;
}

.sf-footer-brand img {
    display: block;
    width: auto;
    height: 3rem;
}

.sf-footer-brand .store-brand-mark-tagline {
    display: block;
    margin-block-start: 0.75rem;
    color: var(--sf-ink-secondary);
}

.sf-footer-contact > div {
    margin-block-start: 0.75rem;
}

.sf-footer-contact strong {
    display: block;
    color: var(--sf-ink);
}

.sf-footer-title {
    margin: 0 0 1rem;
    color: var(--sf-ink);
    font-size: var(--sf-text-block-title);
    font-weight: 700;
    line-height: 1.4;
}

.sf-footer-links a,
.sf-footer-links .store-link-pending {
    display: inline-block;
    padding-block: 0.3125rem;
}

.sf-footer-bottom {
    border-block-start: 1px solid var(--sf-line);
    background: var(--sf-surface-alt);
}

.sf-footer-bottom-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 2rem;
    padding-block: 1rem;
    color: var(--sf-ink-secondary);
}

/* ---------------------------------------------------------------- the home page's pinned category list */

/* On the home page at desktop width the category list hangs open beside the hero, as in KuteShop's home
   layout. With the module the button's state says so ([data-store-pinned]); without it, CSS opens the list. */
@media (min-width: 992px) {
    :root:not([data-store-enhanced]):has([data-store-home]) .sf-categories-list {
        display: block;
    }

    :root:has([data-store-home]) .sf-header:not(.sf-is-stuck) .sf-categories-list {
        box-shadow: none;
    }
}
