/* Page rows and columns (home pages, footer, static pages).
   Same geometry as the Elementor sections the WP sites were built with (SmartMag "el-gap-default"):
   a row is as wide as the site content (--main-width), columns have --col-gutter on each side,
   so the outer columns line up with the header and the rest of the page.

   <section class="page-row [full-width] [reverse-xs] [flush]">
     <div class="cols">
       <div class="col w-50 [has-sep] [desktop-only]"> …blocks… </div>
       <div class="col w-30"><div class="stack ts-sticky-native"> …blocks that stay on screen… </div></div>
     </div>
   </section>

   A column can hold its own row: <div class="col"><div class="cols"><div class="col w-25">…</div>…</div></div>.
   Column widths (w-25 … w-100) apply from 768px; below that every column takes the full width.
   Blocks in a column stack with --blocks-gap between them. */

.page-row {
	--col-gutter: calc(var(--grid-gutter) / 2);
	--grid-gutter-h: var(--col-gutter);
	--spacer: var(--wrap-padding);
	--blocks-gap: 20px;
	position: relative;
	display: flex;
	justify-content: center;
}

/* side space of a boxed row (the page padding) */
.page-row:not(.full-width)::before,
.page-row:not(.full-width)::after {
	content: "";
	padding-left: var(--spacer);
	pointer-events: none;
	z-index: -1;
}

.page-row.full-width {
	max-width: 100%;
	overflow-x: hidden;
}

.page-row .cols {
	position: relative;
	display: flex;
	margin-right: calc(-1 * var(--col-gutter));
	margin-left: calc(-1 * var(--col-gutter));
}

.page-row > .cols {
	flex: 1 1 auto;
	width: 100%;
}

@media (min-width: 1201px) {
	.page-row:not(.full-width) > .cols {
		max-width: calc(var(--main-width) + var(--col-gutter) * 2);
		flex-grow: 0;
	}
}

@media (max-width: 1024px) {
	.page-row .cols {
		flex-wrap: wrap;
	}
}

@media (max-width: 940px) {
	.page-row {
		--spacer: 25px;
	}
	.page-row:not(.full-width) > .cols {
		max-width: calc(var(--max-width-md) + var(--col-gutter) * 2);
	}
}

@media (max-width: 540px) {
	.page-row {
		--spacer: 20px;
	}
}

@media (max-width: 350px) {
	.page-row {
		--spacer: 15px;
	}
}

/* ---- columns */

.page-row .col {
	position: relative;
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	min-height: 1px;
	padding-right: var(--col-gutter);
	padding-left: var(--col-gutter);
}

/* a column's blocks in one box, for SmartMag's sticky column: .stack.ts-sticky-native (CSS sticky, the
   theme JS adds the sticky header height) or .ts-sticky-col column + .stack.theiaStickySidebar (JS) */
.page-row .col > .stack {
	display: flex;
	flex-direction: column;
	width: 100%;
}

/* SmartMag's sticky sidebar script works on a block column (it sets display: block itself when it has to
   add the wrapper) */
.page-row .col.ts-sticky-col {
	display: block;
}

/* space between blocks (a margin, not `gap`: the sticky sidebar script adds a clearfix ::after).
   Weight of one class: beats the theme's tag reset (div { margin: 0 }), a block's own class rule in the
   site / page CSS (loaded later) wins. */
:where(.page-row) :is(.col, .stack) > * + * {
	margin-top: var(--blocks-gap);
}

@media (min-width: 768px) {
	.page-row .w-25 { width: 25%; }
	.page-row .w-30 { width: 30%; }
	.page-row .w-33 { width: 33.333%; }
	.page-row .w-50 { width: 50%; }
	.page-row .w-66 { width: 66.666%; }
	.page-row .w-70 { width: 70%; }
	.page-row .w-100 { width: 100%; }
}

@media (max-width: 767px) {
	.page-row .col {
		width: 100%;
	}
	/* columns in reverse order on phones */
	.page-row.reverse-xs > .cols {
		flex-direction: column-reverse;
	}
}

/* thin line on the left of a column (desktop) */
.page-row .col.has-sep {
	border-left: 1px solid var(--c-sidebar-sep);
}

@media (max-width: 940px) {
	.page-row .col.has-sep {
		border-left: 0;
	}
}

/* content + sidebar: SmartMag's .main-content / .main-sidebar columns give the widths on desktop;
   on tablets and phones both take the full width */
@media (min-width: 941px) {
	.page-row .col.main-sidebar {
		padding-left: var(--sidebar-c-pad);
	}
}
@media (max-width: 1024px) {
	.page-row .col.main-content,
	.page-row .col.main-sidebar {
		width: 100%;
	}
}

/* a row without side gutters (e.g. a line across the content width) */
.page-row.flush {
	--col-gutter: 0px;
	--spacer: 0px;
}

@media (max-width: 1024px) {
	.page-row .col.desktop-only {
		display: none;
	}
}

@media (max-width: 767px) {
	.page-row .col.no-phone {
		display: none;
	}
}

/* a thin horizontal line between blocks */
.page-row .divider {
	padding: 15px 0;
}
.page-row .divider::before {
	content: "";
	display: block;
	border-top: 1px solid #e8e8e8;
}
