<?php
/**
 * Site footer.
 *
 * @package HaPantheon
 */

$footer_about = get_theme_mod(
	'hapantheon_footer_about',
	'ארכיון דיגיטלי אצור לחוויות איכות, תוכן נדיר ומחשבה. סובייקטיבי, ובכוונה.'
);
$footer_line  = get_theme_mod(
	'hapantheon_footer_copyright',
	'נבנה באבן, קוד ושיקול דעת.'
);
$navigation_title  = get_theme_mod( 'hapantheon_footer_navigation_title', 'ניווט' );
$halls_title       = get_theme_mod( 'hapantheon_footer_halls_title', 'האולמות' );
$information_title = get_theme_mod( 'hapantheon_footer_information_title', 'מידע' );
$newsletter_title  = get_theme_mod( 'hapantheon_footer_newsletter_title', 'המגילה החודשית' );
$instagram    = get_theme_mod( 'hapantheon_instagram_url', '' );
$facebook     = get_theme_mod( 'hapantheon_facebook_url', '' );
$youtube      = get_theme_mod( 'hapantheon_youtube_url', '' );
$email        = sanitize_email( get_theme_mod( 'hapantheon_contact_email', get_option( 'admin_email' ) ) );
?>
</main>

<footer class="footer">
	<div class="meander" aria-hidden="true"></div>
	<div class="wrap footer-grid">
		<div class="footer-branding">
			<h4><?php bloginfo( 'name' ); ?></h4>
			<p><?php echo esc_html( $footer_about ); ?></p>
			<div class="socials">
				<?php if ( $instagram ) : ?>
					<a href="<?php echo esc_url( $instagram ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Instagram', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'instagram' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a>
				<?php endif; ?>
				<?php if ( $facebook ) : ?>
					<a href="<?php echo esc_url( $facebook ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'Facebook', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'facebook' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a>
				<?php endif; ?>
				<?php if ( $youtube ) : ?>
					<a href="<?php echo esc_url( $youtube ); ?>" target="_blank" rel="noopener noreferrer" aria-label="<?php esc_attr_e( 'YouTube', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'youtube' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a>
				<?php endif; ?>
				<?php if ( $email ) : ?>
					<a href="mailto:<?php echo esc_attr( antispambot( $email ) ); ?>" aria-label="<?php esc_attr_e( 'דוא״ל', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'mail' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a>
				<?php endif; ?>
				<a href="<?php echo esc_url( get_feed_link() ); ?>" aria-label="<?php esc_attr_e( 'עדכוני RSS', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'rss' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a>
			</div>
		</div>

		<div class="footer-menu-column">
			<h4><?php echo esc_html( $navigation_title ); ?></h4>
			<?php
			wp_nav_menu(
				array(
					'theme_location' => 'footer_navigation',
					'container'      => false,
					'menu_class'     => 'footer-menu',
					'fallback_cb'    => false,
					'depth'          => 1,
				)
			);
			?>
		</div>

		<div class="footer-menu-column">
			<h4><?php echo esc_html( $halls_title ); ?></h4>
			<?php
			wp_nav_menu(
				array(
					'theme_location' => 'footer_halls',
					'container'      => false,
					'menu_class'     => 'footer-menu',
					'fallback_cb'    => false,
					'depth'          => 1,
				)
			);
			?>
		</div>

		<div class="footer-menu-column">
			<h4><?php echo esc_html( $information_title ); ?></h4>
			<?php
			wp_nav_menu(
				array(
					'theme_location' => 'footer_information',
					'container'      => false,
					'menu_class'     => 'footer-menu',
					'fallback_cb'    => false,
					'depth'          => 1,
				)
			);
			?>
		</div>

		<div class="fnews">
			<h4><?php echo esc_html( $newsletter_title ); ?></h4>
			<?php echo do_shortcode( '[hapantheon_newsletter source="footer" style="gold"]' ); ?>
		</div>
	</div>

	<div class="wrap footer-bottom">
		<span class="credit">
			<?php echo hapantheon_icon( 'temple' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
			&copy; <span class="num en"><?php echo esc_html( wp_date( 'Y' ) ); ?></span>
			<?php bloginfo( 'name' ); ?>
		</span>
		<div class="legal">
			<?php
			wp_nav_menu(
				array(
					'theme_location' => 'footer_legal',
					'container'      => false,
					'menu_class'     => 'footer-legal-menu',
					'fallback_cb'    => 'hapantheon_footer_legal_menu_fallback',
					'depth'          => 1,
				)
			);
			?>
			<span class="footer-closing-line"><?php echo esc_html( $footer_line ); ?></span>
		</div>
	</div>
</footer>

<div class="smodal" id="smodal" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e( 'חיפוש', 'hapantheon' ); ?>">
	<div class="smodal-in">
		<button class="smodal-close" type="button" aria-label="<?php esc_attr_e( 'סגירת החיפוש', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'close' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></button>
		<span class="eyebrow">חיפוש בארכיון</span>
		<h2>מה אתם מחפשים?</h2>
		<?php get_search_form(); ?>
		<div class="scats">
			<?php
			$footer_categories = get_categories(
				array(
					'hide_empty' => false,
					'number'     => 5,
				)
			);
			foreach ( $footer_categories as $footer_category ) :
				?>
				<a href="<?php echo esc_url( get_category_link( $footer_category->term_id ) ); ?>">
					<?php echo esc_html( $footer_category->name ); ?>
					<span class="num"><?php echo esc_html( $footer_category->count ); ?></span>
				</a>
			<?php endforeach; ?>
		</div>
		<div class="meander" aria-hidden="true"></div>
	</div>
</div>

<div class="mmodal" id="mmodal" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e( 'תפריט', 'hapantheon' ); ?>">
	<div class="mm-top">
		<a class="brand" href="<?php echo esc_url( home_url( '/' ) ); ?>">
			<?php echo hapantheon_icon( 'temple', 'mark' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
			<span><?php bloginfo( 'name' ); ?><small class="en"><?php bloginfo( 'description' ); ?></small></span>
		</a>
		<div class="mm-top-actions">
			<button class="mm-search" type="button" aria-label="<?php esc_attr_e( 'חיפוש', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'search' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></button>
			<button class="mm-theme" type="button" aria-label="<?php esc_attr_e( 'החלפת ערכת צבעים', 'hapantheon' ); ?>">
				<?php echo hapantheon_icon( 'sun', 'sun' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
				<?php echo hapantheon_icon( 'moon', 'moon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
			</button>
			<button class="mm-close" type="button" aria-label="<?php esc_attr_e( 'סגירת התפריט', 'hapantheon' ); ?>"><?php echo hapantheon_icon( 'close' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></button>
		</div>
	</div>
	<nav class="mm-links" aria-label="<?php esc_attr_e( 'ניווט נייד', 'hapantheon' ); ?>"></nav>
	<div class="mm-foot"><div class="meander" aria-hidden="true"></div></div>
</div>

<?php wp_footer(); ?>
</body>
</html>
