/**
 * Styling for the toggle button only. It reads the site's own tokens where they
 * exist and falls back to neutral values, so the module still looks right when
 * dropped into a theme that has not been tokenised yet.
 */

.dm-toggle {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    line-height: 0;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.dm-toggle__track {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    width: 58px;
    height: 30px;
    padding: 0 7px;
    border: 1px solid var(--c-border, rgba(127, 127, 127, 0.4));
    border-radius: 999px;
    background: var(--c-surface, transparent);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.dm-toggle__icon {
    position: relative;
    z-index: 1;
    width: 15px;
    height: 15px;
    transition: opacity 0.2s ease;
}

.dm-toggle__icon--sun {
    opacity: 1;
}

.dm-toggle__icon--moon {
    opacity: 0.45;
}

[data-theme="dark"] .dm-toggle__icon--sun {
    opacity: 0.45;
}

[data-theme="dark"] .dm-toggle__icon--moon {
    opacity: 1;
}

.dm-toggle__thumb {
    position: absolute;
    top: 50%;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--c-accent, currentColor);
    transform: translate3d(0, -50%, 0);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

[data-theme="dark"] .dm-toggle__thumb {
    transform: translate3d(26px, -50%, 0);
}

.dm-toggle:focus-visible .dm-toggle__track {
    outline: 2px solid var(--c-accent, currentColor);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .dm-toggle__track,
    .dm-toggle__thumb,
    .dm-toggle__icon {
        transition: none;
    }
}
