/*
 * mobile.css — responsive layer for the static copy of pernasvarela.com
 * Only applies below 990px; the desktop layout (962px fixed) is untouched.
 *   660–989px  tablet: single centred column, 2-column Masonry grid
 *   < 660px    phone:  single column, full-width grid tiles with captions
 */

@media (max-width: 989px) {

	html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

	body {
		width: auto;
		max-width: 640px;
		margin: 1.5em auto 0;
		padding: 0 16px;
		font-size: 15px;
		line-height: 1.45em;
	}

	header { font-size: 1.6em; line-height: 1.15em; margin-bottom: 8px; }

	/* ---- every fixed-width column becomes fluid and stacks ---- */
	body #content,
	body.home section#content,
	#sidebar,
	#sidebar .span-6,
	.span-1, .span-2, .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-10,
	.span-11, .span-12, .span-13, .span-14, .span-15, .span-16, .span-17, .span-18, .span-19, .span-20,
	.servizo1, .servizos, .servizos4,
	div.span-20 {
		width: auto !important;
		float: none !important;
		margin-right: 0 !important;
		min-height: 0;
	}
	div.span-6.leftcol { min-height: 0; }
	[class*="prepend-"] { padding-left: 0; }
	[class*="append-"] { padding-right: 0; }
	div.entry-content p { padding-right: 0; }

	/* ---- main menu: one wrapping row, sub-menus as rows below ---- */
	nav#access { margin-bottom: 1em; font-size: 14px; }
	ul.menu {
		display: flex;
		flex-wrap: wrap;
		gap: 0 .85em;
		padding-bottom: 0;
		background: none;
	}
	ul.menu > li,
	ul.menu ul.submenu > li { display: contents; }
	ul.menu > li:after { display: none; }
	ul.menu li > a { padding: .35em 0; }

	ul.menu > li > ul,
	ul.menu ul.submenu {
		position: static;
		order: 99;
		flex-basis: 100%;
		width: auto !important;
		display: flex;
		flex-wrap: wrap;
		gap: 0 .85em;
		margin: .2em 0 0;
		padding: .3em 0 0;
		border-top: 1px solid #e6eef3;
		background: none;
	}
	ul.menu ul.submenu:not(:has(li)) { display: none; }
	ul.sub-menu li, ul.submenu li { padding-right: 0; }
	ul.menu ul.subsubmenu {
		order: 99;
		flex-basis: 100%;
		margin: .2em 0 0;
		padding: 0 0 0 10px;
		border-left: 1px solid #e6eef3;
	}
	ul.subsubmenu li { width: auto; margin-bottom: 0; }

	/* ---- images and embeds never overflow ---- */
	img { max-width: 100%; height: auto; }
	iframe, embed, object, video { max-width: 100%; }
	iframe[src*="youtube"], iframe[src*="vimeo"] { width: 100%; height: auto; aspect-ratio: 16 / 9; }
	.wp-caption { max-width: 100%; }

	/* ---- project pages: text above, slideshow below ---- */
	.page-thumb,
	article.projects.type-projects { height: auto; }
	div.slideshow-controls { display: none; }
	#o-slide { float: none; margin-top: 1em; }
	.ngg-slideshow, .ngg-slideshow-loader { max-width: 100%; }
	#a-descripcion {
		position: static;
		float: none;
		visibility: visible;
		display: none;
		margin-top: 1em;
	}
	.slideshow div.text-holder,
	.slideshow div.image-holder,
	.slideshow_holder div.image-holder,
	.slideshow_holder div.frame { width: auto; height: auto; }

	/* ---- blog / text pages ---- */
	.titulo-post-blog { font-size: 1.6em; }
	.entrada-post p, .entry-post p { -webkit-hyphens: auto; hyphens: auto; }
	#sidebar { margin-top: 10px; }
	#sidebar .span-6 { margin-bottom: 1.5em; }
	#sidebar ul li a { display: inline-block; padding: .15em 0; }

	/* ---- home / blog Masonry grid (2 columns of 315px) ---- */
	#container { max-width: 640px; margin: 0 auto; }

	footer, .peDePaxina, #peDePaxina { text-align: left; }
}

/* ---- phones ---- */
@media (max-width: 659px) {
	#container { height: auto !important; }
	#container .item {
		position: static !important;
		left: auto !important;
		top: auto !important;
		width: auto;
		margin-bottom: 14px;
	}
	.item img { width: 100%; height: auto; margin-bottom: 0; display: block; }
	/* no hover on touch screens: show the title under the photo */
	.item h1 {
		display: block;
		position: static;
		font-size: .9em;
		margin: 4px 0 0;
	}
	.item h1 a { color: #5f5f5f; }
	.item:hover { background: none; }
	.item:hover img { opacity: 1; }
}

/* touch devices of any size (no hover): show the title under each tile
   instead of the hover overlay, and avoid sticky hover states */
@media (hover: none) {
	.item h1 {
		display: block;
		position: static;
		font-size: .9em;
		margin: 4px 0 0;
	}
	.item h1 a { color: #5f5f5f; }
	.item img { margin-bottom: 0; display: block; }
	.item:hover { background: none; }
	.item:hover img { opacity: 1; }
}
