/* http://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly */

#nav
{clear: both;
            width: 100%; /* 1000 */
			font-family: verdana, sans-serif;
			font-weight: 400;
			position: absolute; margin: 0;
			border-bottom: 1px solid #e8e9ed; border-top: 1px solid #e8e9ed;}
    
	#nav > a
    {display: none;}
   
   #nav li
			{position: relative;}
				
			#nav li a 
			{text-decoration: none; color: #31415a; display: block;}
				

			#nav span:after
			{
				width: 0;
				height: 0;
				border: 0.313em solid transparent; /* 5 */
				border-bottom: none;
				border-top-color: #e8e9ed;
				content: '';
				vertical-align: middle;
				display: inline-block;
				position: relative;
				right: -0.313em; /* 5 */
			}

 
    /* first level */
 
   #nav > ul
			{ list-style-type: none; 
				height: 1.6em; /* 60 */
			background-color: #7d3237;  color: #fff; margin: 0; border-bottom: 2px solid #e8e9ed;}
		
		#nav > ul > li
				{width: 25%; margin: 0; padding: 0;
				height: 100%;
				float: left;}
					
					
		#nav > ul > li > span.plain
				{height: 100%; display: block;
				font-size: 1.2em; /* 24 */
				line-height: 1.8em; /* 60 (24) */
				text-align: center; color: #fff;
				border-right: 2px solid #fff;}
		
		#nav > ul > li > a
				{height: 100%;
					font-size: 1em; /* 24 */
					line-height: 1.6em; /* 60 (24) */
					text-align: center; color: #fff; font-weight: bold; padding-top: 3px;}
		
		#nav > ul > li:not( :last-child ) > a
						{border-right: 2px solid #fff;}
		
		#nav > ul > li:hover > a,
		
		#nav > ul:not( :hover ) > li.active > a
						{background-color: #e8e9ed; color: #31415a;}
    /* second level */
 
   #nav li ul
				{   list-style-type: none;
					background-color: #bb514a;
					display: none;
					position: absolute;
					top: 100%; width: 100%; margin: 0;
				}
					#nav li:hover ul
					{
						display: block;
						left: 0;
						right: 0;
					}
					
					#nav > ul ul li
				{padding: 2px; margin: 0; border-top: 1px solid #8f3e39;  border-bottom: 1px solid #ab4741;}
					
						#nav li:not( :first-child ):hover ul
						{
							left: -1px;
						}
						#nav li ul a
						{
							font-size: 1em; /* 20 */
							
							padding: 5px 1em; margin: 0;
						}
							#nav li ul li a:hover,
							#nav li ul:not( :hover ) li.active a
							{
								background-color: #b2c784; color: #2a6722;
							}
		
/* 640 pixels is the major breakpoint at which with the help of a single media query, the navigation shrinks to a button (icon). CSS pseudo selector :target makes it easy to toggle menu as the anchor's href attribute coincides with CSS ID selector name. Therefore, as you might have understood, the first anchor of #nav > a is responsible for showing and the second for hiding the menu. */

@media only screen and ( max-width: 40em ) /* 640 */
		{
			html
			{
				font-size: 75%; /* 12 */
			}
			
			#header {border-bottom: none;}

			#nav
			{   background: #8f3e39; 
				position: relative;
				top: auto;
				left: auto;
			}
				#nav > a
				{
					width: 3.125em; /* 50 */
					height: 3.125em; /* 50 */
					text-align: left;
					text-indent: -9999px;
					background-color: #e15a1f;
					position: relative;
				}
					#nav > a:before,
					#nav > a:after
					{
						position: absolute;
						border: 2px solid #fff;
						top: 35%;
						left: 25%;
						right: 25%;
						content: '';
					}
					#nav > a:after
					{
						top: 60%;
					}

				#nav:not( :target ) > a:first-of-type,
				#nav:target > a:last-of-type
				{
					display: block;
				}


			/* first level */

			#nav > ul
			{   border: none;
				height: auto;
				display: none;
				position: absolute;
				left: 0;
				right: 0;
			}
				#nav:target > ul
				{
					display: block;
				}
				#nav > ul > li
				{
					
					width: 100%;
					float: none;
				}
					#nav > ul > li > a
					{
						height: auto;
						text-align: left;
						
					}
					
					#nav > ul > li > span.plain
				{height: auto; 
				text-align: left;
				padding: 0 0.833em; border-right: none;
				border-bottom: 1px solid #cc470d; }
				
						#nav > ul > li:not( :last-child ) > a
						{
							border-right: none;
							border-bottom: 1px solid #cc470d;
						}


				/* second level */

				#nav li ul
				{
					position: static;
					padding: 0; /* 20 */
					padding-top: 0;
				}
		}
