<!--FansPaysite/header.php-->
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo('charset'); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<?php wp_head(); ?>
</head>

<?php $fanspaysite_layout = get_theme_mod('fanspaysite_layout', 'left-sidebar'); ?>

<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'fanspaysite' ); ?></a>

<?php if ($fanspaysite_layout === 'top-bar') : ?>
<!-- Top Bar Layout (Fansly-style) -->
<div class="site-wrapper">

<header class="site-topbar" role="banner">
	<div class="topbar-logo">
		<?php
		$fanspaysite_has_logo = fanspaysite_render_logos();
		$fanspaysite_title_mode = get_theme_mod('display_site_title', 'auto');
		if ( $fanspaysite_title_mode === 'yes' || ( $fanspaysite_title_mode === 'auto' && ! $fanspaysite_has_logo ) ) {
			if ( is_front_page() ) {
				echo '<h1 class="site-title"><a href="' . esc_url(home_url('/')) . '" rel="home">' . esc_html(get_bloginfo('name')) . '</a></h1>';
			} else {
				echo '<p class="site-title"><a href="' . esc_url(home_url('/')) . '" rel="home">' . esc_html(get_bloginfo('name')) . '</a></p>';
			}
		}
		?>
	</div>

	<nav class="topbar-nav" aria-label="<?php esc_attr_e('Primary navigation', 'fanspaysite'); ?>">
		<div class="topbar-menu">
			<?php
			if ( has_nav_menu( 'menu-1' ) ) {
				wp_nav_menu(array(
					'theme_location' => 'menu-1',
					'menu_id'        => 'topbar-primary-menu',
					'container'      => false,
					'items_wrap'     => '%3$s',
					'fallback_cb'    => false,
					'walker'         => new FansPaysite_TopBar_Walker_Nav_Menu(),
				));
			} else {
				fanspaysite_render_primary_menu_fallback( 'topbar' );
			}
			?>
		</div>
	</nav>

	<div class="topbar-actions">
		<?php if (is_active_sidebar('fanspaysite_menu_widgets')) : ?>
			<div class="fps-menu-widget-area fps-menu-widget-area-topbar" role="group" aria-label="<?php esc_attr_e('Menu widgets', 'fanspaysite'); ?>">
				<?php dynamic_sidebar('fanspaysite_menu_widgets'); ?>
			</div>
		<?php endif; ?>
		<?php if (get_theme_mod('fanspaysite_show_theme_mode_switcher', 'yes') === 'yes') : ?>
			<?php
			$theme_mode = fanspaysite_get_current_theme_mode();
			$theme_modes = array(
				'light' => array(
					'icon'  => 'fas fa-sun',
					'label' => __( 'Light', 'fanspaysite' ),
				),
				'dark' => array(
					'icon'  => 'fas fa-moon',
					'label' => __( 'Dark', 'fanspaysite' ),
				),
				'auto' => array(
					'icon'  => 'fas fa-cog',
					'label' => __( 'Auto', 'fanspaysite' ),
				),
			);
			$current_theme_mode = $theme_modes[ $theme_mode ] ?? $theme_modes['light'];
			?>
			<div id="fanspaysiteMode" class="fps-mode-switcher" data-theme-mode="<?php echo esc_attr( $theme_mode ); ?>">
				<button class="ui button fpsModeCurrent" type="button" title="<?php echo esc_attr__( 'Theme mode', 'fanspaysite' ); ?>" aria-haspopup="true" aria-expanded="false" aria-controls="fanspaysite-mode-options" aria-label="<?php echo esc_attr__( 'Theme mode', 'fanspaysite' ); ?>">
					<i class="<?php echo esc_attr( $current_theme_mode['icon'] ); ?>" aria-hidden="true"></i>
				</button>
				<div id="fanspaysite-mode-options" class="fps-mode-options" aria-label="<?php esc_attr_e( 'Theme mode options', 'fanspaysite' ); ?>" hidden>
					<?php foreach ( $theme_modes as $mode_key => $mode_data ) : ?>
						<button class="ui button fpsMode<?php echo ( $theme_mode === $mode_key ? ' active is-current' : '' ); ?>" type="button" data-theme="<?php echo esc_attr( $mode_key ); ?>" title="<?php echo esc_attr( $mode_data['label'] ); ?>" aria-label="<?php echo esc_attr( $mode_data['label'] ); ?>" aria-selected="<?php echo $theme_mode === $mode_key ? 'true' : 'false'; ?>">
							<i class="<?php echo esc_attr( $mode_data['icon'] ); ?>" aria-hidden="true"></i>
						</button>
					<?php endforeach; ?>
				</div>
			</div>
		<?php endif; ?>
		<button class="topbar-hamburger" id="topbar-hamburger" aria-label="<?php esc_attr_e('Toggle menu', 'fanspaysite'); ?>" aria-expanded="false" aria-controls="topbar-expanded-menu">
			<i class="fas fa-bars"></i>
		</button>
	</div>
</header>

<!-- Expandable full menu panel (hamburger) - always shows icons & text -->
<div class="site-topbar-expanded" id="topbar-expanded-menu" style="display:none;" role="region" aria-label="<?php esc_attr_e('Expanded menu', 'fanspaysite'); ?>">
	<div class="topbar-expanded-inner">
		<div id="fanspaysiteMenu" class="ui vertical menu small fluid fps-expanded-menu">
			<?php
			if ( has_nav_menu( 'menu-1' ) ) {
				wp_nav_menu(array(
					'theme_location' => 'menu-1',
					'menu_id'        => 'expanded-primary-menu',
					'container'      => false,
					'items_wrap'     => '%3$s',
					'fallback_cb'    => false,
					'walker'         => new FansPaysite_Custom_Walker_Nav_Menu(),
				));
			} else {
				fanspaysite_render_primary_menu_fallback();
			}
			?>
		</div>
	</div>
</div>

<?php do_action( 'fanspaysite_breadcrumb' ); ?>

<div class="site-content-wrapper">
<main id="content" class="site-content">

<?php
if ( get_header_image() ) {
	$header_obj = get_custom_header();
	echo '<div class="header-image"><img src="' . esc_url( get_header_image() ) . '"'
		. ' width="' . esc_attr( $header_obj->width ) . '"'
		. ' height="' . esc_attr( $header_obj->height ) . '"'
		. ' alt="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '"></div>';
}
?>

<?php else : ?>
<!-- Left Sidebar Layout (default, OnlyFans-style) -->
<div class="site-wrapper">
<aside class="site-sidebar">

<header id="masthead" class="site-header" role="banner">
    <div class="logo-title">
        <?php
        $fanspaysite_has_logo = fanspaysite_render_logos();

        $fanspaysite_title_mode = get_theme_mod('display_site_title', 'auto');
        if ( $fanspaysite_title_mode === 'yes' || ( $fanspaysite_title_mode === 'auto' && ! $fanspaysite_has_logo ) ) {
            if ( is_front_page() ) {
                echo '<h1 class="site-title"><a href="' . esc_url(home_url('/')) . '" rel="home">' . esc_html(get_bloginfo('name')) . '</a></h1>';
            } else {
                echo '<p class="site-title"><a href="' . esc_url(home_url('/')) . '" rel="home">' . esc_html(get_bloginfo('name')) . '</a></p>';
            }
        }

        $fanspaysite_tagline_mode = get_theme_mod('display_site_tagline', 'auto');
        if ( $fanspaysite_tagline_mode === 'yes' || ( $fanspaysite_tagline_mode === 'auto' && ! $fanspaysite_has_logo ) ) {
            echo '<p class="site-tagline">' . esc_html(get_bloginfo('description')) . '</p>';
        }
        ?>
    </div>
    <button class="sidebar-hamburger" id="sidebar-hamburger" aria-label="<?php esc_attr_e('Toggle menu', 'fanspaysite'); ?>" aria-expanded="false" aria-controls="sidebar-menu-panel">
        <i class="fas fa-bars"></i>
    </button>
</header>

<!-- Sidebar menu panel (wraps nav; becomes full-screen overlay in burger mode) -->
<div id="sidebar-menu-panel" class="sidebar-menu-panel">
    <button class="sidebar-panel-close" id="sidebar-panel-close" aria-label="<?php esc_attr_e('Close menu', 'fanspaysite'); ?>">
        <i class="fas fa-times"></i>
    </button>

    <nav id="site-navigation" class="main-navigation" aria-label="<?php esc_attr_e('Primary navigation', 'fanspaysite'); ?>">
        <div id="fanspaysiteMenu" class="ui vertical menu small fluid">
            <?php
                if ( has_nav_menu( 'menu-1' ) ) {
                    wp_nav_menu(array(
                        'theme_location' => 'menu-1',
                        'menu_id'        => 'primary-menu',
                        'container'      => false,
                        'items_wrap'     => '%3$s',
                        'fallback_cb'    => false,
                        'walker'         => new FansPaysite_Custom_Walker_Nav_Menu(),
                    ));
                } else {
                    fanspaysite_render_primary_menu_fallback();
                }
            ?>
        </div>
    </nav>
	<?php if (is_active_sidebar('fanspaysite_menu_widgets')) : ?>
		<div class="fps-menu-widget-area fps-menu-widget-area-sidebar" role="group" aria-label="<?php esc_attr_e('Menu widgets', 'fanspaysite'); ?>">
			<?php dynamic_sidebar('fanspaysite_menu_widgets'); ?>
		</div>
	<?php endif; ?>
</div>

<?php if (get_theme_mod('fanspaysite_show_theme_mode_switcher', 'yes') === 'yes') : ?>
	<?php
	$theme_mode = fanspaysite_get_current_theme_mode();
	$theme_modes = array(
		'light' => array(
			'icon'  => 'fas fa-sun',
			'label' => __( 'Light', 'fanspaysite' ),
		),
		'dark' => array(
			'icon'  => 'fas fa-moon',
			'label' => __( 'Dark', 'fanspaysite' ),
		),
		'auto' => array(
			'icon'  => 'fas fa-cog',
			'label' => __( 'Auto', 'fanspaysite' ),
		),
	);
	$current_theme_mode = $theme_modes[ $theme_mode ] ?? $theme_modes['light'];
	?>
	<div id="fanspaysiteMode" class="fps-mode-switcher" data-theme-mode="<?php echo esc_attr( $theme_mode ); ?>">
		<button class="ui button fpsModeCurrent" type="button" title="<?php echo esc_attr__( 'Theme mode', 'fanspaysite' ); ?>" aria-haspopup="true" aria-expanded="false" aria-controls="fanspaysite-mode-options" aria-label="<?php echo esc_attr__( 'Theme mode', 'fanspaysite' ); ?>">
			<i class="<?php echo esc_attr( $current_theme_mode['icon'] ); ?>" aria-hidden="true"></i>
		</button>
		<div id="fanspaysite-mode-options" class="fps-mode-options" aria-label="<?php esc_attr_e( 'Theme mode options', 'fanspaysite' ); ?>" hidden>
			<?php foreach ( $theme_modes as $mode_key => $mode_data ) : ?>
				<button class="ui button fpsMode<?php echo ( $theme_mode === $mode_key ? ' active is-current' : '' ); ?>" type="button" data-theme="<?php echo esc_attr( $mode_key ); ?>" title="<?php echo esc_attr( $mode_data['label'] ); ?>" aria-label="<?php echo esc_attr( $mode_data['label'] ); ?>" aria-selected="<?php echo $theme_mode === $mode_key ? 'true' : 'false'; ?>">
					<i class="<?php echo esc_attr( $mode_data['icon'] ); ?>" aria-hidden="true"></i>
				</button>
			<?php endforeach; ?>
		</div>
	</div>
<?php endif; ?>

<!-- Left sidebar, under menu-->
<div class="site-sidebar-left">
  <?php if (is_active_sidebar('fanspaysite_left_sidebar')) : ?>
	  <?php dynamic_sidebar('fanspaysite_left_sidebar'); ?>
  <?php endif; ?>
</div>

</aside>

<?php do_action( 'fanspaysite_breadcrumb' ); ?>

<main id="content" class="site-content">

<?php
if ( get_header_image() ) {
	$header_obj = get_custom_header();
	echo '<div class="header-image"><img src="' . esc_url( get_header_image() ) . '"'
		. ' width="' . esc_attr( $header_obj->width ) . '"'
		. ' height="' . esc_attr( $header_obj->height ) . '"'
		. ' alt="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '"></div>';
}
?>
<?php endif; ?>
