/* =========================================
   LAYOUT & GLOBAL STYLES
   Role: Global regions (Header, Footer) and Scaffolding
   Order: Global > Header > Main > Footer > Widgets > Responsive
   ========================================= */

/* -----------------------------------------
   1. GLOBAL & ACCESSIBILITY
   ----------------------------------------- */

/* Skip Link */
.skip-link {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-link:focus {
    position: fixed;
    top: 10px;
    left: 10px;
    width: auto;
    height: auto;
    background: var(--primary-blue);
    color: white;
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    font-weight: 800;
    z-index: 10000;
    border-radius: 8px;
    border: 2px solid var(--navy-dark);
    box-shadow: var(--tactile-shadow-m);
    overflow: visible;
}

/* Interaction Focus States */
*:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 3px;
}

/* Base Body/Main */
body {
    padding-bottom: 0;
}

main {
    padding-top: var(--header-padding);
    background-color: var(--bg-white);
}

/* -----------------------------------------
   2. HEADER & NAVIGATION (Global)
   ----------------------------------------- */
.header-index {
    background-color: var(--navy-dark);
    padding: 1.5rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.header-index-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header-index-wrapper img {
    width: 80px;
    height: auto;
    transition: width 0.3s ease;
}

.header-index.scrolled {
    padding: 0.75rem 0;
}

.header-index.scrolled img {
    width: 60px;
}

/* Mobile Navigation Drawer */
.header-index-wrapper nav,
.cs-header nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    height: 100vh;
    background: var(--navy-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: right 0.3s ease;
    z-index: 999;
}

.header-index-wrapper nav.active,
.cs-header nav.active {
    right: 0;
}

.header-index-wrapper nav ul,
.cs-header nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    text-align: center;
}

.header-index-wrapper nav ul a,
.cs-header nav ul a {
    color: var(--bg-white);
    font-size: 1.8rem;
    text-decoration: none;
    font-weight: 800;
}

/* Page Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    display: none;
}

.menu-overlay.active {
    display: block;
}

/* Hamburger Menu */
.hamburger {
    display: block;
    width: 32px;
    height: 24px;
    position: relative;
    cursor: pointer;
    z-index: 1001;
    background: none;
    border: none;
    padding: 0;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 4px;
    background: var(--bg-white);
    position: absolute;
    left: 0;
    transition: all 0.3s ease;
    border-radius: 4px;
}

/* Case Study specific hamburger overrides */
.cs-header .hamburger span {
    background: var(--bg-white);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.hamburger span:nth-child(1) {
    top: 0;
}

.hamburger span:nth-child(2) {
    top: 10px;
}

.hamburger span:nth-child(3) {
    top: 20px;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
}


/* -----------------------------------------
   3. FOOTER
   ----------------------------------------- */
.footer {
    background-color: var(--bg-white);
    color: var(--navy-dark);
    transition: all 0.8s ease;
    padding: var(--section-padding-mobile);
    text-align: center;
    position: relative;
    z-index: 1;
    box-shadow: inset 0 20px 40px rgba(0, 0, 0, 0.03);
}

.footer h1 {
    margin-bottom: 1.5rem;
}

.footer h2 {
    margin-bottom: 2rem;
}

.footer.is-active {
    background-color: var(--navy-dark);
    color: var(--bg-white);
    box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.3);
}

.footer.is-active h1,
.footer.is-active a {
    color: var(--bg-white);
}

.footer-credit {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.footer.is-active .footer-credit {
    border-top-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

/* -----------------------------------------
   4. UI WIDGETS
   ----------------------------------------- */

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-left: var(--border-main);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-white);
    border: var(--border-main);
    box-shadow: var(--tactile-shadow-xs);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-tech-grey);
}

/* Back To Top Button */
#backToTop {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 20px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-blue);
    color: var(--bg-white);
    border: var(--border-main);
    cursor: pointer;
    box-shadow: var(--tactile-shadow);
    transform: translate(-2px, -2px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.1s ease, opacity 0.3s ease;
    z-index: 2000;
}

#backToTop:hover {
    transform: translate(-3px, -3px);
    box-shadow: var(--tactile-shadow-ml);
    background: var(--accent-yellow);
    color: var(--navy-dark);
}

#backToTop.visible {
    opacity: 1;
    pointer-events: auto;
}

#backToTop .arrow {
    font-size: 1.2rem;
}

#backToTop .text {
    font-size: 0.6rem;
    font-weight: 700;
    display: none;
}

/* Scroll Crank Animation */
.scroll-crank-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    pointer-events: none;
    display: none;
    /* Hidden on mobile */
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.crank-wheel {
    width: 45px;
    height: 45px;
    border: 2px solid var(--navy-dark);
    border-radius: 50%;
    background: var(--bg-white);
    position: relative;
    box-shadow: var(--tactile-shadow-s);
}

/* Pivot */
.crank-wheel::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: var(--navy-dark);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

/* Arm */
.crank-wheel::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 16px;
    background: var(--navy-dark);
    transform: translate(-50%, 0);
}

.crank-knob {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-yellow);
    border: 2px solid var(--navy-dark);
    border-radius: 50%;
    top: 80%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.crank-label {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--navy-dark);
}

/* =========================================
   5. RESPONSIVE MEDIA QUERIES
   ========================================= */

/* Tablet (768px+) */
@media (min-width: 768px) {

    /* Global */
    body {
        padding-bottom: 0;
    }

    /* Header & Navigation */
    .header-index {
        padding: 2.5rem 0;
    }

    .header-index-wrapper {
        padding: 0 1.5rem;
    }

    .header-index-wrapper img {
        width: 120px;
    }

    .header-index.scrolled img {
        width: 80px;
    }

    /* Show Desktop Nav, Hide Hamburger */
    .hamburger {
        display: none;
    }

    .header-index-wrapper nav {
        display: block;
        position: static;
        width: auto;
        height: auto;
        background: transparent;
        z-index: auto;
    }

    .header-index-wrapper nav ul {
        flex-direction: row;
        gap: 0.75rem;
        background: var(--bg-tech-grey);
        padding: 0.4rem;
        border-radius: 50px;
        border: var(--border-main);
        box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.1), 4px 4px 0px rgba(0, 0, 0, 0.2);
    }

    .header-index-wrapper nav ul a {
        font-size: 1rem;
        padding: 0.6rem 1.2rem;
        border-radius: 50px;
        transition: all 0.2s ease;
        display: inline-block;
        color: var(--navy-dark);
        font-weight: 800;
        text-decoration: none;
    }

    .header-index-wrapper nav ul a:hover {
        background: var(--bg-white);
        transform: translate(-1px, -1px);
        box-shadow: var(--tactile-shadow-xs);
    }

    .header-index-wrapper nav ul a.active-nav {
        background: var(--primary-blue);
        color: var(--bg-white);
        border: 2px solid var(--navy-dark);
        box-shadow: var(--tactile-shadow-s);
    }

    /* Footer */
    .footer {
        padding: var(--section-padding-desktop);
    }

    .footer h1 {
        margin-bottom: 2rem;
    }

    .footer h2 {
        margin-bottom: 2.5rem;
    }

    /* Widgets */
    ::-webkit-scrollbar {
        width: 14px;
    }

    #backToTop {
        display: flex;
        bottom: 25px;
        left: 25px;
        padding: 10px 12px;
        border-radius: 12px;
        width: auto;
        height: auto;
    }

    #backToTop .arrow {
        font-size: 1.4rem;
    }

    #backToTop .text {
        font-size: 0.7rem;
        display: block;
    }

    .scroll-crank-container {
        display: flex;
        bottom: 25px;
        right: 25px;
    }

    .crank-wheel {
        width: 50px;
        height: 50px;
    }

    .crank-knob {
        width: 12px;
        height: 12px;
    }

    .crank-label {
        font-size: 0.7rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {

    /* Header */
    .header-index {
        padding: 4.5rem 0;
    }

    .header-index-wrapper {
        padding: 0 2rem;
    }

    .header-index-wrapper img {
        width: 150px;
    }

    .header-index.scrolled {
        padding: 1rem 0;
    }

    .header-index.scrolled img {
        width: 100px;
    }

    .header-index.scrolled nav ul a {
        font-size: 1rem;
    }

    .header-index-wrapper nav ul {
        gap: 1rem;
        padding: 0.5rem;
    }

    .header-index-wrapper nav ul a {
        font-size: 1.2rem;
        padding: 0.6rem 1.4rem;
    }

    /* Footer */
    .footer {
        padding: var(--section-padding-desktop);
    }

    .footer h1 {
        margin-bottom: 2rem;
    }

    .footer h2 {
        margin-bottom: 3rem;
    }

    /* Widgets */
    ::-webkit-scrollbar {
        width: 16px;
    }

    ::-webkit-scrollbar-thumb {
        box-shadow: var(--tactile-shadow-m);
    }

    #backToTop {
        bottom: 30px;
        left: 30px;
        padding: 12px 15px;
        gap: 4px;
    }

    #backToTop:hover {
        transform: translate(-4px, -4px);
        box-shadow: var(--tactile-shadow-ml);
    }

    #backToTop .arrow {
        font-size: 1.5rem;
    }

    #backToTop .text {
        font-size: 0.75rem;
    }

    .scroll-crank-container {
        bottom: 30px;
        right: 30px;
        gap: 10px;
    }

    .crank-wheel {
        width: 60px;
        height: 60px;
        border-width: 3px;
        box-shadow: var(--tactile-shadow-m);
    }

    .crank-wheel::before {
        width: 8px;
        height: 8px;
    }

    .crank-wheel::after {
        width: 4px;
        height: 22px;
    }

    .crank-knob {
        width: 14px;
        height: 14px;
    }

    .crank-label {
        font-size: 0.75rem;
        letter-spacing: 1px;
    }
}