/* ==========================================================================
   Sassy Square 3D Work Carousel (Inspired by REA Cylinder Showcase)
   ========================================================================== */

.sassy-work-page {
    --work-header-height: 84px;
    --work-dock-space: 0px;
    padding-top: var(--work-header-height);
}

.sassy-3d-stage-wrapper {
    position: relative;
    width: 100%;
    height: calc(100vh - var(--work-header-height) - var(--work-dock-space));
    height: calc(100dvh - var(--work-header-height) - var(--work-dock-space));
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    background: radial-gradient(circle at 50% 45%, #0f0a1c 0%, #06040a 65%, #020104 100%);
    overflow: hidden;
    user-select: none;
    touch-action: pan-y;
}

.sassy-3d-scene {
    position: relative;
    margin-top: clamp(36px, 6dvh, 72px);
    min-height: 0;
    overflow: hidden;
}

#sassy-3d-work-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    z-index: 1;
}

#sassy-3d-work-canvas:active {
    cursor: grabbing;
}

/* Ambient vignette overlay */
.sassy-3d-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(4, 2, 8, 0.7) 80%, rgba(2, 1, 4, 0.98) 100%);
}

/* Top HUD - Placed safely below the fixed header (header height ~95px) */
.sassy-3d-top-hud {
    position: absolute;
    top: 6.8rem;
    left: 0;
    right: 0;
    z-index: 5;
    padding: 0 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

.sassy-3d-heading {
    pointer-events: auto;
}

.sassy-3d-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #a879ff;
    margin-bottom: 0.35rem;
}

.sassy-3d-kicker-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a879ff;
    box-shadow: 0 0 10px #9d60ff, 0 0 20px #8b3eff;
    animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.2); }
}

.sassy-3d-title {
    font-size: clamp(1.6rem, 2.8vw, 2.3rem);
    font-weight: 800;
    color: #ffffff;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
}

.sassy-3d-title span {
    background: linear-gradient(135deg, #ffffff 40%, #c49eff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Filter pills */
.sassy-3d-filters {
    display: flex;
    gap: 0.45rem;
    background: rgba(14, 9, 24, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(168, 121, 255, 0.35);
    border-radius: 999px;
    padding: 0.35rem 0.45rem;
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(124, 58, 237, 0.2);
    position: relative;
    z-index: 11;
}

.sassy-3d-filter-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sassy-3d-filter-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.sassy-3d-filter-btn.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, #7c3aed, #9333ea);
    box-shadow: 0 0 16px rgba(147, 51, 234, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

/* Navigation side arrows */
.sassy-3d-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(18, 12, 32, 0.75);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(168, 121, 255, 0.3);
    color: #ffffff;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.sassy-3d-nav-arrow:hover {
    background: rgba(147, 51, 234, 0.85);
    border-color: rgba(255, 255, 255, 0.65);
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 0 25px rgba(147, 51, 234, 0.75);
}

.sassy-3d-nav-arrow.is-prev {
    left: 2rem;
}

.sassy-3d-nav-arrow.is-next {
    right: 2rem;
}

/* Bottom HUD (Active Card Info) */
.sassy-3d-bottom-hud {
    position: relative;
    transform: translateY(clamp(-210px, -23dvh, -110px));
    justify-self: center;
    margin: 0 0 clamp(12px, 2dvh, 28px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.5rem, 1.2dvh, 0.9rem);
    pointer-events: none;
    width: 92%;
    max-width: 640px;
}

.sassy-3d-info-card {
    pointer-events: auto;
    width: 100%;
    background: rgba(16, 10, 28, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(168, 121, 255, 0.35);
    border-radius: 20px;
    padding: 1.1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 30px rgba(124, 58, 237, 0.25);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.sassy-3d-info-card:hover {
    border-color: rgba(168, 121, 255, 0.6);
    transform: translateY(-2px);
}

.sassy-3d-info-details {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.sassy-3d-info-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sassy-3d-info-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #e0ccff;
    background: rgba(124, 58, 237, 0.35);
    border: 1px solid rgba(168, 121, 255, 0.4);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
}

.sassy-3d-info-counter {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    font-variant-numeric: tabular-nums;
}

.sassy-3d-info-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sassy-3d-info-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.35rem;
    background: linear-gradient(135deg, #8b3eff 0%, #6d28d9 100%);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.45);
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 12;
}

.sassy-3d-info-action:hover {
    background: linear-gradient(135deg, #a879ff 0%, #7c3aed 100%);
    color: #ffffff;
    transform: scale(1.04);
    box-shadow: 0 0 25px rgba(147, 51, 234, 0.65);
}

.sassy-glitch-transition {
    position: fixed;
    inset: 0;
    z-index: 10060;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    background: #080410;
}

html.sassy-glitching .sassy-glitch-transition {
    opacity: 1;
    animation: sassy-glitch-screen 0.46s steps(1, end) both;
}

.sassy-glitch-transition::before,
.sassy-glitch-transition::after {
    content: "";
    position: absolute;
    inset: -12%;
    background:
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.12) 3px 4px),
        linear-gradient(90deg, rgba(164, 84, 255, 0.85), transparent 32%, rgba(255, 36, 129, 0.7) 68%, transparent);
    mix-blend-mode: screen;
    opacity: 0.8;
}

html.sassy-glitching .sassy-glitch-transition::before {
    animation: sassy-glitch-scan 0.46s steps(5, end) both;
}

html.sassy-glitching .sassy-glitch-transition::after {
    background:
        repeating-linear-gradient(90deg, rgba(123, 47, 255, 0.35) 0 2px, transparent 2px 11px),
        linear-gradient(180deg, transparent 0 22%, rgba(255, 255, 255, 0.38) 23% 26%, transparent 27% 72%, rgba(157, 75, 255, 0.45) 73% 76%, transparent 77%);
    mix-blend-mode: color-dodge;
    animation: sassy-glitch-slices 0.46s steps(6, end) both;
}

html.sassy-glitching .sassy-case-study-modal__dialog {
    animation: sassy-glitch-dialog 0.46s steps(5, end) both;
}

@keyframes sassy-glitch-screen {
    0% { opacity: 0; }
    12% { opacity: 1; }
    38% { opacity: 0.7; }
    64% { opacity: 0.95; }
    100% { opacity: 0; }
}

@keyframes sassy-glitch-scan {
    0% { transform: translate(-9%, -2%) skewX(-7deg); clip-path: inset(8% 0 68% 0); }
    20% { transform: translate(7%, 1%) skewX(8deg); clip-path: inset(42% 0 38% 0); }
    42% { transform: translate(-4%, 4%) skewX(-3deg); clip-path: inset(70% 0 12% 0); }
    70% { transform: translate(4%, -5%) skewX(5deg); clip-path: inset(22% 0 58% 0); }
    100% { transform: translate(0); clip-path: inset(0); }
}

@keyframes sassy-glitch-slices {
    0% { transform: translateX(0); clip-path: inset(0 0 0 0); }
    25% { transform: translateX(-4%); clip-path: inset(12% 0 64% 0); }
    50% { transform: translateX(5%); clip-path: inset(51% 0 25% 0); }
    75% { transform: translateX(-2%); clip-path: inset(75% 0 8% 0); }
    100% { transform: translateX(0); clip-path: inset(0); }
}

@keyframes sassy-glitch-dialog {
    0% { transform: translate(0, 18px) scale(0.98); filter: none; }
    22% { transform: translate(-10px, 18px) skewX(-2deg) scale(1.01); filter: saturate(1.8) hue-rotate(18deg); }
    44% { transform: translate(8px, 8px) skewX(2deg) scale(0.99); filter: contrast(1.5) hue-rotate(-15deg); }
    68% { transform: translate(-4px, 2px) skewX(-1deg) scale(1.005); filter: saturate(1.4); }
    100% { transform: translate(0) scale(1); filter: none; }
}

body.sassy-case-study-open {
    overflow: hidden;
}

body.sassy-video-modal-open {
    overflow: hidden;
}

.sassy-video-modal[hidden] {
    display: none;
}

.sassy-video-modal {
    position: fixed;
    inset: 0;
    z-index: 10070;
    display: grid;
    place-items: center;
    padding: clamp(16px, 4vw, 48px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.sassy-video-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.sassy-video-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 1, 8, 0.9);
    backdrop-filter: blur(14px);
}

.sassy-video-modal__dialog {
    position: relative;
    width: min(1120px, 100%);
    overflow: hidden;
    border: 1px solid rgba(168, 121, 255, 0.48);
    border-radius: 22px;
    background: #090510;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85), 0 0 40px rgba(124, 58, 237, 0.24);
    transform: translateY(18px) scale(0.985);
    transition: transform 0.22s ease;
}

.sassy-video-modal.is-open .sassy-video-modal__dialog {
    transform: none;
}

.sassy-video-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 18px 14px 22px;
    color: #fff;
}

.sassy-video-modal__header h2 {
    margin: 0;
    color: #fff;
    font-size: clamp(17px, 2.1vw, 25px);
    line-height: 1.25;
}

.sassy-video-modal__close {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
}

.sassy-video-modal__close:hover,
.sassy-video-modal__close:focus-visible {
    background: #8b3eff;
}

.sassy-video-modal__player {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

.sassy-video-modal__player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

@media (max-width: 640px) {
    .sassy-video-modal { padding: 10px; }
    .sassy-video-modal__dialog { border-radius: 14px; }
    .sassy-video-modal__header { padding: 12px 12px 10px 15px; }
}

/* Sound and Drag hints */
.sassy-3d-bottom-tools {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    pointer-events: auto;
}

.sassy-3d-hint {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sassy-3d-sound-toggle {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    transition: color 0.2s ease;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.sassy-3d-sound-toggle:hover {
    color: #ffffff;
}

.sassy-3d-sound-toggle.is-active {
    color: #c49eff;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .sassy-3d-top-hud {
        top: 6rem;
        flex-direction: column;
        gap: 0.85rem;
        padding: 0 1.5rem;
    }
    
    .sassy-3d-nav-arrow {
        display: none;
    }
}

@media (max-width: 767px) {
    body:has(.sassy-work-page) .sassy-chat-mascot {
        top: 12px;
        bottom: auto;
    }

    body:has(.sassy-work-page) .sassy-chat-mascot__bubble { display: none; }
    body:has(.sassy-work-page) .sassy-chat-mascot__button { width: 60px; height: 60px; }

    .sassy-work-page {
        --work-header-height: 0px;
        --work-dock-space: calc(98px + env(safe-area-inset-bottom, 0px));
    }

    .sassy-3d-stage-wrapper {
        height: auto;
        grid-template-rows: auto auto;
    }

    .sassy-3d-scene {
        height: clamp(360px, 110vw, 490px);
        margin-top: clamp(28px, 6dvh, 56px);
    }

    .sassy-3d-nav-arrow {
        display: flex;
        top: 38%;
        width: 44px;
        height: 44px;
        background: rgba(18, 12, 32, 0.9);
        border-color: rgba(199, 163, 255, 0.65);
        touch-action: manipulation;
    }

    .sassy-3d-nav-arrow i { pointer-events: none; }
    .sassy-3d-nav-arrow.is-prev { left: 12px; }
    .sassy-3d-nav-arrow.is-next { right: 12px; }

    .sassy-3d-bottom-hud {
        gap: 0.6rem;
        transform: none;
    }

    .sassy-3d-filters {
        padding: 0.25rem 0.35rem;
        gap: 0.25rem;
        max-width: 96%;
        overflow-x: auto;
    }

    .sassy-3d-filter-btn {
        padding: 0.35rem 0.75rem;
        font-size: 0.74rem;
        white-space: nowrap;
    }
    
    .sassy-3d-info-card {
        padding: 0.85rem 1rem;
    }
    
    .sassy-3d-info-title {
        font-size: 1rem;
    }
    
    .sassy-3d-info-action {
        padding: 0.5rem 0.9rem;
        font-size: 0.78rem;
    }


}

@media (max-width: 480px) {
    .sassy-3d-filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        max-width: none;
        border-radius: 22px;
        overflow: visible;
    }

    .sassy-3d-filter-btn { min-height: 36px; }
    .sassy-3d-info-card { flex-direction: column; align-items: stretch; gap: 0.6rem; }
    .sassy-3d-info-action { justify-content: center; min-height: 40px; }
    .sassy-3d-bottom-tools { gap: 0.25rem; flex-wrap: wrap; justify-content: center; }
    .sassy-3d-hint { font-size: 0.7rem; }
}

@media (max-height: 560px) {
    .sassy-3d-bottom-hud { gap: 0.35rem; margin-bottom: 8px; }
    .sassy-3d-info-card { padding: 0.5rem 1rem; }
    .sassy-3d-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html.sassy-glitching .sassy-glitch-transition,
    html.sassy-glitching .sassy-case-study-modal__dialog {
        animation-duration: 0.01ms !important;
    }
}
