/* Carlo Tours — Top strip.
   A thin near-black utility bar above the header holding the social
   profiles, plus the frame geometry that has to shift to make room for it.

   Everything here is gated on body.carlo-has-topbar, which the PHP adds
   only when the strip actually renders. So a visitor on a site with no
   social links set gets exactly the phase-4 frame back, untouched, with
   no rule to remember to undo. */

/* ---------------------------------------------------------------
   The strip's own height, declared on the ROOT.
   html needs it for scroll-padding-top and body's descendants need it
   for their offsets, so it cannot live on body -- a custom property is
   only readable on the element that declares it and its descendants,
   and html is not a descendant of body.
   --------------------------------------------------------------- */
:root {
	--carlo-topbar-h: 0px;
}

html:has(body.carlo-has-topbar) {
	--carlo-topbar-h: 36px;
}

/* ---------------------------------------------------------------
   Anchor offset.
   site-frame.css already reserves the header; the strip sits above it,
   so both have to be cleared. Each selector below carries one more
   class than the rule it overrides, so load order is irrelevant.
   --------------------------------------------------------------- */
html:has(body.carlo-has-topbar) {
	scroll-padding-top: calc(var(--wp--custom--header-height) + var(--carlo-topbar-h));
}

html:has(body.admin-bar.carlo-has-topbar) {
	scroll-padding-top: calc(var(--wp--custom--header-height) + var(--carlo-topbar-h) + 32px);
}

@media screen and (max-width: 782px) {
	html:has(body.admin-bar.carlo-has-topbar) {
		scroll-padding-top: calc(var(--wp--custom--header-height) + var(--carlo-topbar-h) + 46px);
	}
}

/* ---------------------------------------------------------------
   The strip.
   Sticky rather than fixed, so it keeps its 36px in the flow and the
   page below it starts where it always did. Its parent is <body>, not
   the one-header-tall template-part wrapper that defeated the sticky
   header in phase 1, so it can travel the whole document.
   --------------------------------------------------------------- */
.carlo-topbar {
	position: sticky;
	top: 0;
	/* one above the header, which is 100 */
	z-index: 101;
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	transition: background-color 0.45s var(--wp--custom--ease);
}

body.admin-bar .carlo-topbar {
	top: var(--wp-admin--admin-bar--height, 32px);
}

@media screen and (max-width: 782px) {
	/* Below 782px the admin bar scrolls away with the page. */
	body.admin-bar .carlo-topbar {
		top: 0;
	}
}

/* Matches the header's alignwide content box exactly. The theme sets
   useRootPaddingAwareAlignments, so an alignwide block's content spans
   min(wideSize, viewport - 2 x gutter) -- adding the gutter to the
   max-width reproduces that from outside .wp-site-blocks. */
.carlo-topbar__inner {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: var(--wp--preset--spacing--30);
	min-height: var(--carlo-topbar-h);
	max-width: calc(var(--wp--style--global--wide-size) + 2 * var(--wp--custom--gutter));
	margin-inline: auto;
	padding-inline: var(--wp--custom--gutter);
}

.carlo-topbar--empty .carlo-topbar__inner {
	justify-content: flex-start;
}

/* ---------------------------------------------------------------
   The icons
   --------------------------------------------------------------- */
.carlo-topbar__social {
	display: flex;
	align-items: center;
	gap: 0.125rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.carlo-topbar__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.carlo-topbar__link {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: var(--carlo-topbar-h);
	color: color-mix(in srgb, var(--wp--preset--color--base) 70%, transparent);
	text-decoration: none;
	transition: color 0.3s var(--wp--custom--ease);
}

.carlo-topbar__link:hover,
.carlo-topbar__link:focus-visible {
	color: var(--wp--preset--color--base);
}

.carlo-topbar__link svg {
	display: block;
	width: 1rem;
	height: 1rem;
	/* The brand marks are filled paths with no fill attribute of their
	   own; the globe sets fill="none" inline, so this cannot flood it. */
	fill: currentColor;
}

/* Focus has to stay visible on near-black. */
.carlo-topbar :focus-visible {
	outline-color: var(--wp--preset--color--base);
	outline-offset: -2px;
}

/* The editor-only prompt shown while no link is set. */
.carlo-topbar__hint {
	margin: 0;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--xs);
	line-height: 1.3;
	color: color-mix(in srgb, var(--wp--preset--color--base) 62%, transparent);
}

.carlo-topbar__hint a {
	color: var(--wp--preset--color--base);
	text-decoration: none;
	border-bottom: var(--wp--custom--rule) solid currentColor;
}

/* ---------------------------------------------------------------
   Make room for it: push the header down by the strip's height.
   --------------------------------------------------------------- */
body.carlo-has-topbar .wp-site-blocks > header.wp-block-template-part {
	top: var(--carlo-topbar-h);
}

body.admin-bar.carlo-has-topbar .wp-site-blocks > header.wp-block-template-part {
	top: calc(var(--wp-admin--admin-bar--height, 32px) + var(--carlo-topbar-h));
}

@media screen and (max-width: 782px) {
	body.admin-bar.carlo-has-topbar .wp-site-blocks > header.wp-block-template-part {
		top: var(--carlo-topbar-h);
	}
}

/* ---------------------------------------------------------------
   THE FILM HERO PAGE
   ---------------------------------------------------------------
   There the header is fixed and floats over the photographs, so the
   strip has to come out of the flow too -- left sticky it would push the
   hero down and the opening frame would stop filling the viewport.
   Over the photographs it goes transparent and the icons pick up a
   shadow; once the hero is behind us it solidifies with the header, off
   the same body class the phase-4 IntersectionObserver already sets.
   --------------------------------------------------------------- */
body.carlo-film-hero .carlo-topbar {
	position: fixed;
	inset-inline: 0;
	top: 0;
}

body.carlo-film-hero.admin-bar .carlo-topbar {
	top: var(--wp-admin--admin-bar--height, 32px);
}

@media screen and (max-width: 782px) {
	body.carlo-film-hero.admin-bar .carlo-topbar {
		top: 0;
	}
}

body.carlo-film-hero:not(.carlo-header-solid) .carlo-topbar {
	background-color: transparent;
}

body.carlo-film-hero:not(.carlo-header-solid) .carlo-topbar__link {
	color: color-mix(in srgb, #ffffff 82%, transparent);
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

body.carlo-film-hero:not(.carlo-header-solid) .carlo-topbar__link:hover,
body.carlo-film-hero:not(.carlo-header-solid) .carlo-topbar__link:focus-visible {
	color: #ffffff;
}

/* The fixed header's own offset on that page. */
body.carlo-film-hero.carlo-has-topbar .wp-site-blocks > header.wp-block-template-part {
	top: var(--carlo-topbar-h);
}

body.carlo-film-hero.admin-bar.carlo-has-topbar .wp-site-blocks > header.wp-block-template-part {
	top: calc(var(--wp-admin--admin-bar--height, 32px) + var(--carlo-topbar-h));
}

@media screen and (max-width: 782px) {
	body.carlo-film-hero.admin-bar.carlo-has-topbar .wp-site-blocks > header.wp-block-template-part {
		top: var(--carlo-topbar-h);
	}
}

/* The hero's opening line clears the header; now it clears the strip too. */
body.carlo-has-topbar .carlo-hero--film .carlo-hero__inner {
	padding-top: calc(
		var(--wp--custom--header-height) + var(--carlo-topbar-h) + clamp(2.5rem, 9vh, 6rem)
	);
}

/* ---------------------------------------------------------------
   Phones.
   Six icons at 28px each plus the gutter is 168px of the 375px we have
   to play with, so nothing needs to drop -- the bar only gets shorter.
   --------------------------------------------------------------- */
@media (max-width: 599px) {
	html:has(body.carlo-has-topbar) {
		--carlo-topbar-h: 34px;
	}

	.carlo-topbar__link {
		width: 1.625rem;
	}

	.carlo-topbar__link svg {
		width: 0.9375rem;
		height: 0.9375rem;
	}
}
