/* ============================================================
   SHOWCASE.CSS — Device frames, compare sliders, scene blocks,
   breakpoint cascades, and scroll-triggered animations.
   Light theme — works with the existing case-study.css palette.
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
    --device-bezel: #1c1c1e;
    --device-bezel-edge: #2c2c2e;
    --device-screen-bg: #f8f8f8;
    --device-radius-ipad: 24px;
    --device-radius-iphone: 48px;
    --device-radius-desktop: 12px;
}

/* ============================================================
   CSS DEVICE FRAMES — Flexible aspect ratio
   Images dictate size; the bezel wraps around them.
   ============================================================ */

/* ---- iPad Frame ---- */
.device-ipad {
    position: relative;
    background: var(--device-bezel);
    border-radius: var(--device-radius-ipad);
    padding: 20px;
    box-shadow:
        0 0 0 1px var(--device-bezel-edge),
        0 12px 40px rgba(0,0,0,0.18),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease;
    z-index: 1;
}

.device-ipad .device-screen {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: var(--device-screen-bg);
}

.device-ipad .device-screen img,
.device-ipad .device-screen video {
    width: 100%;
    height: auto;
    display: block;
}

/* Camera dot */
.device-ipad::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2c2c2e;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
    z-index: 2;
}

/* Landscape iPad */
.device-ipad-landscape {
    padding: 16px 24px;
}

.device-ipad-landscape::before {
    top: 50%;
    left: 8px;
    transform: translateY(-50%) translateX(0);
}

/* ---- iPhone Frame ---- */
.device-iphone {
    position: relative;
    background: var(--device-bezel);
    border-radius: var(--device-radius-iphone);
    padding: 14px;
    box-shadow:
        0 0 0 1px var(--device-bezel-edge),
        0 12px 40px rgba(0,0,0,0.18),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    width: 280px;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease;
    z-index: 1;
}

.device-iphone .device-screen {
    position: relative;
    border-radius: 36px;
    overflow: hidden;
    background: var(--device-screen-bg);
}

.device-iphone .device-screen img,
.device-iphone .device-screen video {
    width: 100%;
    height: auto;
    display: block;
}

/* Dynamic Island */
.device-iphone .device-notch {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 28px;
    background: #000;
    border-radius: 20px;
    z-index: 3;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05);
}

/* ---- Desktop / Browser Frame ---- */
.device-desktop {
    position: relative;
    background: var(--device-bezel);
    border-radius: var(--device-radius-desktop);
    overflow: hidden;
    box-shadow:
        0 0 0 1px var(--device-bezel-edge),
        0 16px 60px rgba(0,0,0,0.15),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease;
    z-index: 1;
}

.device-desktop .device-titlebar {
    height: 36px;
    background: #2c2c2e;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
    position: relative;
}

.device-titlebar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.device-titlebar-dot:nth-child(1) { background: #ff5f57; }
.device-titlebar-dot:nth-child(2) { background: #febc2e; }
.device-titlebar-dot:nth-child(3) { background: #28c840; }

.device-titlebar-url {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 4px 16px;
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: 0.02em;
}

.device-desktop .device-screen {
    position: relative;
    overflow: hidden;
    background: var(--device-screen-bg);
}

.device-desktop .device-screen img,
.device-desktop .device-screen video {
    width: 100%;
    height: auto;
    display: block;
}

/* ---- Tablet Portrait ---- */
.device-tablet-v {
    position: relative;
    background: var(--device-bezel);
    border-radius: 20px;
    padding: 18px 14px;
    box-shadow:
        0 0 0 1px var(--device-bezel-edge),
        0 12px 40px rgba(0,0,0,0.18),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease;
    z-index: 1;
}

.device-tablet-v .device-screen {
    border-radius: 6px;
    overflow: hidden;
    background: var(--device-screen-bg);
}

.device-tablet-v .device-screen img {
    width: 100%;
    height: auto;
    display: block;
}

/* ============================================================
   DEVICE HOVER EFFECTS
   ============================================================ */

.device-tilt {
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.6s ease;
    will-change: transform;
}

.device-tilt:hover {
    box-shadow:
        0 0 0 1px var(--device-bezel-edge),
        0 24px 80px rgba(0,0,0,0.22),
        0 0 0 1px rgba(255,255,255,0.05) inset;
}

.device-tilt[data-tilt-active] {
    transform: perspective(1200px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.device-float {
    animation: float 5s ease-in-out infinite;
}

/* ============================================================
   BEFORE / AFTER COMPARE SLIDER
   ============================================================ */

.compare-slider {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

.compare-slider img {
    display: block;
    width: 100%;
    pointer-events: none;
}

.compare-before {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.compare-before img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.compare-after img {
    width: 100%;
    display: block;
}

.compare-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: white;
    z-index: 3;
    cursor: col-resize;
    box-shadow: 0 0 12px rgba(0,0,0,0.3);
}

.compare-handle::before,
.compare-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.compare-handle::before {
    left: -16px;
    transform: translateY(-50%);
}

.compare-handle::after {
    right: -16px;
    transform: translateY(-50%);
}

.compare-handle .compare-arrow-left,
.compare-handle .compare-arrow-right {
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    border-style: solid;
}

.compare-handle .compare-arrow-left {
    left: -14px;
    transform: translateY(-50%);
    border-width: 5px 6px 5px 0;
    border-color: transparent var(--text-dark) transparent transparent;
}

.compare-handle .compare-arrow-right {
    right: -14px;
    transform: translateY(-50%);
    border-width: 5px 0 5px 6px;
    border-color: transparent transparent transparent var(--text-dark);
}

.compare-label {
    position: absolute;
    top: 16px;
    z-index: 4;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 5px 12px;
    border-radius: 100px;
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.compare-label-before {
    left: 16px;
    background: rgba(0,0,0,0.6);
    color: white;
}

.compare-label-after {
    right: 16px;
    background: rgba(241, 53, 47, 0.85);
    color: white;
}

/* ============================================================
   SCENE BLOCKS — Narrative presentation (light theme)
   ============================================================ */

.scene-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
    padding: 60px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.scene-block:last-child {
    border-bottom: none;
}

.scene-block.scene-reverse {
    direction: rtl;
}

.scene-block.scene-reverse > * {
    direction: ltr;
}

.scene-narrative {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.scene-number {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--primary-red);
}

.scene-heading {
    font-family: 'Fresh Mango', 'Roboto', sans-serif;
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-dark);
    line-height: 1.2;
}

.scene-description {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-light);
}

.scene-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* ============================================================
   BREAKPOINT SWITCHER — Tabbed device display
   ============================================================ */

.bp-switcher {
    margin: 0 auto;
}

/* Tab bar */
.bp-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 40px;
    background: rgba(0,0,0,0.04);
    border-radius: 12px;
    padding: 4px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.bp-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-family: inherit;
}

.bp-tab:hover {
    color: var(--text-dark);
    background: rgba(0,0,0,0.04);
}

.bp-tab.active {
    background: white;
    color: var(--text-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}

/* Display area */
.bp-display {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 200px;
}

.bp-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: bpFadeIn 0.4s ease-out;
}

.bp-panel.active {
    display: flex;
}

@keyframes bpFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Constrain device widths inside the display area */
.bp-panel .device-desktop {
    width: 100%;
}

.bp-panel .device-ipad {
    width: 80%;
}

.bp-panel .device-tablet-v {
    width: 45%;
}

.bp-panel .device-iphone {
    width: 280px;
}

.bp-panel-label {
    margin-top: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-light);
}

/* ============================================================
   STAGGERED SCROLL ANIMATIONS
   ============================================================ */

.stagger-item {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.stagger-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.stagger-item:nth-child(1) { transition-delay: 0s; }
.stagger-item:nth-child(2) { transition-delay: 0.12s; }
.stagger-item:nth-child(3) { transition-delay: 0.24s; }
.stagger-item:nth-child(4) { transition-delay: 0.36s; }
.stagger-item:nth-child(5) { transition-delay: 0.48s; }
.stagger-item:nth-child(6) { transition-delay: 0.6s; }

.stagger-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.stagger-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.stagger-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.stagger-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.stagger-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.stagger-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ============================================================
   DESIGN SYSTEM SHOWCASE — Card grid (light)
   ============================================================ */

.ds-showcase-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: var(--spacing-element);
}

.ds-showcase-card {
    border-radius: 12px;
    overflow: hidden;
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    transition: all 0.4s ease;
    cursor: pointer;
}

.ds-showcase-card:hover {
    transform: translateY(-6px);
    border-color: rgba(0,0,0,0.12);
    box-shadow: 0 16px 48px rgba(0,0,0,0.1);
}

.ds-showcase-card img {
    width: 100%;
    display: block;
    transition: transform 0.4s ease;
}

.ds-showcase-card:hover img {
    transform: scale(1.02);
}

.ds-showcase-card-caption {
    padding: 14px 16px;
    font-size: 0.8125rem;
    color: var(--text-light);
    line-height: 1.5;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.ds-showcase-card-caption strong {
    color: var(--text-dark);
    font-weight: 600;
}

.ds-showcase-card-full {
    grid-column: 1 / -1;
}

/* ============================================================
   HERO DEVICE
   ============================================================ */

.showcase-hero-device {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
}

.showcase-hero-device .device-ipad {
    width: 100%;
}

.showcase-hero-device .device-screen video {
    object-fit: contain;
    background: #f0f0f0;
}

/* ============================================================
   IMAGE LIGHTBOX
   ============================================================ */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(20px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.lightbox-overlay.active img {
    transform: scale(1);
}

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

@media (max-width: 968px) {
    .scene-block {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 40px 0;
    }

    .scene-block.scene-reverse {
        direction: ltr;
    }

    .scene-heading {
        font-size: 1.75rem;
    }

    .bp-tabs {
        max-width: 100%;
    }

    .bp-tab {
        font-size: 0.75rem;
        padding: 8px 10px;
    }

    .bp-panel .device-ipad {
        width: 100%;
    }

    .bp-panel .device-tablet-v {
        width: 60%;
    }

    .ds-showcase-grid {
        grid-template-columns: 1fr;
    }

    .device-iphone {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .scene-block {
        padding: 32px 0;
    }

    .device-ipad {
        padding: 12px;
        border-radius: 18px;
    }

    .device-iphone {
        width: 200px;
        padding: 10px;
        border-radius: 36px;
    }

    .device-iphone .device-screen {
        border-radius: 28px;
    }

    .device-iphone .device-notch {
        width: 70px;
        height: 22px;
        top: 14px;
    }

    .compare-label {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .scene-heading {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .device-iphone {
        width: 180px;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .device-float {
        animation: none;
    }

    .device-tilt,
    .stagger-item,
    .stagger-left,
    .stagger-right,
    .stagger-scale {
        transition: none !important;
        animation: none !important;
    }

    .stagger-item,
    .stagger-left,
    .stagger-right,
    .stagger-scale {
        opacity: 1;
        transform: none;
    }
}
