/* ========================================================================
   ANDREA VISCARDI V4 - FULL HORIZONTAL PAGE SCROLL
   Inspired by Ólafur Arnalds
   ======================================================================== */

/* ========================================================================
   1. RESET & BASE
   ======================================================================== */

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

/* ========================================================================
   2. CSS CUSTOM PROPERTIES
   ======================================================================== */

:root {
    /* Colors */
    --color-white: #FFFFFF;
    --color-off-white: #F5F5F5;
    --color-black: #000000;
    --color-charcoal: #2B2B2B;
    --color-gray: #808080;
    --color-gray-light: #D3D3D3;

    /* Typography */
    --font-primary: 'Akshar', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --text-h1: clamp(3rem, 8vw, 7rem);
    --text-h2: clamp(2rem, 5vw, 4rem);
    --text-h3: clamp(1.5rem, 3vw, 2.5rem);
    --text-body: clamp(1rem, 2vw, 1.125rem);
    --text-small: clamp(0.75rem, 1.5vw, 0.875rem);
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-bold: 700;
    --leading-tight: 0.95;
    --leading-normal: 1.5;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-s: 1rem;
    --space-m: 2rem;
    --space-l: 3rem;
    --space-xl: 4rem;
    --space-xxl: 6rem;
    --space-xxxl: 8rem;

    /* Container */
    --container-max: 1440px;
    --header-height: 80px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    --transition-page: 0.8s cubic-bezier(0.65, 0, 0.35, 1);

    /* Z-Index */
    --z-base: 1;
    --z-elevated: 10;
    --z-header: 100;
    --z-overlay: 1000;
}

/* ========================================================================
   3. TYPOGRAPHY
   ======================================================================== */

@font-face {
    font-family: 'Akshar';
    src: url('../fonts/Akshar-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Akshar';
    src: url('../fonts/Akshar-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Akshar';
    src: url('../fonts/Akshar-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ========================================================================
   4. HORIZONTAL PAGE SCROLL BASE
   ======================================================================== */

html {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

body {
    font-family: var(--font-primary);
    font-size: var(--text-body);
    line-height: var(--leading-normal);
    color: var(--color-charcoal);
    background: var(--color-white);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================================================
   5. FIXED HEADER
   ======================================================================== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-white);
    z-index: var(--z-header);
    transition: background-color var(--transition-base);
}

.header__inner {
    height: 100%;
    padding: 0 var(--space-m);
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--container-max);
    margin: 0 auto;
}

.header__logo {
    font-size: var(--text-body);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    color: var(--color-black);
    transition: opacity var(--transition-fast);
}

.header__logo:hover {
    opacity: 0.7;
}

.header__menu-btn {
    background: none;
    border: none;
    font-family: var(--font-primary);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: opacity var(--transition-fast);
    color: var(--color-black);
    padding: var(--space-s);
}

.header__menu-btn:hover {
    opacity: 0.7;
}

/* ========================================================================
   6. NAVIGATION OVERLAY
   ======================================================================== */

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-black);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

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

.nav-overlay__header {
    padding: var(--space-m);
    display: flex;
    justify-content: flex-end;
}

.nav-overlay__close {
    background: none;
    border: none;
    font-family: var(--font-primary);
    font-size: var(--text-small);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-white);
    cursor: pointer;
    transition: opacity var(--transition-fast);
    padding: var(--space-s);
}

.nav-overlay__close:hover {
    opacity: 0.7;
}

.nav-overlay__content {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 3rem 0;
    -webkit-overflow-scrolling: touch;
}

.nav-overlay__menu {
    list-style: none;
}

.nav-overlay__item {
    margin: 1rem 0;
}

.nav-overlay__link {
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.1;
    padding: 0;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    color: var(--color-white);
    text-decoration: none;
    transition: opacity var(--transition-fast);
    display: inline-block;
}

.nav-overlay__link:hover {
    opacity: 0.7;
}

/* ========================================================================
   7. MAIN HORIZONTAL CONTAINER
   ======================================================================== */

.main-horizontal {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--header-height));
    overflow-x: auto;
    overflow-y: hidden;
    cursor: grab;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    will-change: scroll-position; /* Optimize for scrolling */
}

.main-horizontal:active {
    cursor: grabbing;
}

/* Hide scrollbar but keep functionality */
.main-horizontal::-webkit-scrollbar {
    height: 8px;
}

.main-horizontal::-webkit-scrollbar-track {
    background: transparent;
}

.main-horizontal::-webkit-scrollbar-thumb {
    background: var(--color-gray-light);
    border-radius: 4px;
}

.main-horizontal::-webkit-scrollbar-thumb:hover {
    background: var(--color-charcoal);
}

.h-wrapper {
    height: 100%;
    width: fit-content;
}

.h-track {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: fit-content;
}

/* ========================================================================
   8. HORIZONTAL SECTIONS
   ======================================================================== */

.h-section {
    flex-shrink: 0;
    height: 100%;
    display: flex;
    position: relative;
    text-decoration: none;
    color: inherit;
    transform: translateZ(0); /* Enable hardware acceleration */
    backface-visibility: hidden; /* Prevent flickering */
}

/* Hero Section - Full Width Split Screen */
.h-section--hero {
    width: 100vw;
}

.h-section--hero .h-section__visual {
    width: 50%;
}

.h-section--hero .h-section__content {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: var(--space-xxl);
    background: var(--color-white);
}

.h-section__content-inner {
    max-width: 600px;
}

.h-section__title--large {
    font-size: var(--text-h1);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: var(--leading-tight);
    margin-bottom: var(--space-m);
}

.h-section__subtitle {
    font-size: var(--text-small);
    font-weight: var(--weight-regular);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-xl);
    opacity: 0.8;
}

/* Card Sections - Half Width */
.h-section--card {
    width: 50vw;
    transition: transform var(--transition-base);
    will-change: transform; /* Optimize hover animation */
}

.h-section--card:hover {
    transform: translateY(-10px) translateZ(0);
}

.h-section--card .h-section__visual {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.h-section--card .h-section__content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-xl);
    color: var(--color-white);
    z-index: var(--z-elevated);
}

.h-section--card .h-section__subtitle {
    display: block;
    font-size: var(--text-small);
    font-weight: var(--weight-regular);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-xs);
    opacity: 0.8;
}

.h-section--card .h-section__title {
    font-size: var(--text-h1);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: var(--leading-tight);
}

.h-section__visual {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.h-section__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform var(--transition-page), opacity 0.5s ease-in-out;
    opacity: 1;
    will-change: transform, opacity; /* Optimize animations */
    transform: translateZ(0); /* Hardware acceleration */
}

/* Lazy loaded images start invisible and fade in */
.h-section__image[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.5s ease-in-out, transform var(--transition-page);
}

.h-section__image[loading="lazy"].loaded {
    opacity: 1;
}

.h-section:hover .h-section__image {
    transform: scale(1.05);
}

.h-section__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0) 100%);
    z-index: var(--z-base);
}

/* Footer Section */
.h-section--footer {
    width: 40vw;
    background: var(--color-black);
    color: var(--color-white);
    padding: var(--space-xxl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer__content {
    text-align: center;
}

.footer__social {
    display: flex;
    gap: var(--space-m);
    justify-content: center;
    margin-bottom: var(--space-xl);
}

.footer__social-link {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    transition: opacity var(--transition-fast);
}

.footer__social-link:hover {
    opacity: 0.7;
}

.footer__social-link svg {
    width: 24px;
    height: 24px;
}

.footer__copyright {
    font-size: var(--text-small);
    opacity: 0.6;
}

/* ========================================================================
   9. BUTTONS
   ======================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-s);
    padding: var(--space-s) var(--space-xl);
    font-family: var(--font-primary);
    font-size: var(--text-body);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn--primary {
    background: var(--color-black);
    color: var(--color-white);
}

.btn--primary:hover {
    background: var(--color-charcoal);
    transform: translateX(5px);
}

.btn__text {
    display: flex;
    gap: 0.25em;
}

.btn__arrow {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
}

.btn:hover .btn__arrow {
    transform: translateX(5px);
}

/* ========================================================================
   10. SCROLL INDICATOR
   ======================================================================== */

.scroll-indicator {
    position: absolute;
    bottom: var(--space-xl);
    left: var(--space-xxl);
    display: flex;
    align-items: center;
    gap: var(--space-s);
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
    animation: fade-in-out 2s ease-in-out infinite;
}

.scroll-indicator__icon {
    width: 20px;
    height: 20px;
    transform: rotate(90deg); /* Rotate arrow to point right for horizontal scroll */
}

@keyframes fade-in-out {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ========================================================================
   11. ACCESSIBILITY
   ======================================================================== */

.keyboard-nav *:focus {
    outline: 2px solid var(--color-black);
    outline-offset: 4px;
}

body:not(.keyboard-nav) *:focus {
    outline: none;
}

.menu-open {
    overflow: hidden;
}

/* ========================================================================
   12. RESPONSIVE
   ======================================================================== */

@media (max-width: 1023px) {
    :root {
        --header-height: 60px;
        --space-xxl: 4rem;
        --space-xxxl: 5rem;
    }

    .h-section--hero .h-section__visual,
    .h-section--hero .h-section__content {
        width: 100%;
    }

    .h-section--hero {
        flex-direction: column;
    }

    .h-section--hero .h-section__visual {
        height: 50%;
    }

    .h-section--hero .h-section__content {
        height: 50%;
        padding: var(--space-l);
    }

    .h-section--card {
        width: 70vw;
    }

    .h-section--footer {
        width: 60vw;
    }
}

@media (max-width: 767px) {
    :root {
        --header-height: 50px;
        --space-xl: 2rem;
        --space-xxl: 3rem;
        --space-xxxl: 4rem;
    }

    .header__inner {
        padding: 0 var(--space-s);
    }

    .h-section--hero .h-section__content {
        padding: var(--space-m);
    }

    .h-section--card {
        width: 90vw;
    }

    .h-section--card .h-section__content {
        padding: var(--space-l);
    }

    .h-section--footer {
        width: 90vw;
        padding: var(--space-xl);
    }

    .footer__social {
        gap: var(--space-s);
    }

    .footer__social-link {
        width: 32px;
        height: 32px;
    }

    .footer__social-link svg {
        width: 20px;
        height: 20px;
    }

    .scroll-indicator {
        left: var(--space-l);
        bottom: var(--space-l);
    }

    .nav-overlay__link {
        font-size: var(--text-h2);
    }
}

/* ========================================================================
   13. ANIMATIONS
   ======================================================================== */

.page-loaded .h-section {
    animation: fade-in 0.8s ease forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
