/*
Theme Name: Tribitat
Theme URI: https://tribitat.com/
Author: Tribitat Team
Author URI: https://tribitat.com
Description: Tribitat is a theme design inspired by the Brutalist concepts of the homonymous Architectural movement. It aims to be harsh, honest, utilitarian, and useful. It is a good portfolio pick for architects, design studios, and creative organizations.
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 7.4
Version: 2.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: tribitat
Tags: photography, one-column, right-sidebar, wide-blocks, block-patterns, custom-colors, custom-logo, custom-menu, editor-style, featured-images, full-site-editing, rtl-language-support, theme-options, threaded-comments, translation-ready, accessibility-ready

/* Progresive enhancement to reduce widows and orphans.
/* https://github.com/WordPress/gutenberg/issues/55190
*/

h1, h2, h3, h4, h5, h6, blockquote, caption, figcaption {
    text-wrap: balance;
}
p {
    text-wrap: pretty;
}

/**
 * Currently table styles are only available with 'wp-block-styles' 
 * theme support (block css) thus the following needs to be included
 * since 'wp-block-styles' aren't used for this theme.
 * https://github.com/WordPress/gutenberg/issues/45065
 */

/*
 * Control the hover stylings of outline block style.
 * Unnecessary once block styles are configurable via theme.json
 * https://github.com/WordPress/gutenberg/issues/42794
 */
.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-background):hover {
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--background);
	border-color: var(--wp--preset--color--secondary);
}

/**
 * Currently table styles are only available with 'wp-block-styles' 
 * theme support (block css) thus the following needs to be included
 * since 'wp-block-styles' aren't used for this theme.
 * https://github.com/WordPress/gutenberg/issues/45065
 */
.wp-block-table thead {
	border-bottom: 3px solid;
}
.wp-block-table tfoot {
	border-top: 3px solid;
}
.wp-block-table td,
.wp-block-table th {
	padding: var(--wp--preset--spacing--30);
	border: 1px solid;
	word-break: normal;
}
.wp-block-table figcaption {
	font-size: var(--wp--preset--font-size--small);
	text-align: center;
}

/*
 * Link styles
 * https://github.com/WordPress/gutenberg/issues/42319
 */
a {
	text-decoration-thickness: 1px !important;
	text-underline-offset: .1em;
}

/* Focus styles */
:where(.wp-site-blocks *:focus) {
	outline-width: 2px;
	outline-style: solid;
}

/* Caption styles for better readability */
figcaption,
.wp-element-caption {
	font-size: 0.875rem;
	line-height: 1.4;
	margin-top: 0.5rem;
}

/* List styles for better spacing */
.wp-block-list li,
ul li,
ol li {
	margin-top: 0.5rem;
}

/* Better paragraph spacing in content */
.entry-content p,
.wp-block-post-content p {
	margin-bottom: 1.2em;
}

/*
 * Hero Section Styles for Single Posts
 * SEO-friendly and mobile-responsive hero header
 */
.tribitat-post-hero {
	position: relative;
}

.tribitat-post-hero .wp-block-cover__inner-container {
	z-index: 2;
}

/* Enhanced text readability with subtle shadow */
.tribitat-post-hero h1,
.tribitat-post-hero .wp-block-post-title {
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	margin-bottom: 1rem;
	padding: 1rem;
	border-radius: 8px;
}

.tribitat-post-hero .wp-block-post-excerpt,
.tribitat-post-hero .wp-block-post-terms,
.tribitat-post-hero .wp-block-post-date,
.tribitat-post-hero .wp-block-post-author-name,
.tribitat-post-hero p {
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Mobile responsive adjustments */
@media (max-width: 782px) {
	.tribitat-post-hero {
		min-height: 400px !important;
		padding-top: 3rem !important;
		padding-bottom: 3rem !important;
	}
	
	.tribitat-post-hero h1,
	.tribitat-post-hero .wp-block-post-title {
		font-size: clamp(1.75rem, 5vw, 3rem) !important;
		line-height: 1.2 !important;
	}
	
	.tribitat-post-hero .wp-block-post-excerpt {
		font-size: 1rem !important;
	}
}

@media (max-width: 480px) {
	.tribitat-post-hero {
		min-height: 350px !important;
		padding-left: 1.5rem !important;
		padding-right: 1.5rem !important;
	}
	
	.tribitat-post-hero .wp-block-group {
		padding-left: 0 !important;
		padding-right: 0 !important;
	}
}

/* SEO-friendly: Ensure featured image loads properly */
.tribitat-post-hero .wp-block-cover__image-background {
	object-fit: cover;
	object-position: center;
	filter: none !important; /* Keep colors, no grayscale */
}

/* Accessibility: High contrast for better readability */
@media (prefers-contrast: high) {
	.tribitat-post-hero .wp-block-cover__background {
		opacity: 0.6 !important;
	}
	
	.tribitat-post-hero h1,
	.tribitat-post-hero .wp-block-post-title,
	.tribitat-post-hero p {
		text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
	}
}

/*
 * Scroll to Top Button
 * Clean, accessible, and performant
 */
#tribitat-scroll-top {
	position: fixed;
	bottom: 2rem;
	right: 2rem;
	z-index: 99;
	width: 48px;
	height: 48px;
	background-color: var(--wp--preset--color--primary);
	border: 2px solid var(--wp--preset--color--secondary);
	border-radius: 4px;
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.25rem;
	color: var(--wp--preset--color--secondary);
	padding: 0;
	line-height: 1;
}

#tribitat-scroll-top:hover {
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
}

#tribitat-scroll-top:focus {
	outline: 2px solid var(--wp--preset--color--secondary);
	outline-offset: 2px;
}

#tribitat-scroll-top.show {
	opacity: 1;
	visibility: visible;
}

/* Hero Section Group Block Styling */
.wp-block-cover .wp-block-group.has-base-background-color.has-background {
	background-color: var(--wp--preset--color--background);
	padding: 2rem;
	border-radius: 8px;
	opacity: 0.8;
}

/* Single Post Hero Title Opacity */
.tribitat-post-hero .wp-block-post-title,
.tribitat-post-hero .wp-block-heading {
	opacity: 0.8;
}

/* Mobile responsive */
@media (max-width: 480px) {
	#tribitat-scroll-top {
		bottom: 1rem;
		right: 1rem;
		width: 44px;
		height: 44px;
		font-size: 1.1rem;
	}
}

/* Mobile typography improvements */
@media (max-width: 768px) {
	/* Adjust base font size for better mobile readability */
	body {
		font-size: 1.125rem;
		line-height: 1.6;
	}

	/* Adjust headings for mobile */
	h1 {
		font-size: 2.15rem;
		line-height: 1.2;
	}

	h2 {
		font-size: 1.75rem;
		line-height: 1.2;
	}

	h3 {
		font-size: 1.375rem;
		line-height: 1.3;
	}

	h4 {
		font-size: 1.125rem;
		line-height: 1.3;
	}

	h5, h6 {
		font-size: 0.875rem;
		line-height: 1.4;
	}

	/* Better paragraph spacing on mobile */
	p {
		margin-bottom: 1.25em;
	}

	/* Adjust list spacing */
	ul, ol {
		padding-left: 1.25em;
	}

	li {
		margin-top: 0.4rem;
	}
}

/* Small mobile devices - extra readability */
@media (max-width: 480px) {
	body {
		font-size: 1rem;
	}

	h1 {
		font-size: 1.75rem;
	}

	h2 {
		font-size: 1.5rem;
	}

	h3 {
		font-size: 1.25rem;
	}
}

/* Tablet typography adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
	body {
		font-size: 1.25rem;
		line-height: 1.6;
	}
}

/* Large screens - optimal reading experience */
@media (min-width: 1440px) {
	.entry-content,
	.wp-block-post-content {
		font-size: 1.375rem;
		line-height: 1.6;
	}
}

/* --------------------------------------------------
 * Mobile Header: Hamburger + Fullscreen Overlay Menu
 * -------------------------------------------------- */
.tribi-mobile-header { display: none; }

/* Default: hide mobile header unless small screen overrides */
.wp-block-group.alignfull > .tribi-mobile-header { display: none !important; }

.tribi-hamburger {
	appearance: none;
	background: transparent;
	color: var(--wp--preset--color--secondary);
	border: 1px solid currentColor;
	border-radius: 8px;
	padding: 0.75rem;
	line-height: 1;
	cursor: pointer;
	min-width: 44px;
	min-height: 44px;
	display: flex;
}

.tribi-hamburger .tribi-hamburger-box {
	display: inline-flex;
	flex-direction: column;
	gap: 4px;
	justify-content: center;
	align-items: center;
	flex: 1;
}

.tribi-hamburger .tribi-hamburger-box {
	position: relative;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tribi-hamburger .tribi-hamburger-box::before {
	content: "☰";
	font-size: 24px;
	font-weight: bold;
	line-height: 1;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transition: content 0.2s ease;
}

.tribi-hamburger[aria-expanded="true"] .tribi-hamburger-box::before {
	content: "✕";
}

.tribi-mobile-overlay[hidden] {
	display: none !important;
}

.tribi-mobile-overlay {
	margin: 0;
	position: fixed;
	inset: 0;
	background: var(--wp--preset--color--background);
	color: var(--wp--preset--color--foreground, var(--wp--preset--color--secondary));
	z-index: 9999;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tribi-mobile-overlay.open {
	opacity: 1;
	visibility: visible;
}

.tribi-no-scroll {
	overflow: hidden;
}

.tribi-overlay-inner {
	max-width: min(100%, 960px);
	margin: 0 auto;
	padding: 1rem;
}

.tribi-overlay-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 2rem;
}

.tribi-overlay-nav .wp-block-navigation__container {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* Show mobile bar, hide desktop columns on small screens */
@media (max-width: 782px) {
	/* Show the mobile bar on small screens */
	.wp-block-group.alignfull > .tribi-mobile-header {
		display: flex !important;
		align-items: center;
		justify-content: space-between;
		padding-top: 0.75rem;
		padding-bottom: 0.75rem;
	}

	/* Hide desktop header columns on small screens */
	.wp-block-group.alignfull > .wp-block-columns.alignwide {
		display: none !important;
	}
}

@media (min-width: 783px) {
	/* Ensure mobile header never shows on desktop */
	.tribi-mobile-header { display: none !important; }
	.tribi-mobile-overlay { display: none !important; }
}
