body {
    margin: 0;
    font-family: Arial, sans-serif;
    padding-left: 4%;
    padding-right: 4%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header,
footer {
    background: #ffffff;
    color: #000000;
    padding: 1rem;
    text-align: center;
}

main,
.main-content,
.main-flex,
.content-block {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-flex {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    padding-right: 0;
}

.main-sections {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

section {
    margin-top: 60px;
    margin-bottom: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 400px;
    /* Centra con la imagen */
}

article {
    margin-top: 48px;
    margin-bottom: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 400px;
    /* Centra con la imagen */
}

aside {
    width: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    background: #f4f4f4;
    padding: 1rem 0.5rem;
    box-sizing: border-box;
    margin-top: 60px;
    /* Alinea con section */
    position: sticky;
    top: 120px;
    height: fit-content;
}

header {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    /* Glassmorphism */
    color: #000000;
    padding: 1rem;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    box-shadow: 0 4px 24px 0 rgba(31, 38, 135, 0.07);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-left {
    position: relative;
    display: flex;
    align-items: center;
}

.logo {
    height: 48px;
    width: auto;
    margin-right: 8px;
    /* Reducido de 16px a 8px para menor espacio */
    transition: filter 0.3s;
    cursor: pointer;
    filter: drop-shadow(0 0 2px #000);
    will-change: filter;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    font-family: 'Space Mono', monospace !important;
    font-weight: bold;
    padding-right: 20px;
}

.header-menu {
    display: flex;
    gap: 12px;
}

.menu-btn,
.btn {
    background: rgba(255, 255, 255, 0.35);
    border: none;
    /* Quita los bordes */
    color: #222;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    /* Usa Space Mono */
    transition: background 0.2s, text-decoration 0.2s;
    box-shadow: 0 4px 24px 0 rgba(31, 38, 135, 0.07);
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    text-decoration: none;
    display: inline-block;
}

.menu-btn:hover,
.btn:hover {
    text-decoration: underline;
    background: rgba(255, 255, 255, 0.55);
}

.footer-menu {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 1rem 0;
}

.footer-menu {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2vw;
}

.footer-links {
    text-align: center;
    margin-bottom: 1rem;
}

.footer-links a {
    color: #222;
    text-decoration: none;
    margin: 0 8px;
    font-weight: bold;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #ef233c;
}

h1,
h2,
h3 {
    font-family: 'IBM Plex Mono', monospace;
}

p {
    font-family: 'Space Mono', monospace;
}

.footer-links a,
footer {
    font-family: 'Space Mono', monospace;
}

/* Subrayado en hover para todos los h2 excepto el de bienvenida (.content h2), y para h3 */
.main-content h2:not(.content h2):hover,
.main-content section h2:hover,
.main-content article h2:hover,
.main-content h3:hover,
.header-menu .menu-btn:hover,
.footer-menu .menu-btn:hover {
    text-decoration: underline;
}

/* Agrupa cada bloque de contenido con su imagen */
.content-block {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-bottom: 48px;
    width: 100%;
    max-width: 1100px;
}

/* El contenido textual de cada bloque */
.content-block .text {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* La imagen asociada a cada bloque */
.content-block .aside-img-group {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 32px;
}

.aside-img {
    width: 500px;
    height: 400px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow:
        0 8px 32px 0 rgba(40, 40, 40, 0.18),
        0 2px 8px 0 rgba(0, 0, 0, 0.18),
        0 1.5px 12px 0 rgba(0, 0, 0, 0.10);
    transition: transform 0.25s cubic-bezier(.25, 1.25, .5, 1.25), box-shadow 0.25s;
}

.aside-img:hover {
    transform: scale(1.03, 1.06);
    box-shadow:
        0 16px 48px 0 rgba(0, 0, 0, 0.22),
        0 4px 16px 0 rgba(40, 40, 40, 0.13);
}

.content {
    width: 100%;
    max-width: 1100px;
    padding-left: 15%;
    padding-right: 15%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* Centra el texto solo en el content */
}

/* ------------------- RESPONSIVE DESIGN ------------------- */

/* Tablet (≤ 1024px) */
@media (max-width: 1024px) {
    body {
        padding-left: 2%;
        padding-right: 2%;
    }

    .content {
        padding-left: 5%;
        padding-right: 5%;
    }

    .content-block,
    .main-sections,
    .main-content {
        max-width: 98vw;
    }

    .aside-img {
        width: 350px;
        height: 240px;
    }

    aside {
        width: 370px;
        padding: 0.5rem 0.2rem;
    }
}

/* Smartphone (≤ 700px) */
@media (max-width: 700px) {
    body {
        padding-left: 0;
        padding-right: 0;
    }

    header,
    footer {
        padding: 0.5rem;
    }

    .header-left {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        text-align: center;
        width: 100%;
    }

    #logo-night-toggle {
        margin-right: 0;
        margin-left: 0;
        display: block;
    }

    .logo {
        height: 36px;
        margin-right: 6px;
    }

    header h1 {
        font-size: 1.2rem;
        padding-right: 0 !important;
        text-align: center;
        margin-left: 0;
        margin-right: 0;
        flex: none;
    }

    .header-menu,
    .footer-menu {
        gap: 6px;
    }

    .menu-btn,
    .btn {
        font-size: 0.95rem;
        padding: 0.4rem 0.7rem;
    }

    .content {
        padding-left: 2%;
        padding-right: 2%;
        font-size: 0.98rem;
    }

    .main-flex {
        width: 100%;
    }

    .content-block,
    section,
    article {
        flex-direction: column;
        align-items: center;
        margin-bottom: 32px;
        max-width: 100vw;
        padding-left: 2%;
        padding-right: 2%;
        box-sizing: border-box;
        text-align: center;
        /* Centra el texto en móviles */
    }

    .content-block .aside-img-group {
        margin-left: 0;
        margin-top: 16px;
    }

    .aside-img {
        width: 98vw;
        max-width: 340px;
        height: 180px;
    }

    aside {
        width: 100%;
        padding: 0;
        margin-top: 0;
        background: none;
        box-shadow: none;
    }

    .main-content,
    .main-sections {
        max-width: 100vw;
        padding: 0;
    }

    section,
    article {
        min-height: unset;
        margin-top: 32px;
        margin-bottom: 32px;
    }

    .footer-links {
        font-size: 0.95rem;
    }

    .content-block {
        flex-direction: column;
        align-items: center;
    }

    .content-block .btn {
        order: 3;
        margin: 1em 0 0.5em 0;
        align-self: center;
        width: fit-content;
    }

    .content-block .aside-img-group {
        order: 2;
        margin-bottom: 0.5em;
    }

    .content-block .text {
        order: 1;
        width: 100%;
    }
}

/* Espaciado reducido en móviles para <p> y h2 dentro de article y section bajo .content */
@media (max-width: 900px) {

    article p,
    .content-block section p {
        margin-bottom: 0.5em;
    }

    article h2,
    .content-block section h2 {
        margin-top: 0.5em;
    }
}

/* En móviles, los botones de los articles debajo de las imágenes */
@media (max-width: 900px) {
    .content-block {
        flex-direction: column;
        align-items: center;
    }

    .content-block .aside-img-group {
        order: 1;
        margin-top: 16px;
        margin-bottom: 0;
    }

    .content-block .text {
        order: 0;
        width: 100%;
    }

    .content-block .btn {
        order: 2;
        display: block;
        margin: 1.2em auto 2em auto;
        /* más espacio abajo para separar del siguiente bloque */
        width: fit-content;
        float: none;
        position: static;
    }

    /* En móviles, agrega margen entre la imagen y el botón para que la imagen respire */
    .content-block .aside-img-group+.btn {
        margin-top: 1.2em;
    }

    .content-block .btn {
        margin-bottom: 2em;
    }
}

/* Oculta el espacio en blanco entre el botón y el siguiente artículo en móviles */
@media (max-width: 900px) {
    .content-block {
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .content-block .btn {
        margin-bottom: 0;
    }

    /* Opcional: elimina el margen superior del siguiente artículo */
    .content-block+.content-block article {
        margin-top: 0;
    }
}

/* Nuevas reglas para pantallas pequeñas (≤ 600px) */
@media (max-width: 600px) {
    .content-block {
        display: flex;
        flex-direction: column;
    }

    .content-block .text {
        order: 1;
        width: 100%;
    }

    .content-block .aside-img-group {
        order: 2;
        width: 100%;
        margin-bottom: 0.5em;
    }

    /* Mueve el botón debajo de la imagen */
    .content-block article {
        display: flex;
        flex-direction: column;
    }

    .content-block article .btn {
        order: 2;
        margin-top: 0.5em;
        align-self: flex-start;
    }

    /* Elimina espacio entre button y article */
    .content-block article {
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .content-block article .btn {
        margin-bottom: 0;
    }
}

/* Simetría visual para el último botón en móviles */
@media (max-width: 700px) {
    .content-block:last-of-type .btn {
        /* Calcula el margen inferior igual al margen entre la imagen y el botón */
        margin-bottom: 2.5em;
        /* Ajusta este valor para igualar visualmente la distancia */
    }

    /* Opcional: si el botón ya tiene margen inferior, puedes sobreescribirlo */
    .content-block:last-of-type .btn {
        margin-bottom: 2.5em !important;
    }
}

/* Header y elementos internos adaptados para móviles */
@media (max-width: 700px) {
    header {
        min-width: 0;
        max-width: 100vw;
        margin: 0;
        padding: 3vw 4vw 3vw 4vw;
        /* Padding proporcional al ancho de pantalla */
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .header-left {
        width: 100%;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .header-left h1 {
        font-size: 5vw;
        margin: 0;
        padding: 0;
        text-align: center;
    }

    .header-menu {
        width: 100%;
        margin: 2vw 0 0 0;
        padding: 0;
        box-sizing: border-box;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 2vw;
        font-size: 4vw;
    }

    .header-menu .menu-btn {
        padding: 2vw 4vw;
        font-size: 1em;
        min-width: 0;
        box-sizing: border-box;
    }

    .header-menu {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 2vw;
    }

    .header-menu a.menu-btn:nth-child(2) {
        order: 1;
    }

    /* PROYECTO */
    .header-menu a.menu-btn:nth-child(1) {
        order: 2;
    }

    /* INICIO */
    .header-menu a.menu-btn:nth-child(3) {
        order: 3;
    }

    /* CONTACTO */
}

/* --- Modo noche --- */
body.night-mode {
    background: #181818;
    color: #fff;
}

body.night-mode header,
body.night-mode footer {
    background: #232323;
    color: #fff;
}

body.night-mode .content,
body.night-mode .main-content,
body.night-mode .main-sections,
body.night-mode .content-block,
body.night-mode section,
body.night-mode article {
    background: transparent;
    color: #fff;
}

body.night-mode .menu-btn,
body.night-mode .btn {
    background: rgba(30, 30, 30, 0.35);
    color: #fff;
}

body.night-mode .menu-btn:hover,
body.night-mode .btn:hover {
    background: rgba(60, 60, 60, 0.55);
}

body.night-mode .footer-links a {
    color: #fff;
}

body.night-mode .footer-links a:hover {
    color: #a3e3ff;
}

/* Sombra de imágenes en modo noche: personalizada por imagen */
body.night-mode .aside-img {
    /* Por defecto, sombra blanca neutra, pero puedes sobrescribir por clase */
    box-shadow:
        0 8px 32px 0 rgba(255, 255, 255, 0.18),
        0 2px 8px 0 rgba(255, 255, 255, 0.18),
        0 1.5px 12px 0 rgba(255, 255, 255, 0.10);
}

/* Sombra personalizada para cada imagen en modo noche */
body.night-mode .aside-img.img1 {
    box-shadow:
        0 8px 32px 0 rgba(255, 0, 149, 0.18),
        0 2px 8px 0 rgba(255, 0, 140, 0.18),
        0 1.5px 12px 0 rgba(255, 0, 119, 0.1);
}

body.night-mode .aside-img.img2 {
    box-shadow:
        0 8px 32px 0 rgba(255, 0, 255, 0.18),
        0 2px 8px 0 rgba(255, 0, 255, 0.18),
        0 1.5px 12px 0 rgba(255, 0, 255, 0.10);
}

body.night-mode .aside-img.img3 {
    box-shadow:
        0 8px 32px 0 rgba(255, 255, 0, 0.18),
        0 2px 8px 0 rgba(255, 255, 0, 0.18),
        0 1.5px 12px 0 rgba(255, 255, 0, 0.10);
}

body.night-mode .aside-img.img4 {
    box-shadow:
        0 8px 32px 0 rgba(0, 255, 128, 0.18),
        0 2px 8px 0 rgba(0, 255, 128, 0.18),
        0 1.5px 12px 0 rgba(0, 255, 128, 0.10);
}

body.night-mode .aside-img.img5 {
    box-shadow:
        0 8px 32px 0 rgba(255, 128, 0, 0.18),
        0 2px 8px 0 rgba(255, 128, 0, 0.18),
        0 1.5px 12px 0 rgba(255, 128, 0, 0.10);
}

/* Ejemplo para personalizar por imagen (puedes cambiar los colores a gusto) */

/* Luna en dos tintas, centrada debajo del logo */
.night-hint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 54px;
    background: rgba(255, 255, 255, 0.6);
    color: #222;
    border-radius: 2px;
    padding: 4px 10px;
    font-size: 1.1rem;
    font-family: 'Space Mono', monospace;
    box-shadow:
        0 2px 8px 0 rgba(31, 38, 135, 0.18),
        0 1px 4px 0 rgba(31, 38, 135, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.95;
    z-index: 200;
    animation: hint-bounce 1.6s infinite;
    pointer-events: none;
    min-width: 32px;
    min-height: 32px;
    /* Oculta por defecto, solo visible en hover en PC */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
}

.header-left:hover .night-hint {
    visibility: visible;
    opacity: 1;
}

.night-hint .moon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0;
}

.night-hint .moon svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* Modo noche: fondo traslúcido oscuro, color blanco, mismo drop-shadow */
body.night-mode .night-hint {
    background: rgba(30, 30, 30, 0.92);
    color: #fff;
    box-shadow:
        0 2px 8px 0 rgba(80, 120, 255, 0.18),
        0 1px 4px 0 rgba(80, 120, 255, 0.10);
}

/* Centra la luna justo debajo del logo PNG, ignorando el título */
.header-left {
    position: relative;
    display: flex;
    align-items: center;
}

#logo-night-toggle {
    position: relative;
    z-index: 2;
    display: block;
}

/* Ajuste night-hint: centrada respecto al logo PNG */
.night-hint {
    position: absolute;
    left: 0;
    top: 100%;
    /* Centra respecto al logo usando su ancho */
    transform: translateY(8px);
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    color: #222;
    border-radius: 2px;
    padding: 4px 10px;
    font-size: 1.1rem;
    font-family: 'Space Mono', monospace;
    box-shadow:
        0 2px 8px 0 rgba(31, 38, 135, 0.18),
        0 1px 4px 0 rgba(31, 38, 135, 0.10);
    opacity: 0.95;
    z-index: 200;
    animation: hint-bounce 1.6s infinite;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
}

/* Mostrar solo en hover en PC */
.header-left:hover .night-hint {
    visibility: visible;
    opacity: 1;
}

/* Centrado exacto bajo el logo PNG */
#logo-night-toggle+.night-hint {
    left: 50%;
    transform: translate(-50%, 8px);
    right: auto;
}

/* Oculta la luna en móviles */
@media (max-width: 900px) {
    .night-hint {
        display: none !important;
    }
}

/* Header traslúcido en modo claro */
header {
    background: rgba(255, 255, 255, 0.70);
    /* antes 0.85 */
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    box-shadow: 0 2px 16px 0 rgba(31, 38, 135, 0.07);
    transition: background 0.3s, box-shadow 0.3s;
}

/* Header traslúcido en modo oscuro */
body.night-mode header {
    background: rgba(30, 30, 30, 0.60);
    /* antes 0.85 */
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
    box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.18);
    transition: background 0.3s, box-shadow 0.3s;
}

/* Hover verde/coral para botones en modo claro */
.btn:not(.night-mode):hover,
.menu-btn:not(.night-mode):hover {
    background: #fae337;
    /* Verde Spotify */
    color: #ffffff;
    /* Coral */
    border-color: #fae337;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

/* Si tus botones tienen la clase .night-mode en modo oscuro, esto asegura que solo se aplique en modo claro */
body:not(.night-mode) .btn:hover,
body:not(.night-mode) .menu-btn:hover {
    background: #fae337;
    /* Verde Spotify */
    color: #000;
    /* Coral */
    border-color: #fae337;
}

/* Bordes inferiores redondeados para el header en ambos modos */
header {
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
}

body.night-mode header {
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
}

/* Footer: ordena los elementos en fila y centra en móviles */
@media (max-width: 700px) {
    .footer-menu {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 2vw;
    }

    .footer-menu>a:nth-child(2) {
        order: 1;
    }

    .footer-menu>a:nth-child(1) {
        order: 2;
    }

    .footer-menu>a:nth-child(3) {
        order: 3;
    }
}