/* --- Story Mode Layout --- */
.project-story-item {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    /* Tighter gap on mobile */
    align-items: center;
    margin-bottom: 6rem;
    /* Reduced from 8rem for mobile */
    opacity: 1;
}

@media (min-width: 900px) {
    .project-story-item {
        flex-direction: row;
        gap: 5rem;
        margin-bottom: 10vh;
        /* Balanced vertical spacing */
    }

    /* Alternating Layout (Zig-Zag) - Handled via JS now */
    .project-story-item.reverse {
        flex-direction: row-reverse;
    }
}

.story-visual {
    flex: 1.5;
    width: 100%;
}

.story-content {
    flex: 1;
    width: 100%;
    padding: 1rem 0;
    /* Reduced padding on mobile */
    text-align: center;
    /* Center align text on mobile for better balance */
}

@media (min-width: 900px) {
    .story-content {
        text-align: left;
        /* Left align on desktop */
        padding: 2rem 0;
    }
}

.story-category {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.7rem;
    color: var(--accent-secondary);
    /* Muted Teal */
    margin-bottom: 0.5rem;
    display: block;
    font-weight: 700;
}

.story-title {
    font-size: 2rem;
    /* Mobile Size */
    line-height: 1.1;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 700;
}

@media (min-width: 900px) {
    .story-title {
        font-size: 3.5rem;
        /* Desktop Size */
    }
}

.story-description {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    /* Muted Grey */
    margin-bottom: 2rem;
    max-width: 500px;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    /* Center on mobile */
    margin-bottom: 2rem;
}

@media (min-width: 900px) {
    .tech-stack {
        justify-content: flex-start;
        /* Left on desktop */
    }
}

.tech-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--accent-primary);
    background: rgba(102, 252, 241, 0.05);
    /* Slight tint */
}

.btn-visit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: 1px solid var(--accent-primary);
    /* Cyan Border */
    border-radius: 50px;
    color: var(--accent-primary);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-visit:hover {
    background: var(--accent-primary);
    color: var(--bg-color);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-visit span {
    font-size: 1.2rem;
    line-height: 0;
    position: relative;
    top: -1px;
    transition: transform 0.3s ease;
}

.btn-visit:hover span {
    transform: translateX(5px);
}

/* --- Browser Mockup (Refined) --- */
.mockup-browser {
    width: 100%;
    aspect-ratio: 16 / 12;
    /* Taller windows */
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
    border: 1px solid #333;
    transition: transform 0.6s cubic-bezier(0.2, 1, 0.3, 1), box-shadow 0.6s ease;
}

.project-story-item:hover .mockup-browser {
    transform: translateY(-15px) scale(1.02);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
    border-color: #555;
    /* No cyan glow for story mode, kept cleaner */
}

.mockup-header {
    background: #1e1e1e;
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-bottom: 1px solid #333;
}

.mockup-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #444;
}

.dot.red {
    background: #ff5f56;
}

.dot.yellow {
    background: #ffbd2e;
}

.dot.green {
    background: #27c93f;
}

.mockup-address-bar {
    margin-left: 20px;
    flex-grow: 1;
    height: 20px;
    background: #111;
    border-radius: 4px;
    font-size: 10px;
    color: #666;
    display: flex;
    align-items: center;
    padding-left: 10px;
}

.mockup-content {
    width: 100%;
    height: calc(100% - 30px);
    background: #fff;
    position: relative;
    overflow: hidden;
    /* Hide scrollbars from scale overflow if any */
}

.mockup-content iframe {
    width: 200%;
    /* Double width to simulate desktop */
    height: 200%;
    /* Double height to maintain aspect ratio */
    border: none;
    transform: scale(0.5);
    /* Scale back down to fit */
    transform-origin: 0 0;
    pointer-events: auto;
    /* Enable scrolling and interaction */
    /* Enable scrolling and interaction */
    background: #fff;
}

/* Interaction Hint Overlay */
.interaction-hint {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(11, 12, 16, 0.85);
    backdrop-filter: blur(5px);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--accent-primary);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    /* Let clicks pass through to iframe */
    transition: all 0.5s ease;
    z-index: 10;
}

.interaction-hint svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

.interaction-hint span {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: #fff;
}

/* Hide on Hover so it doesn't obstruct view */
.mockup-content:hover .interaction-hint,
.mockup-content:focus-within .interaction-hint {
    opacity: 0;
    transform: translateY(10px);
}

/* --- Next Project Scroll Button --- */
.story-visual {
    position: relative;
}

/* Common Button Styles */
.scroll-next-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(11, 12, 16, 0.4); /* Darker, more contrast */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 252, 241, 0.15);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    padding: 0;
}

.scroll-next-btn:hover {
    background: rgba(11, 12, 16, 0.6);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 30px rgba(102, 252, 241, 0.2);
    transform: scale(1.15) translateY(-5px);
}

.next-btn-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    color: var(--accent-primary);
    transition: all 0.5s ease;
    
    /* Subtle breathing icon */
    animation: icon-breathe 4s infinite ease-in-out;
}

@keyframes icon-breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.15); }
}

.next-btn-text {
    width: 100%;
    height: 100%;
    animation: spinText 12s linear infinite;
    pointer-events: none;
    
    /* Solid Neon Blue - No Glow for Readability */
    color: var(--accent-primary);
    font-weight: 700;
    transition: all 0.5s ease;
}

.scroll-next-btn:hover .next-btn-text {
    color: #00ffff; /* Brighter on hover */
    transform: scale(1.05);
}

/* Mobile Instance (Floating) */
.scroll-next-btn.mobile-only {
    position: absolute;
    bottom: -35px;
    right: 0;
    left: 0;
    margin: 0 auto;
}

/* Desktop Instance (Static) */
.story-header-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: nowrap; /* Prevent button from wrapping to new line */
}

.story-title {
    flex: 1; /* Take all available space */
}

.scroll-next-btn.desktop-only {
    flex-shrink: 0; /* Don't shrink the circle button */
}

/* Visibility (Mobile First) */
.scroll-next-btn.desktop-only {
    display: none;
}

.scroll-next-btn.mobile-only {
    display: flex;
}

.next-btn-text text {
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes spinText {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (min-width: 900px) {

    /* Swap Visibility */
    .scroll-next-btn.mobile-only {
        display: none;
    }

    .scroll-next-btn.desktop-only {
        display: flex;
    }

    /* Remove the old floating logic since we have a dedicated desktop button now */

    .story-title {
        margin-bottom: 0;
        /* Remove bottom margin since it's in a flex row now */
    }
}

/* --- Filters --- */
/* --- Filters --- */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 4rem;
    /* Horizontal Scroll Setup */
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll iOS */
    padding: 0.5rem 1rem;
    /* Padding for scroll spacing */

    /* Hide scrollbar */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE */
}

.filter-bar::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Center on Desktop */
@media (min-width: 768px) {
    .filter-bar {
        justify-content: center;
        overflow-x: visible;
    }
}

.filter-btn {
    background: var(--surface-color);
    /* Button Surface */
    border: 1px solid var(--border-color);
    /* Muted Teal Border */
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.filter-btn.active,
.filter-btn:hover {
    color: var(--bg-color);
    /* Contrast Text */
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    /* Electric Cylance Fill */
    box-shadow: 0 0 15px var(--accent-glow);
}

/* --- Controls Row (Filters + Toggles) --- */
.controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 2rem;
    /* Reduced from 5rem */
}

/* --- Filters --- */
/* .filter-wrapper removed */

.filter-bar {
    display: flex;
    gap: 1rem;
    /* Horizontal Scroll Setup */
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll iOS */
    padding: 0.5rem 1rem;
    /* Padding for scroll spacing */

    /* Hide scrollbar */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE */
}

.scroll-hint {
    display: block;
    /* Visible by default on mobile */
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    animation: fadePulse 2s infinite;

    /* Force to new line ABOVE controls */
    flex-basis: 100%;
    width: 100%;
    order: -1;
    /* First visually */
    margin-bottom: 0.5rem;
}

@keyframes fadePulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}

@media (min-width: 768px) {
    .scroll-hint {
        display: none;
        /* Hide on desktop */
    }
}

.view-toggles {
    display: flex;
    gap: 0.5rem;
    background: var(--surface-color);
    padding: 0.25rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
}

/* Floating Side Dock Logic */
.fixed-toggles {
    position: fixed;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    /* Stack vertically on the side */
    z-index: 100;

    /* Initially Hidden (Revealed by JS) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

@media (max-width: 900px) {
    .fixed-toggles {
        /* On mobile, maybe keep it at the top or bottom right? 
           For now, let's keep it left but smaller or adjust position */
        left: 1rem;
        padding: 0.25rem;
    }
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.view-btn.active,
.view-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-color);
}

/* Stop wrapping on desktop to ensure single line */
@media (min-width: 768px) {
    .controls-row {
        flex-wrap: nowrap;
        gap: 2rem;
    }
}

/* --- Compact Grid Mode Overrides --- */
.grid-layout.compact-mode {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding-bottom: 10vh;
}

/* Reset Story Styles when in Compact Mode */
.grid-layout.compact-mode .project-story-item {
    flex-direction: column !important;
    /* Force vertical stack */
    gap: 1rem;
    margin-bottom: 0;
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.grid-layout.compact-mode .story-visual {
    flex: none;
    width: 100%;
}

.grid-layout.compact-mode .mockup-browser {
    aspect-ratio: 16/9;
    /* Standard ratio for small cards */
}

/* Disable interaction in compact mode to make scrolling easier */
.grid-layout.compact-mode .mockup-content iframe {
    pointer-events: none;
}

/* Hide Next Button in Grid Mode */
.grid-layout.compact-mode .scroll-next-btn {
    display: none !important;
}

/* Hide Preview Hint in Grid Mode */
.grid-layout.compact-mode .interaction-hint {
    display: none !important;
}

.grid-layout.compact-mode .story-content {
    text-align: left;
    padding: 0;
}

.grid-layout.compact-mode .story-title {
    font-size: 1.5rem;
    /* Smaller titles */
}

.grid-layout.compact-mode .story-description {
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    /* Standard property for compatibility */
    /* Limit text lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
}

.grid-layout.compact-mode .btn-visit {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}