/*
 * Storefront theme demo widget: a round palette button bottom-left (the
 * floating cart, back-to-top and chat sit bottom-right) and a small panel.
 * Tokens only, so it follows whichever preset it previews.
 */
.stw {
    position: fixed;
    left: 20px;
    bottom: 24px;
    z-index: 1039;
    font-family: inherit;
}

.stw-fab {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--theme-border-strong);
    background: var(--theme-surface-raised);
    color: var(--theme-primary);
    box-shadow: var(--theme-shadow-md);
    font-size: 1.15rem;
    cursor: grab;
    touch-action: none;
    transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.stw-fab:active { cursor: grabbing; }

.stw-fab:hover {
    background: var(--theme-hover);
    transform: translateY(-1px);
    box-shadow: var(--theme-shadow-lg);
}

.stw.is-open .stw-fab {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: var(--theme-on-primary);
}

.stw-fab:focus-visible,
.stw-panel button:focus-visible,
.stw-panel:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--theme-focus);
}

.stw-panel {
    position: absolute;
    left: 0;
    bottom: 60px;
    width: min(320px, calc(100vw - 32px));
    max-height: min(560px, calc(100vh - 120px));
    overflow-y: auto;
    padding: 16px;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-3xl);
    background: var(--theme-surface-raised);
    color: var(--theme-text);
    box-shadow: var(--theme-shadow-lg);
}

.stw-panel[hidden] {
    display: none;
}

.stw-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stw-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--theme-text-strong);
}

.stw-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
}

.stw-close:hover {
    background: var(--theme-hover);
    color: var(--theme-text-strong);
}

.stw-intro {
    margin: 4px 0 12px;
    font-size: .8125rem;
    line-height: 1.45;
    color: var(--theme-text-muted);
}

.stw-swatches {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.stw-swatch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-xl);
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: start;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.stw-swatch:first-child {
    grid-column: 1 / -1;
}

.stw-swatch:hover {
    border-color: var(--theme-border-strong);
    background: var(--theme-hover);
}

.stw-swatch[aria-pressed="true"] {
    border-color: var(--theme-primary);
    box-shadow: inset 0 0 0 1px var(--theme-primary);
}

.stw-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stw-name small {
    font-size: .6875rem;
    font-weight: 500;
    color: var(--theme-text-muted);
}

.stw-dots {
    display: inline-flex;
    flex: 0 0 auto;
}

.stw-dots span {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--theme-surface);
    background: var(--stw-a);
}

.stw-dots span + span {
    margin-inline-start: -6px;
}

.stw-dots span:nth-child(2) { background: var(--stw-b); }
.stw-dots span:nth-child(3) { background: var(--stw-c); }

.stw-check {
    margin-inline-start: auto;
    font-size: .75rem;
    color: var(--theme-primary);
    visibility: hidden;
}

.stw-swatch[aria-pressed="true"] .stw-check {
    visibility: visible;
}

.stw-mode {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-xl);
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}

.stw-mode-label i {
    margin-inline-end: 6px;
    color: var(--theme-text-muted);
}

.stw-switch {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-border-strong);
    transition: background-color .15s ease;
}

.stw-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--theme-surface-raised);
    box-shadow: var(--theme-shadow-sm);
    transition: transform .15s ease;
}

.stw-mode[aria-checked="true"] .stw-switch {
    background: var(--theme-primary);
}

.stw-mode[aria-checked="true"] .stw-switch::after {
    transform: translateX(16px);
}

[dir="rtl"] .stw-mode[aria-checked="true"] .stw-switch::after {
    transform: translateX(-16px);
}

[dir="rtl"] .stw-switch::after {
    left: auto;
    right: 2px;
}

.stw-actions {
    margin-top: 12px;
}

.stw-reset {
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: var(--theme-primary);
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}

.stw-reset:hover {
    color: var(--theme-primary-hover);
    text-decoration: underline;
}

.stw-apply {
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--theme-border);
}

.stw-apply-btn {
    width: 100%;
    min-height: 40px;
    border: 0;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-accent-strong);
    color: var(--theme-on-accent);
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
}

.stw-apply-btn:hover:not(:disabled) {
    background: var(--theme-accent-strong-hover);
}

.stw-apply-btn:disabled {
    background: var(--theme-neutral-bg);
    color: var(--theme-text-muted);
    cursor: not-allowed;
}

.stw-apply-hint {
    margin: 6px 0 0;
    font-size: .75rem;
    color: var(--theme-text-muted);
}

.stw-live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Phones: sit above the bottom navigation bar. */
@media (max-width: 767px) {
    .stw {
        left: 12px;
        bottom: calc(76px + env(safe-area-inset-bottom));
    }

    .stw-fab {
        width: 44px;
        height: 44px;
    }
}

@media print {
    .stw {
        display: none !important;
    }
}
