/*
  style.css
  Optimized for performance and mobile support
*/

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #000;
    color: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
    position: fixed;
    width: 100vw;
    height: 100vh;
}

/* 4:3 Aspect Ratio Container - Desktop only */
.desktop-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1200px, 90vw);
    height: min(900px, 67.5vw);
    z-index: 100;
    pointer-events: none;
}

/* Mobile container - full screen */
.mobile-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
    display: none;
}

/* Lateral letterboxing (desktop only) */
.letterbox-left,
.letterbox-right {
    position: fixed;
    top: 0;
    width: calc((100vw - min(1200px, 90vw)) / 2);
    height: 100vh;
    background-color: #000;
    z-index: 1;
    pointer-events: all;
}

.letterbox-left {
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 40px 30px;
}

.letterbox-right {
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding: 40px 30px;
}

/* Name/Logo in left letterbox */
.letterbox-left .logo {
    font-size: 2.2rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    text-align: center;
    letter-spacing: 4px;
    margin-top: 20px;
}

/* Privacy link */
.letterbox-left .privacy-link {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.letterbox-left .privacy-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* Tab buttons in right letterbox */
.letterbox-right .menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin: 0;
    padding: 0;
    align-items: flex-end;
}

.letterbox-right .menu li {
    cursor: pointer;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.8rem 1.4rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
    text-align: center;
    pointer-events: all;
    position: relative;
    z-index: 2001;
    min-width: 100px;
}

.letterbox-right .menu li:hover {
    border: 1px solid #ffffff;
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-3px);
}

.letterbox-right .menu li.active {
    border: 1px solid #ffffff;
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-1px);
}

/* Video grid */
#video-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 4px;
    /* Reduced for performance */
    overflow: hidden;
    border-radius: 4px;
    opacity: 1 !important;
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Optimized video cells */
.video-cell {
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    position: relative;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.video-cell video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    /* Remove blur filter for performance */
    filter: brightness(1.05);
    -webkit-filter: brightness(1.05);
}

/* Main content */
main {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 10;
    pointer-events: none;
}

/* Text block */
.text-block {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    pointer-events: all;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Works section - properly scrollable */
#works.tab-content .text-block {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#works .text-block-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

/* Hide scrollbar by default, show on hover */
#works .text-block-content::-webkit-scrollbar {
    width: 6px;
}

#works .text-block-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#works .text-block-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#works .text-block-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Tabs visibility */
.tab-content {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    width: 100%;
    height: 100%;
}

.active-tab {
    display: flex;
    opacity: 1;
}

/* Typography */
.text-block h1 {
    margin-bottom: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #ffffff;
    font-size: 1.8rem;
    line-height: 1.1;
}

.text-block h2 {
    margin-bottom: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ffffff;
    font-size: 1.4rem;
}

.text-block h3 {
    margin-bottom: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #ffffff;
    font-size: 1.1rem;
}

.text-block p {
    margin-bottom: 1rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
}

/* Links */
.text-block a {
    color: #a3d5ff;
    text-decoration: none;
    border-bottom: 1px solid rgba(163, 213, 255, 0.4);
    transition: all 0.2s;
    font-weight: 500;
}

.text-block a:hover {
    color: #ffffff;
    border-bottom-color: #ffffff;
}

/* Works section styling */
.portfolio-subsection {
    margin-bottom: 2rem;
}

.portfolio-subsection h2 {
    margin-top: 0;
    margin-bottom: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.project-item {
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.project-info img {
    max-width: 100%;
    height: auto;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    max-width: 260px;
}

/* Contact list */
.contact-list {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.contact-list li {
    font-size: 0.95rem;
}

/* Audio player */
.audio-player-container {
    position: fixed !important;
    right: calc((100vw - min(1200px, 90vw)) / 2 + 30px) !important;
    bottom: 40px !important;
    z-index: 9999 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: #fff !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    font-family: 'Inter', Arial, sans-serif !important;
    font-size: 13px !important;
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    min-width: 180px !important;
    max-width: 220px !important;
    pointer-events: all !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.audio-player-container button {
    cursor: pointer !important;
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    padding: 6px 10px !important;
    color: #fff !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    min-width: 60px !important;
}

.audio-player-container>div {
    min-width: 120px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Mobile header and footer */
.mobile-header {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: all;
}

.mobile-header .logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
    letter-spacing: 2px;
}

.mobile-footer {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: all;
}

.mobile-footer .menu {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 0;
    padding: 0;
}

.mobile-footer .menu li {
    cursor: pointer;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
}

.mobile-footer .menu li.active {
    border: 1px solid #ffffff;
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile audio player */
.mobile-audio-player {
    position: absolute !important;
    bottom: 80px !important;
    right: 20px !important;
    z-index: 9999 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: #fff !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    max-width: 160px !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Mobile privacy link */
.mobile-privacy-link {
    position: absolute !important;
    bottom: 80px !important;
    left: 20px !important;
    z-index: 9999 !important;
    color: rgba(255, 255, 255, 0.6) !important;
    text-decoration: none !important;
    font-size: 0.8rem !important;
}

/* Remove loading indicator */
#video-loading {
    display: none !important;
}

/* Performance optimizations */
#defaultCanvas0 {
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    -ms-interpolation-mode: nearest-neighbor;
}

/* Media queries for mobile */
@media (max-width: 1024px) {

    /* Switch to mobile layout */
    .desktop-container,
    .letterbox-left,
    .letterbox-right {
        display: none !important;
    }

    .mobile-container {
        display: block !important;
    }

    .mobile-header,
    .mobile-footer {
        display: block;
    }

    main {
        padding: 4rem 1rem 5rem 1rem !important;
    }

    .text-block {
        padding: 1.5rem;
        background: rgba(255, 255, 255, 0.05);
        backdrop-filter: blur(5px);
    }

    .text-block h1 {
        font-size: 1.5rem;
    }

    .text-block h2 {
        font-size: 1.2rem;
    }

    .text-block h3 {
        font-size: 1rem;
    }

    .text-block p {
        font-size: 0.9rem;
    }

    #video-grid {
        gap: 2px;
    }

    .audio-player-container {
        display: none !important;
    }

    .project-info img {
        max-width: 220px;
    }

    #works .text-block-content {
        padding-right: 0.25rem;
    }
}

/* Performance optimizations for low-end devices */
@media (max-width: 768px) and (max-height: 1024px) {
    #video-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    .video-cell video {
        filter: none !important;
        -webkit-filter: none !important;
    }

    .text-block {
        backdrop-filter: blur(2px);
    }
}

/* iPhone notch safe areas */
@supports (padding: max(0px)) {
    .mobile-header {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .mobile-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .mobile-container main {
        padding-top: max(4rem, calc(env(safe-area-inset-top) + 3rem)) !important;
        padding-bottom: max(5rem, calc(env(safe-area-inset-bottom) + 4rem)) !important;
    }

    .mobile-audio-player {
        bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px)) !important;
    }

    .mobile-privacy-link {
        bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px)) !important;
    }
}

/* Disable animations on mobile for performance */
@media (max-width: 768px) {
    .tab-content {
        transition: none;
    }

    .video-cell video {
        animation: none !important;
    }
}

/* High DPI screens optimization */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .text-block {
        backdrop-filter: blur(10px);
    }
}