/* =============================================================================
   FILE: layout.css
   WHAT: Structural page layout -- the overall page skeleton (header, main
         content area, footer), the .container width-limiting wrapper, and
         reusable CSS Grid/Flexbox layout helper classes.
   WHY separate from components.css: layout.css answers "where on the page
         do things go and how wide are they?" while components.css answers
         "what does this specific reusable piece (a button, a card) look
         like?" Keeping structural layout separate from visual components
         makes each file smaller and easier to scan.
   LOAD ORDER: fourth, after base.css (see inc/enqueue.php).
   MOBILE-FIRST: base rules = phone (usually single column, stacked). Media
         queries ADD multi-column layouts for wider screens.
   ============================================================================= */

/* -----------------------------------------------------------------------
   CONTAINER
   The single most-used layout class in the whole theme. Wraps page
   content so it never gets wider than --container-max, and centers it
   with side padding that grows on bigger screens (more breathing room)
   but stays small on phones (to not waste precious mobile screen width).
   ----------------------------------------------------------------------- */
.container {
	width: 100%;
	max-width: var(--container-max);
	margin-inline: auto; /* "inline" margins = left+right in left-to-right
	                        languages; centers the container horizontally */
	padding-inline: var(--space-4); /* 16px side padding on mobile */
}

@media (min-width: 768px) {
	.container {
		padding-inline: var(--space-8); /* 32px side padding on tablet+ */
	}
}

/* -----------------------------------------------------------------------
   STICKY FOOTER SKELETON
   Makes the footer sit at the very bottom of the browser window even on
   pages with very little content (instead of floating awkwardly in the
   middle of a tall, empty page). Uses a flex column on the <body> (see
   reset.css for the html/body height:100% this depends on): the <main>
   element is told to grow and fill any leftover vertical space, pushing
   the footer down to the bottom.
   ----------------------------------------------------------------------- */
body {
	display: flex;
	flex-direction: column;
	min-height: 100%;
}

.site-main {
	flex: 1 0 auto; /* grow to fill available space, don't shrink below content size */
}

/* -----------------------------------------------------------------------
   SITE HEADER
   Sticks to the top of the viewport while scrolling ("position: sticky")
   so the navigation/cart/search icons are always reachable -- important
   on long technical articles where a reader may want to jump to search
   or the cart without scrolling all the way back up.
   ----------------------------------------------------------------------- */
.site-header {
	position: sticky;
	top: 0;
	z-index: 50; /* sits above page content but below the mobile nav
	                overlay/mini-cart flyout, which use a higher z-index --
	                see components.css for those values */
	background-color: var(--color-white);
	/* A soft drop shadow reads as a cleaner, more "lifted" edge than a
	   flat 1px border -- reusing the same --shadow-card token already
	   used on post/product cards (tokens.css), rather than inventing a
	   one-off shadow value, so the header's elevation matches the rest
	   of the site's visual language. */
	box-shadow: var(--shadow-card);
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-4);
	padding-block: var(--space-4);
	position: relative; /* gives the absolutely-positioned .header-search-form
	                        dropdown below a reference point to anchor to */
}

/* -----------------------------------------------------------------------
   SITE BRANDING (logo / site title fallback)
   IMPORTANT BUG FIX: the_custom_logo() (see template-parts/header/
   site-branding.php) prints whatever size image was uploaded in
   Appearance > Customize > Site Identity, completely unconstrained --
   without a rule like the one below, a large uploaded logo file renders
   at its full raw pixel size and can dwarf the entire header. Capping
   its height (and letting width scale proportionally) is what keeps the
   header a consistent, sane size no matter what gets uploaded.
   ----------------------------------------------------------------------- */
.site-branding {
	display: flex;
	align-items: center;
	flex-shrink: 0; /* never let the logo get squeezed by a long nav menu on a narrower screen */
}

.site-branding img {
	max-height: 44px;
	width: auto; /* scale width proportionally as height is capped, so the logo never looks stretched */
	display: block;
}

/* Plain-text fallback, only shown if no logo has been uploaded yet (see
   the has_custom_logo() check in site-branding.php) -- styled to look
   like an intentional wordmark rather than default browser text. */
.site-title {
	font-size: var(--text-h4);
	margin-bottom: 0;
	line-height: 1;
}
.site-title a {
	color: var(--color-black);
	text-decoration: none;
}
.site-description {
	font-size: var(--text-caption); /* tagline = meta text, per the theme's font-size rule */
	color: var(--color-gray-600);
	margin-bottom: 0;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: var(--space-3);
}

.header-actions button {
	background: none;
	border: none;
	border-radius: 50%;
	padding: var(--space-2);
	cursor: pointer;
	position: relative; /* anchors the .cart-count badge, positioned below */
	transition: background-color 0.15s ease;
}

/* A soft circular hover/focus background -- previously these buttons had
   no hover feedback at all, which read as unfinished/unpolished next to
   the rest of the site's interactive elements. */
.header-actions button:hover,
.header-actions button:focus-visible {
	background-color: var(--color-blue-100);
}

.header-actions svg {
	width: 22px;
	height: 22px;
}

.cart-count {
	position: absolute;
	top: -2px;
	right: -2px;
	background-color: var(--color-blue-600);
	color: var(--color-white);
	font-size: 0.65rem;
	min-width: 16px;
	height: 16px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* The expandable header search form (see header-actions.php and
   nav-toggle.js) drops down below the header as a small floating panel,
   rather than permanently taking up space in the header row. */
.header-search-form {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	background-color: var(--color-white);
	border-bottom: 1px solid var(--color-gray-200);
	padding: var(--space-4);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

/* -----------------------------------------------------------------------
   PRIMARY NAVIGATION
   Mobile: the <nav> is hidden off-canvas by default and slides in as a
   full-height panel when the menu button is tapped (see assets/js/nav-
   toggle.js for the class-toggling logic, and template-parts/header/
   primary-nav.php for the markup).
   Desktop: the <nav> becomes a normal inline row of links, and the mobile
   toggle button is hidden entirely.
   ----------------------------------------------------------------------- */

/* The hamburger-menu button itself (see template-parts/header/
   primary-nav.php) -- without this rule it renders as a bare, unstyled
   <button>, which browsers draw with tiny default padding and no
   guaranteed size, making the icon inside nearly invisible. */
.nav-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px; /* matches the same minimum touch-target size as .btn, see components.css */
	height: 44px;
	background: none;
	border: none;
	cursor: pointer;
	padding: var(--space-2);
	flex-shrink: 0;
}

.nav-toggle svg {
	width: 24px;
	height: 24px;
}

@media (min-width: 1024px) {
	.nav-toggle {
		/* On desktop the primary nav is always visible inline (see the
		   min-width: 1024px override on .primary-nav below), so there's
		   nothing left for this button to toggle -- hide it entirely. */
		display: none;
	}
}

.primary-nav {
	position: fixed;
	inset: 0 0 0 auto; /* shorthand for top:0; right:0; bottom:0; left:auto --
	                      pins the panel to the right edge, full height */
	width: min(85vw, 320px); /* never wider than 320px, but shrinks on very
	                            narrow phones so it doesn't cover 100% of
	                            the screen */
	background-color: var(--color-white);
	box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
	padding: var(--space-6) var(--space-4);
	overflow-y: auto;
	z-index: 100;

	/* Hidden by sliding fully off-screen to the right. translateX is used
	   (instead of display:none) specifically because it can be smoothly
	   ANIMATED with a transition -- display:none cannot be transitioned. */
	transform: translateX(100%);
	transition: transform 0.25s ease;
}

/* JS (nav-toggle.js) adds this class to <body> when the menu is open. */
.nav-is-open .primary-nav {
	transform: translateX(0);
}

.primary-nav__menu {
	list-style: none;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

/* Mobile (base/default) styling for a nested sub-menu (e.g. "Shop" >
   Cart / Checkout) -- WordPress's wp_nav_menu() outputs this as a plain
   nested <ul class="sub-menu"> for any menu item with children, which
   does NOT automatically inherit the list-style/padding reset above
   (that only targets the exact .primary-nav__menu element, not menu
   items nested inside it) -- without this it would show default browser
   bullets/indentation. On mobile this is left as a normal, slightly
   indented list under its parent -- a completely standard, expected
   mobile nav pattern needing no dropdown/hover behavior at all (that's
   added separately, desktop-only, further down). */
.sub-menu {
	list-style: none;
	padding-left: var(--space-4);
}

.primary-nav__menu a {
	display: block;
	position: relative; /* anchors the animated underline ::after below */
	padding: var(--space-2) 0;
	color: var(--color-black);
	text-decoration: none;
	font-weight: 600;
}

/* SIGNATURE MICRO-INTERACTION: a thin blue underline that grows in from
   the left on hover/focus, rather than an instant color change -- a
   small, restrained bit of motion that still feels deliberate. Built
   with `transform: scaleX()` (not `width`) because transforms are
   GPU-accelerated and don't trigger layout recalculation on every
   animation frame the way animating `width` would. */
.primary-nav__menu a::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 2px;
	background-color: var(--color-blue-600);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.25s ease;
}

.primary-nav__menu a:hover::after,
.primary-nav__menu a:focus-visible::after {
	transform: scaleX(1);
}

/* WordPress automatically adds "current-menu-item"/"current_page_item"
   to whichever nav <li> matches the page currently being viewed (no PHP
   needed on our end for this) -- keep ITS underline permanently visible
   and tinted blue, so a visitor always has a clear "you are here" cue. */
.current-menu-item > a,
.current_page_item > a {
	color: var(--color-blue-600);
}
.current-menu-item > a::after,
.current_page_item > a::after {
	transform: scaleX(1);
}

/* A semi-transparent overlay behind the open mobile nav, so the rest of
   the page visibly dims and tapping it closes the menu (handled in
   nav-toggle.js). Sits just below the nav panel's z-index. */
.nav-overlay {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.4);
	z-index: 90;
	opacity: 0;
	pointer-events: none; /* invisible AND unclickable while closed */
	transition: opacity 0.25s ease;
}

.nav-is-open .nav-overlay {
	opacity: 1;
	pointer-events: auto;
}

@media (min-width: 1024px) {
	/* On desktop/laptop screens there's plenty of horizontal room, so the
	   nav becomes a normal always-visible inline row instead of an
	   off-canvas panel -- all the "slide-in panel" CSS above is undone. */
	.primary-nav {
		position: static;
		inset: auto;
		width: auto;
		height: auto;
		box-shadow: none;
		padding: 0;
		overflow: visible;
		transform: none;
		transition: none;
	}

	.primary-nav__menu {
		flex-direction: row;
		gap: var(--space-6);
	}

	.nav-overlay {
		display: none; /* no overlay needed when there's no slide-in panel to dim behind */
	}

	/* -------------------------------------------------------------------
	   DROPDOWN SUBMENUS (e.g. "Shop" > Cart / Checkout)
	   WordPress's wp_nav_menu() already outputs a nested <ul class="sub-
	   menu"> for any menu item with children (see Appearance > Menus --
	   "Cart"/"Checkout" are configured as children of "Shop") -- with NO
	   CSS at all for it, that nested list just displayed inline, always
	   expanded, breaking the horizontal row. This turns it into a proper
	   hover/click dropdown instead. Scoped to desktop only: on mobile the
	   off-canvas panel is already a vertical list, where a plain nested
	   sub-list under "Shop" reads perfectly normally with no dropdown
	   behavior needed.
	   ------------------------------------------------------------------- */
	.primary-nav__menu li {
		position: relative; /* anchors the absolutely-positioned .sub-menu below */
	}

	.primary-nav__menu .sub-menu {
		display: none; /* hidden until the parent li is hovered/focused, see below */
		position: absolute;
		top: 100%;
		left: 0;
		flex-direction: column;
		gap: 0;
		min-width: 160px;
		padding: var(--space-2);
		margin: 0;
		background-color: var(--color-white);
		border-radius: var(--radius-sm);
		box-shadow: var(--shadow-card);
		z-index: 60; /* above page content, below the mobile nav panel/mini-cart (components.css) */
	}

	/* :hover covers mouse users; :focus-within keeps the dropdown open
	   while a keyboard user has tabbed into any link inside it (tabbing
	   into a child <a> puts focus INSIDE the parent <li>, which is what
	   :focus-within detects) -- without this, keyboard users could never
	   reach Cart/Checkout at all, since they'd be invisible until hovered. */
	.primary-nav__menu li:hover > .sub-menu,
	.primary-nav__menu li:focus-within > .sub-menu {
		display: flex;
	}

	.primary-nav__menu .sub-menu a {
		padding: var(--space-2) var(--space-3);
		white-space: nowrap;
		border-radius: var(--radius-sm);
	}

	/* The dropdown's own links don't need the hover-underline signature
	   the top-level nav links use just above -- inside a dropdown card,
	   a plain background-color hover reads more like "a menu" than
	   another set of top-level page links. */
	.primary-nav__menu .sub-menu a::after {
		display: none;
	}
	.primary-nav__menu .sub-menu a:hover,
	.primary-nav__menu .sub-menu a:focus-visible {
		background-color: var(--color-blue-100);
	}

	/* A small down-caret on any top-level link that HAS a dropdown --
	   "menu-item-has-children" is another class wp_nav_menu() already
	   adds automatically, no PHP change needed. Uses ::before specifically
	   because ::after is already taken by the hover-underline signature
	   on .primary-nav__menu a above -- an element can only have one of
	   each pseudo-element, so the caret needs the other slot. */
	.menu-item-has-children > a::before {
		content: "\25BE"; /* a small solid down-triangle character */
		display: inline-block;
		margin-left: var(--space-1);
		font-size: 0.7em;
		vertical-align: middle;
	}
}

/* -----------------------------------------------------------------------
   SITE FOOTER
   ----------------------------------------------------------------------- */
.site-footer {
	background-color: var(--color-gray-50);
	border-top: 1px solid var(--color-gray-200);
	margin-top: var(--space-16);
}

.footer-widgets {
	display: grid;
	grid-template-columns: 1fr; /* one column on mobile: widgets stack vertically */
	gap: var(--space-8);
	padding-block: var(--space-12);
}

@media (min-width: 768px) {
	.footer-widgets {
		/* 3 even columns once there's enough width for them side by side */
		grid-template-columns: repeat(3, 1fr);
	}
}

.footer-bottom {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-2);
	padding-block: var(--space-4);
	border-top: 1px solid var(--color-gray-200);
	font-size: var(--text-caption); /* copyright/legal line = meta text, 12px */
	color: var(--color-gray-600);
}

/* -----------------------------------------------------------------------
   FOOTER SOCIAL LINKS
   A compact row of small circular icon buttons (see footer-bottom.php
   for the 3 hardcoded links: Facebook Group, Facebook Profile, LinkedIn,
   using the SAME andyfe_get_icon() SVGs as the post-share row in
   components.css) -- sized down from that component's 40px to 28px here
   specifically because the brief asked for this row to read as
   "compact," sitting quietly next to the copyright line rather than
   competing with it for attention.
   ----------------------------------------------------------------------- */
.footer-social {
	display: flex;
	gap: var(--space-2);
	list-style: none;
	padding: 0;
}

.footer-social a {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background-color: var(--color-white);
	border: 1px solid var(--color-gray-200);
	color: var(--color-gray-600);
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.footer-social a:hover,
.footer-social a:focus-visible {
	background-color: var(--color-blue-600);
	border-color: var(--color-blue-600);
	color: var(--color-white);
}

.footer-social svg {
	width: 14px;
	height: 14px;
}

/* The small "footer" menu (Privacy Policy, Terms, etc) next to the
   copyright line -- a plain inline row of links, same 12px meta size. */
.footer-nav__menu {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--space-4);
	list-style: none;
	padding: 0;
}

.footer-nav__menu a {
	color: var(--color-gray-600);
}

@media (min-width: 768px) {
	.footer-bottom {
		flex-direction: row;
		justify-content: space-between;
	}
}

/* -----------------------------------------------------------------------
   GENERIC GRID HELPERS
   Reusable across homepage sections, blog card grids, and product grids.
   "auto-fill" + "minmax" is a single-line CSS Grid trick that creates a
   RESPONSIVE grid with NO media queries needed at all: the browser fits
   as many columns as will comfortably hold a card at least 260px wide,
   and automatically drops to fewer (down to 1) columns on narrow screens.
   ----------------------------------------------------------------------- */
.grid-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: var(--space-6);
}

/* A tighter 2-column grid used for compact sections (e.g. "highlights")
   that shouldn't have as many columns as a full card grid even on very
   wide screens. */
.grid-2 {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-6);
}

@media (min-width: 768px) {
	.grid-2 {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* -----------------------------------------------------------------------
   SECTION SPACING
   A consistent vertical rhythm between homepage/page sections, using the
   spacing scale instead of one-off values per section.
   ----------------------------------------------------------------------- */
.section {
	padding-block: var(--space-12);
}

@media (min-width: 1024px) {
	.section {
		padding-block: var(--space-16);
	}
}

/* -----------------------------------------------------------------------
   SKIP LINK
   An invisible-until-focused link at the very top of the page that lets
   keyboard/screen-reader users jump straight to the main content, past
   the header/nav -- a standard, important accessibility pattern. See
   header.php for the matching HTML.
   ----------------------------------------------------------------------- */
.skip-link {
	position: absolute;
	top: -100px; /* pushed off-screen until it receives keyboard focus */
	left: var(--space-4);
	background: var(--color-blue-600);
	color: var(--color-white);
	padding: var(--space-2) var(--space-4);
	z-index: 200;
	border-radius: var(--radius-sm);
	transition: top 0.2s ease;
}

.skip-link:focus {
	top: var(--space-4); /* tabbing onto it slides it into view */
}
