/* Base */
* {
    scroll-behavior: smooth;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

/* Animations */
@keyframes colorCycle {
    0% { color: #ffffff; }
    25% { color: #fcbf49; }
    50% { color: #80ed99; }
    75% { color: #a29bfe; }
    100% { color: #ffffff; }
}

@keyframes typing {
    from { width: 0; }
    to { width: 63ch; }
}

@keyframes blink-caret {
    0%, 100% { border-color: white; }
    50% { border-color: transparent; }
}

/* Index components */
header {
    background: linear-gradient(135deg, #6fb2d6, #234b83);
    color: white;
    padding: 3rem 1rem 2rem;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 2.8rem;
    animation: colorCycle 6s infinite;
}

#subtitulo {
    display: inline-block;
    font-size: 1.2rem;
    margin-top: 0.5rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid white;
    width: 0;
    animation: typing 4s steps(83, end) forwards, blink-caret 0.75s step-end infinite;
    animation-delay: 0s, 4s;
    animation-fill-mode: forwards, none;
}

nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85); /* Glassmorphism */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

nav a {
    text-decoration: none;
    color: #2b2d42;
    font-weight: 600;
    font-size: 1.05rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 3px;
    bottom: -2px;
    left: 50%;
    background-color: #6fb2d6;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform: translateX(-50%);
    border-radius: 2px;
}

nav a:hover {
    color: #234b83;
    background: rgba(111, 178, 214, 0.1);
}

nav a:hover::after {
    width: 80%;
}

@media (max-width: 600px) {
    nav {
        gap: 0.5rem;
        padding: 0.8rem 1rem;
        flex-wrap: wrap;
    }
    nav a {
        font-size: 0.95rem;
        padding: 0.4rem 0.6rem;
    }
}

main section {
    max-width: 900px;
    margin: 4rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    scroll-margin-top: 60px;
}

h2 {
    color: #2b2d42;
}

footer {
    text-align: center;
    padding: 1rem;
    background-color: #2b2d42;
    color: white;
}

#contacto a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

#contacto a[href^="mailto"] { background-color: #e63946; }
#contacto a[href*="linkedin.com"] { background-color: #0077b5; }
#contacto a[href*="github.com"] { background-color: #333; }

#contacto a[href^="mailto"]:hover {
    background-color: #c62828;
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.6);
    transform: scale(1.05);
}
#contacto a[href*="linkedin.com"]:hover {
    background-color: #005582;
    box-shadow: 0 4px 12px rgba(0, 85, 130, 0.6);
    transform: scale(1.05);
}
#contacto a[href*="github.com"]:hover {
    background-color: #1a1a1a;
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.6);
    transform: scale(1.05);
}

.fade-in-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.fade-in-section.visible {
    opacity: 1;
    transform: none;
}

#scrollTopBtn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #2b2d42;
    color: white;
    border: none;
    padding: 10px 14px;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    z-index: 999;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#scrollTopBtn:hover {
    background-color: #1e1f32;
}

/* Project cards */
.projects-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1rem;
    padding: 1rem 0;
}

.project-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
    width: 250px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    color: inherit;
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-card img {
    width: 100%;
    height: 150px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    object-fit: cover;
}

.project-card h3 {
    margin: 0.5rem 0 0;
}

.project-card p {
    padding: 0 0.5rem 1rem;
    font-size: 0.9rem;
    color: #666;
}

@media (max-width: 600px) {
    header h1 { font-size: 2rem; }
    #subtitulo { font-size: 1rem; }
}

/* Proyecto Challenge components */
.header-sub {
    background: linear-gradient(135deg, #98c1d9, #3d5a80);
    padding: 2.5rem 2rem;
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    color: #f0f0f0;
    border-bottom: 4px solid #293241;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.header-title-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.header-sub h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
    animation: colorCycle 6s infinite;
}

.content {
    max-width: 1200px;
    margin: 2rem auto;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    line-height: 1.6;
}

.img-wrapper {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

img.project-img {
    max-width: 70%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: zoom-in;
    transition: transform 0.4s ease, box-shadow 0.3s ease;
}

img.project-img:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Modal and Floating Button */
#imgModal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

#modalImg {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.floating-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #e0fbfc;
    color: #293241;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s, transform 0.3s;
    z-index: 10000;
}

.floating-button:hover {
    background-color: #c2e1ec;
    transform: scale(1.05);
}

.header-sub a {
    display: none;
}
