/* ==========================================================================
   Satsang Darshan — site header & navigation
   Self-contained: no dependency on style.css or the template scripts.
   Mobile-first: burger + slide-down panel below 1200px, dropdown bar above.
   ========================================================================== */

:root {
	--sd-h: 58px;                              /* header bar height (mobile) */
	--sd-bg: rgba(18, 12, 8, 0.94);
	--sd-bg-solid: #120c08;                    /* opaque twin of --sd-bg; used on mobile so the pinned bar needs no per-frame backdrop sampling */
	--sd-panel-bg: #171009;
	--sd-line: rgba(255, 174, 66, 0.30);
	--sd-text: #f0e5d2;
	--sd-text-dim: #cbb999;
	--sd-accent: #ffae42;
	--sd-accent-hot: #ff4500;
}

html {
	scroll-padding-top: calc(var(--sd-h) + 10px);
}

/* The header is position:fixed (see .sd-header), so it's out of flow — offset
   the page content by the header height so nothing hides underneath it. */
.page {
	padding-top: var(--sd-h);
}

/* Fallback for pages that never defined the radiant brand font inline */
.tangerine-bold-radiant {
	font-family: "Tangerine", cursive;
	font-weight: 700;
	font-style: normal;
	font-size: 4rem;
	color: #ff4500;
	text-shadow: 0 0 10px #ffae42, 0 0 20px #ff4500, 0 0 30px #ff6347, 0 0 40px rgba(255, 69, 0, 0.8);
	animation: radiate-pulse 3s infinite ease-in-out;
}

@keyframes radiate-pulse {
	0% {
		text-shadow: 0 0 10px #ffae42, 0 0 20px #ff4500, 0 0 30px #ff6347, 0 0 40px rgba(255, 69, 0, 0.8);
		transform: scale(1);
	}
	50% {
		text-shadow: 0 0 15px #ffae42, 0 0 30px #ff4500, 0 0 45px #ff6347, 0 0 60px rgba(255, 69, 0, 0.8);
		transform: scale(1.02);
	}
	100% {
		text-shadow: 0 0 10px #ffae42, 0 0 20px #ff4500, 0 0 30px #ff6347, 0 0 40px rgba(255, 69, 0, 0.8);
		transform: scale(1);
	}
}

/* --------------------------------------------------------------------------
   Header shell
   NOTE: .sd-header itself carries no transform/filter/overflow so that the
   absolutely-positioned panel and fixed scrim behave predictably.
   -------------------------------------------------------------------------- */

.sd-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10000;
	width: 100%;
	font-family: "Roboto Mono", Monaco, Consolas, "Courier New", monospace;
	/* FIXED, not sticky. A sticky header sticks relative to the page's scroll
	   container; when the menu set overflow:hidden on <html>/<body> to lock
	   scrolling, that broke the sticky header on iOS — the bar vanished on tap
	   and the page froze. A fixed header is positioned to the viewport and is
	   immune to that, and it stays visible while scrolling. Kept plain: solid
	   background, no backdrop-filter/compositing hint/animation on mobile. */
}

.sd-header *,
.sd-header *:before,
.sd-header *:after {
	box-sizing: border-box;
}

.sd-bar {
	position: relative;
	z-index: 2;
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	-webkit-box-pack: justify;
	-ms-flex-pack: justify;
	justify-content: space-between;
	height: var(--sd-h);
	padding: 0 14px 0 16px;
	padding-left: calc(16px + env(safe-area-inset-left, 0px));
	padding-right: calc(14px + env(safe-area-inset-right, 0px));
	/* Opaque background by default (mobile): a backdrop-filter on a scroll-pinned
	   bar forces the browser to re-sample the blurred page beneath it every frame,
	   which is what froze scrolling / blanked the header on phones. The frosted
	   blur is re-enabled only on desktop (min-width:1200px) below, where it is cheap. */
	background: var(--sd-bg-solid);
	border-bottom: 1px solid var(--sd-line);
	box-shadow: 0 2px 20px rgba(0, 0, 0, 0.38);
}

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

.sd-brand {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	-ms-flex-item-align: stretch;
	align-self: stretch; /* full-height tap target inside the bar */
	gap: 10px;
	text-decoration: none;
	line-height: 1;
	min-width: 0;
}

.sd-brand-ohm {
	height: 30px;
	width: auto;
	display: block;
	-ms-flex-negative: 0;
	flex-shrink: 0;
	filter: drop-shadow(0 0 6px rgba(255, 174, 66, 0.45));
}

/* Keep the user's radiant Tangerine brand font, scaled for a header bar */
.sd-header .sd-brand-text.tangerine-bold-radiant {
	font-size: 31px; /* px on purpose: style.css sets the root font-size to 10px, so rem is unreliable here */
	line-height: 1;
	display: inline-block;
	margin: 0;
	padding-top: 2px;
	white-space: nowrap;
	/* no overflow clipping here — it would box in the radiant glow */
	text-shadow: 0 0 6px #ffae42, 0 0 12px #ff4500, 0 0 20px rgba(255, 99, 71, 0.7);
	/* Off on mobile. The page's generic .tangerine-bold-radiant rule animates
	   transform:scale, which repaints the pinned bar every frame and compounds
	   scroll jank on phones; this higher-specificity rule cancels it. */
	-webkit-animation: none;
	animation: none;
}

/* Desktop re-enables the pulsing glow — desktop GPUs pin it without the
   mobile scroll penalty. Its own text-shadow keyframes avoid transform:scale. */
@media (min-width: 1200px) {
	.sd-header .sd-brand-text.tangerine-bold-radiant {
		-webkit-animation: sd-radiate 3s infinite ease-in-out;
		animation: sd-radiate 3s infinite ease-in-out;
	}
}

@keyframes sd-radiate {
	0%, 100% { text-shadow: 0 0 6px #ffae42, 0 0 12px #ff4500, 0 0 20px rgba(255, 99, 71, 0.7); }
	50%      { text-shadow: 0 0 9px #ffae42, 0 0 18px #ff4500, 0 0 30px rgba(255, 99, 71, 0.85); }
}

/* Burger ------------------------------------------------------------------ */

.sd-burger {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	-ms-flex-direction: column;
	flex-direction: column;
	-webkit-box-pack: center;
	-ms-flex-pack: center;
	justify-content: center;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	gap: 5px;
	width: 48px;
	height: 48px;
	padding: 0;
	margin: 0;
	background: none;
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	-ms-flex-negative: 0;
	flex-shrink: 0;
}

.sd-burger span {
	display: block;
	width: 24px;
	height: 2px;
	border-radius: 2px;
	background: var(--sd-text);
	transition: transform 0.28s ease, opacity 0.2s ease, background-color 0.2s ease;
}

.sd-burger:hover span { background: var(--sd-accent); }

.sd-header.sd-open .sd-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sd-header.sd-open .sd-burger span:nth-child(2) { opacity: 0; }
.sd-header.sd-open .sd-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Scrim (mobile, behind the open panel) ----------------------------------- */

/* The old dark scrim is unused now — the mobile menu is a full opaque overlay,
   so there is nothing to dim behind it. */
.sd-scrim {
	display: none;
}

/* Nav panel — mobile: full-screen opaque overlay under the fixed bar.
   Because it covers the whole page there is no need to lock body scrolling
   (which was what froze the page), and overscroll-behavior stops the page
   behind it from scroll-chaining. */
.sd-nav {
	position: fixed;
	top: var(--sd-h);
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	background: var(--sd-panel-bg);
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.sd-header.sd-open .sd-nav {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.sd-menu {
	list-style: none;
	margin: 0;
	padding: 8px 0 14px;
	padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

.sd-item { border-bottom: 1px solid rgba(255, 174, 66, 0.10); }
.sd-item:last-child { border-bottom: 0; }

/* Top-level rows: generous 52px touch targets */
.sd-link {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	-webkit-box-pack: justify;
	-ms-flex-pack: justify;
	justify-content: space-between;
	width: 100%;
	min-height: 52px;
	padding: 8px 20px;
	margin: 0;
	background: none;
	border: 0;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	text-align: left;
	text-decoration: none;
	color: var(--sd-text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.sd-link:hover,
.sd-link:focus-visible {
	color: var(--sd-accent);
	text-decoration: none;
}

/* style.css declares 'a:focus, button:focus { outline: none !important }' and
   'a:focus { color: #aa9144 }' — these rules must out-gun that reset. */
.sd-header a:focus,
.sd-header button:focus {
	color: var(--sd-accent);
	text-decoration: none;
}

.sd-header .sd-link:focus-visible,
.sd-header .sd-sub-link:focus-visible,
.sd-header .sd-burger:focus-visible,
.sd-header .sd-brand:focus-visible,
.sd-header .sd-flag:focus-visible {
	outline: 2px solid var(--sd-accent) !important;
	outline-offset: -2px;
}

.sd-caret {
	-ms-flex-negative: 0;
	flex-shrink: 0;
	margin-left: 12px;
	transition: transform 0.28s ease;
}

.sd-item.sd-expanded > .sd-link .sd-caret { transform: rotate(180deg); }
.sd-item.sd-expanded > .sd-link { color: var(--sd-accent); }

/* Submenus — mobile: accordion. visibility keeps collapsed links out of the
   tab order; its transition delays the flip until the collapse animation ends. */
.sd-sub {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	max-height: 0;
	visibility: hidden;
	transition: max-height 0.34s ease, visibility 0.34s;
	background: rgba(255, 174, 66, 0.05);
}

.sd-item.sd-expanded > .sd-sub {
	max-height: 560px;
	visibility: visible;
}

.sd-sub-link {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	min-height: 48px;
	padding: 6px 20px 6px 38px;
	font-size: 13px;
	letter-spacing: 0.06em;
	text-decoration: none;
	color: var(--sd-text-dim);
	-webkit-tap-highlight-color: transparent;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.sd-sub-link:hover,
.sd-sub-link:focus-visible {
	color: var(--sd-accent);
	background: rgba(255, 174, 66, 0.08);
	text-decoration: none;
}

/* Current page highlight */
.sd-header a.sd-current { color: var(--sd-accent); }
.sd-header .sd-sub-toggle.sd-current-group { color: var(--sd-accent); }

/* Language flag ------------------------------------------------------------ */

.sd-lang .sd-flag {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-ms-flex-align: center;
	align-items: center;
	gap: 12px;
	min-height: 52px;
	padding: 8px 20px;
	text-decoration: none;
	color: var(--sd-text-dim);
	font-size: 12px;
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

.sd-lang .sd-flag:hover { color: var(--sd-accent); text-decoration: none; }

.sd-flag img {
	display: block;
	width: 30px;
	height: auto;
	border-radius: 3px;
	border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Body scroll lock while the mobile panel is open.
   overflow only — a height clamp would reset the scroll position to the top. */
/* --------------------------------------------------------------------------
   Desktop: horizontal bar with dropdowns
   -------------------------------------------------------------------------- */

@media (min-width: 1200px) {

	:root { --sd-h: 66px; }

	/* Desktop only: restore the frosted translucent bar. Desktop GPUs handle
	   backdrop-filter on a sticky element without the mobile scroll penalty. */
	.sd-bar {
		padding: 0 30px;
		background: var(--sd-bg);
		-webkit-backdrop-filter: blur(10px);
		backdrop-filter: blur(10px);
	}

	.sd-header .sd-brand-text.tangerine-bold-radiant { font-size: 38px; }
	.sd-brand-ohm { height: 34px; }

	.sd-burger { display: none; }
	.sd-scrim { display: none; }

	.sd-nav {
		position: static;
		max-height: none;
		overflow: visible;
		background: none;
		border: 0;
		box-shadow: none;
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: none;
	}

	.sd-menu {
		display: -webkit-box;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-align: center;
		-ms-flex-align: center;
		align-items: center;
		padding: 0;
	}

	.sd-item {
		position: relative;
		border-bottom: 0;
	}

	.sd-link {
		width: auto;
		min-height: var(--sd-h);
		padding: 0 15px;
		font-size: 12px;
		letter-spacing: 0.18em;
		position: relative;
	}

	/* refined underline indicator */
	.sd-link:after {
		content: '';
		position: absolute;
		left: 15px;
		right: 15px;
		bottom: 14px;
		height: 1px;
		background: var(--sd-accent);
		transform: scaleX(0);
		transform-origin: left center;
		transition: transform 0.25s ease;
	}

	.sd-link:hover:after,
	.sd-item.sd-expanded > .sd-link:after,
	a.sd-link.sd-current:after,
	.sd-sub-toggle.sd-current-group:after { transform: scaleX(1); }

	.sd-caret { margin-left: 8px; }

	/* Dropdown card */
	.sd-sub {
		position: absolute;
		top: calc(100% - 8px);
		left: 50%;
		transform: translateX(-50%) translateY(8px);
		min-width: 240px;
		max-height: none;
		overflow: visible;
		padding: 8px 0;
		background: var(--sd-panel-bg);
		border: 1px solid var(--sd-line);
		border-radius: 10px;
		box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
	}

	/* hover bridge so the pointer can travel from the toggle to the card */
	.sd-sub:before {
		content: '';
		position: absolute;
		top: -14px;
		left: 0;
		right: 0;
		height: 14px;
	}

	.sd-item.sd-expanded > .sd-sub {
		opacity: 1;
		visibility: visible;
		transform: translateX(-50%) translateY(0);
		max-height: none;
	}

	/* keep the last dropdowns on-screen */
	.sd-item:nth-last-child(-n+3) .sd-sub {
		left: auto;
		right: 0;
		transform: translateY(8px);
	}

	.sd-item:nth-last-child(-n+3).sd-expanded > .sd-sub {
		transform: translateY(0);
	}

	.sd-sub-link {
		min-height: 42px;
		padding: 6px 22px;
		white-space: nowrap;
	}

	.sd-lang .sd-flag {
		min-height: var(--sd-h);
		padding: 0 4px 0 14px;
	}

	.sd-lang .sd-flag span { display: none; }
}

/* Tiny screens: slightly smaller brand so nothing collides */
@media (max-width: 374px) {
	.sd-header .sd-brand-text.tangerine-bold-radiant { font-size: 26px; }
	.sd-brand-ohm { height: 26px; }
}

/* The pages now declare a real viewport (width=device-width), so keep the
   legacy fixed-size content from overflowing small screens. */
@media (max-width: 767px) {
	.page img {
		max-width: 100%;
		height: auto;
	}
	.page iframe {
		max-width: 100%;
	}
	.page iframe[src*="youtube"],
	.page iframe[src*="youtu.be"],
	.page iframe[src*="vimeo"] {
		aspect-ratio: 16 / 9;
		height: auto;
	}
	.page table {
		max-width: 100%;
	}

	/* Widen the main content column on phones. By default .custom-section is a
	   white card at width:80% + 20px padding, often holding a table sized at ~80%
	   again — so the text ends up ~half the intro's width and looks "boxed inside
	   two tables". Here the card spans the full width minus a small 10px gutter
	   each side (via auto margins, which the pages that force `margin:auto
	   !important` also honour). border-box makes the width exact regardless of
	   each page's box-sizing, so the padding never causes overflow. The intro
	   itself is untouched, so the body now reads at the intro's comfortable width. */
	.page .custom-section {
		box-sizing: border-box;
		width: calc(100% - 20px);
		margin-left: auto;
		margin-right: auto;
		padding-left: 14px;
		padding-right: 14px;
	}
	/* Let inner content tables use the full card width instead of nesting
	   narrower (they are capped by .page table max-width:100% above, so fixed
	   pixel-width layout tables can't overflow). */
	.page .custom-section table {
		width: 100%;
	}
	.page .custom-section td,
	.page .custom-section th {
		padding: 8px;
	}
	/* Legacy oversized images are often wrapped in an inline-block <a> that
	   shrink-wraps to the image's fixed width attribute and so escapes the
	   img max-width:100% above. Constrain the wrapper too so linked images
	   scale down to the card instead of being cropped by the page edge. */
	.page .custom-section a {
		max-width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sd-header .sd-brand-text.tangerine-bold-radiant,
	.tangerine-bold-radiant { animation: none; }
	.sd-nav, .sd-sub, .sd-caret, .sd-burger span, .sd-scrim, .sd-link:after { transition: none; }
}
