/**
 * Footer design: Monogram — .esptb-ft-monogram
 *
 * Minimal and typographic: airy columns, each under a hairline rule with a
 * short accent tick; the about text as a lead line; contact details as
 * caption + value (the hotline large, in the display font); then the site
 * name as a giant wordmark, sized to the content width with container
 * units and fading into the bottom bar it sits on. Every colour, font and
 * size comes from the kit tokens (the theme's settings) unless the block
 * sets its own. Phones: one column; the link lists fold (footer.js), the
 * contact details stay open.
 */

/* --------------------------------------------------------------- columns */

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid {
	display: grid;
	gap: calc(var(--ftc-gap) * 1.25);
	grid-template-columns: minmax(0, 1fr);
}

/* A hairline rule over every column … */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid > .esptb-ft-col {
	border-top: 1px solid var(--ftc-line);
	padding-top: 22px;
	position: relative;
}

/* … with a short accent tick where it starts. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid > .esptb-ft-col::before {
	background: var(--ftc-accent);
	content: "";
	height: 2px;
	left: 0;
	position: absolute;
	top: -1px;
	width: 28px;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-title { margin-bottom: 16px; }

/* ----------------------------------------------------------------- brand */

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-brand .esptb-ft-about {
	color: var(--ftc-heading);
	font-size: calc(var(--ft-link-size, var(--fk-link-size)) * 1.2);
	line-height: 1.65;
	margin-top: 18px;
	max-width: 36ch;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-brand > .esptb-ft-social-h {
	color: var(--ftc-muted);
	letter-spacing: 0.06em;
	margin-top: 24px;
	opacity: 1;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-brand > .esptb-ft-social { margin-top: 24px; }
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-brand > .esptb-ft-social-h + .esptb-ft-social { margin-top: 12px; }

/* ------------------------------------------------------------ contact */

/* Caption + value, left-aligned like the link lists: a small accent icon
   and the caption on one line, the value under them. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact { gap: 16px; }

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .esptb-ft-crow {
	align-items: center;
	column-gap: 8px;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	row-gap: 1px;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .esptb-ft-crow-t { display: contents; }

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .esptb-ft-ic {
	background: none;
	border-radius: 0;
	color: var(--ftc-accent-ink);
	height: auto;
	width: auto;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .esptb-ft-ic svg {
	height: 14px;
	width: 14px;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .esptb-ft-crow-k {
	color: var(--ftc-muted);
	display: block;
	font-size: 12px;
	letter-spacing: 0.04em;
	line-height: 1.4;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .esptb-ft-crow-v {
	color: var(--ftc-heading);
	font-weight: 600;
	grid-column: 1 / -1;
	line-height: 1.45;
}

/* The hotline is what a COD shopper looks for — set it large. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact .is-phone .esptb-ft-crow-v {
	font-family: var(--fk-display);
	font-size: calc(var(--ft-link-size, var(--fk-link-size)) * 1.45);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.25;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact a.esptb-ft-crow:hover .esptb-ft-crow-v { color: var(--ftc-link-h); }

/* -------------------------------------------------------------- wordmark */

/* The wordmark is fitted to the content width without a script: a hidden
   twin of the name (half its estimated size) takes its natural width in a
   flex row; the growing sibling — a size container — is then the content
   width minus the twin, and the ratio of the two lengths (tan(atan2()))
   gives the exact font size. Registered so 100cqi is captured as a length
   where it is set. Older browsers keep the estimate from the letter count. */
@property --esptb-mg-w {
	syntax: "<length>";
	inherits: true;
	initial-value: 0px;
}

@property --esptb-mg-rest {
	syntax: "<length>";
	inherits: true;
	initial-value: 0px;
}

/* The band crops the letters at the bar; the wrap is the size container. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-mark { overflow: hidden; }
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-mark .esptb-ft-wrap { container-type: inline-size; }

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-fit {
	--esptb-mg-w: 100cqi;
	align-items: flex-start;
	display: flex;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-fit-in {
	container-type: inline-size;
	flex: 1 1 0;
	min-width: 0;
}

/* Both copies share the type settings, so they measure alike. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-mark .esptb-ft-wordmark {
	/* Roughly how many em the name needs: ~0.6em a letter. */
	--mg-fit: calc(var(--wm-len, 8) * 0.6 + 0.1);
	font-weight: 800;
	letter-spacing: -0.035em;
	line-height: 1;
	overflow: visible;
	text-align: center;
}

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-twin { display: none; }

.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-word {
	color: var(--ftc-heading);
	font-size: clamp(32px, calc(88vw / var(--mg-fit)), 240px);
	padding-top: 0.24em;
}

/* Estimated from the letter count, against the content width. */
@supports (width: 1cqi) {
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-word { font-size: min(calc(100cqi / var(--mg-fit)), 26cqi); }
}

/* Measured: the name runs exactly from the first column's edge to the last. */
@supports (width: calc(1cqi * tan(atan2(1px, 2px)))) {
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-twin {
		display: block;
		flex: none;
		font-size: calc(var(--esptb-mg-w) * 0.5 / var(--mg-fit));
		visibility: hidden;
	}

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-word {
		--esptb-mg-rest: 100cqi;
		/* Short names stop growing at 28% of the width (and stay centred). */
		font-size: min(calc(var(--esptb-mg-w) * 0.5 / var(--mg-fit) * tan(atan2(var(--esptb-mg-w), var(--esptb-mg-w) - var(--esptb-mg-rest)))), calc(var(--esptb-mg-w) * 0.28));
		width: var(--esptb-mg-w);
	}
}

/* The baseline sits exactly on the bottom bar. */
@supports (text-box: trim-both cap alphabetic) {
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-word {
		padding-top: 0.26em;
		text-box: trim-both cap alphabetic;
	}
}

/* The letters fade from the heading colour into the bar. */
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-word {
		background: linear-gradient(180deg, var(--ftc-heading) 35%, color-mix(in srgb, var(--ftc-heading) 16%, transparent));
		-webkit-background-clip: text;
		background-clip: text;
		color: transparent;
		-webkit-text-fill-color: transparent;
	}
}

/* The wordmark brings its own air: a shorter gap under the columns. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-body { padding-bottom: calc(var(--ft-pad, var(--fk-pad-r)) * 0.5); }
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-body:last-child { padding-bottom: var(--ft-pad, var(--fk-pad-r)); }

/* No columns above: the wordmark opens the footer. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-mark:first-child { padding-top: var(--ft-pad, var(--fk-pad-r)); }

/* No bottom bar below: room for the descenders. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-mark:last-child .esptb-ft-mg-word { padding-bottom: 0.2em; }

/* Bengali (and other Indic) names: the vowel signs above the headline and
   below the baseline stay whole. */
.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-mark .esptb-ft-mg-word.is-indic {
	padding-bottom: 0.3em;
	padding-top: 0.44em;
}

/* ---------------------------------------------------------------- phones */

@media (max-width: 767px) {
	/* Taller tap areas for the list links without changing the rhythm: at
	   least 40px, and never less than the gap around each link. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-links a { position: relative; }

	.espt-block-footer .esptb-ft-monogram .esptb-ft-links a::after {
		content: "";
		inset: min(calc(var(--ft-link-gap, var(--fk-link-gap)) / -2), calc((100% - 40px) / 2)) 0;
		position: absolute;
	}

	/* The contact rows and the bottom bar's links reach 40px too. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-contact a.esptb-ft-crow { min-height: 40px; }

	.espt-block-footer .esptb-ft-monogram .esptb-ft-bottom .esptb-ft-policy a,
	.espt-block-footer .esptb-ft-monogram .esptb-ft-bottom .esptb-ft-credit a { padding: 9px 0; }
}

/* Folded rows sit flush between two hairlines; the brand block and the
   contact details keep their air. */
.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid { row-gap: 0; }
.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .esptb-ft-brand { padding-bottom: 28px; }

.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .esptb-ft-col.is-foldable {
	border-top: 0;
	padding-top: 0;
}

.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .esptb-ft-col.is-foldable:first-child,
.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .esptb-ft-brand + .esptb-ft-col.is-foldable { border-top: 1px solid var(--ftc-line); }

.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .esptb-ft-col.is-foldable::before,
.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .is-foldable + .is-contact::before { content: none; }

.espt-block-footer .esptb-ft-monogram.is-folded .esptb-ft-mg-grid > .is-foldable + .is-contact {
	border-top: 0;
	padding-top: 28px;
}

/* --------------------------------------------------------------- tablets */

@media (min-width: 768px) {
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid {
		column-gap: calc(var(--ftc-gap) * 1.5);
		grid-template-columns: repeat(2, minmax(0, 1fr));
		row-gap: calc(var(--ftc-gap) * 1.5);
	}

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-1 { grid-template-columns: minmax(0, 1fr); }

	/* A bar that wraps keeps both lines left-aligned under the wordmark. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-bottom .esptb-ft-bottom-r { margin-left: 0; }

	/* The brand block is ruled like the columns from here on. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid > .esptb-ft-brand {
		border-top: 1px solid var(--ftc-line);
		padding-top: 22px;
		position: relative;
	}

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid > .esptb-ft-brand::before {
		background: var(--ftc-accent);
		content: "";
		height: 2px;
		left: 0;
		position: absolute;
		top: -1px;
		width: 28px;
	}
}

@media (min-width: 768px) and (max-width: 1023px) {
	/* The brand and the contact details share the first row; the link
	   lists pair up under them. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-contact > .esptb-ft-brand {
		grid-column: 1;
		grid-row: 1;
	}

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-contact > .is-contact {
		grid-column: 2;
		grid-row: 1;
	}

	/* One list: it tucks under the contact details, beside the brand. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-contact.has-links-1 > .esptb-ft-brand { grid-row: 1 / span 2; }

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-contact.has-links-1 > .esptb-ft-col:not(.is-contact) {
		grid-column: 2;
		grid-row: 2;
	}

	/* Three lists: the third, alone on its row, spans it with its links in
	   two columns. */
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-contact.has-links-3 > .esptb-ft-col:nth-last-child(2) { grid-column: 1 / -1; }

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-contact.has-links-3 > .esptb-ft-col:nth-last-child(2) .esptb-ft-links {
		column-gap: calc(var(--ftc-gap) * 1.5);
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* --------------------------------------------------------------- desktop */

@media (min-width: 1024px) {
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid { column-gap: calc(var(--ftc-gap) * 1.4); }
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid > .esptb-ft-brand { padding-right: calc(var(--ftc-gap) * 0.75); }

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-3 { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr) minmax(0, 1.2fr); }
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-4 { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr); }
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-brand.has-5 { grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) minmax(0, 1.25fr); }

	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-3:not(.has-brand) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.espt-block-footer .esptb-ft-monogram .esptb-ft-mg-grid.has-4:not(.has-brand) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
