/*
 * Hero — DESIGN.md §11. Text + CTAs left, quick-calc form as a floating
 * card top-right, full-bleed media behind both.
 */

.hero {
	position: relative;
	overflow: hidden;
	/*
	 * Hero uses its own (tighter) rhythm rather than the shared
	 * --ark-space-section-* tokens: this is the first screen and needs to
	 * read dense/premium (DESIGN.md §2), not like a later content section.
	 */
	padding-block: clamp(40px, 3vw + 16px, 64px) clamp(32px, 2.5vw + 16px, 52px);
}

/*
 * Hero media — full-bleed layer behind Hero content + form (DESIGN.md §11:
 * image lives center/right, text stays legible over it via a left-side
 * dark gradient). Structure:
 *   .hero__media            — positioning/clipping wrapper
 *     .hero__media-picture    — <picture>/<img>, only rendered once a real
 *                               image is wired in (hero.php)
 *     .hero__media-overlay    — permanent legibility gradient, sits above
 *                               the image (or the placeholder) always
 *
 * [data-has-image="false"] carries today's DEV PLACEHOLDER geometry only.
 * Swapping in a real photo means setting $ark_hero_image_src in hero.php —
 * no markup/CSS restructuring needed; the placeholder rules simply stop
 * matching once data-has-image flips to "true".
 */
.hero__media {
	position: absolute;
	inset: 0;
	z-index: 0;
	overflow: hidden;
	background-color: var(--ark-bg-850);
}

.hero__media-picture {
	display: contents;
}

.hero__media-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	/*
	 * ark-hero-master.png: the lit lobby/entrance sits center-right and in
	 * the lower half of the frame; the sky above is the most dispensable
	 * part of the shot. Bias down + slightly right so cover-cropping trims
	 * sky first, keeps the building's lit mass in frame. Overridden for the
	 * mobile boxed crop below, where cover crops left/right instead.
	 */
	object-position: var(--ark-hero-image-position, 68% 62%);
}

/*
 * Always-on legibility gradient — stays after the placeholder is replaced.
 * Widened against ark-hero-master.png specifically: at wide/narrow-ish
 * desktop ratios alike, object-fit:cover ends up cropping this photo
 * almost entirely by height (not width), so the building's left glass
 * facade sits closer to the H1 text column than a "photo occupies
 * center/right" read would suggest. The dark zone below is pushed further
 * right (~32%/52% vs. a plain 24%/46%) so H1 stays clearly legible.
 */
.hero__media-overlay {
	position: absolute;
	inset: 0;
	background-image: linear-gradient(
		100deg,
		rgba(5, 12, 18, 0.96) 0%,
		rgba(5, 12, 18, 0.86) 32%,
		rgba(18, 30, 40, 0.6) 52%,
		rgba(32, 50, 62, 0.32) 74%,
		rgba(48, 72, 88, 0.16) 100%
	);
}

/*
 * DEV PLACEHOLDER — geometry only, not a finished visual. Marks out the
 * area + tone a real photo will occupy. Removed automatically (never
 * matches) once hero.php renders a real <picture> and flips this to "true".
 */
.hero__media[data-has-image="false"] {
	background-image:
		linear-gradient(100deg, var(--ark-bg-850) 0%, var(--ark-bg-800) 35%, #1C2B36 65%, #2A3C48 100%),
		repeating-linear-gradient(0deg, rgba(166, 176, 186, 0.05) 0 1px, transparent 1px 64px),
		repeating-linear-gradient(90deg, rgba(166, 176, 186, 0.05) 0 1px, transparent 1px 64px);
}

.hero__layout {
	position: relative;
	z-index: 1;
	display: grid;
	/* Form column narrows a bit before the layout stacks (below), so the
	   text column keeps enough room to hold "Инженерные системы" on one line. */
	grid-template-columns: minmax(0, 1fr) clamp(320px, 34vw, 380px);
	gap: 48px;
	align-items: start;
}

.hero__content {
	max-width: 760px;
}

.hero__overline {
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.16em;
	color: var(--ark-text-secondary);
	margin-bottom: 16px;
}

.hero__title {
	font-family: var(--ark-font-display);
	font-weight: 500;
	font-size: var(--ark-fs-hero-h1);
	line-height: 1.08;
	color: var(--ark-text-primary);
	margin-bottom: 20px;
}

.hero__title-line {
	display: block;
}

/*
 * Each phrase becomes a hard, non-wrapping unit only once the 2-column
 * desktop composition is active (>920px — matches the .hero__layout
 * stacking breakpoint below). At that width there's a generous, checked
 * margin (see hero.css history) for "Инженерные системы" to hold one line
 * regardless of font metrics — verified holding one line with the real
 * local Cormorant Garamond at 921/1024/1240/1440px. Below 920px the phrase is allowed to wrap normally again:
 * mobile/tablet-stacked Hero was never required to hold exactly 3 lines,
 * and forcing nowrap that low risks real horizontal overflow instead.
 */
@media (min-width: 921px) {
	.hero__title-line {
		white-space: nowrap;
	}
}

.hero__subtitle {
	font-size: 1.05rem;
	color: var(--ark-text-secondary);
	max-width: 540px;
	margin-bottom: 28px;
}

.hero__actions {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

/* Below this, text+form no longer fit side by side comfortably — stack. */
@media (max-width: 920px) {
	.hero__layout {
		grid-template-columns: 1fr;
	}

	.hero__content {
		max-width: none;
	}
}

/*
 * Mobile order per DESIGN.md §19 / homepage-structure.md §27:
 * overline+H1+subtitle+CTAs, secondary CTA, hero image, trust bar, form.
 * .hero and its wrappers become `display: contents` so hero__content,
 * hero__media and the hero-form card become direct siblings of the
 * trust-bar section inside .home-intro, letting `order` do the reordering
 * across what are otherwise two separate <section>s.
 */
@media (max-width: 767px) {
	.hero {
		padding-block: var(--ark-space-section-md) var(--ark-space-section-sm);
	}

	.home-intro {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 40px;
	}

	.hero,
	.hero .container,
	.hero__layout {
		display: contents;
	}

	/*
	 * .container normally supplies the side gutter (DESIGN.md §9), but it
	 * becomes `display: contents` above, which drops its width/padding too.
	 * Re-apply the same gutter directly on each promoted item so hero
	 * content doesn't run edge-to-edge on mobile.
	 */
	.hero__content,
	.hero__media,
	.hero-form {
		margin-inline: var(--ark-container-pad);
	}

	.hero__content {
		order: 1;
	}

	.hero__media {
		order: 2;
		position: relative;
		inset: auto;
		height: 320px;
		border: 1px solid var(--ark-border-soft);
		border-radius: var(--ark-radius-lg);
		/* Narrow box crops left/right instead of top/bottom — bias further
		   right to keep the lit building mass in frame over empty sky/plaza. */
		--ark-hero-image-position: 78% 55%;
	}

	.hero-form {
		order: 3;
	}

	.trust-bar {
		order: 4;
	}
}

/* fix(home): remove mobile horizontal overflow — .ark-btn (base.css) is
   white-space: nowrap sitewide by design, which is correct everywhere
   except this specific label ("Рассчитать стоимость проекта") at very
   narrow widths: at 320px its nowrap text pushes the button past the
   viewport, confirmed via Playwright as a real contributor to document
   horizontal overflow (hiding it brought scrollWidth back to clientWidth).
   Scoped to this Hero CTA only, and only ≤340px where 360px+ already fit
   on one line — .ark-btn itself and every other button on the site keep
   nowrap untouched. */
@media (max-width: 340px) {
	.hero__actions .ark-btn {
		white-space: normal;
		text-align: center;
	}
}
