/*
 * Storefront — header & footer options from the theme editor.
 * Loaded after the theme stylesheets; each rule is keyed on a data attribute
 * the layout writes from ThemeConfig, so defaults look exactly as before.
 */

/* ---------- Logo size ---------- */

html[data-theme] .sf-brand img {
    height: var(--sf-logo-h, 40px);
    max-width: calc(var(--sf-logo-h, 40px) * 4.5);
}

@media (max-width: 991.98px) {
    html[data-theme] .sf-brand img {
        height: min(var(--sf-logo-h, 40px), 48px);
    }
}

/* ---------- Sticky ---------- */

html[data-theme] .sf-header[data-sticky="0"] {
    position: relative;
}

/* ---------- Announcement bar: still ---------- */

html[data-theme] .sf-ticker[data-mode="static"] .sf-ticker-track {
    width: 100%;
    animation: none;
    justify-content: center;
}

html[data-theme] .sf-ticker[data-mode="static"] .sf-ticker-list {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 0.25rem;
    column-gap: 2rem;
}

/* Phones: one line that can be swiped instead of a tall wrapped block */
@media (max-width: 575.98px) {
    html[data-theme] .sf-ticker[data-mode="static"] .sf-ticker-track {
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
    }

    html[data-theme] .sf-ticker[data-mode="static"] .sf-ticker-track::-webkit-scrollbar {
        display: none;
    }

    html[data-theme] .sf-ticker[data-mode="static"] .sf-ticker-list {
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
}

/* ---------- Search bar hidden behind an icon ---------- */

html[data-theme] .sf-header[data-search="0"] .sf-masthead .sf-search {
    display: none;
}

html[data-theme] .sf-header[data-search="0"].is-search-open .sf-masthead .sf-search {
    display: flex;
    order: 10;
    flex-basis: 100%;
    max-width: none;
    margin-block-end: 0.75rem;
}

.sf-search-toggle {
    border: 0;
    background: none;
}

.sf-header.is-search-open .sf-search-toggle {
    color: var(--theme-color-primary);
}

/* ---------- Centered layout ---------- */

@media (min-width: 992px) {
    html[data-theme] .sf-header[data-layout="centered"] .sf-masthead-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
    }

    html[data-theme] .sf-header[data-layout="centered"] .sf-brand {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
    }

    html[data-theme] .sf-header[data-layout="centered"] .sf-masthead .sf-search {
        grid-column: 1;
        grid-row: 1;
        width: 100%;
        max-width: 340px;
        margin-inline: 0;
    }

    html[data-theme] .sf-header[data-layout="centered"].is-search-open .sf-masthead .sf-search {
        grid-column: 1 / -1;
        grid-row: 2;
        max-width: 640px;
        justify-self: center;
    }

    html[data-theme] .sf-header[data-layout="centered"] .sf-masthead-actions {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
    }

    html[data-theme] .sf-header[data-layout="centered"] .sf-catbar-list {
        justify-content: center;
    }

    html[data-theme] .sf-header[data-layout="centered"] .sf-catbar-secondary.is-push {
        margin-inline-start: 0;
    }
}

@media (max-width: 991.98px) {
    html[data-theme] .sf-header[data-layout="centered"] .sf-brand {
        margin-inline: auto;
    }

    html[data-theme] .sf-header[data-layout="centered"] .sf-masthead-actions {
        margin-inline-start: 0;
    }
}

/* ---------- Footer tones ---------- */

html[data-theme] .sf-footer[data-tone="light"] {
    background: #fff !important;
    border-top: 1px solid var(--theme-color-border);
}

html[data-theme] .sf-footer[data-tone="dark"],
html[data-theme] .sf-footer[data-tone="brand"] {
    --sf-ft-text: rgba(255, 255, 255, 0.78);
    --sf-ft-strong: #fff;
    --sf-ft-line: rgba(255, 255, 255, 0.16);
    background: #111827 !important;
    border-top: 0;
    color: var(--sf-ft-text) !important;
}

html[data-theme] .sf-footer[data-tone="brand"] {
    background: var(--theme-color-primary) !important;
}

html[data-theme] .sf-footer[data-tone="dark"] .sf-footer-heading,
html[data-theme] .sf-footer[data-tone="brand"] .sf-footer-heading {
    color: var(--sf-ft-strong);
}

html[data-theme] .sf-footer[data-tone="dark"] .sf-footer-link,
html[data-theme] .sf-footer[data-tone="brand"] .sf-footer-link,
html[data-theme] .sf-footer[data-tone="dark"] .sf-footer-list .bi,
html[data-theme] .sf-footer[data-tone="brand"] .sf-footer-list .bi {
    color: var(--sf-ft-text);
}

html[data-theme] .sf-footer[data-tone="dark"] .sf-footer-link:hover,
html[data-theme] .sf-footer[data-tone="brand"] .sf-footer-link:hover {
    color: var(--sf-ft-strong);
}

html[data-theme] .sf-footer[data-tone="dark"] .sf-footer-bottom,
html[data-theme] .sf-footer[data-tone="brand"] .sf-footer-bottom {
    border-top-color: var(--sf-ft-line);
}

html[data-theme] .sf-footer[data-tone="dark"] .sf-social-btn,
html[data-theme] .sf-footer[data-tone="brand"] .sf-social-btn {
    border-color: var(--sf-ft-line);
    background: rgba(255, 255, 255, 0.08);
    color: var(--sf-ft-strong) !important;
}

html[data-theme] .sf-footer[data-tone="dark"] .sf-social-btn:hover,
html[data-theme] .sf-footer[data-tone="brand"] .sf-social-btn:hover {
    background: #fff;
    border-color: #fff;
    color: #111827 !important;
}

/* A dark logo stays readable on a dark footer */
html[data-theme] .sf-footer[data-tone="dark"] img,
html[data-theme] .sf-footer[data-tone="brand"] img {
    padding: 6px 10px;
    border-radius: var(--theme-radius-sm);
    background: #fff;
}

/* ---------- Theme editor preview: edit shortcuts ---------- */

.tb-edit-target {
    position: relative;
}

.tb-edit-target.tb-edit-hover {
    outline: 2px dashed #2271b1;
    outline-offset: -2px;
}

.tb-edit-btn {
    position: absolute;
    top: 6px;
    inset-inline-start: 6px;
    z-index: 1040;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px 0 8px;
    border: 2px solid #fff;
    border-radius: 15px;
    background: #2271b1;
    color: #fff;
    font: 600 12px/1 system-ui, sans-serif;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms ease;
}

.tb-edit-target:hover > .tb-edit-btn,
.tb-edit-btn:focus-visible {
    opacity: 1;
}

.tb-edit-btn:focus-visible {
    outline: 2px solid #111;
}
