/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #0a0a0c;
}
::-webkit-scrollbar-thumb {
    background: #2a2a35;
    border: 1px solid #0a0a0c;
}
::-webkit-scrollbar-thumb:hover {
    background: #7f13ec;
}

/* Efectos visuales */
.scanline {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1));
    background-size: 100% 4px;
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

/* Navegación */
.nav-link {
    position: relative;
}
.nav-link::before {
    content: '[';
    position: absolute;
    left: -12px;
    opacity: 0;
    transition: all 0.2s;
    color: #fbbf24;
    font-family: 'Space Mono', monospace;
}
.nav-link::after {
    content: ']';
    position: absolute;
    right: -12px;
    opacity: 0;
    transition: all 0.2s;
    color: #fbbf24;
    font-family: 'Space Mono', monospace;
}
.nav-link:hover::before,
.nav-link:hover::after {
    opacity: 1;
}
.nav-link:hover::before {
    left: -18px;
}
.nav-link:hover::after {
    right: -18px;
}

/* Comportamiento general */
html {
    scroll-behavior: smooth;
}

header {
    transition: transform 0.28s ease, opacity 0.28s ease;
    will-change: transform;
}

.header-hidden {
    transform: translateY(-110%);
}

/* Utilidades para Proyectos y Layout */
.tech-border {
    position: relative;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}

.chip-border {
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.full-bleed {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
}

.projects-injected {
    margin-bottom: 3rem;
}

.projects-spacer {
    height: 4rem;
    width: 100%;
}

@media (min-width: 768px) {
    .projects-spacer {
        height: 6rem;
    }
}

main > section {
    min-height: calc(100vh - 5rem);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Responsive fixes: avoid horizontal clipping on small screens */
html {
    box-sizing: border-box;
}
*, *::before, *::after {
    box-sizing: inherit;
}

/* Allow long words and headings to wrap instead of overflowing */
p, h1, h2, h3, h4, a, span, li, button {
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

/* Remove decorative clip-paths and add safe padding on narrow viewports */
@media (max-width: 640px) {
    body {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    header, main, footer {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    /* Many decorative borders use clip-path which can visually cut content on very small screens */
    .clip-path-polygon, .tech-border, .chip-border {
        clip-path: none !important;
        -webkit-clip-path: none !important;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    /* Ensure absolutely positioned decorative elements don't push text outside viewport */
    .group > .absolute, .relative > .absolute {
        left: 0.5rem !important;
        right: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }

    /* Scale very large headings down slightly for small screens */
    .text-5xl { font-size: 2.25rem; }
    .text-7xl { font-size: 3rem; }
}

/* Additional mobile fixes for flex/grid children and container padding */
@media (max-width: 640px) {
    /* Ensure centered containers keep inner padding */
    .max-w-\[1200px\], .max-w-\[1000px\] {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Allow flex and grid children to shrink and wrap properly */
    .flex > *, .grid > * {
        min-width: 0 !important;
    }

    /* Ensure images scale within their containers */
    img {
        max-width: 100% !important;
        height: auto !important;
        display: block;
    }

    /* Make large headings wrap and not force horizontal overflow */
    h1, h2, h3, h4, .text-4xl, .text-5xl, .text-7xl {
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
    }

    /* If anything still overflows, allow horizontal scroll rather than clipping */
    body.overflow-x-hidden {
        overflow-x: auto !important;
    }
}

/* Prevent headings from breaking mid-word on large screens */
@media (min-width: 1024px) {
    h1, h2, h3, h4,
    .text-4xl, .text-5xl, .text-7xl {
        overflow-wrap: normal !important;
        word-break: normal !important;
        hyphens: none !important;
        white-space: normal !important;
    }

    /* Restore normal wrapping for inline elements at large sizes */
    p, a, span, li, button {
        overflow-wrap: normal !important;
        word-break: normal !important;
    }
}

/* Make the experience section title match the projects title size for visual consistency */
#experience .flex.items-end h3 {
    font-size: 2.25rem; /* matches Tailwind's text-4xl */
    line-height: 1;
}

@media (min-width: 768px) {
    #experience .flex.items-end h3 {
        font-size: 2.25rem; /* keep consistent on md+ */
    }
}

/* Subtle pulse for active/ongoing items */
@keyframes pulse-weak {
    0% {
        box-shadow: 0 0 0 0 rgba(99,102,241,0);
    }
    50% {
        box-shadow: 0 18px 40px -22px rgba(99,102,241,0.14);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(99,102,241,0);
    }
}

.pulse-weak {
    animation: pulse-weak 3.2s ease-in-out infinite;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .pulse-weak {
        animation: none !important;
        box-shadow: none !important;
    }
}

/* Mobile menu icon swap using aria-expanded to avoid overlapping/visible close icon */
#mobile-menu-btn .icon-close {
    display: none;
}
#mobile-menu-btn .icon-menu {
    display: inline-block;
    
}
#mobile-menu-btn .icon-menu,
#mobile-menu-btn .icon-close {
    line-height: 1;
    vertical-align: middle;
}
#mobile-menu-btn[aria-expanded="true"] .icon-menu {
    display: none;
    transform: translate(-50%, -50%);
    transition: opacity 200ms ease, transform 200ms ease;
}
#mobile-menu-btn[aria-expanded="true"] .icon-close {
    display: inline-block;
    transition: opacity 200ms ease, transform 200ms ease;
}

/* Small transition for icon swap */
#mobile-menu-btn .icon-menu, #mobile-menu-btn .icon-close {
    transition: opacity 160ms ease, transform 160ms ease;
}