/* Primary colour:
--ANUWD-01-variables-primary-colour

Focus ring variables (for accessibility) off by default:
--ANUWD-01-variables-primary-focous-ring-thickness
--ANUWD-01-variables-primary-focous-ring-colour

Scale for components, default 1:
--ANUWD-01-variables-component-scale */

/* Root base variables */
:root {
    /* Set light theme variables */
    --ANUWD-01-ui-selection-controls-toggle-switch-track-background-color: #f5f5f5;
    --ANUWD-01-ui-selection-controls-toggle-switch-slider-pill-background-color: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ANUWD-01-ui-selection-controls-toggle-switch-track-background-color: #666666;
        --ANUWD-01-ui-selection-controls-toggle-switch-slider-pill-background-color: #e7e7e7;
    }
}

/* Scoped override */
[data-ANUWD-01-theme="light"] {
    --ANUWD-01-ui-selection-controls-toggle-switch-track-background-color: #f5f5f5;
    --ANUWD-01-ui-selection-controls-toggle-switch-slider-pill-background-color: #ffffff;
}

[data-ANUWD-01-theme="dark"] {
    --ANUWD-01-ui-selection-controls-toggle-switch-track-background-color: #666666;
    --ANUWD-01-ui-selection-controls-toggle-switch-slider-pill-background-color: #e7e7e7;
}

/* Toggle container */
.ANUWD-01-ui-selection-controls-toggle-switch {
    position: relative;
    display: inline-block;
    width: calc(65px * var(--ANUWD-01-variables-component-scale, 1));
    min-width: calc(65px * var(--ANUWD-01-variables-component-scale, 1));
    height: calc(27px * var(--ANUWD-01-variables-component-scale, 1));
    min-height: calc(27px * var(--ANUWD-01-variables-component-scale, 1));

    /* Prevent odd text/button highlighting and selecting */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

.ANUWD-01-ui-selection-controls-toggle-switch input[type="checkbox"] {
    overflow: visible;
}

/* Hide default checkbox */
.ANUWD-01-ui-selection-controls-toggle-switch input {
    position: absolute;
    /* hidden but keeps it focusable for keyboard users */
    opacity: 0;
    width: 0;
    height: 0;
}

/* Track (background) */
.ANUWD-01-ui-selection-controls-toggle-switch .ANUWD-01-ui-selection-controls-toggle-switch-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: pointer;
    border-radius: calc(50px * var(--ANUWD-01-variables-component-scale, 1));
    overflow: hidden;
    box-shadow: inset 0 calc(2px * var(--ANUWD-01-variables-component-scale, 1)) calc(8px * var(--ANUWD-01-variables-component-scale, 1)) rgba(0, 0, 0, 0.25);
    background-color: var(--ANUWD-01-ui-selection-controls-toggle-switch-track-background-color);
    transition: background-color 0.15s, filter 0.15s, transform 0.2s, box-shadow 0.2s, outline 0.2s;
}

/* Pill (circle) */
.ANUWD-01-ui-selection-controls-toggle-switch .ANUWD-01-ui-selection-controls-toggle-switch-slider::before {
    content: "";
    position: absolute;
    margin: calc(4px * var(--ANUWD-01-variables-component-scale, 1));
    width: calc(28px * var(--ANUWD-01-variables-component-scale, 1));
    height: calc(19px * var(--ANUWD-01-variables-component-scale, 1));
    border-radius: calc(50px * var(--ANUWD-01-variables-component-scale, 1));
    transition: transform 0.15s;
    box-shadow:
        0px calc(1px * var(--ANUWD-01-variables-component-scale, 1)) calc(10px * var(--ANUWD-01-variables-component-scale, 1)) rgba(0, 0, 0, 0.20),
        inset 0px calc(-1px * var(--ANUWD-01-variables-component-scale, 1)) calc(2.5px * var(--ANUWD-01-variables-component-scale, 1)) rgba(0, 0, 0, 0.3);
    /* bottom shadow */
    background-color: var(--ANUWD-01-ui-selection-controls-toggle-switch-slider-pill-background-color);
}

/* Focus state */
.ANUWD-01-ui-selection-controls-toggle-switch input:focus+.ANUWD-01-ui-selection-controls-toggle-switch-slider {
    outline: calc(var(--ANUWD-01-variables-primary-focous-ring-thickness, 0) * var(--ANUWD-01-variables-component-scale, 1)) solid var(--ANUWD-01-variables-primary-focous-ring-colour, #007bff);
    outline-offset: calc(4px * var(--ANUWD-01-variables-component-scale, 1));
}

/* Checked state */
.ANUWD-01-ui-selection-controls-toggle-switch input:checked+.ANUWD-01-ui-selection-controls-toggle-switch-slider {
    background-color: var(--ANUWD-01-variables-primary-colour, #007bff)
}

.ANUWD-01-ui-selection-controls-toggle-switch input:checked+.ANUWD-01-ui-selection-controls-toggle-switch-slider::before {
    transform: translateX(calc(29px * var(--ANUWD-01-variables-component-scale, 1)));
}

.ANUWD-01-ui-selection-controls-toggle-switch input:disabled+.ANUWD-01-ui-selection-controls-toggle-switch-slider {
    cursor: not-allowed;
    opacity: 0.5;
}

.ANUWD-01-ui-selection-controls-toggle-switch input:checked:disabled+.ANUWD-01-ui-selection-controls-toggle-switch-slider {
    background-color: var(--ANUWD-01-variables-primary-colour, #007bff)
}