* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background 0.7s ease, color 0.7s ease, border-color 0.7s ease;
}

:root {
    --text-color: #FFF;
    --color: #4FA3C5;
    --first: #FFF;
    --second: #000;
    --mob-color: #6a6e73;
    --bg-color: #1e1f26;
    --box-bg: #2b2d3a;
    --clr-bg: #3a3d4a;
    --place-clr: #aeb3c1;
}

body.dark-mode {
    --text-color: #2b2b2b;
    --first: #2b2b2b;
    --second: #ffffff;
    --mob-color: #e8e8e8;
    --bg-color: #f6f6f8;
    --box-bg: #eaeaea;
    --clr-bg: #ededed;
    --place-clr: #7a7a7a;
}

body {
    background: var(--bg-color);
}

section {
    min-height: 60vh; /* Reduced from 100vh for flexibility */
    padding: clamp(4rem, 8vw, 6rem) 5% clamp(2rem, 5vw, 3rem); /* Responsive padding */
    margin-bottom: clamp(2rem, 5vw, 3rem); /* Increased margin for better separation */
}

/* Container */
.container {
    max-width: 1250px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- HEADER --- */
header {
    top: 0;
    left: 0;
    height: 90px;
    width: 100%;
    position: fixed;
    z-index: 99;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--clr-bg);
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* --- LOGO --- */
.logo {
    z-index: 1;
}

.logo a {
    text-decoration: none;
    font-size: 32px;
    font-weight: 600;
    color: var(--first);
}

.logo span {
    color: var(--color);
}

/* --- MENU --- */
.list-darkmode-menu {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

.list-darkmode-menu ul {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 35px;
    font-size: 18px;
    list-style: none;
    z-index: 1;
}

.list-darkmode-menu li a {
    position: relative;
    text-decoration: none;
    font-size: 18px;
    color: var(--first);
    font-weight: 500;
    transition: 0.3s ease;
}

.list-darkmode-menu li a:hover {
    color: var(--color);
}

.list-darkmode-menu li a::before {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 0;
    width: 0;
    height: 2.5px;
    background: var(--color);
    transition: width .3s ease;
}

.list-darkmode-menu li a:hover::before {
    width: 100%;
}

.mode {
    color: var(--text-color);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    user-select: none;
}

/* Ocultamos el input */
.mode input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Íconos de sol y luna */
.mode .fa-sun,
.mode .fa-moon {
    position: absolute;
    transition: all 0.5s ease;
    opacity: 0;
    transform: scale(0) rotate(-180deg);
}

/* Sol visible por defecto */
.mode .fa-sun {
    opacity: 1;
    transform: scale(1) rotate(0);
    color: #FFD43B;
}

/* Cuando se activa el modo oscuro */
.mode input:checked~.fa-sun {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

.mode input:checked~.fa-moon {
    opacity: 1;
    transform: scale(1) rotate(0);
    color: #C3C8FF;
}

.mode .fa-sun,
.mode .fa-moon {
    animation: fadeInRotate 0.5s ease;
}

/* Animación sutil de aparición */
@keyframes fadeInRotate {
    0% {
        transform: rotate(-180deg) scale(0);
        opacity: 0;
    }

    100% {
        transform: rotate(0deg) scale(1);
        opacity: 1;
    }
}

/* --- HAMBURGER MENU --- */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 100;
}

.hamburger .bar {
    width: 100%;
    height: 3px;
    background: var(--first);
    transition: all 0.3s ease;
}

/* Animación del menú hamburguesa al abrir/cerrar */
.hamburger.active .bar:nth-child(2) {
    opacity: 0;
}

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

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

/* -- Profile -- */
.home {
    padding-top: clamp(8rem, 12vw, 20rem);
}

.home .home-info {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: clamp(2rem, 5vw, 3rem); /* Reduced and responsive */
    gap: 2rem;
}

.home-info .left {
    flex: 1;
    max-width: 600px;
}

.home-info .left h3 {
    font-size: clamp(1.5rem, 4vw, 1.8rem);
    font-weight: bold;
    letter-spacing: 0.5px;
    color: var(--first);
}

.home-info .left h1 {
    font-size: clamp(2.5rem, 6vw, 3.2rem);
    color: var(--first);
    margin: 10px 0;
}

.home-info .left h4 {
    font-size: clamp(1.4rem, 3.5vw, 1.8rem);
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--first);
}

.home-info .left h4 span {
    color: var(--color);
}

.home-info .left p {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 500;
    line-height: 1.6;
    color: var(--first);
    text-align: justify;
    max-width: 100%; /* Fixed overflow */
    margin-bottom: 15px;
}

.home-info .right {
    flex: 1;
    display: flex;
    justify-content: center;
}

.home-info .right .profile img {
    width: clamp(200px, 45vw, 300px);
    height: clamp(200px, 45vw, 300px);
    object-fit: cover;
    object-position: top;
    border-radius: 50%;
    background: var(--bg-color);
    border: 3px solid var(--color);
    box-shadow: 0 0 40px var(--color);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.home-info .right .profile img:hover {
    transform: scale(1.05);
    box-shadow: 0 0 80px var(--color);
}

.social {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.social a {
    width: clamp(40px, 10vw, 48px);
    height: clamp(40px, 10vw, 48px);
    border-radius: 50%;
    border: 2px solid var(--color);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--color);
    font-size: clamp(1.2rem, 3vw, 1.4rem);
    transition: all 0.3s ease;
    background: transparent;
}

.social a:hover {
    background: var(--color);
    color: var(--second);
    transform: translateY(-4px);
    box-shadow: 0 0 15px var(--color);
}

/* --- ABOUT SECTION --- */
.about-section {
    background: var(--bg-color);
    color: var(--first);
}

h2 {
    font-size: clamp(2rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--first);
    margin: 0 auto 40px;
    text-align: center;
    width: 100%;
    border-bottom: 2px solid var(--color);
    padding-bottom: 10px;
    max-width: 300px;
    animation: fadeIn 1s ease-in;
}

h2 span {
    color: var(--color);
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.about-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 40px;
    margin: clamp(2rem, 5vw, 3rem) 0; /* Consistent with section margin */
}

.about-text {
    flex: 1 1 45%;
    min-width: 300px;
}

.about-text h3 {
    font-size: clamp(1.5rem, 3.5vw, 1.8rem);
    font-weight: 600;
    color: var(--place-clr);
    margin-bottom: 15px;
}

.about-text .highlight {
    color: var(--color);
    font-weight: bold;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin-bottom: 15px;
    display: block;
}

.about-text p {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    line-height: 1.6;
    color: var(--first);
    margin-bottom: 15px;
}

.skills {
    flex: 1 1 45%;
    min-width: 300px;
}

.skills h3 {
    font-size: clamp(1.5rem, 3.5vw, 1.8rem);
    font-weight: 600;
    color: var(--place-clr);
    margin-bottom: 15px;
    text-align: center;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.skill-card {
    background: var(--box-bg);
    text-align: center;
    padding: 25px 0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.skill-card:hover {
    background: var(--color);
    transform: translateY(-5px);
}

.skill-card i {
    font-size: clamp(2rem, 5vw, 2.5rem);
    color: var(--first);
    margin-bottom: 10px;
}

.skill-card span {
    display: block;
    font-weight: bold;
    color: var(--first);
}

/* --- SERVICES SECTION --- */
.services-section {
    background-color: var(--bg-color); /* Aligned with other sections */
    color: var(--first);
    text-align: center;
}

.services-section h2 {
    margin-bottom: clamp(2rem, 5vw, 3rem); /* Consistent spacing */
}

.subtitle {
    color: var(--place-clr);
    margin-bottom: clamp(1.5rem, 4vw, 2rem);
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.services-grid {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.service-card {
    background-color: var(--box-bg);
    border-radius: 12px;
    padding: 40px 25px;
    width: clamp(250px, 30vw, 280px);
    text-align: center;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.05);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.service-card:hover {
    transform: translateY(-8px);
    border-color: var(--color);
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.3);
}

.service-card i {
    font-size: clamp(2.5rem, 6vw, 3rem);
    color: var(--color);
    margin-bottom: 20px;
}

.service-card h3 {
    font-size: clamp(1.2rem, 3vw, 1.3rem);
    margin-bottom: 10px;
    color: var(--first);
}

.service-card p {
    color: var(--place-clr);
    font-size: clamp(0.85rem, 2.2vw, 0.95rem);
    line-height: 1.5;
}

/* --- PORTFOLIO --- */
.portfolio {
    background-color: var(--bg-color);
    color: var(--first);
    text-align: center;
}

.portfolio h2 {
    margin-bottom: clamp(2rem, 5vw, 3rem);
}

.portfolio-grid {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.portfolio-card {
    position: relative;
    width: clamp(250px, 30vw, 300px);
    height: clamp(250px, 30vw, 300px);
    border-radius: 15px;
    overflow: hidden;
    background-color: var(--box-bg);
    border: 1px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.05);
    margin: 10px;
}

.portfolio-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease, opacity .3s ease;
}

.portfolio-card:hover {
    transform: translateY(-8px);
    border-color: var(--color);
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.3);
}

.portfolio-card:hover img {
    transform: scale(1.1);
    opacity: 0.3;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--first);
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(0, 0, 0, 0.6);
    padding: 20px;
}

.portfolio-card:hover .overlay {
    opacity: 1;
}

.overlay h3 {
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    font-weight: 600;
    color: var(--color);
    margin-bottom: 10px;
}

.overlay p {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: var(--place-clr);
    margin-bottom: 15px;
}

.portfolio-btn {
    display: inline-block;
    padding: 8px 18px;
    background-color: var(--color);
    color: var(--second);
    border-radius: 20px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.portfolio-btn:hover {
    background-color: #00ccff;
    transform: scale(1.05);
}

/* --- CONTACT --- */
.contact form {
    max-width: 640px;
    margin: clamp(1rem, 3vw, 1.5rem) auto clamp(2rem, 5vw, 3rem);
    text-align: center;
}

.contact .input-box {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1em;
}

.contact .input-box input {
    width: 48%;
    padding: 1em;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: var(--first);
    background: var(--clr-bg);
    border: none;
    outline: none;
    border-radius: 8px;
    margin: 8px 0;
}

.contact .input-box input::placeholder {
    color: var(--place-clr);
}

.contact textarea {
    width: 100%;
    padding: 15px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: var(--first);
    background: var(--clr-bg);
    border: none;
    outline: none;
    resize: none;
    border-radius: 8px;
    margin: 8px 0;
}

.contact textarea::placeholder {
    color: var(--place-clr);
}

.contact button {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 600;
    padding: 12px 30px;
    margin-top: 1.5em;
    border-radius: 30px;
    color: var(--first);
    background: var(--color);
    border: none;
    outline: none;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease-in-out;
}

.contact button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #2575fc, #6a11cb);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    section {
        padding: clamp(3rem, 6vw, 4rem) 5% clamp(1.5rem, 4vw, 2rem);
        margin-bottom: clamp(1.5rem, 4vw, 2rem);
    }

    .hamburger {
        display: flex;
    }

    .list-darkmode-menu {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        width: 250px;
        background: var(--box-bg);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s ease;
        z-index: 99;
    }

    .list-darkmode-menu.active {
        right: 0;
    }

    .list-darkmode-menu ul {
        flex-direction: column;
        gap: 20px;
    }

    .list-darkmode-menu li a {
        font-size: 24px;
    }

    .mode {
        margin-top: 20px;
    }

    .home .home-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-bottom: clamp(1.5rem, 4vw, 2rem);
    }

    .home-info .left {
        max-width: 100%;
    }

    .home-info .right {
        text-align: center;
    }

    .home-info .right .profile img {
        width: clamp(150px, 40vw, 200px);
        height: clamp(150px, 40vw, 200px);
    }

    .social {
        gap: 12px;
    }

    .social a {
        width: clamp(36px, 8vw, 40px);
        height: clamp(36px, 8vw, 40px);
        font-size: clamp(1rem, 2.5vw, 1.2rem);
    }

    .about-section {
        padding: clamp(3rem, 6vw, 4rem) 5% clamp(1.5rem, 4vw, 2rem);
    }

    .about-content {
        flex-direction: column;
        gap: 30px;
        margin: clamp(1.5rem, 4vw, 2rem) 0;
    }

    .about-text,
    .skills {
        flex: 1 1 100%;
    }

    .about-text h3,
    .skills h3 {
        font-size: clamp(1.3rem, 3vw, 1.5rem);
    }

    .about-text p {
        font-size: clamp(0.9rem, 2.2vw, 1rem);
    }

    .skills-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 15px;
    }

    .skill-card {
        padding: 20px 0;
    }

    .skill-card i {
        font-size: clamp(1.8rem, 4vw, 2rem);
    }

    .services-section h2 {
        margin-bottom: clamp(1.5rem, 4vw, 2rem);
    }

    .portfolio h2 {
        margin-bottom: clamp(1.5rem, 4vw, 2rem);
    }

    .contact form {
        margin: clamp(0.8rem, 2.5vw, 1rem) auto clamp(1.5rem, 4vw, 2rem);
    }
}

@media (max-width: 480px) {
    section {
        padding: clamp(2rem, 5vw, 3rem) 3% clamp(1rem, 3vw, 1.5rem);
        margin-bottom: clamp(1rem, 3vw, 1.5rem);
    }

    .home-info .left h3 {
        font-size: clamp(1.2rem, 3.5vw, 1.5rem);
    }

    .home-info .left h1 {
        font-size: clamp(2rem, 5vw, 2.5rem);
    }

    .home-info .left h4 {
        font-size: clamp(1.2rem, 3vw, 1.5rem);
    }

    .home-info .left p {
        font-size: clamp(0.85rem, 2.2vw, 0.95rem);
    }

    .home-info .right .profile img {
        width: clamp(120px, 35vw, 160px);
        height: clamp(120px, 35vw, 160px);
    }

    .social {
        gap: 10px;
    }

    .social a {
        width: clamp(32px, 7vw, 36px);
        height: clamp(32px, 7vw, 36px);
        font-size: clamp(0.9rem, 2vw, 1rem);
    }

    .about-content {
        margin: clamp(1rem, 3vw, 1.5rem) 0;
    }

    .about-text h3,
    .skills h3 {
        font-size: clamp(1.2rem, 2.8vw, 1.4rem);
    }

    .about-text p {
        font-size: clamp(0.85rem, 2vw, 0.95rem);
    }

    .skills-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
    }

    .service-card {
        width: clamp(200px, 80vw, 250px);
    }

    .portfolio-card {
        width: clamp(200px, 80vw, 250px);
        height: clamp(200px, 80vw, 250px);
    }
}