/* ================================================================
   POLISH.CSS — Final pass: loader, cursor, progress, back-to-top,
   hamburger, mobile fixes, accessibility, consistency
   ================================================================ */

/* ================================================================
   PAGE LOAD — CINEMATIC LOADER
   ================================================================ */

/* Hide all content until loader exits (prevents FOUC) */
body.loading {
    overflow: hidden;
}
body.loading > *:not(#page-loader):not(#cursor-dot):not(#cursor-ring):not(#scroll-progress) {
    visibility: hidden;
}

/* Loader full-screen overlay */
#page-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #0d0d10;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    will-change: transform;
}

/* Curtain-exit state — slides up off screen */
#page-loader.exiting {
    transition: transform 0.7s cubic-bezier(0.76, 0, 0.24, 1);
    transform: translateY(-100%);
    pointer-events: none;
}

/* Content wrapper (centered column) */
.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* ── KS Logo ── */
.loader-ks {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 72px;
    color: #f0f0f5;
    letter-spacing: 0.5em;
    opacity: 0;
    transform: translateY(0);
    transition:
        opacity 0.4s ease,
        letter-spacing 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    line-height: 1;
    user-select: none;
}
.loader-ks.visible {
    opacity: 1;
    letter-spacing: 0.05em;
}
/* Gentle pulse in phase 3 */
.loader-ks.pulse {
    animation: loader-pulse 0.5s ease-in-out;
}
@keyframes loader-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}
/* Fade out in phase 4 */
.loader-ks.fade-out {
    transition: opacity 0.15s ease;
    opacity: 0;
}

/* ── Horizontal line ── */
.loader-line {
    height: 1px;
    width: 0;
    background: #e8473f;
    margin-top: 14px;
    box-shadow: 0 0 6px rgba(232, 71, 63, 0.5);
    transition: width 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.loader-line.expand {
    width: min(220px, 60vw);
}
.loader-line.collapse {
    transition: width 0.1s ease;
    width: 0;
}

/* ── Role text ── */
.loader-role {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #e8473f;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 10px;
    min-height: 16px;
    opacity: 1;
    transition: opacity 0.15s ease;
}
.loader-role.fade-out {
    opacity: 0;
}

/* ── Navbar & hero entrance (triggered by JS after loader exits) ── */
.navbar {
    transform: translateY(-100%);
    transition:
        transform 0.6s var(--ease-out) 0.4s,
        padding var(--transition-base),
        background-color var(--transition-base),
        box-shadow var(--transition-base);
}
.navbar.nav-visible {
    transform: translateY(0);
}

/* Hero entrance — only fires on first visit when loader is active */
body.loading .hero-layer-fg {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
#home.hero-content-visible .hero-layer-fg {
    opacity: 1;
    transform: translateY(0);
}



/* ================================================================
   SCROLL PROGRESS BAR
   ================================================================ */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background: #e8473f;
    z-index: 99998;
    transition: width 0.1s linear;
    pointer-events: none;
    box-shadow: 0 0 8px rgba(232, 71, 63, 0.6);
}

/* ================================================================
   BACK TO TOP BUTTON
   ================================================================ */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    background: #e8473f;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.25s ease;
    border-radius: 0;
}
#back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}
#back-to-top:hover {
    background: #ff5a52;
    transform: translateY(-2px);
}
#back-to-top svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* ================================================================
   CUSTOM CURSOR (desktop only)
   ================================================================ */
@media (hover: hover) and (pointer: fine) {
    body { cursor: none; }
    a, button, [onclick], label, select, textarea, input { cursor: none; }

    #cursor-dot {
        position: fixed;
        width: 8px;
        height: 8px;
        background: #e8473f;
        border-radius: 50%;
        pointer-events: none;
        z-index: 99999;
        transform: translate(-50%, -50%);
        transition: width 0.2s ease, height 0.2s ease, background 0.2s ease;
        will-change: transform;
    }
    #cursor-ring {
        position: fixed;
        width: 28px;
        height: 28px;
        border: 1.5px solid rgba(232, 71, 63, 0.5);
        border-radius: 50%;
        pointer-events: none;
        z-index: 99998;
        transform: translate(-50%, -50%);
        will-change: transform;
        transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease, background 0.3s ease;
    }
    body.cursor-hover #cursor-dot {
        width: 12px;
        height: 12px;
        background: #ff5a52;
    }
    body.cursor-hover #cursor-ring {
        width: 40px;
        height: 40px;
        border-color: rgba(232, 71, 63, 0.3);
        background: rgba(232, 71, 63, 0.06);
    }
}

/* ================================================================
   HAMBURGER MENU
   ================================================================ */
.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 4px;
    background: none;
    border: none;
    z-index: 1100;
}
.nav-hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease;
    transform-origin: center;
}
.nav-hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-hamburger.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.nav-hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile overlay menu */
.nav-mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(13, 13, 16, 0.96);
    backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.nav-mobile-overlay.open {
    opacity: 1;
    pointer-events: all;
}
.nav-mobile-overlay a {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(36px, 8vw, 64px);
    color: var(--text-secondary);
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 0.6rem 0;
    transition: color 0.2s ease, letter-spacing 0.2s ease;
    display: block;
    text-align: center;
}
.nav-mobile-overlay a:hover,
.nav-mobile-overlay a.active {
    color: #e8473f;
    letter-spacing: 5px;
}
.nav-mobile-overlay .nav-mobile-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}

/* ================================================================
   MOBILE RESPONSIVENESS
   ================================================================ */
@media (max-width: 768px) {
    /* Show hamburger, hide desktop links + CTA */
    .nav-hamburger { display: flex; }
    .nav-links { display: none; }
    .navbar > .btn { display: none; }

    /* Hero */
    .hero { min-height: 90svh; }

    /* About grid */
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
    .about-col-image { min-height: 280px; }
    .about-counters { flex-wrap: wrap; gap: 1rem; }
    .about-counter { flex: 1 1 40%; }

    /* Skills */
    .skills-grid { grid-template-columns: 1fr !important; }

    /* Timeline */
    .timeline-wrap { padding-left: 0; }
    .tl-item { flex-direction: column; }

    /* Projects */
    .proj-grid { grid-template-columns: 1fr !important; }
    .proj-filters { flex-wrap: wrap; gap: 0.5rem; }

    /* Contact */
    .cf-row { grid-template-columns: 1fr !important; }

    /* Footer */
    .footer-main {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .footer-socials { justify-content: center; }

    /* Back-to-top smaller on mobile */
    #back-to-top { bottom: 1rem; right: 1rem; }
}

@media (max-width: 480px) {
    .contact-heading .ch-get,
    .contact-heading .ch-touch {
        font-size: clamp(44px, 16vw, 72px);
    }
    .tl-counters { grid-template-columns: 1fr 1fr; }
}

/* ================================================================
   ACCESSIBILITY — Focus rings
   ================================================================ */
:focus-visible {
    outline: 2px solid #e8473f;
    outline-offset: 3px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #e8473f;
    outline-offset: 3px;
}

/* ================================================================
   CONSISTENCY — section padding
   ================================================================ */
section.container {
    padding-top: 100px;
    padding-bottom: 100px;
}

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
    #scroll-progress,
    #back-to-top,
    #cursor-dot,
    #cursor-ring,
    .nav-mobile-overlay,
    #page-loader { display: none !important; }
}
