/* =========================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
========================================= */
:root {
    /* Paleta de colores: Estética Samurai (Negro, Blanco, Rojo) */
    --bg-main: #050505; /* Negro profundo */
    --bg-alt: #0a0a0a; /* Carbón muy oscuro */
    --bg-card: #121212; /* Fondo terminal */
    
    --text-main: #ffffff; /* Blanco puro */
    --text-muted: #888888; /* Gris técnico */
    
    --accent-red: #d32f2f; /* Rojo carmesí / katana */
    --accent-red-hover: #b71c1c;
    
    /* Tipografías */
    --font-mono: 'Fira Code', monospace;
    --font-sans: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth; /* Desplazamiento suave */
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
}

/* =========================================
   REUTILIZABLES
========================================= */
a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s ease;
}

ul {
    list-style: none;
}

.section {
    padding: 100px 20px;
    background-color: var(--bg-main);
}

.section:nth-child(even) {
    background-color: var(--bg-alt);
}

.section-content {
    max-width: 1000px;
    margin: 0 auto;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 2rem;
    margin-bottom: 40px;
    color: var(--text-muted);
}

.section-title span {
    color: var(--text-main);
}

/* Botones */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent-red);
    color: var(--text-main);
}

.btn-primary:hover {
    background-color: var(--accent-red-hover);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.btn-outline:hover {
    background-color: rgba(211, 47, 47, 0.1);
}

/* =========================================
   NAVEGACIÓN (HEADER)
========================================= */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: rgba(5, 5, 5, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    white-space: nowrap;
}

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

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.visit-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.visit-count[hidden] {
    display: none;
}

.visit-count svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--accent-red);
}

/* en celular no entran juntos el nombre, el contador completo y el menú */
@media (max-width: 480px) {
    .logo {
        font-size: 1.25rem;
    }

    .nav-brand {
        gap: 10px;
    }

    .visit-word {
        display: none;
    }
}

.nav-links {
    display: none;
    gap: 30px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 10px 20px 20px;
    gap: 0;
    background-color: rgba(5, 5, 5, 0.97);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-links.open a {
    display: block;
    padding: 12px 0;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background-color: var(--text-main);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-links a:hover {
    color: var(--accent-red);
}

/* =========================================
   HERO (INICIO)
========================================= */
.hero {
    position: relative;
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    width: 100%;
}

/* En celular el video ocupa todo el fondo, oscurecido para que el texto se lea */
.hero-media {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(5, 5, 5, 0.65);
}

.hero-title {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.1;
}

.hero-title span {
    color: var(--accent-red);
}

.typewriter-container {
    height: 40px; /* Previene saltos de diseño */
    margin-bottom: 40px;
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: clamp(1rem, 4vw, 1.5rem);
    color: var(--text-muted);
    font-weight: 400;
}

.cursor {
    display: inline-block;
    width: 10px;
    background-color: var(--accent-red);
    color: transparent;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.hero-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

/* =========================================
   SOBRE MÍ
========================================= */
.about-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.about-text {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.about-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.badge {
    background-color: rgba(211, 47, 47, 0.1);
    color: var(--accent-red);
    padding: 6px 12px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    border: 1px solid rgba(211, 47, 47, 0.3);
}

/* =========================================
   HABILIDADES
========================================= */
.skills-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.skill-category h3 {
    font-family: var(--font-mono);
    color: var(--text-main);
    margin-bottom: 15px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.skill-category h3 i {
    color: var(--accent-red);
}

.skill-category ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--text-muted);
}

.skill-category li {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =========================================
   PROYECTOS (Tarjetas tipo Terminal)
========================================= */
.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.terminal-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.terminal-card:hover {
    transform: translateY(-5px);
    border-color: rgba(211, 47, 47, 0.5);
}

.terminal-header {
    background-color: #1a1a1a;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.close { background-color: #ff5f56; }
.dot.minimize { background-color: #ffbd2e; }
.dot.maximize { background-color: #27c93f; }

.terminal-title {
    margin-left: 15px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.terminal-body {
    padding: 25px;
}

.cert-image {
    display: block;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
}

.cert-image img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.3s ease;
}

.cert-image:hover img {
    transform: scale(1.02);
}

.project-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-main);
}

.project-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.project-tags span {
    color: var(--accent-red);
}

.project-tags span::before {
    content: "#";
}

.project-link {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.project-link:hover {
    color: var(--accent-red);
}

.project-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 22px;
}

/* =========================================
   CONTACTO (FOOTER)
========================================= */
.footer {
    background-color: var(--bg-alt);
    padding: 80px 20px 40px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-title {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    margin-bottom: 30px;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 40px;
}

.social-links a {
    color: var(--text-muted);
    font-size: 1.5rem;
    transition: color 0.3s ease, transform 0.3s ease;
}

.social-links a:hover {
    color: var(--accent-red);
    transform: translateY(-3px);
}

.footer-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================================
   MEDIA QUERIES (Responsividad)
========================================= */
@media (min-width: 768px) {
    .nav-links,
    .nav-links.open {
        display: flex;
        flex-direction: row;
        position: static;
        padding: 0;
        gap: 30px;
        background: none;
        border: none;
    }

    .nav-links.open a {
        padding: 0;
    }

    .nav-toggle {
        display: none;
    }

    /* El video ocupa la mitad derecha y se funde hacia el texto */
    .hero-media {
        left: 40%;
        -webkit-mask-image: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.5) 40%, #000 75%);
        mask-image: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.5) 40%, #000 75%);
    }

    .hero-media::after {
        background-color: rgba(5, 5, 5, 0.25);
    }

    /* Versión optimizada para albergar dinámicamente las 4 columnas */
    .skills-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .about-grid {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .about-text {
        max-width: 50%;
    }
}

/* Manejo de visibilidad en la lista */
.skill-item {
    display: flex;
    align-items: center;
}


/* =========================================
   COMPONENTES DE FILTRADO (TOGGLES UNIFICADOS)
========================================= */
.habilidades-header, .proyectos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
    gap: 15px;
}

.habilidades-header .section-title, 
.proyectos-header .section-title {
    margin-bottom: 0;
}

/* El contenedor del switch con estética Samurai */
.toggle-container {
    display: flex;
    background-color: var(--bg-alt);
    border: 1px solid rgba(211, 47, 47, 0.3); /* Borde rojo sutil tipo badge */
    border-radius: 4px;
    overflow: hidden;
    padding: 2px;
}

.toggle-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 6px 16px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 2px;
}

.toggle-btn:hover {
    color: var(--text-main);
}

/* Estado activo: Mayormente Rojo con un sutil brillo neón */
.toggle-btn.active {
    background-color: var(--accent-red);
    color: var(--text-main);
    box-shadow: 0 0 8px rgba(211, 47, 47, 0.3);
}

/* Ocultación por defecto de elementos secundarios al cargar */
.skill-item.secundario,
.project-item.secundario {
    display: none;
}

/* Badges de estado en la barra superior de la terminal (Logs) */
.status-badge {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

/* En celular el título y el badge no entran en una línea: el badge baja a la siguiente.
   64px = los tres puntos (48px) más el margen del título. */
@media (max-width: 480px) {
    .terminal-header {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .terminal-title {
        flex: 1 1 auto;
        max-width: calc(100% - 64px);
        overflow-wrap: anywhere;
    }
}

.status-finalizado {
    color: #27c93f;
    background-color: rgba(39, 201, 99, 0.1);
}

.status-completado {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.08);
}

.status-desarrollo {
    color: #ffbd2e;
    background-color: rgba(255, 189, 46, 0.1);
}
a[data-href] {
    cursor: pointer;
}
