/*
 * Site header, styled like the institutional site https://www.tirolez.com.br
 * (.specs/archive/header-institutional-look, findings F1): a Sand top bar over the red
 * bar, Larken links with an underline that grows from the left, and the logo across both
 * bars. Always solid: the red bar is the colour of the banners that slide under it.
 */

.site-header {
	position: sticky;
	top: 0;
	z-index: var(--z-header);
	/* Anchor for the search takeover and the dropdown, both positioned overlays. */
	isolation: isolate;
	background-color: var(--color-surface-brand);
	/* The logo badge hangs below the red bar on purpose. */
	overflow: visible;
	transition: box-shadow var(--duration-base) var(--ease-out);
}

.site-header--stuck {
	box-shadow: var(--shadow-header);
}

/*
 * The containers of the header take the wider box of the institutional site, so the logo
 * and the menu sit at the left edge and the search at the right one (space-between). The
 * search takeover follows, so its logo opens exactly over the header logo.
 */
.top-nav,
.site-header__inner,
.site-search__inner {
	--container-max: var(--header-container-max);
	--container-gutter: var(--header-gutter);
}

/*
 * Sand top bar. No z-index, so it opens no stacking context: the bar itself stays below the
 * red one (z 2) and the logo paints over it, while its "Vamos conversar?" submenu (z 3)
 * can still hang over the red bar.
 */
.site-header__top {
	position: relative;
	height: var(--header-top-height);
	background-color: var(--color-header-top-bg);
}

.top-nav {
	display: flex;
	align-items: center;
	height: 100%;
}

/* The links start where those of the red bar start, after the logo. */
.top-nav__list {
	display: flex;
	/* As tall as the bar, so an item with a submenu can stretch to its bottom edge. */
	align-self: stretch;
	align-items: center;
	gap: var(--space-6);
	margin-inline-start: var(--header-nav-offset);
}

/*
 * Above the dropdown panel and the Sand bar: the logo hangs from the Sand bar down past
 * the red one, and a panel painting over it would cut the badge.
 */
.site-header__inner {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	height: var(--header-main-height);
}

/* Absolute, so each bar keeps its own height while the badge crosses both. */
.site-header__logo {
	position: absolute;
	top: calc(var(--space-1) - var(--header-top-height));
	left: var(--container-gutter);
	display: block;
	width: var(--logo-header-width);
}

.site-header__logo-image {
	width: 100%;
	height: auto;
}

/* Desktop navigation */

.site-nav {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: space-between;
	margin-inline-start: var(--header-nav-offset);
}

.site-nav__close,
.site-header__burger,
.site-nav__extra {
	display: none;
}

.site-nav__list {
	display: flex;
	align-items: center;
	gap: var(--space-nav-main);
}

.site-nav__item {
	position: relative;
}

/*
 * Larken Bold in both bars: 22px Sand on the red one, 19px Main Red on the Sand one.
 *
 * 700 and not the 660 of the headings: the file is the static Bold instance, so every
 * weight renders the very same glyphs (findings F6), and 700 is what makes the links
 * count as bold large text for the contrast check. Both pairs are 3.46:1 (F3).
 */
.site-nav__link,
.top-nav__link {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	color: var(--color-nav-main-link);
	font-family: var(--font-heading);
	font-size: var(--font-nav-main);
	font-weight: 700;
	line-height: var(--lh-heading);
	letter-spacing: normal;
}

.top-nav__link {
	color: var(--color-nav-top-link);
	font-size: var(--font-nav-top);
}

.site-nav__link--static,
.top-nav__link--static {
	cursor: default;
}

/*
 * "Vamos conversar?" submenu (hotfix/client-feedback-2), from the institutional top bar.
 * Provisional look (docs/BACKLOG.md 118): the institutional site blocks automated reads,
 * so its submenu could not be measured. A Sand panel that continues the bar, with the
 * links of the bar. The item fills the bar's height, so the panel starts at its bottom
 * edge and the pointer never crosses a gap on its way down.
 */
.top-nav__item--has-children {
	position: relative;
	display: flex;
	align-self: stretch;
	align-items: center;
}

.top-nav__chevron {
	width: 13px;
	height: 8px;
	transition: transform var(--duration-fast) var(--ease-out);
}

.top-nav__chevron path {
	stroke: currentColor;
}

.top-nav__link--toggle[aria-expanded='true'] .top-nav__chevron {
	transform: rotate(180deg);
}

.top-nav__submenu {
	position: absolute;
	top: 100%;
	left: calc(var(--space-4) * -1);
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-width: max-content;
	padding: var(--space-3) var(--space-4);
	border-radius: 0 0 var(--radius-card) var(--radius-card);
	background-color: var(--color-header-top-bg);
	box-shadow: var(--shadow-header);
	list-style: none;
}

.top-nav__submenu[hidden] {
	display: none;
}

.top-nav__submenu-link {
	position: relative;
	display: inline-flex;
	color: var(--color-nav-top-link);
	font-family: var(--font-heading);
	font-size: var(--font-nav-top);
	font-weight: 700;
	line-height: var(--lh-heading);
}

/*
 * The institutional underline: 2px in the colour of the text, 2px below it, growing from
 * the left in 200ms on hover, and kept under the current section and the open dropdown.
 */
.site-header .has-underline::after {
	--underline-offset: -2px;
	--underline-thickness: 2px;
	opacity: 1;
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--duration-nav-underline) ease;
}

.site-header a:hover > .has-underline::after,
.site-header a:focus-visible > .has-underline::after,
.site-header button:hover > .has-underline::after,
.site-header button:focus-visible > .has-underline::after,
.site-header [aria-current='page'] > .has-underline::after,
.site-header [aria-expanded='true'] > .has-underline::after {
	transform: scaleX(1);
}

/* Only the mobile breakpoint uses the inline submenu, see the media query below. */
.site-nav__submenu {
	display: none;
}

.site-nav__chevron {
	width: 13px;
	height: 8px;
	transition: transform var(--duration-fast) var(--ease-out);
}

/* The glyph is drawn white; the stroke follows the colour of the link instead. */
.site-nav__chevron path,
.site-nav__search-icon path {
	stroke: currentColor;
}

.site-nav__link--toggle[aria-expanded='true'] .site-nav__chevron {
	transform: rotate(180deg);
}

/* A plain magnifier at the end of the red bar, as on the institutional site. */
.site-nav__search-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 48px;
	height: 48px;
	color: var(--color-nav-main-link);
}

.site-nav__search-icon {
	width: var(--space-4);
	height: var(--space-4);
}

/*
 * "Seu Negócio" dropdown, overlay 728:38906. The node is 1440x572 filled white, with the
 * 88px red bar drawn over it and a 672px block of content aligned to the container
 * gutter. The white is the panel, not a floating card.
 *
 * Out of flow on purpose: as a block inside the sticky header the open panel pushed the
 * whole page down by its own height and left the transparent bar of the home page sitting
 * over the white body, which made the white links and icons invisible.
 */
.business-dropdown {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	background-color: var(--color-surface);
}

.business-dropdown[hidden] {
	display: none;
}

/*
 * The scrim starts where the white panel ends: the node fills 572px from the top of the
 * viewport and the overlayBackground darkens only what is left below it.
 */
.business-dropdown__scrim {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	height: 100vh;
	background-color: var(--color-overlay-scrim);
}

/*
 * The block of content is at y=182 in a node whose bar is 88px tall, so it sits 94px below
 * the bar. In 728:38802 the block is 313px tall and the panel ends at y=572, 77px after it.
 */
.business-dropdown__panel {
	position: relative;
	z-index: 1;
	padding-block: 94px 77px;
}

.business-dropdown__box {
	display: flex;
	gap: 103px;
	width: 672px;
	max-width: 100%;
}

/* The node puts the image at y=58 of a block whose title is 34px tall, so the gap is 24px. */
.business-dropdown__intro {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: var(--space-4);
	width: 289px;
}

.business-dropdown__title {
	color: var(--color-heading-dialog);
	font-family: var(--font-heading);
	font-size: var(--font-h4);
	font-weight: var(--weight-heading);
	line-height: var(--lh-heading);
	letter-spacing: var(--ls-body);
}

.business-dropdown__media {
	position: relative;
	height: 255px;
	border-radius: var(--radius-card);
	background-color: var(--color-surface-subtle);
	overflow: hidden;
}

/* Only one of the five images shows at a time, swapped by hovering a segment link. */
.business-dropdown__image-slot {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity var(--duration-base) var(--ease-out);
}

.business-dropdown__image-slot[data-active='true'] {
	opacity: 1;
}

.business-dropdown__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * In 728:38802 the list has a 2px Gray 30 divider, a 24px inset and its 48px links on an
 * 8px gap, centred against the height of the title column.
 */
.business-dropdown__list {
	display: flex;
	flex: 1;
	flex-direction: column;
	justify-content: center;
	gap: var(--space-1);
	border-left: 2px solid var(--color-divider);
	/* The 24px of the node are measured from the frame edge, where the stroke sits. */
	padding-inline-start: calc(var(--space-4) - 2px);
}

.business-dropdown__list li {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--space-1);
}

.business-dropdown__link {
	display: flex;
	flex: 1;
	align-items: center;
	block-size: 48px;
	padding-inline: var(--space-4);
	border-radius: var(--radius-card);
	color: var(--color-text);
	font-size: var(--font-p2);
	line-height: 1.4;
	transition: background-color var(--duration-base) var(--ease-out);
}

a.business-dropdown__link:hover {
	background-color: var(--color-hover-surface);
}

/* The row whose photo is on show: Light Gray, Dark Red and Medium, as Pizzarias in 728:38802. */
.business-dropdown__list li[data-active] .business-dropdown__link {
	background-color: var(--color-hover-surface);
	color: var(--color-heading-dialog);
	font-weight: 500;
}

.business-dropdown__link--all {
	color: var(--color-link);
}

/*
 * Items whose destination is still undefined render as plain text (pendency 8). They keep
 * the normal reading color instead of being dimmed: Gray BRAND fails AA here.
 */
.business-dropdown__link--static {
	cursor: default;
}

/*
 * The arrow of "Ver todas" is inside the link, right after the text, so that row hugs its
 * label instead of stretching it to the width of the column.
 */
.business-dropdown__link--all {
	flex: none;
	padding-inline-end: 0;
}

.business-dropdown__arrow {
	flex: none;
	width: 13px;
	height: 13px;
	color: var(--color-link);
}

/*
 * CLOSE sits at y=111 in the node, 23px below the 88px bar, and is a plain X: Ellipse 157
 * is in the component but with an empty fill in this state, and the X is Dark Red over
 * the white panel. The hover tint is ours, the node gives no hover for the empty variant.
 */
.business-dropdown__close {
	position: absolute;
	top: 23px;
	right: var(--container-gutter);
	z-index: 1;
	background-color: transparent;
	backdrop-filter: none;
	color: var(--color-icon-accent);
}

.business-dropdown__close:hover {
	background-color: var(--color-hover-surface);
}

/* 596:13041 draws a 16px X with a 3.2 stroke: the modal close glyph, not the overlay one. */
.business-dropdown__close svg {
	width: 32px;
	height: 32px;
}

.business-dropdown :focus-visible {
	outline-color: var(--color-focus-ring);
}

/*
 * Search panel, from overlay 301:17801. A full width red band that hangs right below the
 * menu bar, over the page (change search-results): the bar stays visible and usable, so
 * the panel no longer covers it or repeats the logo. overlayBackground NONE, so no scrim.
 *
 * z-index 1, under .site-header__inner (2): the logo badge that hangs below the bar keeps
 * painting over the band, as it does over the page.
 */

.site-search {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	z-index: 1;
	background-color: var(--color-surface-brand);
	box-shadow: var(--shadow-search-panel);
}

.site-search[hidden] {
	display: none;
}

.site-search__inner {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-3);
	padding-block: var(--space-5);
}

.site-search__close {
	position: absolute;
	top: 50%;
	right: var(--container-gutter);
	transform: translateY(-50%);
}

.search-form {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	width: 638px;
	max-width: 100%;
	height: 64px;
	padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
	border-radius: var(--radius-pill);
	background-color: var(--color-surface);
}

.search-form__icon {
	flex: none;
	width: 24px;
	height: 24px;
	color: var(--color-text-placeholder);
}

.search-form__input {
	flex: 1;
	min-width: 0;
	border: 0;
	background: none;
	color: var(--color-text);
	font-size: var(--font-p2);
	line-height: 1.4;
}

.search-form__input::placeholder {
	color: var(--color-text);
	opacity: 0.64;
}

.search-form__input:focus {
	outline: none;
}

/* The plain CTA 1ª | DARK of 1046:71261: 52 tall and 24 of side padding, centred in the 64px field. */
.search-form__submit {
	flex: none;
}

.site-search :focus-visible {
	outline-color: var(--color-focus-ring-on-brand);
}

/* Inside the white field the white ring would vanish, so the controls there go dark. */
.search-form :focus-visible {
	outline-color: var(--color-focus-ring);
}

.search-form:focus-within {
	outline: 2px solid var(--color-focus-ring-on-brand);
	outline-offset: 2px;
}

@media (max-width: 1279px) {
	.business-dropdown__box {
		gap: var(--space-6);
	}
}

@media (max-width: 1023px) {
	/* In the row beside the field: absolute, it would sit over the Buscar button. */
	.site-search__close {
		position: static;
		flex: none;
		transform: none;
	}

	/*
	 * Here the field runs from gutter to gutter, under the logo badge, which hangs about
	 * 27px below the 72px bar (100px wide, 8px from the top): 40 on top clears it, as the
	 * 64 on top of the nav panel does.
	 */
	.site-search__inner {
		padding-block: var(--space-6) var(--space-4);
	}

	.site-header__top {
		display: none;
	}

	.site-header__inner {
		justify-content: flex-end;
		height: var(--header-height);
	}

	/* Over the white panel, which opens under the red bar the badge hangs from. */
	.site-header__logo {
		top: var(--space-1);
		z-index: calc(var(--z-nav-panel) + 1);
	}

	.site-header__burger {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 48px;
		height: 48px;
		border-radius: var(--radius-pill);
		color: var(--color-burger);
	}

	.site-header__burger-bars,
	.site-header__burger-bars::before,
	.site-header__burger-bars::after {
		display: block;
		width: 22px;
		height: 2px;
		border-radius: 2px;
		background-color: currentColor;
	}

	.site-header__burger-bars {
		position: relative;
	}

	.site-header__burger-bars::before,
	.site-header__burger-bars::after {
		position: absolute;
		left: 0;
		content: '';
	}

	.site-header__burger-bars::before {
		top: -7px;
	}

	.site-header__burger-bars::after {
		top: 7px;
	}

	/*
	 * The institutional mobile menu: a white panel the width of the screen, under the red
	 * bar, with the links centred in Main Red between thin rules. Opening, closing, the
	 * focus trap and Escape are still header.js, untouched.
	 */
	.site-nav {
		position: fixed;
		top: var(--header-height);
		right: 0;
		left: 0;
		z-index: var(--z-nav-panel);
		flex-direction: column;
		align-items: stretch;
		justify-content: flex-start;
		gap: var(--space-4);
		height: calc(100vh - var(--header-height));
		height: calc(100dvh - var(--header-height));
		margin-inline-start: 0;
		padding: var(--space-7) var(--space-4) var(--space-4);
		background-color: var(--color-nav-panel-bg);
		box-shadow: var(--shadow-header);
		overflow-y: auto;
		transform: translateX(100%);
		transition: transform var(--duration-base) var(--ease-out);
	}

	.site-nav[data-open='true'] {
		transform: translateX(0);
	}

	.site-nav:not([data-open='true']) {
		visibility: hidden;
	}

	.site-nav__close {
		position: absolute;
		top: var(--space-3);
		right: var(--space-3);
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		border-radius: var(--radius-pill);
		color: var(--color-nav-panel-link);
	}

	.site-nav__close-icon {
		width: 24px;
		height: 24px;
	}

	.site-nav__list,
	.site-nav__extra {
		display: flex;
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}

	.site-nav__item,
	.site-nav__extra-item {
		border-block-start: 1px solid var(--color-text);
	}

	.site-nav__extra-item:last-child {
		border-block-end: 1px solid var(--color-text);
	}

	/* One continuous list of rules, as on the institutional site: no panel gap between the two. */
	.site-nav__list + .site-nav__extra {
		margin-block-start: calc(var(--space-4) * -1);
	}

	.site-nav__link,
	.site-nav__link--toggle {
		justify-content: center;
		width: 100%;
		padding-block: var(--space-3);
		color: var(--color-nav-panel-link);
		font-family: var(--font-body);
		font-size: var(--font-h4);
		font-weight: 600;
		text-align: center;
	}

	/* The panel is white: the focus ring goes dark. */
	.site-nav :focus-visible {
		outline-color: var(--color-focus-ring);
	}

	/*
	 * Inline disclosure of "Seu Negócio". It replaces the mega menu overlay here: the
	 * 672px panel does not fit, and the prototype has no mobile frame that says otherwise.
	 */
	.site-nav__submenu,
	.site-nav__extra-submenu {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-block-end: var(--space-2);
	}

	.site-nav__submenu[hidden] {
		display: none;
	}

	.site-nav__submenu-link {
		display: block;
		padding: var(--space-1) var(--space-3);
		color: var(--color-nav-panel-link);
		font-size: var(--font-p3);
		line-height: 1.4;
		text-align: center;
	}

	/*
	 * "Vamos conversar?" links are always visible here, and Main Red on white is 4.13:1:
	 * 19px bold makes them large text (AA 3:1), the same size and weight as the desktop
	 * submenu of the Sand bar.
	 */
	.site-nav__extra-submenu .site-nav__submenu-link {
		font-size: var(--font-nav-top);
		font-weight: 700;
	}

	.site-nav__search-toggle {
		align-self: center;
		color: var(--color-nav-panel-link);
	}
}

@media (max-width: 767px) {
	.search-form {
		height: 56px;
		padding-inline-start: var(--space-3);
	}

	.search-form__submit {
		height: 40px;
		padding-inline: var(--space-3);
	}
}
