/* Device Animation and 3D Styles */
.device-float {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 120px;
    animation: float 6s ease-in-out infinite;
    z-index: 20;
    cursor: pointer;
    will-change: transform;
}

/* Hey Sociail Text Animation */
.hey-sociail-text {
    position: absolute;
    bottom: calc(100% + var(--assistant-text-gap, 5px));
    left: 50%;
    transform: translateX(-50%);
    font-size: calc(32px * var(--device-base-scale, 1));
    font-weight: 600;
    background: linear-gradient(135deg,
        var(--sociail-indigo),
        var(--sociail-purple),
        var(--sociail-indigo));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    z-index: 30;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.3));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: min(70vw, 560px);
    min-height: 2.6em;
    line-height: 1.2;
    transition: opacity 0.25s ease, filter 0.25s ease;
    will-change: opacity;
}

.hey-sociail-text.is-fading {
    opacity: 0;
}

.hey-sociail-text.is-hovering {
    filter: drop-shadow(0 6px 12px rgba(99, 102, 241, 0.4));
}

@keyframes float {
    0%, 100% { transform: translate(-50%, -50%) translateY(0) rotateX(0deg) rotateY(0deg); }
    25% { transform: translate(-50%, -50%) translateY(-20px) rotateX(5deg) rotateY(15deg); }
    75% { transform: translate(-50%, -50%) translateY(10px) rotateX(-5deg) rotateY(-15deg); }
}

.device-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    /* Combine viewport-driven base scale with hover scale */
    transform: scale(calc(var(--device-base-scale, 1) * var(--assistant-scale, 1)));
    transform-origin: center;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.device-shadow-layer {
    position: absolute;
    top: 12px;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #d4a017 0%, #b8901e 50%, #9c7a1a 100%);
    border-radius: 60px;
    z-index: 0;
}

.device-body {
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 64% 20%, rgba(255, 255, 255, 0.5), transparent 19%),
        linear-gradient(180deg, #ffe45f 0%, #f4d01f 48%, #e0bc1e 100%);
    border-radius: 60px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.74),
        inset 0 -10px 18px rgba(133, 101, 0, 0.22),
        0 50px 100px rgba(0, 0, 0, 0.3),
        0 30px 60px rgba(0, 0, 0, 0.2),
        0 20px 40px rgba(249, 217, 73, 0.38);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.device-body::before {
    content: "";
    position: absolute;
    inset: 10px 28px auto;
    height: 24px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0));
    filter: blur(1px);
    pointer-events: none;
}

.device-wrapper::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 10%;
    right: 10%;
    height: 40px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3) 0%, transparent 70%);
    filter: blur(20px);
    z-index: -1;
}

/* Device Elements */
.speaker-grille {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    width: 100px;
    height: 60px;
    background: repeating-linear-gradient(
        0deg,
        #d4a017 0px,
        #d4a017 2px,
        transparent 2px,
        transparent 4px
    );
    border-radius: 30px;
    opacity: 0.6;
}

.device-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--assistant-center-scale, 1));
    width: 70px;
    height: 70px;
    background: radial-gradient(circle at 30% 30%, #0066ff 0%, #0052cc 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 -3px 6px rgba(0, 0, 0, 0.3),
        inset 0 3px 6px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(0, 102, 255, 0.6);
    border: 3px solid #0052cc;
    animation: aiSpeaking 20s ease-in-out infinite;
    animation-delay: 0.5s;
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.device-center::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(0, 102, 255, 0.35);
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.device-indicators {
    position: absolute;
    top: 50%;
    right: 90px;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}

.indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
}

.indicator-dot.active {
    background: #00ff00;
    box-shadow: 0 0 6px #00ff00;
}

.device-mute {
    position: absolute;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    width: 40px;
    height: 20px;
    background: #d4a017;
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.device-mute::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 14px;
    height: 14px;
    background: #0066ff;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* AI Speech Animation */
@keyframes aiSpeaking {
    0%, 30%, 100% { opacity: 1; }
    40% { opacity: 0.3; }
    40.2% { opacity: 0.8; }
    40.4% { opacity: 0.4; }
    40.6% { opacity: 0.9; }
    40.8% { opacity: 0.5; }
    41% { opacity: 1; }
    41.2% { opacity: 0.6; }
    41.4% { opacity: 0.9; }
    41.6% { opacity: 0.7; }
    41.8% { opacity: 1; }
    42%, 42.5% { opacity: 1; }
    42.6% { opacity: 0.5; }
    42.7% { opacity: 0.8; }
    42.8% { opacity: 0.6; }
    42.9% { opacity: 0.9; }
    43% { opacity: 0.4; }
    43.1% { opacity: 0.7; }
    43.2% { opacity: 0.5; }
    43.3% { opacity: 0.8; }
    43.4% { opacity: 0.6; }
    43.5% { opacity: 1; }
    43.6%, 45% { opacity: 1; }
    45.1% { opacity: 0.4; }
    45.2% { opacity: 0.7; }
    45.3% { opacity: 0.5; }
    45.4% { opacity: 0.9; }
    45.5% { opacity: 1; }
    45.6% { opacity: 0.5; }
    45.7% { opacity: 0.8; }
    45.8% { opacity: 0.4; }
    45.9% { opacity: 0.7; }
    46% { opacity: 0.6; }
    46.1% { opacity: 0.9; }
    46.2% { opacity: 0.5; }
    46.3% { opacity: 0.8; }
    46.4% { opacity: 1; }
    46.5% { opacity: 0.6; }
    46.6% { opacity: 0.8; }
    46.7% { opacity: 0.4; }
    46.8% { opacity: 0.7; }
    46.9% { opacity: 0.5; }
    47% { opacity: 0.9; }
    47.1% { opacity: 0.6; }
    47.2% { opacity: 1; }
    47.3%, 70% { opacity: 1; }
    75% { opacity: 0.4; }
    75.2% { opacity: 0.9; }
    75.4% { opacity: 0.3; }
    75.6% { opacity: 0.8; }
    75.8% { opacity: 0.5; }
    76% { opacity: 1; }
    76.2% { opacity: 0.7; }
    76.4% { opacity: 0.9; }
    76.6%, 77% { opacity: 1; }
    77.1% { opacity: 0.6; }
    77.2% { opacity: 0.8; }
    77.3% { opacity: 0.4; }
    77.4% { opacity: 0.7; }
    77.5% { opacity: 0.5; }
    77.6% { opacity: 0.9; }
    77.7% { opacity: 0.6; }
    77.8% { opacity: 1; }
    77.9%, 79% { opacity: 1; }
    79.1% { opacity: 0.5; }
    79.2% { opacity: 0.8; }
    79.3% { opacity: 0.6; }
    79.4% { opacity: 1; }
    79.5% { opacity: 0.4; }
    79.6% { opacity: 0.7; }
    79.7% { opacity: 0.5; }
    79.8% { opacity: 0.9; }
    79.9% { opacity: 0.6; }
    80% { opacity: 0.8; }
    80.1% { opacity: 0.5; }
    80.2% { opacity: 0.7; }
    80.3% { opacity: 0.6; }
    80.4% { opacity: 1; }
}

/* Ecosystem Device Silhouettes */
.ecosystem-device {
    position: absolute;
    z-index: 0;
    opacity: 0.6;
}

.iphone-silhouette {
    left: -32px;
    top: 38%;
    transform: translateY(-50%) rotate(-8deg) scale(1);
    transform-origin: center;
    width: 140px;
    height: 280px;
    background: #c4c4c9;
    border-radius: 24px;
    box-shadow:
        inset 0 0 0 10px #d1d1d6,
        inset 0 0 0 12px #c4c4c9;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease;
}

.iphone-silhouette::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: #d1d1d6;
    border-radius: 2px;
}

.iphone-silhouette::after {
    content: '';
    position: absolute;
    top: 35px;
    left: 18px;
    right: 18px;
    bottom: 35px;
    background: var(--screen-color);
    border-radius: 4px;
    opacity: 1;
    animation: aiSpeaking 20s ease-in-out infinite;
    animation-delay: 0.5s;
}

.laptop-silhouette {
    right: -190px;
    top: 38%;
    transform: translateY(-50%) rotate(8deg) scale(1);
    transform-origin: center;
    width: 320px;
    height: 200px;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease;
}

.laptop-screen {
    width: 100%;
    height: 180px;
    background: #c4c4c9;
    border-radius: 10px;
    position: relative;
    box-shadow: inset 0 0 0 10px #d1d1d6;
}

.laptop-screen::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    bottom: 18px;
    background: var(--screen-color);
    border-radius: 4px;
    opacity: 1;
    animation: aiSpeaking 20s ease-in-out infinite;
    animation-delay: 0.5s;
}

.laptop-base {
    width: 120%;
    height: 10px;
    background: #c4c4c9;
    margin: -2px auto 0;
    border-radius: 0 0 6px 6px;
    position: relative;
    left: -10%;
}

.laptop-base::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: #d1d1d6;
    border-radius: 1px;
}

/* ============================================
   Device Hotspots and Tooltips
   ============================================ */

.device-hotspot {
    position: absolute;
    cursor: pointer;
    --device-scale: 1;
}

/* Hotspot positioning - matches device positions */
.device-hotspot.iphone-hotspot {
    left: -32px;
    top: 38%;
    transform: translateY(-50%);
    width: 140px;
    height: 280px;
    z-index: 50;
}

.device-hotspot.laptop-hotspot {
    right: -190px;
    top: 38%;
    transform: translateY(-50%);
    width: 320px;
    height: 200px;
    z-index: 50;
}

.device-hotspot.assistant-hotspot {
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 120px;
    z-index: 50;
    --assistant-scale: 1;
    --assistant-center-scale: 1;
    /*
     * Viewport-driven base scale for the central assistant device.
     * Stays at 1.0 through the "sweet spot" (<= 1440px) so the magical
     * proportions on small/medium screens are preserved exactly,
     * then steps up at wider breakpoints to fill the void between the
     * edge-anchored phone and laptop silhouettes. Stepped (not fluid)
     * because CSS calc cannot reliably mix lengths and numbers.
     * Breakpoint values are set in @media blocks below.
     */
    --device-base-scale: 1;
    /*
     * Gap between "Hey Sociail" label and the device top.
     * Compensates for the fact that transform: scale grows the wrapper
     * VISUALLY around its center, so the wrapper's visual top edge
     * extends ABOVE its layout box by (height / 2) * (scale - 1).
     * For a 120px device that's 60 * (scale - 1) px of visual overhang.
     * We add 80 * (scale - 1) so there's always a clear gap above the
     * visually-grown wrapper, plus 5px baseline.
     */
    --assistant-text-gap: calc(5px + (var(--device-base-scale, 1) * var(--assistant-scale, 1) - 1) * 80px);
}

/*
 * Viewport-driven base scale steps. Visual-diff at 1440px showed the
 * device floating with too much air around it even in the sweet spot,
 * so the ramp now starts at 1280px with subtle growth (1.05x) to fill
 * the void without disturbing the proportional balance, then ramps
 * gently up to 1.35x at 1920px+.
 */
@media (min-width: 1280px) {
    .device-hotspot.assistant-hotspot { --device-base-scale: 1.05; }
}
@media (min-width: 1400px) {
    .device-hotspot.assistant-hotspot { --device-base-scale: 1.10; }
}
@media (min-width: 1550px) {
    .device-hotspot.assistant-hotspot { --device-base-scale: 1.18; }
}
@media (min-width: 1700px) {
    .device-hotspot.assistant-hotspot { --device-base-scale: 1.25; }
}
@media (min-width: 1850px) {
    .device-hotspot.assistant-hotspot { --device-base-scale: 1.32; }
}
@media (min-width: 2000px) {
    .device-hotspot.assistant-hotspot { --device-base-scale: 1.35; }
}

.device-hotspot:hover {
    z-index: 9999;
}

/* Override device positioning when inside hotspot */
.device-hotspot .ecosystem-device {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    transform: none;
}

.device-hotspot .iphone-silhouette {
    transform: rotate(-8deg) scale(var(--device-scale));
}

.device-hotspot .laptop-silhouette {
    transform: rotate(8deg) scale(var(--device-scale));
}

/* Assistant device inside hotspot - fill container, keep animation */
.device-hotspot.assistant-hotspot .device-float {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: none;
    animation: floatInPlace 6s ease-in-out infinite;
}

@keyframes floatInPlace {
    0%, 100% { transform: translateY(0) rotateX(0deg) rotateY(0deg); }
    25% { transform: translateY(-20px) rotateX(5deg) rotateY(15deg); }
    75% { transform: translateY(10px) rotateX(-5deg) rotateY(-15deg); }
}

/* Tooltip styles */
.device-tooltip {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    width: 280px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    backdrop-filter: blur(10px);
    z-index: 10000;
}

.device-hotspot.assistant-hotspot .device-tooltip {
    width: min(70vw, 720px);
    max-width: 70vw;
    transform: translateX(-50%) translateY(10px);
    z-index: 15;
}

.device-hotspot:hover .device-tooltip {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Tooltip positions */
.device-tooltip.tooltip-right {
    left: calc(100% + 20px);
    top: 50%;
    transform: translateY(-50%) translateX(-10px);
}

.device-tooltip.tooltip-left {
    right: calc(100% + 20px);
    top: 50%;
    transform: translateY(-50%) translateX(10px);
}

.device-tooltip.tooltip-bottom {
    top: calc(100% + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
}

.device-tooltip.tooltip-top {
    bottom: calc(100% + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
}

/* Tooltip hover transforms */
.device-hotspot:hover .device-tooltip.tooltip-right {
    transform: translateY(-50%) translateX(0);
}

.device-hotspot:hover .device-tooltip.tooltip-left {
    transform: translateY(-50%) translateX(0);
}

.device-hotspot:hover .device-tooltip.tooltip-bottom {
    transform: translateX(-50%) translateY(0);
}

/* Tooltip content styles */
.device-tooltip h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-tooltip p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

.device-tooltip ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.device-tooltip li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-tooltip li::before {
    content: '✓';
    color: #34c759;
    font-weight: bold;
    font-size: 14px;
}

.tooltip-icon {
    font-size: 16px;
}

/* Glow effect on hover */
.device-hotspot:hover .iphone-silhouette,
.device-hotspot:hover .laptop-silhouette,
.device-hotspot:hover .device-body {
    filter: brightness(1.1);
    transition: filter 0.3s ease;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .device-hotspot.iphone-hotspot:hover {
        --device-scale: 1.06;
    }

    .device-hotspot.laptop-hotspot:hover {
        --device-scale: 1.05;
    }

    .device-hotspot.assistant-hotspot:hover {
        --assistant-scale: 1.18;
        --assistant-center-scale: 1.12;
    }

    .device-hotspot.assistant-hotspot:hover .device-center {
        box-shadow:
            inset 0 -3px 6px rgba(0, 0, 0, 0.3),
            inset 0 3px 6px rgba(255, 255, 255, 0.25),
            0 0 45px rgba(0, 102, 255, 0.9);
    }

    .device-hotspot.assistant-hotspot:hover .device-center::after {
        opacity: 1;
        animation: centerPulse 1.4s ease-out infinite;
    }
}

@keyframes centerPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .device-float,
    .device-center,
    .device-hotspot.assistant-hotspot .device-float,
    .device-preview * {
        animation: none !important;
        transition: none !important;
    }

    .device-center::after {
        animation: none !important;
        opacity: 0 !important;
    }
}
