/* ==========================================================================
   THEME SELECTOR — "WOW" REDESIGN
   Loaded after full.css (see layouts/partials/themeSelector.blade.php), so it
   only layers on top of the base .theme-* rules and never edits the bundle.

   Every bundle gets its own signature hover / focus effect:
     default  Lantern  - warm glow, drifting bokeh, pieces swing like lanterns
     floral   Blossom  - falling petals, pieces bloom and spin
     golden   Gilded   - light sheen sweeps across, sparkles twinkle
     wooden   Timber   - heavy "clack": pieces drop onto a chunky wood block
     ocean    Tide     - rolling waves, pieces bob on the water
     flame    Ember    - flickering fire, rising sparks, heat-shimmer pieces

   Shared across all: cursor-following spotlight (--mx/--my) and 3D tilt
   (--rx/--ry) written by public/js/theme-selector-fx.js.
   No new visible strings, so no i18n changes are needed.
   ========================================================================== */

/* ---------------------------------------------------------------- Tokens */
.theme-bundle {
    --tb-rgb: 230, 57, 70; /* accent as r,g,b (for rgba()) */
    --tb-lift: -5px;
    --mx: 50%;
    --my: 50%;
    --rx: 0deg;
    --ry: 0deg;
}
.theme-bundle[data-bundle="default"] {
    --tb-rgb: 255, 96, 64;
    --tb-accent: #ff6040;
}
.theme-bundle[data-bundle="floral"] {
    --tb-rgb: 240, 128, 170;
    --tb-accent: #f080aa;
}
.theme-bundle[data-bundle="golden"] {
    --tb-rgb: 255, 208, 64;
    --tb-accent: #ffd040;
}
.theme-bundle[data-bundle="wooden"] {
    --tb-rgb: 185, 120, 58;
    --tb-accent: #c98440;
    --tb-lift: 1px;
}
/* ocean + flame had no tokens before: they fell back to the generic accent */
.theme-bundle[data-bundle="ocean"] {
    --tb-rgb: 41, 182, 246;
    --tb-accent: #29b6f6;
    --tb-fallback: #0d4a6b;
}
.theme-bundle[data-bundle="flame"] {
    --tb-rgb: 255, 106, 26;
    --tb-accent: #ff6a1a;
    --tb-fallback: #4a1208;
}

/* ------------------------------------------------------- Panel: glass+glow */
.theme-selector-panel {
    border-radius: 16px;
    border: 1px solid transparent;
    background:
        linear-gradient(var(--ts-panel-bg), var(--ts-panel-bg)) padding-box,
        linear-gradient(
                135deg,
                rgba(var(--xq-accent-rgb), 0.9),
                rgba(var(--xq-accent-rgb), 0.08) 35%,
                rgba(var(--xq-accent-rgb), 0.08) 65%,
                rgba(var(--xq-accent-rgb), 0.9)
            )
            border-box;
    background-size:
        100% 100%,
        200% 200%;
    animation: none;
}
.theme-selector-panel.show {
    animation:
        floatUp 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        tsBorderFlow 6s linear 0.45s infinite;
}
@keyframes tsBorderFlow {
    0% {
        background-position:
            0 0,
            0% 50%;
    }
    50% {
        background-position:
            0 0,
            100% 50%;
    }
    100% {
        background-position:
            0 0,
            0% 50%;
    }
}

.theme-title {
    font-size: 15px;
    letter-spacing: 2px;
    justify-content: center;
    background: linear-gradient(
        90deg,
        var(--ts-title),
        #fff 45%,
        var(--ts-title) 90%
    );
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    animation: tsTitleShine 4.5s ease-in-out infinite;
}
.theme-title i {
    -webkit-text-fill-color: var(--ts-title);
    filter: drop-shadow(0 0 6px rgba(var(--xq-accent-rgb), 0.7));
}
@keyframes tsTitleShine {
    0%,
    100% {
        background-position: 100% 0;
    }
    50% {
        background-position: 0 0;
    }
}

/* Cards pop in one after another when the panel opens (fill-mode "backwards"
   so the hover transform still works once the entrance is finished). */
.theme-selector-panel.show .theme-bundle {
    animation: tbPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
    animation-delay: calc(var(--i, 0) * 60ms + 120ms);
}
@keyframes tbPop {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ----------------------------------------------------------- Card (shared) */
.theme-bundle {
    border-radius: 14px;
    border-width: 2px;
    overflow: visible;
    will-change: transform;
    transform-style: preserve-3d;
    background-image: radial-gradient(
        circle at var(--mx) var(--my),
        rgba(var(--tb-rgb), 0) 0,
        rgba(var(--tb-rgb), 0) 100%
    );
    transition:
        transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        border-color 0.3s ease,
        background-color 0.3s ease,
        box-shadow 0.35s ease;
}
.theme-bundle:hover,
.theme-bundle:focus-visible {
    transform: perspective(700px) rotateX(var(--ry)) rotateY(var(--rx))
        translateY(var(--tb-lift)) scale(1.03);
    border-color: var(--tb-accent);
    /* cursor spotlight */
    background-image: radial-gradient(
        circle at var(--mx) var(--my),
        rgba(var(--tb-rgb), 0.28) 0,
        rgba(var(--tb-rgb), 0) 70%
    );
    box-shadow:
        0 16px 30px rgba(0, 0, 0, 0.55),
        0 0 26px rgba(var(--tb-rgb), 0.45);
}
.theme-bundle.active {
    border-color: var(--tb-accent);
    box-shadow:
        inset 0 0 18px rgba(var(--tb-rgb), 0.35),
        0 0 22px rgba(var(--tb-rgb), 0.55);
    animation: tbActivePulse 2.4s ease-in-out infinite;
}
@keyframes tbActivePulse {
    0%,
    100% {
        box-shadow:
            inset 0 0 14px rgba(var(--tb-rgb), 0.3),
            0 0 14px rgba(var(--tb-rgb), 0.4);
    }
    50% {
        box-shadow:
            inset 0 0 22px rgba(var(--tb-rgb), 0.45),
            0 0 28px rgba(var(--tb-rgb), 0.7);
    }
}
/* The entrance animation and the pulse share the element: let the pulse win once open. */
.theme-selector-panel.show .theme-bundle.active {
    animation:
        tbPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards
            calc(var(--i, 0) * 60ms + 120ms),
        tbActivePulse 2.4s ease-in-out 0.8s infinite;
}
.theme-bundle:active {
    transform: perspective(700px) translateY(0) scale(0.97);
    transition-duration: 0.12s;
}

.theme-bundle-name {
    transition:
        letter-spacing 0.3s ease,
        text-shadow 0.3s ease,
        color 0.3s ease;
}
.theme-bundle:hover .theme-bundle-name,
.theme-bundle:focus-visible .theme-bundle-name {
    letter-spacing: 1.4px;
    color: var(--tb-accent);
    text-shadow: 0 0 12px rgba(var(--tb-rgb), 0.8);
}

/* ------------------------------------------------- Preview: effect layers */
.theme-bundle-preview {
    position: relative;
    isolation: isolate;
    border-radius: 10px;
    height: 92px;
    gap: 10px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 -18px 28px rgba(0, 0, 0, 0.25);
    transition:
        background-size 0.6s ease,
        filter 0.4s ease;
}
.theme-bundle-preview::before,
.theme-bundle-preview::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
}
.theme-bundle:hover .theme-bundle-preview::before,
.theme-bundle:hover .theme-bundle-preview::after,
.theme-bundle:focus-visible .theme-bundle-preview::before,
.theme-bundle:focus-visible .theme-bundle-preview::after {
    opacity: 1;
}
.theme-bundle:hover .theme-bundle-preview,
.theme-bundle:focus-visible .theme-bundle-preview {
    background-size: 118% auto; /* slow "push-in" on the board image */
}

.tb-piece {
    position: relative;
    z-index: 2;
    width: 42px;
    height: 42px;
    transition:
        transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        filter 0.35s ease;
}

/* ==========================================================================
   1. DEFAULT — LANTERN
   ========================================================================== */
.theme-bundle[data-bundle="default"] .theme-bundle-preview::before {
    background: radial-gradient(
        ellipse at 50% -10%,
        rgba(255, 150, 70, 0.75),
        rgba(255, 90, 40, 0.25) 45%,
        transparent 70%
    );
    animation: lanternGlow 1.8s ease-in-out infinite;
}
.theme-bundle[data-bundle="default"] .theme-bundle-preview::after {
    /* drifting warm bokeh */
    background:
        radial-gradient(circle, rgba(255, 210, 140, 0.9) 0 2px, transparent 3px)
            0 0 / 34px 34px,
        radial-gradient(
                circle,
                rgba(255, 170, 90, 0.7) 0 1.5px,
                transparent 2.5px
            )
            12px 18px / 26px 26px;
    animation: lanternDrift 5s linear infinite;
}
.theme-bundle[data-bundle="default"]:hover .tb-piece:first-child,
.theme-bundle[data-bundle="default"]:focus-visible .tb-piece:first-child {
    transform-origin: 50% -30%;
    animation: lanternSwingA 1.6s ease-in-out infinite;
}
.theme-bundle[data-bundle="default"]:hover .tb-piece:last-child,
.theme-bundle[data-bundle="default"]:focus-visible .tb-piece:last-child {
    transform-origin: 50% -30%;
    animation: lanternSwingB 1.6s ease-in-out infinite;
}
.theme-bundle[data-bundle="default"]:hover .tb-piece,
.theme-bundle[data-bundle="default"]:focus-visible .tb-piece {
    filter: drop-shadow(0 0 8px rgba(255, 120, 60, 0.9));
}
@keyframes lanternGlow {
    0%,
    100% {
        opacity: 0.65;
    }
    50% {
        opacity: 1;
    }
}
@keyframes lanternDrift {
    to {
        background-position:
            0 -68px,
            12px -34px;
    }
}
@keyframes lanternSwingA {
    0%,
    100% {
        transform: rotate(-9deg);
    }
    50% {
        transform: rotate(9deg);
    }
}
@keyframes lanternSwingB {
    0%,
    100% {
        transform: rotate(9deg);
    }
    50% {
        transform: rotate(-9deg);
    }
}

/* ==========================================================================
   2. FLORAL — BLOSSOM
   ========================================================================== */
.theme-bundle[data-bundle="floral"] .theme-bundle-preview::before {
    /* falling petals: soft pink ellipses on two offset lattices */
    background:
        radial-gradient(
                ellipse 4px 6px at 50% 50%,
                rgba(255, 183, 208, 0.95) 0 60%,
                transparent 70%
            )
            0 0 / 30px 30px,
        radial-gradient(
                ellipse 3px 5px at 50% 50%,
                rgba(255, 220, 232, 0.9) 0 60%,
                transparent 70%
            )
            14px 9px / 22px 26px,
        radial-gradient(
                ellipse 3px 4px at 50% 50%,
                rgba(240, 128, 170, 0.85) 0 60%,
                transparent 70%
            )
            6px 20px / 38px 34px;
    animation: petalFall 3.6s linear infinite;
}
.theme-bundle[data-bundle="floral"] .theme-bundle-preview::after {
    background: radial-gradient(
        circle at 50% 120%,
        rgba(255, 170, 200, 0.45),
        transparent 65%
    );
    mix-blend-mode: screen;
}
.theme-bundle[data-bundle="floral"]:hover .tb-piece:first-child,
.theme-bundle[data-bundle="floral"]:focus-visible .tb-piece:first-child {
    transform: scale(1.22) rotate(-14deg);
}
.theme-bundle[data-bundle="floral"]:hover .tb-piece:last-child,
.theme-bundle[data-bundle="floral"]:focus-visible .tb-piece:last-child {
    transform: scale(1.22) rotate(14deg);
}
.theme-bundle[data-bundle="floral"]:hover .tb-piece,
.theme-bundle[data-bundle="floral"]:focus-visible .tb-piece {
    filter: drop-shadow(0 0 7px rgba(255, 150, 190, 0.95)) saturate(1.2);
}
@keyframes petalFall {
    to {
        background-position:
            18px 30px,
            -8px 26px,
            22px 34px;
    }
}

/* ==========================================================================
   3. GOLDEN — GILDED
   ========================================================================== */
.theme-bundle[data-bundle="golden"] .theme-bundle-preview::before {
    /* diagonal sheen sweeping across the board */
    inset: -20% -60%;
    background: linear-gradient(
        115deg,
        transparent 38%,
        rgba(255, 250, 200, 0.85) 50%,
        transparent 62%
    );
    transform: translateX(-60%);
    animation: goldSheen 1.5s ease-in-out infinite;
}
.theme-bundle[data-bundle="golden"] .theme-bundle-preview::after {
    /* twinkling sparkles */
    background:
        radial-gradient(circle, #fff 0 1.5px, transparent 2.5px) 8px 10px / 38px
            30px,
        radial-gradient(circle, #ffe9a0 0 1px, transparent 2px) 24px 22px / 30px
            40px;
    animation: goldTwinkle 1s steps(2, end) infinite alternate;
}
.theme-bundle[data-bundle="golden"]:hover .tb-piece,
.theme-bundle[data-bundle="golden"]:focus-visible .tb-piece {
    transform: translateY(-6px) scale(1.14);
    filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.45))
        drop-shadow(0 0 9px rgba(255, 215, 80, 0.95));
}
.theme-bundle[data-bundle="golden"]:hover .tb-piece:last-child,
.theme-bundle[data-bundle="golden"]:focus-visible .tb-piece:last-child {
    transition-delay: 0.08s;
}
@keyframes goldSheen {
    0% {
        transform: translateX(-60%);
    }
    100% {
        transform: translateX(60%);
    }
}
@keyframes goldTwinkle {
    from {
        opacity: 0.25;
    }
    to {
        opacity: 1;
    }
}

/* ==========================================================================
   4. WOODEN — TIMBER  (tactile: the block is pressed, pieces "clack" down)
   ========================================================================== */
.theme-bundle[data-bundle="wooden"]:hover,
.theme-bundle[data-bundle="wooden"]:focus-visible {
    box-shadow:
        0 6px 0 #5a3517,
        /* chunky block edge */ 0 12px 18px rgba(0, 0, 0, 0.5);
    transform: perspective(700px) rotateX(var(--ry)) rotateY(var(--rx))
        translateY(-3px) rotate(-0.8deg);
}
.theme-bundle[data-bundle="wooden"] .theme-bundle-preview::before {
    /* wood grain */
    background: repeating-linear-gradient(
        92deg,
        rgba(70, 38, 14, 0) 0 5px,
        rgba(70, 38, 14, 0.16) 5px 6px,
        rgba(70, 38, 14, 0) 6px 11px
    );
    mix-blend-mode: multiply;
}
.theme-bundle[data-bundle="wooden"] .theme-bundle-preview::after {
    /* warm lamp-light wash that slowly slides */
    background: linear-gradient(
        100deg,
        transparent 25%,
        rgba(255, 214, 150, 0.4) 50%,
        transparent 75%
    );
    background-size: 220% 100%;
    animation: woodLight 2.6s ease-in-out infinite;
}
.theme-bundle[data-bundle="wooden"]:hover .tb-piece:first-child,
.theme-bundle[data-bundle="wooden"]:focus-visible .tb-piece:first-child {
    animation: woodClack 0.7s cubic-bezier(0.3, 0, 0.4, 1) both;
}
.theme-bundle[data-bundle="wooden"]:hover .tb-piece:last-child,
.theme-bundle[data-bundle="wooden"]:focus-visible .tb-piece:last-child {
    animation: woodClack 0.7s cubic-bezier(0.3, 0, 0.4, 1) 0.18s both;
}
.theme-bundle[data-bundle="wooden"]:hover .tb-piece,
.theme-bundle[data-bundle="wooden"]:focus-visible .tb-piece {
    filter: drop-shadow(0 4px 2px rgba(40, 20, 6, 0.75));
}
@keyframes woodClack {
    0% {
        transform: translateY(-26px) rotate(-8deg);
        opacity: 0;
    }
    55% {
        transform: translateY(2px) rotate(1deg);
        opacity: 1;
    }
    72% {
        transform: translateY(-4px);
    }
    100% {
        transform: translateY(0) rotate(0);
        opacity: 1;
    }
}
@keyframes woodLight {
    0%,
    100% {
        background-position: 100% 0;
    }
    50% {
        background-position: 0 0;
    }
}

/* ==========================================================================
   5. OCEAN — TIDE
   ========================================================================== */
.theme-bundle[data-bundle="ocean"] .theme-bundle-preview::before {
    /* rolling wave crests along the bottom */
    top: auto;
    height: 55%;
    background:
        radial-gradient(
                circle at 50% 100%,
                rgba(170, 235, 255, 0.85) 0 34%,
                transparent 36%
            )
            0 100% / 34px 20px repeat-x,
        radial-gradient(
                circle at 50% 100%,
                rgba(41, 182, 246, 0.75) 0 38%,
                transparent 40%
            )
            17px 100% / 34px 26px repeat-x,
        linear-gradient(to top, rgba(10, 90, 140, 0.8), transparent);
    animation: tideRoll 2.4s linear infinite;
}
.theme-bundle[data-bundle="ocean"] .theme-bundle-preview::after {
    /* light shafts */
    background: repeating-linear-gradient(
        105deg,
        transparent 0 14px,
        rgba(190, 240, 255, 0.16) 14px 22px
    );
    animation: tideShafts 4s ease-in-out infinite alternate;
}
.theme-bundle[data-bundle="ocean"]:hover .tb-piece:first-child,
.theme-bundle[data-bundle="ocean"]:focus-visible .tb-piece:first-child {
    animation: tideBob 1.8s ease-in-out infinite;
}
.theme-bundle[data-bundle="ocean"]:hover .tb-piece:last-child,
.theme-bundle[data-bundle="ocean"]:focus-visible .tb-piece:last-child {
    animation: tideBob 1.8s ease-in-out -0.9s infinite;
}
.theme-bundle[data-bundle="ocean"]:hover .tb-piece,
.theme-bundle[data-bundle="ocean"]:focus-visible .tb-piece {
    filter: drop-shadow(0 0 7px rgba(80, 200, 255, 0.9));
}
@keyframes tideRoll {
    to {
        background-position:
            34px 100%,
            51px 100%,
            0 0;
    }
}
@keyframes tideShafts {
    from {
        transform: translateX(-8px);
        opacity: 0.5;
    }
    to {
        transform: translateX(8px);
        opacity: 1;
    }
}
@keyframes tideBob {
    0%,
    100% {
        transform: translateY(4px) rotate(-5deg);
    }
    50% {
        transform: translateY(-8px) rotate(5deg);
    }
}

/* ==========================================================================
   6. FLAME — EMBER
   ========================================================================== */
.theme-bundle[data-bundle="flame"] .theme-bundle-preview::before {
    /* flickering fire rising from the bottom */
    transform-origin: 50% 100%;
    background: radial-gradient(
        ellipse 60% 70% at 50% 115%,
        #fff3a0 0,
        #ffb52e 22%,
        #ff5a14 48%,
        rgba(255, 30, 0, 0) 78%
    );
    animation: emberFlicker 0.55s ease-in-out infinite alternate;
}
.theme-bundle[data-bundle="flame"] .theme-bundle-preview::after {
    /* rising sparks */
    background:
        radial-gradient(circle, #ffd27a 0 1.5px, transparent 2.5px) 6px 0 / 28px
            36px,
        radial-gradient(circle, #ff8a30 0 1px, transparent 2px) 18px 14px / 22px
            30px;
    animation: emberRise 1.6s linear infinite;
}
.theme-bundle[data-bundle="flame"]:hover .tb-piece,
.theme-bundle[data-bundle="flame"]:focus-visible .tb-piece {
    animation: emberHeat 0.35s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 8px #ff7a1a)
        drop-shadow(0 0 14px rgba(255, 60, 0, 0.7));
}
.theme-bundle[data-bundle="flame"]:hover .tb-piece:last-child,
.theme-bundle[data-bundle="flame"]:focus-visible .tb-piece:last-child {
    animation-delay: -0.17s;
}
@keyframes emberFlicker {
    from {
        transform: scaleY(0.85) scaleX(1);
        opacity: 0.8;
    }
    to {
        transform: scaleY(1.12) scaleX(1.06);
        opacity: 1;
    }
}
@keyframes emberRise {
    to {
        background-position:
            6px -36px,
            18px -16px;
    }
}
@keyframes emberHeat {
    from {
        transform: translate(-0.6px, 0) scale(1.06) skewX(-1.5deg);
    }
    to {
        transform: translate(0.6px, -2px) scale(1.1) skewX(1.5deg);
    }
}

/* ------------------------------------------------ Toggle + Apply buttons */
.theme-toggle-btn {
    position: relative;
    overflow: hidden;
    border-radius: 999px;
}
.theme-toggle-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        115deg,
        transparent 35%,
        rgba(255, 255, 255, 0.35) 50%,
        transparent 65%
    );
    transform: translateX(-120%);
    pointer-events: none;
}
.theme-toggle-btn:hover::after,
.theme-toggle-btn:focus-visible::after {
    transform: translateX(120%);
    transition: transform 0.8s ease;
}
.theme-toggle-btn i {
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.theme-toggle-btn:hover i,
.theme-toggle-btn:focus-visible i {
    transform: rotate(360deg) scale(1.2);
}
.theme-toggle-btn[aria-expanded="true"] {
    box-shadow: var(--ts-btn-shadow-hover);
}

#apply-theme-btn {
    border-radius: 999px;
}
#apply-theme-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        115deg,
        transparent 35%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 65%
    );
    transform: translateX(-120%);
    pointer-events: none;
}
#apply-theme-btn:hover::after {
    transform: translateX(120%);
    transition: transform 0.7s ease;
}

/* ---------------------------------------------------------- Responsive */
@media (max-width: 768px) {
    .theme-bundle-preview {
        height: 78px;
    }
    .tb-piece {
        width: 34px;
        height: 34px;
    }
}

/* Touch devices have no hover: keep the effect running on the selected card
   instead, so the preview still feels alive. */
@media (hover: none) {
    .theme-bundle.active .theme-bundle-preview::before,
    .theme-bundle.active .theme-bundle-preview::after {
        opacity: 1;
    }
}

/* ------------------------------------------------ Reduced-motion safety */
@media (prefers-reduced-motion: reduce) {
    .theme-selector-panel.show,
    .theme-selector-panel.show .theme-bundle,
    .theme-selector-panel.show .theme-bundle.active,
    .theme-bundle.active,
    .theme-title,
    .theme-bundle .tb-piece,
    .theme-bundle-preview::before,
    .theme-bundle-preview::after {
        animation: none !important;
    }
    .theme-bundle,
    .theme-bundle:hover,
    .theme-bundle:focus-visible,
    .theme-bundle:active {
        transform: none;
    }
    .theme-toggle-btn:hover i,
    .theme-toggle-btn:focus-visible i {
        transform: none;
    }
}
