/*
 * Orange Pacific Mental Health — site chrome.
 *
 * Header (sticky bar, brand lockup, nav, mobile panel), the sun scroll rule,
 * and the footer. Ported from the Dawn Horizon mockup's sections 5 and 20.
 *
 * Tokens live in design-system.css. Anything shared by BLOCKS (buttons,
 * eyebrows, the wave divider, .op-container, .op-section) belongs there, not
 * here — this file is only what wraps the page.
 *
 * Element IDs referenced by assets/js/theme.js: opHeader, opNav, opNavToggle,
 * opSunruleFill, opYear.
 */

/* ==========================================================================
   Header
   ========================================================================== */

.op-header {
	position: sticky;
	top: 0;
	z-index: 100;
	/* Matches --op-cream at 88%. Written as rgba because CSS cannot take an
	   alpha of a hex custom property without color-mix(); change both together
	   if the cream ever moves. */
	background: rgba(254, 247, 232, 0.88);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
}

.op-header__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--op-sp-m);
	padding-block: 0.85rem;
	/* The mobile nav panel is absolutely positioned against this row. */
	position: relative;
}

/* --- Brand lockup --- */

.op-brand {
	display: inline-flex;
	align-items: center;
	gap: 0.7rem;
	text-decoration: none;
	flex-shrink: 0;
}

.op-brand__mark {
	width: 40px;
	height: 40px;
	flex: none;
}

.op-brand__name {
	font-family: var(--op-font-display);
	font-size: 1.12rem;
	font-weight: 600;
	line-height: 1.05;
	color: var(--op-navy-900);
	letter-spacing: -0.01em;
}

.op-brand__sub {
	display: block;
	font-family: var(--op-font-body);
	font-size: 0.6rem;
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--op-azure-600);
	margin-top: 0.15em;
}

/* --- Nav --- */

.op-nav {
	display: flex;
	align-items: center;
	gap: var(--op-sp-m);
}

.op-nav__link {
	font-size: 0.97rem;
	font-weight: 500;
	color: var(--op-navy-900);
	text-decoration: none;
	padding-block: 0.3em;
	border-bottom: 2px solid transparent;
}

.op-nav__link:hover {
	border-bottom-color: var(--op-sun-500);
	color: var(--op-navy-900);
}

.op-nav__link.is-current {
	border-bottom-color: var(--op-sun-500);
}

/* --- Submenu (one level, header only) ---------------------------------------

   A parent keeps its own link and gets an ADJACENT disclosure button, so the
   link navigates and the button discloses. Hover-only dropdowns were rejected:
   they fail on touch and for keyboard users.

   PROGRESSIVE ENHANCEMENT, the same way .op-reveal does it. Everything that
   HIDES the submenu is scoped to .js (printed in <head>, see inc/enqueue.php).
   With no JavaScript the button is hidden and the submenu renders as plain
   inline links after the parent — the nav degrades to the flat row of every
   link, which is what shipped before menus existed. No link is ever stranded
   behind a control that cannot be operated.
   -------------------------------------------------------------------------- */

.op-nav__item--parent {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	/* The dropdown is positioned against this, not against the header row. */
	position: relative;
}

.op-nav__sub-toggle {
	display: none;
	background: transparent;
	border: 0;
	padding: 0.3em 0.15em;
	font: inherit;
	line-height: 0;
	color: var(--op-navy-900);
	cursor: pointer;
}

.js .op-nav__item--parent > .op-nav__sub-toggle {
	display: inline-flex;
}

.op-nav__chevron {
	display: block;
	width: 0.42em;
	height: 0.42em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-0.1em, -0.1em);
	transition: transform 0.18s var(--op-ease);
}

.op-nav__item.is-open .op-nav__chevron {
	transform: rotate(225deg) translate(-0.16em, -0.16em);
}

.op-subnav {
	list-style: none;
	margin: 0;
	padding: 0;
	/* No-JS desktop fallback: a plain inline continuation of the flat row. */
	display: inline-flex;
	gap: var(--op-sp-s);
}

.js .op-subnav {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 10;
	min-width: 13rem;
	flex-direction: column;
	gap: 0;
	margin-top: 0.5rem;
	padding: 0.4rem;
	background: var(--op-cream);
	border: 1px solid var(--op-sand-deep);
	border-radius: var(--op-r-sm);
	box-shadow: var(--op-shadow);
}

.js .op-nav__item.is-open > .op-subnav {
	display: flex;
}

.op-subnav__link {
	display: block;
	padding: 0.5em 0.6em;
	border-radius: var(--op-r-sm);
	font-size: 0.94rem;
	font-weight: 500;
	color: var(--op-navy-900);
	text-decoration: none;
	white-space: nowrap;
}

.op-subnav__link:hover,
.op-subnav__link.is-current {
	background: var(--op-sand);
	color: var(--op-navy-900);
}

.op-nav-toggle {
	display: none;
	background: transparent;
	border: 1.5px solid var(--op-sand-deep);
	border-radius: var(--op-r-sm);
	padding: 0.5em 0.8em;
	font: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--op-navy-900);
	cursor: pointer;
}

/* ==========================================================================
   The sun rule (signature element, part 2)

   Scroll progress drawn as the horizon gradient. Width is set by theme.js via
   the --op-progress custom property; with no JS the fill simply sits at 0 and
   the track reads as a hairline, which is why the whole thing is decorative.
   ========================================================================== */

.op-sunrule {
	height: 3px;
	width: 100%;
	background: var(--op-sand);
	position: relative;
	overflow: hidden;
}

.op-sunrule__fill {
	position: absolute;
	inset: 0;
	background: var(--op-horizon);
	transform-origin: left center;
	transform: scaleX(var(--op-progress, 0));
	will-change: transform;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.op-footer {
	background: var(--op-navy-900);
	color: var(--op-ink-on-dark-muted);
	padding-block: var(--op-sp-xl) var(--op-sp-l);
	font-size: 0.95rem;
}

.op-footer a {
	color: var(--op-apricot);
}

.op-footer a:hover {
	color: var(--op-cream);
}

.op-footer__head {
	font-family: var(--op-font-body);
	font-size: var(--op-step--1);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--op-cream);
	margin-bottom: var(--op-sp-s);
}

.op-footer__grid {
	display: grid;
	gap: var(--op-sp-l);
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.op-footer__list {
	list-style: none;
	display: grid;
	gap: var(--op-sp-2xs);
}

.op-footer p {
	max-width: 40ch;
}

/* --- Crisis notice. Dashed border so it reads as a standing notice rather
   than a promotional panel. --- */

.op-crisis {
	margin-top: var(--op-sp-xl);
	padding: var(--op-sp-m);
	border: 1px dashed rgba(254, 247, 232, 0.35);
	border-radius: var(--op-r-md);
	background: rgba(254, 247, 232, 0.04);
}

.op-crisis .op-footer__head {
	color: var(--op-apricot);
	margin-bottom: var(--op-sp-2xs);
}

.op-crisis p {
	color: var(--op-ink-on-dark-muted);
	max-width: 70ch;
}

.op-footer__base {
	margin-top: var(--op-sp-xl);
	padding-top: var(--op-sp-m);
	border-top: 1px solid rgba(254, 247, 232, 0.16);
	display: flex;
	flex-wrap: wrap;
	gap: var(--op-sp-s) var(--op-sp-m);
	justify-content: space-between;
	font-size: 0.85rem;
}

.op-footer__legal a {
	margin-right: var(--op-sp-s);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media ( max-width: 860px ) {
	.op-nav-toggle {
		display: block;
	}

	/* The nav becomes a panel dropped from the bar. Same element and the same
	   link list as the desktop nav, so the two cannot drift apart. */
	.op-nav {
		display: none;
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		background: var(--op-cream);
		border-bottom: 1px solid var(--op-sand-deep);
		padding: var(--op-sp-s) var(--op-gutter) var(--op-sp-m);
	}

	.op-nav.is-open {
		display: flex;
	}

	.op-nav__link {
		padding-block: 0.75em;
		border-bottom: 1px solid var(--op-sand);
	}

	/* The submenu becomes an inline, indented continuation of the stacked
	   panel — same element, same button, same JS as the desktop dropdown, so
	   the two layouts cannot drift apart. Only the positioning differs. */
	.op-nav__item--parent {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		position: static;
		border-bottom: 1px solid var(--op-sand);
	}

	.op-nav__item--parent > .op-nav__link {
		flex: 1;
		border-bottom: 0;
	}

	.op-nav__item--parent > .op-nav__sub-toggle {
		padding: 0.75em 0.4em;
	}

	.op-subnav,
	.js .op-subnav {
		position: static;
		flex-basis: 100%;
		flex-direction: column;
		min-width: 0;
		margin-top: 0;
		margin-bottom: 0.4rem;
		padding: 0 0 0 var(--op-sp-s);
		border: 0;
		box-shadow: none;
		background: transparent;
	}

	.op-subnav__link {
		padding-block: 0.6em;
		white-space: normal;
	}

	.op-nav .op-btn {
		margin-top: var(--op-sp-s);
		justify-content: center;
	}
}

@media ( max-width: 560px ) {
	:root {
		--op-sp-2xl: 3.75rem;
		--op-sp-xl: 2.5rem;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	/* The sun rule stops tracking scroll and simply renders, dimmed. */
	.op-sunrule__fill {
		transform: none;
		opacity: 0.5;
	}
}
