/* ── Pure CSS Light Switch (адаптация codepen.io/scrimothy/DLOjwe) ──
   Оригинал: Tim Scribble. Переключает светлую/тёмную тему. */

.theme-switch {
    position: absolute;
    top: 175px;
    right: 20px;
    z-index: 999;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    display: block;
    /* 200×300 art, масштаб 0.45 → 90×135 */
    width: 90px;
    height: 135px;
}

/* Контейнер исходного размера (200×300), уменьшается трансформом */
.theme-switch__scale {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 300px;
    transform: scale(0.45);
    transform-origin: top left;
    perspective: 240px;
}

/* Общие свойства частей */
.ts-base,
.ts-side,
.ts-front,
.ts-plate,
.ts-screw {
    outline: none;
    position: absolute;
    backface-visibility: visible;
    transition: margin 120ms ease, transform 120ms ease,
                box-shadow 120ms ease, background 120ms ease;
}

.ts-plate { z-index: 1; }
.ts-base  { z-index: 2; }
.ts-screw { z-index: 3; }
.ts-side  { z-index: 5; }
.ts-onoff { z-index: 6; }

/* ── Пластина ──────────────────────────────────────────── */
.ts-plate {
    background: #e6e5e3;
    background: linear-gradient(135deg, #e0dfde 0%, #ededed 49%, #c6c6c6 100%);
    box-shadow:
        2px 2px 6px 2px rgba(0,0,0,.1) inset,
        -3px -3px 8px rgba(0,0,0,.3) inset,
        3px 3px 20px 3px #fff inset,
        3px 3px 6px rgba(0,0,0,.2),
        -2px -1px 4px rgba(0,0,0,.1);
    height: 300px;
    left: 50%;
    margin: -150px 0 0 -100px;
    top: 50%;
    width: 200px;
    border-radius: 4px;
}

/* ── Шурупы ────────────────────────────────────────────── */
.ts-screw {
    width: 14px;
    height: 14px;
    box-shadow: 1px 1px 3px #fff inset, -1px -1px 3px rgba(0,0,0,.3) inset;
    border-radius: 50%;
    left: 50%;
    top: 75px;
    margin: 0 0 0 -7px;
    text-align: center;
    color: rgba(0,0,0,.1);
    font-weight: bold;
    font-size: 18px;
    line-height: 10px;
    transform: rotate(-24deg);
}

.ts-screw.bottom {
    top: auto;
    bottom: 75px;
}

/* ── Корпус-основание клавиши ──────────────────────────── */
.ts-base {
    background: #e5e3e0;
    border-top: 0;
    box-shadow: 1px 1px 2px 2px rgba(0,0,0,.4), -1px -6px 4px rgba(0,0,0,.2) inset;
    height: 68px;
    left: 50%;
    margin: -30px 0 0 -15px;
    top: 50%;
    width: 30px;
}

/* ── Клавиша (это сам чекбокс) ─────────────────────────── */
.ts-side {
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to bottom,
        rgba(230,229,227,1) 0%,
        rgba(134,125,116,1) 20%,
        rgba(180,173,168,1) 90%,
        #e5e3e0 100%);
    border-radius: 3px;
    border: 0;
    cursor: pointer;
    display: block;
    height: 38px;
    left: 50%;
    margin: -38px -15px;
    top: 50%;
    width: 30px;
}

.ts-side:after {
    content: '';
    display: block;
    position: absolute;
    width: 15px;
    height: 100%;
    box-shadow: 8px -2px 4px rgba(0,0,0,.3);
    right: 2px;
    transform: skew(-15deg, 10deg);
    z-index: -1;
}

/* ── ON/OFF индикатор ──────────────────────────────────── */
.ts-onoff {
    background: transparent;
    color: #b7b0aa;
    font: normal 11px 'Arial Narrow', Arial, sans-serif;
    text-align: center;
    left: 50%;
    margin: 4px -15px;
    top: 50%;
    position: absolute;
    width: 30px;
}

.ts-onoff .off { display: none; }

/* ── Передняя грань клавиши ────────────────────────────── */
.ts-front {
    background: #eaeae8;
    border-radius: 3px;
    box-shadow: 1px 1px 5px #fff inset, -1px -1px 5px rgba(0,0,0,.3) inset;
    cursor: pointer;
    display: block;
    height: 30px;
    left: 50%;
    margin: -63px -15px;
    top: 50%;
    transform: rotateX(30deg);
    width: 32px;
    z-index: 25;
}

/* ── СОСТОЯНИЕ ВКЛ (тёмная тема) — неоновое свечение ────── */
.ts-side:checked {
    background: linear-gradient(to bottom, #f7dc2c 0%, #e8811b 100%);
    box-shadow: 0 0 6px 3px #fb492b inset, 0 0 15px 1px #fb492b;
    margin: 0 -15px;
    top: 50%;
    width: 30px;
}

.ts-side:checked ~ .ts-onoff {
    background: linear-gradient(to bottom, #f7dc2c 0%, #e8811b 100%);
    box-shadow: 0 0 5px 1px #fb492b inset, 0 0 10px #fb492b;
    color: #fa522d;
    display: block;
    font-size: 10px;
    left: 50%;
    margin: -32px -15px;
    top: 50%;
    border-radius: 2px;
    padding: 7px 0 9px;
    width: 30px;
}

.ts-side:checked ~ .ts-onoff .on { display: none; }
.ts-side:checked ~ .ts-onoff .off { display: block; }

.ts-side:checked:after {
    transform: skew(10deg, -15deg);
    box-shadow: 6px 10px 4px rgba(0,0,0,.3), 4px 10px 15px 2px rgba(0,0,0,.3);
    width: 30px;
}

.ts-side:checked ~ .ts-front {
    background: linear-gradient(to bottom, #f7dc2c 0%, #e8811b 100%);
    box-shadow: 0 0 8px 5px #fb492b inset, 0 0 15px 1px #fb492b;
    margin: 30px -15px;
    top: 50%;
    transform: rotateX(-30deg);
    width: 30px;
}

.ts-side:checked ~ .ts-plate {
    background: linear-gradient(to bottom, #afafaf 0%, #b2b2b2 49%, #898989 100%);
    box-shadow:
        2px 2px 6px 2px rgba(0,0,0,.1) inset,
        -3px -3px 8px rgba(0,0,0,.3) inset,
        3px 3px 20px 3px rgba(255,255,255,.5) inset,
        3px 3px 6px rgba(0,0,0,.2),
        -2px -1px 4px rgba(0,0,0,.1);
}

/* ── Responsive ────────────────────────────────────────── */

/* Nest Hub / Nest Hub Max (769–1300px) */
@media (min-width: 769px) and (max-width: 1300px) {
    .theme-switch {
        position: fixed;
        top: auto;
        bottom: 22px;
        right: 18px;
    }
}

/* Планшеты */
@media (max-width: 768px) {
    .theme-switch {
        position: fixed;
        top: auto;
        bottom: 22px;
        right: 14px;
        width: 80px;
        height: 120px;
    }
    .theme-switch__scale { transform: scale(0.4); }
}

/* Телефоны */
@media (max-width: 480px) {
    .theme-switch {
        position: fixed;
        top: auto;
        bottom: 18px;
        right: 10px;
        width: 68px;
        height: 102px;
    }
    .theme-switch__scale { transform: scale(0.34); }
}

/* ── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ts-base, .ts-side, .ts-front, .ts-plate, .ts-screw {
        transition: none !important;
    }
}

/* Без анимации при первой отрисовке / смене страницы (checked синхронизируется в head) */
.theme-switch--hydrating .ts-base,
.theme-switch--hydrating .ts-side,
.theme-switch--hydrating .ts-front,
.theme-switch--hydrating .ts-plate,
.theme-switch--hydrating .ts-screw,
.theme-switch--hydrating .ts-onoff {
    transition: none !important;
}

.theme-switch.fade-in {
    animation: v08FadeIn 0.4s ease both;
}
