/* ============================================================
   EmbedFlows — Theme Selector Component
   Premium animated navigation with traveling selection capsule.
   ============================================================ */

/* ---- Design Tokens ---- */
.vts {
    --vts-bg: #111318;
    --vts-border: rgba(255, 255, 255, 0.06);
    --vts-card-bg: rgba(255, 255, 255, 0.035);
    --vts-card-bg-hover: rgba(255, 255, 255, 0.06);
    --vts-card-bg-active: rgba(255, 255, 255, 0.08);
    --vts-text: #e8e6f0;
    --vts-text-muted: rgba(232, 230, 240, 0.5);
    --vts-radius: 18px;
    --vts-card-radius: 16px;
    --vts-arrow-size: 48px;
    --vts-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --vts-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --vts-duration: 380ms;
    --vts-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ---- Container ---- */
.vts {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0;
    background: var(--vts-bg);
    border: 1px solid var(--vts-border);
    border-radius: var(--vts-radius);
    padding: 18px 18px 14px;
    margin-bottom: var(--vx-gap, 24px);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.35),
        0 1px 3px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* Subtle gradient overlay */
.vts::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.012) 0%, transparent 50%, rgba(0,0,0,0.06) 100%);
    pointer-events: none;
    border-radius: var(--vts-radius);
    z-index: 0;
}

/* ---- Hidden Radios ---- */
.vts__radio {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0; padding: 0; margin: -1px;
}

/* ============================================================
   NAVIGATION ARROWS
   ============================================================ */
.vts__arrow {
    grid-row: 1;
    position: relative;
    z-index: 10;
    width: var(--vts-arrow-size);
    height: var(--vts-arrow-size);
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    flex-shrink: 0;
    box-shadow:
        0 2px 12px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.06);
    transition:
        transform 250ms var(--vts-ease),
        background 250ms var(--vts-ease),
        box-shadow 250ms var(--vts-ease),
        border-color 250ms var(--vts-ease),
        color 250ms var(--vts-ease);
    -webkit-tap-highlight-color: transparent;
    font-family: var(--vts-font);
}

.vts__arrow--prev { grid-column: 1; margin-right: 14px; }
.vts__arrow--next { grid-column: 3; margin-left: 14px; }

/* Arrow icon nudge on click */
.vts__arrow svg {
    transition: transform 200ms var(--vts-ease);
    flex-shrink: 0;
}

/* Hover */
.vts__arrow:hover {
    transform: scale(1.08);
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.16);
    color: #fff;
    box-shadow:
        0 4px 20px rgba(0,0,0,0.35),
        0 0 16px rgba(108,92,231,0.15),
        inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Active press */
.vts__arrow:active {
    transform: scale(0.94);
    transition-duration: 80ms;
}

.vts__arrow--prev:active svg { transform: translateX(-4px); }
.vts__arrow--next:active svg { transform: translateX(4px); }

/* Focus */
.vts__arrow:focus-visible {
    outline: 2px solid rgba(108,92,231,0.6);
    outline-offset: 2px;
}

/* Ripple pseudo-element */
.vts__arrow::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 300ms, transform 300ms;
    pointer-events: none;
}

.vts__arrow:active::after {
    opacity: 1;
    transform: scale(1.1);
    transition-duration: 80ms;
}

/* ============================================================
   CARDS TRACK
   ============================================================ */
.vts__track {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    z-index: 1;
}

/* ============================================================
   TRAVELING SELECTION CAPSULE
   ============================================================
   An absolutely-positioned frame that moves from card to card
   using JS-calculated FLIP transforms. The capsule lives in the
   track and is positioned over whichever card is active.        */

.vts__capsule {
    position: absolute;
    z-index: 0;
    border-radius: var(--vts-card-radius);
    pointer-events: none;
    /* JS sets top, left, width, height */
    transition:
        top    var(--vts-duration) var(--vts-spring),
        left   var(--vts-duration) var(--vts-spring),
        width  var(--vts-duration) var(--vts-ease),
        height var(--vts-duration) var(--vts-ease);
}

/* Outer glow */
.vts__capsule-glow {
    position: absolute;
    inset: -4px;
    border-radius: calc(var(--vts-card-radius) + 4px);
    box-shadow: 0 0 28px var(--vts-capsule-glow, rgba(108,92,231,0.35));
    opacity: 0.6;
    transition: box-shadow var(--vts-duration) var(--vts-ease), opacity var(--vts-duration) var(--vts-ease);
    pointer-events: none;
}

/* Animated border frame */
.vts__capsule-border {
    position: absolute;
    inset: 0;
    border-radius: var(--vts-card-radius);
    pointer-events: none;
    overflow: hidden;
}

.vts__capsule-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(
        from var(--vts-angle, 0deg),
        var(--vts-capsule-accent, #6c5ce7) 0%,
        transparent 25%,
        transparent 75%,
        var(--vts-capsule-accent, #6c5ce7) 100%
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: vts-rotate-border 3s linear infinite;
}

@keyframes vts-rotate-border {
    to { --vts-angle: 360deg; }
}

@property --vts-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Shimmer sweep */
.vts__capsule-shimmer {
    position: absolute;
    inset: 0;
    border-radius: var(--vts-card-radius);
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

.vts__capsule-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        105deg,
        transparent 30%,
        rgba(255,255,255,0.08) 50%,
        transparent 70%
    );
    transform: skewX(-15deg);
}

/* Triggered by JS adding a class */
.vts__capsule--shimmer .vts__capsule-shimmer {
    opacity: 1;
}

.vts__capsule--shimmer .vts__capsule-shimmer::before {
    animation: vts-shimmer-sweep 600ms var(--vts-ease) forwards;
}

@keyframes vts-shimmer-sweep {
    from { left: -100%; }
    to   { left: 150%; }
}

/* Subtle pulse when idle */
.vts__capsule-glow {
    animation: vts-capsule-pulse 2.5s ease-in-out infinite;
}

@keyframes vts-capsule-pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 0.75; }
}

/* ============================================================
   SLIDING BOTTOM INDICATOR
   ============================================================
   A 4px rounded bar that slides horizontally beneath cards,
   stretching slightly mid-travel for a spring feel.             */

.vts__slider {
    display: none;
    position: absolute;
    bottom: 0;
    height: 4px;
    border-radius: 4px 4px 0 0;
    background: var(--vts-slider-color, #6c5ce7);
    z-index: 5;
    pointer-events: none;
    box-shadow: 0 0 14px var(--vts-slider-glow, rgba(108,92,231,0.5));
    /* JS sets left and width */
    transition:
        left   var(--vts-duration) var(--vts-spring),
        width  var(--vts-duration) var(--vts-spring),
        background var(--vts-duration) var(--vts-ease),
        box-shadow var(--vts-duration) var(--vts-ease);
}

/* Stretch during movement (toggled by JS) */
.vts__slider--stretching {
    /* Temporarily widen by ~20% for that elastic feel */
    transition:
        left   var(--vts-duration) var(--vts-spring),
        width  180ms var(--vts-ease),
        background var(--vts-duration) var(--vts-ease),
        box-shadow var(--vts-duration) var(--vts-ease);
}

/* ============================================================
   FLYING TRANSITION ARROW / COMET
   ============================================================
   A glowing directional beam with an arrowhead that flies across
   the gap between cards during theme navigation (see reference image). */

.vts__flight {
    display: none;
    position: absolute;
    z-index: 15;
    height: 28px;
    align-items: center;
    pointer-events: none;
    opacity: 0;
}

.vts__flight--next {
    flex-direction: row;
}

.vts__flight--next .vts__flight-beam {
    background: linear-gradient(90deg, transparent 0%, var(--vts-flight-color, #6c5ce7) 100%);
}

.vts__flight--prev {
    flex-direction: row-reverse;
}

.vts__flight--prev .vts__flight-beam {
    background: linear-gradient(270deg, transparent 0%, var(--vts-flight-color, #6c5ce7) 100%);
}

.vts__flight--prev .vts__flight-head {
    transform: rotate(180deg);
}

.vts__flight-beam {
    flex: 1;
    height: 7px;
    border-radius: 7px;
    box-shadow: 
        0 0 20px var(--vts-flight-glow, rgba(108,92,231,0.8)),
        0 0 8px var(--vts-flight-color, #6c5ce7);
}

.vts__flight-head {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--vts-flight-color, #6c5ce7);
    filter: 
        drop-shadow(0 0 14px var(--vts-flight-glow, rgba(108,92,231,0.9)))
        drop-shadow(0 0 5px var(--vts-flight-color, #6c5ce7));
    flex-shrink: 0;
}

/* Triggered by JS when navigating right — medium slow-motion (650ms) */
.vts__flight--shooting-next {
    animation: vts-flight-anim-next 650ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes vts-flight-anim-next {
    0%   { opacity: 0; clip-path: inset(0 100% 0 0); }
    20%  { opacity: 1; clip-path: inset(0 0 0 0); }
    75%  { opacity: 1; clip-path: inset(0 0 0 0); }
    100% { opacity: 0; clip-path: inset(0 0 0 100%); }
}

/* Triggered by JS when navigating left — medium slow-motion (650ms) */
.vts__flight--shooting-prev {
    animation: vts-flight-anim-prev 650ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes vts-flight-anim-prev {
    0%   { opacity: 0; clip-path: inset(0 0 0 100%); }
    20%  { opacity: 1; clip-path: inset(0 0 0 0); }
    75%  { opacity: 1; clip-path: inset(0 0 0 0); }
    100% { opacity: 0; clip-path: inset(0 100% 0 0); }
}

/* ============================================================
   THEME CARD
   ============================================================ */
.vts__card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px 22px;
    background: var(--vts-card-bg);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--vts-card-radius);
    cursor: pointer;
    z-index: 2;
    outline: none;
    font-family: var(--vts-font);
    color: var(--vts-text);
    -webkit-tap-highlight-color: transparent;

    transform: translateY(0) scale(1);
    will-change: transform, box-shadow, opacity;

    transition:
        transform var(--vts-duration) var(--vts-ease),
        box-shadow var(--vts-duration) var(--vts-ease),
        background var(--vts-duration) var(--vts-ease),
        border-color var(--vts-duration) var(--vts-ease),
        opacity var(--vts-duration) var(--vts-ease);

    /* Entrance stagger */
    animation: vts-entrance 500ms var(--vts-delay, 0ms) var(--vts-ease) both;
}

@keyframes vts-entrance {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Icon Preview ---- */
.vts__icon {
    width: 54px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.08);
    transition: box-shadow var(--vts-duration) var(--vts-ease), transform var(--vts-duration) var(--vts-ease);
}

.vts__icon-inner {
    position: absolute;
    inset: 0;
    background: var(--vts-gradient);
    border-radius: inherit;
}

/* Play triangle */
.vts__icon::after {
    content: '';
    position: relative;
    z-index: 1;
    width: 0; height: 0;
    border-style: solid;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent rgba(255,255,255,0.85);
    margin-left: 2px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* ---- Typography ---- */
.vts__name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--vts-text);
    line-height: 1.2;
    transition: color var(--vts-duration) var(--vts-ease);
}

.vts__desc {
    font-size: 11px;
    font-weight: 400;
    color: var(--vts-text-muted);
    line-height: 1.3;
    transition: color var(--vts-duration) var(--vts-ease);
}

/* ============================================================
   HOVER STATE (non-active cards only)
   ============================================================ */
.vts__card:not(.vts__card--active):hover {
    transform: translateY(-3px) scale(1.02);
    background: var(--vts-card-bg-hover);
    border-color: rgba(255,255,255,0.1);
    box-shadow:
        0 8px 28px rgba(0,0,0,0.25),
        0 0 16px color-mix(in srgb, var(--vts-glow) 20%, transparent);
}

.vts__card:not(.vts__card--active):hover .vts__icon {
    box-shadow:
        0 4px 14px rgba(0,0,0,0.3),
        0 0 14px color-mix(in srgb, var(--vts-glow) 25%, transparent);
    transform: scale(1.04);
}

.vts__card:not(.vts__card--active):hover .vts__name {
    color: #fff;
}

/* ============================================================
   FOCUS STATE
   ============================================================ */
.vts__card:focus-visible {
    outline: 2px solid var(--vts-accent);
    outline-offset: 2px;
}

/* ============================================================
   ACTIVE CARD
   ============================================================
   The capsule provides the glowing border frame, so the card
   itself just lifts and brightens — no per-card border anim.   */

.vts__card--active {
    transform: translateY(-4px) scale(1);
    background: var(--vts-card-bg-active);
    border-color: transparent;
    box-shadow:
        0 8px 32px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.06);
}

.vts__card--active .vts__name {
    color: #fff;
}

.vts__card--active .vts__desc {
    color: rgba(232,230,240,0.65);
}

.vts__card--active .vts__icon {
    box-shadow:
        0 4px 16px rgba(0,0,0,0.35),
        0 0 20px color-mix(in srgb, var(--vts-glow) 35%, transparent);
}

/* Active + hover */
.vts__card--active:hover {
    transform: translateY(-5px) scale(1.02);
}

/* ---- Deactivating card (added by JS briefly) ---- */
.vts__card--leaving {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition-duration: 250ms;
}

/* ---- Activating card (added by JS briefly) ---- */
.vts__card--entering {
    animation: vts-card-enter var(--vts-duration) var(--vts-spring) forwards;
}

@keyframes vts-card-enter {
    0%   { transform: translateY(0) scale(0.98); }
    60%  { transform: translateY(-5px) scale(1.01); }
    100% { transform: translateY(-4px) scale(1); }
}

/* ============================================================
   PAGINATION DOTS
   ============================================================ */
.vts__dots {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding-top: 14px;
    z-index: 1;
}

.vts__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    cursor: pointer;
    transition:
        background var(--vts-duration) var(--vts-ease),
        transform var(--vts-duration) var(--vts-ease),
        box-shadow var(--vts-duration) var(--vts-ease);
}

.vts__dot:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.25);
}

.vts__dot--active {
    background: var(--vts-dot-color, #6c5ce7);
    transform: scale(1.3);
    box-shadow: 0 0 8px var(--vts-dot-glow, rgba(108,92,231,0.5));
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet: arrows inside, 3-col track would be tight, keep 4 */
@media (max-width: 900px) {
    .vts {
        padding: 14px 10px 12px;
        border-radius: 14px;
    }

    .vts__arrow {
        --vts-arrow-size: 40px;
    }

    .vts__arrow--prev { margin-right: 8px; }
    .vts__arrow--next { margin-left: 8px; }

    .vts__track { gap: 10px; }
}

/* Mobile: smaller arrows, 2-col track */
@media (max-width: 600px) {
    .vts {
        padding: 12px 8px 10px;
        border-radius: 12px;
    }

    .vts__arrow {
        --vts-arrow-size: 36px;
    }

    .vts__arrow--prev { margin-right: 6px; }
    .vts__arrow--next { margin-left: 6px; }

    .vts__track {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .vts__card {
        padding: 14px 8px 16px;
        gap: 8px;
        border-radius: 12px;
    }

    .vts__icon {
        width: 44px;
        height: 23px;
        border-radius: 6px;
    }

    .vts__name { font-size: 12px; }
    .vts__desc { font-size: 10px; }

    .vts__dots { gap: 6px; padding-top: 10px; }
    .vts__dot  { width: 6px; height: 6px; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .vts__card,
    .vts__capsule,
    .vts__slider,
    .vts__arrow {
        transition-duration: 0ms !important;
        animation: none !important;
    }

    .vts__capsule-border::before {
        animation: none;
    }
}
