/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #000;
    color: #fff;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent mobile scrolling while keeping content panels scrollable */
@media (max-width: 767px) {
    html, body {
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important; /* Safari dynamic viewport */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        touch-action: none !important;
        overscroll-behavior: none !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .portfolio-container {
        touch-action: pan-x;
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important; /* Safari dynamic viewport */
        position: relative !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .portfolio-section {
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important; /* Safari dynamic viewport */
        position: relative !important;
    }
    
    /* Responsive content panel positioning for different mobile screen heights */
    .content-card {
        /* More aggressive positioning for better tablet/fold support */
        bottom: calc(-100vh + 140px) !important;
        bottom: calc(-100dvh + 140px) !important; /* Safari dynamic viewport */
        max-height: calc(100vh - 30px) !important;
        max-height: calc(100dvh - 30px) !important;
    }
}

/* Tablet-specific adjustments */
@media (max-width: 767px) and (min-height: 800px) {
    .content-card {
        bottom: calc(-100vh + 200px) !important;
        bottom: calc(-100dvh + 200px) !important;
        max-height: calc(100vh - 50px) !important;
        max-height: calc(100dvh - 50px) !important;
    }
}

@media (max-width: 767px) and (min-height: 1000px) {
    .content-card {
        bottom: calc(-100vh + 250px) !important;
        bottom: calc(-100dvh + 250px) !important;
        max-height: calc(100vh - 80px) !important;
        max-height: calc(100dvh - 80px) !important;
    }
}

/* Z Fold and ultra-wide tablets */
@media (max-width: 767px) and (min-height: 1200px) {
    .content-card {
        bottom: calc(-100vh + 300px) !important;
        bottom: calc(-100dvh + 300px) !important;
        max-height: calc(100vh - 100px) !important;
        max-height: calc(100dvh - 100px) !important;
    }
}

/* Tablet landscape mode and large tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) and (pointer: coarse) {
    /* Hide desktop elements */
    .desktop-timeline,
    .desktop-content-panels,
    .content-panel {
        display: none !important;
    }
    
    /* Show mobile elements */
    .mobile-top-timeline,
    .content-card {
        display: block !important;
    }
    
    /* Apply mobile-style scroll prevention */
    html, body {
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        touch-action: none !important;
        overscroll-behavior: none !important;
    }
    
    .portfolio-container {
        touch-action: pan-x;
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important;
        position: relative !important;
    }
    
    .portfolio-section {
        overflow: hidden !important;
        height: 100vh !important;
        height: 100dvh !important;
        position: relative !important;
    }
    
    /* Content panel positioning for tablets */
    .content-card {
        position: absolute !important;
        bottom: calc(-100vh + 250px) !important;
        bottom: calc(-100dvh + 250px) !important;
        left: 0 !important;
        right: 0 !important;
        background: rgba(0, 0, 0, 0.9) !important;
        backdrop-filter: blur(20px) !important;
        border-radius: 24px 24px 0 0 !important;
        padding: 24px !important;
        z-index: 100 !important;
        transition: bottom 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
        will-change: bottom !important;
        max-height: calc(100vh - 80px) !important;
        max-height: calc(100dvh - 80px) !important;
        overflow-y: auto !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        touch-action: pan-y !important;
    }
    
    .content-card::-webkit-scrollbar {
        display: none !important;
    }
    
    .content-card.expanded {
        bottom: 0 !important;
    }
}

/* ============================================
   MOBILE-FIRST DESIGN (Default < 768px)
   ============================================ */

/* Main Portfolio Container */
.portfolio-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    touch-action: pan-y;
}

/* Portfolio Sections */
.portfolio-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform, opacity;
    display: flex;
    flex-direction: column;
}

.portfolio-section.active {
    opacity: 1;
    transform: translateX(0);
    z-index: 10;
}

.portfolio-section.prev {
    transform: translateX(-100%);
}

/* Section Backgrounds */
.section-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Hero Media for Mobile */
.hero-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-media img,
.hero-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.hero-media::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
    z-index: 2;
}

/* Desktop Mosaic - Hidden on Mobile */
.desktop-mosaic {
    display: none;
}

/* Mobile Content Cards */
.content-card {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    z-index: 100;
    bottom: calc(-100vh + 120px);
    transition: bottom 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: bottom;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-y;
    display: block;
}

.content-card::-webkit-scrollbar {
    display: none;
}

.content-card.expanded {
    bottom: 0;
}

.content-card::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.card-header {
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
}

.card-header .subtitle {
    font-size: 16px;
    color: #ccc;
    margin-bottom: 0;
}

.card-content p {
    line-height: 1.6;
    margin-bottom: 16px;
    font-size: 14px;
    color: #eee;
}

.highlights {
    background: rgba(255, 255, 255, 0.1);
    padding: 16px;
    border-radius: 12px;
    margin: 20px 0;
}

.highlights h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
}

.highlights ul {
    list-style: none;
}

.highlights li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
    font-size: 13px;
    line-height: 1.4;
    color: #eee;
}

.highlights li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: #888;
}


/* Mobile Top Timeline */
.mobile-top-timeline {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 16px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    padding: 12px 20px;
    border-radius: 24px;
    transition: opacity 0.3s ease;
}

.timeline-logo {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.timeline-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.timeline-logo.active {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px;
}

.timeline-logo.active img {
    opacity: 1;
}

.timeline-logo:hover img {
    opacity: 0.9;
}

/* Mobile Mosaic - Cycling Background Images */
.mobile-mosaic {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.mobile-mosaic-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.mobile-mosaic-item.active {
    opacity: 1;
}

.mobile-mosaic-item img,
.mobile-mosaic-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

/* Show Mobile Mosaic on Mobile */
.mobile-mosaic {
    display: block;
}

/* Desktop Elements - Hidden on Mobile */
.desktop-timeline,
.desktop-content-panels,
.content-panel {
    display: none !important;
}


/* Swipe Hints */
.swipe-hint {
    position: fixed;
    z-index: 500;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s ease;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.swipe-hint.horizontal {
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
}

.swipe-hint.vertical {
    right: 80px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

.swipe-hint.hidden {
    opacity: 0;
}

/* Project Specific Background Colors */
.bio-bg {
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
}

.howlcast-bg {
    background: linear-gradient(135deg, #63388b 0%, #663e79 100%);
}

.im-bg {
    background: linear-gradient(135deg, #eb2ed1 0%, #2a5298 100%);
}

.voyagers-bg {
    background: linear-gradient(135deg, #1e3c72 0%, #982a2a 100%);
}

.steel-town-bg {
    background: linear-gradient(135deg, #68342d 0%, #8a571c 100%);
}

/* ============================================
   DESKTOP DESIGN (>= 768px)
   ============================================ */

@media (min-width: 768px) {
    /* Hide Mobile Elements */
    .mobile-top-timeline,
    .swipe-hint,
    .mobile-mosaic {
        display: none !important;
    }
    
    .content-card {
        display: none !important;
    }
    
    .hero-media {
        display: none;
    }
    
    /* Show Desktop Elements */
    .desktop-timeline,
    .desktop-content-panels,
    .desktop-mosaic {
        display: block !important;
    }
    
    /* Override content panel positioning for desktop */
    .content-panel {
        display: block !important;
        position: fixed;
        right: 50px;
        top: 50%;
        transform: translateY(-50%) translateX(50px);
        width: 400px;
        max-height: 80vh;
        background: rgba(255, 255, 255, 0);
        backdrop-filter: blur(20px) brightness(0.8);
        color: #000;
        border-radius: 16px;
        padding: 40px;
        z-index: 1000;
        opacity: 0;
        transition: all 1s cubic-bezier(0.4, 0.0, 0.2, 1);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        bottom: auto;
        left: auto;
    }
    
    .content-panel.visible {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
    
    .content-panel::-webkit-scrollbar {
        display: none;
    }
    
    .content-panel h2 {
        font-size: 32px;
        color: #EEEEEE;
        font-weight: 700;
        margin-bottom: 8px;
        line-height: 1.2;
    }
    
    .content-panel .subtitle {
        font-size: 16px;
        color: #BBBBBB;
        margin-bottom: 24px;
    }
    
    .content-panel p {
        line-height: 1.6;
        color: #EEEEEE;
        margin-bottom: 16px;
        font-size: 14px;
    }
    
    .content-panel .highlights {
        background: rgba(255, 255, 255, 0.1);
        padding: 20px;
        border-radius: 8px;
        margin: 20px 0;
    }
    
    .content-panel .highlights h4 {
        font-size: 14px;
        color: #EEEEEE;
        font-weight: 600;
        margin-bottom: 8px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .content-panel .highlights ul {
        list-style: none;
        font-size: 13px;
        color: #EEEEEE;
        line-height: 1.5;
    }
    
    .content-panel .highlights li {
        margin-bottom: 4px;
        padding-left: 16px;
        position: relative;
    }
    
    .content-panel .highlights li::before {
        content: "→";
        position: absolute;
        left: 0;
        color: #888;
    }
    
    .mobile-mosaic {
        display: none !important;
    }
    
    /* High contrast support for desktop content panels */
    @media (prefers-contrast: high) {
        .content-panel {
            background: rgba(255, 255, 255, 0.95);
            border: 1px solid #000;
        }
    }
    
    /* Portfolio Container - Full height sections */
    .portfolio-container {
        height: auto;
        overflow: visible;
        position: static;
    }
    
    .portfolio-section {
        position: relative;
        height: 100vh;
        width: 100vw;
        opacity: 1;
        transform: none;
        transition: none;
        display: block;
        min-height: 100vh;
    }
    
    /* Desktop Mosaic Layout */
    .desktop-mosaic {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        columns: 4;
        column-gap: 8px;
        padding: 4px 20px 4px 4px;
        z-index: 1;
        transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
    }
    
    .mosaic-item {
        background: transparent;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
        break-inside: avoid;
        margin-bottom: 8px;
        height: auto;
        min-height: 160px;
    }
    
    .mosaic-item:nth-child(3n) {
        min-height: 280px;
    }
    
    .mosaic-item:nth-child(7n) {
        min-height: 320px;
    }
    
    
    .mosaic-item.hero {
        column-span: all;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
        border: none;
        z-index: 0;
    }
    
    .mosaic-item img,
    .mosaic-item video,
    .mosaic-item iframe {
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 0.9;
        transition: opacity 0.3s ease;
        display: block;
        border-radius: 8px;
        position: absolute;
        top: 0;
        left: 0;
    }
    
    
    /* Desktop Timeline */
    .desktop-timeline {
        position: fixed;
        left: 30px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1000;
        display: flex;
        flex-direction: column;
        gap: 72px;
    }
    
    .timeline-item {
        display: flex;
        align-items: center;
        cursor: pointer;
        transition: all 0.3s ease;
        min-height: 60px;
        margin-bottom: 36px;
    }
    
    .timeline-item:last-child {
        margin-bottom: 0;
    }
    
    .timeline-dot {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: transparent;
        margin-right: 12px;
        transition: all 1s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        flex-shrink: 0;
    }
    
    .timeline-dot img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
    }
    
    /* Disable circular cropping for Steel Town Tales */
    .timeline-item[data-section="4"] .timeline-dot img {
        border-radius: 0;
    }
    
    .timeline-item.active .timeline-dot {
        background: transparent;
        transform: scale(1.5);
    }
    
    .timeline-info {
        opacity: 0;
        transform: translateX(0px);
        transition: all 1s ease;
        min-width: 150px;
    }
    
    .timeline-item:hover .timeline-info,
    .timeline-item.active .timeline-info {
        opacity: 1;
        transform: translateX(0);
    }
    
    .timeline-title {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 2px;
        color: #fff;
    }
    
    .timeline-date {
        font-size: 12px;
        opacity: 0.7;
        color: #ccc;
    }
    
}

/* ============================================
   TABLET ADJUSTMENTS (768px - 1024px)
   ============================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .desktop-timeline {
        left: 20px;
    }
    
    .desktop-content-panels {
        right: 20px;
    }
    
    .content-panel {
        width: 350px;
        padding: 30px;
    }
    
    .desktop-mosaic {
        columns: 3;
        padding: 4px 15px 4px 4px;
    }
}

/* ============================================
   LARGE DESKTOP ADJUSTMENTS (> 1440px)
   ============================================ */

@media (min-width: 1440px) {
    .content-panel {
        width: 450px;
        padding: 50px;
    }
    
    .content-panel h2 {
        font-size: 36px;
    }
    
    .timeline-dot {
        width: 56px;
        height: 56px;
        margin-right: 56px;
    }
}

/* ============================================
   ACCESSIBILITY & PERFORMANCE
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Focus indicators for keyboard navigation */
.nav-dot:focus,
.timeline-logo:focus,
.timeline-item:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .content-card {
        background: rgba(0, 0, 0, 0.95);
        border: 1px solid #fff;
    }
    
    .highlights {
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
}