/*
Theme Name: Twenty Seventeen Child
Description: Twenty Seventeen Child Theme
Theme URI: http://milonga.site
Author: David Silva
Author URI: http://milonga.site
Template: twentyseventeen
Version: 1.0.0
Text Domain: twentyseventeen-child
*/

/*---------------------------------------------------------------------------
>>> TABLE OF CONTENTS:
-----------------------------------------------------------------------------

	1. 	Page Templates
		a. 	Template: Cover Template
		c. 	Template: Full Width
	2.  Align Page Title and H1
	3.	Footer content areas equal width
	4.	Footer Legal Menu
	5.  Center the logo and Site branding-text
	6.  Center the menu and Remove the arrow.
	
----------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/*	1.  Page Templates														  */
/*		a. 	Template: Cover Template										  */
/* -------------------------------------------------------------------------- */



/* -------------------------------------------------------------------------- */
/*	1.  Page Templates														  */
/*		Template: Full Width												  */
/* -------------------------------------------------------------------------- */



/* -------------------------------------------------------------------------- */
/*	2.  Align Page Title and H1												  */
/* -------------------------------------------------------------------------- */



/* -------------------------------------------------------------------------- */
/*	3.	Footer content areas equal width									  */
/* -------------------------------------------------------------------------- */

	/* Footer */

	.site-footer {
	font-size: 14px;
	font-size: 0.875rem;
	line-height: 1.6;
	margin-top: 0em;
	text-align: center;
	}

	/* Footer 1 content */
	@media screen and (min-width: 48em) {
	.site-footer .widget-column.footer-widget-1 {
    /* float: left; */
    width: 47%;
	}
	}

	/* Footer 2 content */
	@media screen and (min-width: 48em) {
	.site-footer .widget-column.footer-widget-2 {
    /* float: right; */
    width: 47%;
	}
	}

	/* Social icons */
	@media screen and (min-width: 48em) {
	.social-navigation {
    /* clear: left; */
    /* float: left; */
    /* margin-bottom: 0; */
    width: 47%;
	}
	}

	/* Site info (Legal) */
	@media screen and (min-width: 48em) {
	.site-info {
	/* float: right; */
    width: 47%;
	}
	}

/* -------------------------------------------------------------------------- */
/*	4.	Footer Legal Menu													  */
/* -------------------------------------------------------------------------- */

	#footer-menu li{
	display:inline-block;
	margin-left: 5px;
	margin-right: 5px;
}

/* -------------------------------------------------------------------------- */
/*	5.  Center the logo and Site branding-text								  */
/* -------------------------------------------------------------------------- */

	#masthead .wrap {
    /* position: relative; */
	text-align: center;
	}

	@media screen and (min-width: 48em) {
	.custom-logo-link {
	padding-right: 0em;
	display: block;
	}
	}

	@media screen and (min-width: 48em) {
	.custom-logo-link img {
	max-width: 200px;
	}
	}
	
	.custom-logo-link img {
	display: inline-block;
    max-height: 125px !important;
    width: auto;
	}

	.site-description {
	color: black;
	font-size: 36px;
	font-size: 2.5rem;
	margin-bottom: 0;
	}

	body.has-header-image .site-description,
	body.has-header-video .site-description {
	color: black !important;
	opacity: 0.8;	
	}

/* -------------------------------------------------------------------------- */
/*	6.  Center the menu and Remove the arrow.							  */
/* -------------------------------------------------------------------------- */	

	ul#top-menu {
	text-align: center;
	}

	a.menu-scroll-down {
	display: none !important;
	}






/* -------------------------------------------------------------------------- */
/* 	ENVÍO: Mensaje personalizado y bloqueo checkout sin método de envío       */
/* -------------------------------------------------------------------------- */

// 1. Cambiar mensaje "No hay opciones de envío" por texto personalizado
add_filter( 'woocommerce_no_shipping_available_html', function( $html ) {
	return '<p class="woocommerce-shipping-contents"><strong>⚠️ Consultar envío fuera de Palma</strong><br>Para pedidos fuera de Palma de Mallorca, contáctanos por WhatsApp antes de finalizar tu pedido.</p>';
} );

// 2. Bloquear checkout si no hay método de envío seleccionado
add_action( 'woocommerce_check_cart_items', function() {
	if ( ! WC()->cart->needs_shipping() ) return;
	$packages = WC()->shipping()->get_packages();
	$chosen = WC()->session->get( 'chosen_shipping_methods', array() );
	foreach ( $packages as $i => $package ) {
		$rates = $package['rates'];
		if ( empty( $rates ) ) {
			wc_add_notice( '⚠️ Tu dirección está fuera de Palma de Mallorca. Por favor, consúltanos el precio de envío por WhatsApp antes de finalizar el pedido.', 'error' );
			return;
		}
	}
} );
