/*
Theme Name:        Mashrabiya Light
Description:       Child theme of Twenty Twenty-Five with a generated Islamic geometric background (a faint eight-point star lattice with slow electric pulses, parallax depth and soft focus), automatic dark mode, and a transparent header with an animated "Mohammad Hafzah → hafzah.io" logo, centered menu, search icon and a Light / Dark / Auto switch.
Theme URI:         https://hafzah.io
Author:            Mohammad Hafzah
Author URI:        https://hafzah.io
Template:          twentytwentyfive
Version:           1.5.0
Requires at least: 6.7
Requires PHP:      7.4
License:           GNU General Public License v2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       mashrabiya-light
*/

/* Always reserve space for the scrollbar, so the centered menu
   doesn't jump sideways between short and long pages. */
html {
	scrollbar-gutter: stable;
}

/* =========================================================
   1. Header layout: [ Home ] [ Menu (centered) ] [ Search ]
   ========================================================= */

.cth-header {
	--cth-ink: var(--wp--preset--color--contrast, currentColor);
	--cth-surface: var(--wp--preset--color--base, #fff);
	--cth-height: 44px;   /* same as apple.com's global nav bar */
	--cth-button: 36px;   /* tap area for each icon */
	--cth-icon: 18px;

	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 1rem;
	height: var(--cth-height);
	padding-block: 0;
	padding-inline: var(--wp--preset--spacing--50, 1.5rem);
	background: transparent;
	color: var(--cth-ink);
	position: relative;
	z-index: 100;
}

/* Cancel the block editor's flow-layout margins on direct children */
.cth-header > * {
	margin: 0;
}

.cth-home {
	justify-self: start; /* start = left in LTR, right in RTL (Arabic) */
}

.cth-header__center {
	justify-self: center;
	position: relative;
	display: flex;
	align-items: center;
}

.cth-search {
	justify-self: end;
}

/* =========================================================
   2. Icons (Home + Search) — inherit text colour so they blend
   ========================================================= */

.cth-icon-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--cth-button);
	height: var(--cth-button);
	color: inherit;
	opacity: 0.8;
	text-decoration: none;
	border-radius: 50%;
	transition: opacity 0.2s ease;
}

.cth-icon-link:hover,
.cth-icon-link:focus-visible {
	opacity: 1;
}

.cth-icon-link svg {
	width: var(--cth-icon);
	height: var(--cth-icon);
}

/* The house drawing has built-in padding inside its 24px canvas,
   so it renders the SVG at 24px to make the house itself 18px wide,
   matching the hamburger lines. Stroke stays 1.5px, like the bars. */
.cth-home svg {
	width: 24px;
	height: 24px;
	stroke-width: 2; /* bold: 2px lines, same as the hamburger bars */
}

/* =========================================================
   3. Search block (core "button only" expandable search)
   ========================================================= */

.cth-header .cth-search .wp-block-search__inside-wrapper {
	border: 0;
	padding: 0;
	background: transparent;
	align-items: center;
}

.cth-header .cth-search .wp-block-search__button.wp-element-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--cth-button);
	height: var(--cth-button);
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.8;
	box-shadow: none;
	transition: opacity 0.2s ease;
}

.cth-header .cth-search .wp-block-search__button.wp-element-button:hover,
.cth-header .cth-search .wp-block-search__button.wp-element-button:focus-visible {
	opacity: 1;
}

.cth-header .cth-search .wp-block-search__button svg {
	width: var(--cth-icon);
	height: var(--cth-icon);
	fill: currentColor;
	/* The core search icon is a filled shape, so a thin outline
	   of the same colour thickens it to match the other icons. */
	stroke: currentColor;
	stroke-width: 1.1;
	stroke-linejoin: round;
}

/* The text field that slides open when the icon is clicked */
.cth-header .cth-search .wp-block-search__input {
	background: transparent;
	color: inherit;
	border: 0;
	border-bottom: 1px solid currentColor;
	border-radius: 0;
	font-size: var(--wp--preset--font-size--small, 0.9rem);
	padding: 0.2rem 0.25rem;
	line-height: 1.4;
}

.cth-header .cth-search:not(.wp-block-search__searchfield-hidden) .wp-block-search__input {
	min-width: min(14rem, 45vw);
}

.cth-header .cth-search .wp-block-search__input::placeholder {
	color: inherit;
	opacity: 0.55;
}

.cth-header .cth-search .wp-block-search__input:focus {
	outline: none;
}

/* =========================================================
   4. Navigation — horizontal (5 items or fewer)
   ========================================================= */

.cth-nav .wp-block-navigation__container {
	gap: clamp(1rem, 2.5vw, 2.25rem);
}

/* Softened colour instead of opacity (opacity animations make text
   re-render and shift by a sub-pixel). The underline is always there
   but invisible, and only its colour changes — nothing re-lays out. */
.cth-nav .wp-block-navigation-item__content {
	color: color-mix(in srgb, var(--cth-ink) 78%, transparent);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 700;
	line-height: 1;
	padding-block: 0;
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.35em;
	-webkit-tap-highlight-color: transparent;
	transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.cth-nav .wp-block-navigation-item__content:hover,
.cth-nav .wp-block-navigation-item__content:focus,
.cth-nav .wp-block-navigation-item__content:active,
.cth-nav .current-menu-item > .wp-block-navigation-item__content {
	color: var(--cth-ink);
	text-decoration: underline;
	text-decoration-color: currentColor;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.35em;
}

/* =========================================================
   5. Hamburger toggle (injected by header.js)
   ========================================================= */

.cth-menu-toggle {
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	width: var(--cth-button);
	height: var(--cth-button);
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.8;
	cursor: pointer;
}

.cth-menu-toggle:hover,
.cth-menu-toggle:focus-visible {
	opacity: 1;
}

.cth-menu-toggle__bar {
	display: block;
	width: 18px;
	height: 2px;
	border-radius: 2px;
	background: currentColor;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Bars morph into an "X" when the menu is open */
.cth-header.is-menu-open .cth-menu-toggle__bar:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}
.cth-header.is-menu-open .cth-menu-toggle__bar:nth-child(2) {
	opacity: 0;
}
.cth-header.is-menu-open .cth-menu-toggle__bar:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

/* =========================================================
   6. Collapsed state (more than 5 items) → dropdown
   ========================================================= */

.cth-header.is-collapsed .cth-menu-toggle {
	display: inline-flex;
}

.cth-header.is-collapsed .cth-nav {
	position: static; /* let the dropdown anchor to .cth-header__center */
}

.cth-header.is-collapsed .cth-nav .wp-block-navigation__container {
	display: none;
}

.cth-header.is-collapsed.is-menu-open .cth-nav .wp-block-navigation__container {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.85rem;
	position: absolute;
	top: calc(100% + 0.5rem);
	left: 50%;
	transform: translateX(-50%);
	min-width: 13rem;
	max-height: 70vh;
	overflow-y: auto;
	padding: 1.25rem 1.5rem;
	background: color-mix(in srgb, var(--cth-surface) 88%, transparent);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
	border-radius: 14px;
	box-shadow: 0 16px 40px -18px rgb(0 0 0 / 0.25);
	text-align: center;
	animation: cth-drop 0.18s ease-out;
}

/* Sub-menus: show them inline inside the dropdown instead of on hover */
.cth-header.is-collapsed .wp-block-navigation__submenu-icon {
	display: none;
}

.cth-header.is-collapsed .wp-block-navigation-item.has-child {
	flex-direction: column;
}

.cth-header.is-collapsed .wp-block-navigation .wp-block-navigation__submenu-container {
	position: static;
	visibility: visible;
	opacity: 1;
	width: auto;
	height: auto;
	min-width: 0;
	overflow: visible;
	border: 0;
	background: transparent;
	padding: 0.4rem 0 0;
	gap: 0.4rem;
	align-items: center;
}

.cth-header.is-collapsed .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	font-size: 0.85em;
	color: color-mix(in srgb, var(--cth-ink) 62%, transparent);
	padding: 0;
}

@keyframes cth-drop {
	from { opacity: 0; transform: translate(-50%, -6px); }
	to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
	.cth-header *,
	.cth-header *::before,
	.cth-header *::after {
		animation: none !important;
		transition: none !important;
	}
}

/* =========================================================
   7. Keyboard focus
   ========================================================= */

.cth-header a:focus-visible,
.cth-header button:focus-visible {
	outline: 1.5px solid currentColor;
	outline-offset: 3px;
}

/* =========================================================
   8. OPTIONAL — float the header over a full-width hero image.
   Uncomment if you want the header to sit ON TOP of the first
   section (e.g. a photo) instead of above it.
   ========================================================= */
/*
.wp-site-blocks > header.wp-block-template-part {
	position: absolute;
	inset: 0 0 auto 0;
	z-index: 100;
}
.admin-bar .wp-site-blocks > header.wp-block-template-part {
	top: var(--wp-admin--admin-bar--height, 32px);
}
.cth-header {
	--cth-ink: #fff;         // light icons/text over dark photos
	--cth-surface: #1a1a1a;  // dark dropdown so white text stays readable
}
*/

/* =========================================================
   9. Logo (hafzah/logo block) inside the header
   ========================================================= */

/* The logo takes the Home icon's place on the left */
.cth-header > .mh-logo {
	justify-self: start;
	/* Scales down on narrow screens so the logo, menu button and
	   search icon always fit on one line. Desktop uses the size
	   set in Appearance → Logo. */
	font-size: min(var(--mh-size, 1.5rem), 5vw) !important;
}

/* Phones: the search field opens as a small panel under the header,
   instead of pushing the logo and menu off the screen. */
@media (max-width: 600px) {
	.cth-header .cth-search:not(.wp-block-search__searchfield-hidden) .wp-block-search__input {
		position: absolute;
		top: calc(100% + 0.5rem);
		inset-inline-end: var(--wp--preset--spacing--50, 1.5rem);
		width: min(18rem, calc(100vw - 3rem));
		min-width: 0;
		padding: 0.6rem 0.9rem;
		background: color-mix(in srgb, var(--cth-surface) 88%, transparent);
		-webkit-backdrop-filter: blur(14px);
		backdrop-filter: blur(14px);
		border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
		border-radius: 14px;
		box-shadow: 0 16px 40px -18px rgb(0 0 0 / 0.25);
	}
}

/* =========================================================
   10. Right side: [ Search ] [ Light / Dark / Auto switch ]
   ========================================================= */

.cth-header__end {
	justify-self: end;
	display: flex;
	align-items: center;
	gap: 0.25rem;
}
.cth-header__end > * {
	margin: 0;
}

/* Holds the switch's place in the header; the pill opens over the page */
.cth-theme {
	--cth-ease: cubic-bezier(0.2, 0.75, 0.2, 1);
	position: relative;
	flex: none;
	width: var(--cth-button);
	height: var(--cth-button);
}

.cth-theme__pill {
	position: absolute;
	top: 0;
	inset-inline-start: 0;
	display: flex;
	flex-direction: column;
	width: var(--cth-button);
	height: var(--cth-button);
	overflow: hidden;
	border-radius: calc(var(--cth-button) / 2);
	background: transparent;
	box-shadow: none;
	transition:
		height 0.28s var(--cth-ease),
		background-color 0.2s ease,
		box-shadow 0.2s ease;
}

/* Open: hover (mouse), tap (touch, via .is-open) or keyboard focus */
@media (hover: hover) {
	.cth-theme:hover .cth-theme__pill {
		height: calc(var(--cth-button) * 3);
		background: color-mix(in srgb, var(--cth-surface) 88%, transparent);
		-webkit-backdrop-filter: blur(14px);
		backdrop-filter: blur(14px);
		box-shadow:
			inset 0 0 0 1px color-mix(in srgb, currentColor 12%, transparent),
			0 16px 40px -18px rgb(0 0 0 / 0.25);
	}
}
.cth-theme.is-open .cth-theme__pill,
.cth-theme:has(:focus-visible) .cth-theme__pill {
	height: calc(var(--cth-button) * 3);
	background: color-mix(in srgb, var(--cth-surface) 88%, transparent);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	box-shadow:
		inset 0 0 0 1px color-mix(in srgb, currentColor 12%, transparent),
		0 16px 40px -18px rgb(0 0 0 / 0.25);
}

.cth-theme__opt {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--cth-button);
	height: var(--cth-button);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.8;
	cursor: pointer;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}
.cth-theme__opt:hover,
.cth-theme__opt:focus-visible {
	opacity: 1;
}
.cth-theme__opt:focus-visible {
	outline: 1.5px solid currentColor;
	outline-offset: -4px;
}

/* Same weight as the other header icons */
.cth-theme__opt svg {
	width: var(--cth-icon);
	height: var(--cth-icon);
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.cth-theme__opt .cth-theme__fill {
	fill: currentColor;
	stroke: none;
}

/* The active choice sits on top (set before the script loads, too) */
:root[data-theme="dark"] .cth-theme__opt[data-mode="dark"],
:root[data-theme="auto"] .cth-theme__opt[data-mode="auto"] {
	order: -1;
}

/* Once the script is running: the other two can't be reached with Tab
   while the pill is closed, and the active one is softly highlighted
   when it's open. */
.cth-theme.is-ready .cth-theme__opt[aria-pressed="false"] {
	visibility: hidden;
	transition: opacity 0.2s ease, background-color 0.2s ease, visibility 0s linear 0.28s;
}
.cth-theme.is-ready.is-open .cth-theme__opt,
.cth-theme.is-ready:has(:focus-visible) .cth-theme__opt {
	visibility: visible;
	transition-delay: 0s;
}
@media (hover: hover) {
	.cth-theme.is-ready:hover .cth-theme__opt {
		visibility: visible;
		transition-delay: 0s;
	}
	.cth-theme:hover .cth-theme__opt[aria-pressed="true"] {
		background: color-mix(in srgb, currentColor 10%, transparent);
	}
}
.cth-theme.is-open .cth-theme__opt[aria-pressed="true"],
.cth-theme:has(:focus-visible) .cth-theme__opt[aria-pressed="true"] {
	background: color-mix(in srgb, currentColor 10%, transparent);
}

@media (prefers-reduced-motion: reduce) {
	.cth-theme__pill,
	.cth-theme__opt {
		transition: none;
	}
}

/* Phones: a little tighter so logo, menu, search and switch fit one line */
@media (max-width: 600px) {
	.cth-header {
		gap: 0.5rem;
	}
	.cth-header__end {
		gap: 0;
	}
}

/* =========================================================
   11. Add any custom CSS for your site below this line.
   ========================================================= */
