/* =========================================================================
 * MARK GALLERY — phone login / sign-up modal
 * =========================================================================
 * Two columns: the form on the starting side (the right on this RTL site,
 * where the eye lands first) and a photograph on the far side. Square
 * corners, a hairline border, and the store's own two fonts — the same
 * language as the account cards and the quick-view dialog.
 *
 * Three layout rules worth knowing before editing:
 *
 *   1. The box is a grid with a single row. The photo column has no
 *      intrinsic height, so the row is exactly as tall as the form; the
 *      photo grows and shrinks with it and crops itself with
 *      background-size:cover. That is why the phone step gives a landscape
 *      card and the sign-up step a tall one, without any height in between
 *      being written by hand.
 *
 *   2. The form column is the scroller, not the box. The sign-up step has
 *      five fields and on a short laptop screen it is taller than the card;
 *      if the box scrolled instead, the photo would slide out of the frame.
 *
 *   3. On phones the photo is dropped. A shallow band across the top of a
 *      portrait crop cuts the mark in half, and the sign-up step needs that
 *      height more than the decoration does.
 * ========================================================================= */

.ba-ov {
	position: fixed;
	inset: 0;
	z-index: 9990;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(10, 10, 10, .62);
}

.ba-ov.on {
	display: flex;
}

.ba-box {
	position: relative;
	display: grid;
	/* line 1 is the right-hand edge on an RTL page */
	grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
	grid-template-rows: minmax(0, 1fr);
	width: min(700px, 100%);
	max-height: min(92vh, 720px);
	max-height: min(92dvh, 720px);
	overflow: hidden;
	background: #fff;
	color: var(--ink, #0a0a0a);
	border: 1px solid var(--line, #e9e9e9);
	border-radius: 0;
	box-shadow: 0 32px 80px -28px rgba(10, 10, 10, .55);
	font-family: var(--mg-font, "Estedad", Tahoma, sans-serif);
	direction: rtl;
	text-align: right;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	/* The closed state is display:none on purpose: a browser does not fetch
	 * the background image of an element that is not rendered, so the photo
	 * costs every other page view nothing. Toggling display also restarts
	 * this animation each time the overlay opens. */
	-webkit-animation: ba-in .3s cubic-bezier(.2, .7, .2, 1) both;
	animation: ba-in .3s cubic-bezier(.2, .7, .2, 1) both;
}

@-webkit-keyframes ba-in {
	from { opacity: 0; -webkit-transform: translateY(8px); }
	to   { opacity: 1; -webkit-transform: none; }
}

@keyframes ba-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

/* ---------- the photograph ---------- */
/* The row is stated explicitly on both columns. With auto row placement the
 * photo would claim row 1 column 2, the auto-placement cursor would move past
 * column 1, and the form would be pushed down into a second, implicit row —
 * leaving this column with no height at all. */
.ba-media {
	grid-column: 2;
	grid-row: 1;
	background-color: #14161f;
	background-image: url("../img/login-cover.webp");
	background-repeat: no-repeat;
	background-position: center center;
	background-size: cover;
}

/* ---------- close ---------- */
/* A chip floating on the card rather than a control inside the scrolling
 * column, so it cannot scroll out of reach. It sits on the far corner next
 * to the photo, opposite the title. */
.ba-x {
	position: absolute;
	z-index: 3;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, .08);
	border-radius: 50%;
	background: rgba(255, 255, 255, .94);
	color: var(--ink, #0a0a0a);
	font-family: inherit;
	font-size: 21px;
	line-height: 1;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .16);
	transition: background-color .18s ease, color .18s ease;
}

.ba-x:hover {
	background: var(--ink, #0a0a0a);
	color: #fff;
}

.ba-x:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 2px;
}

/* ---------- the form column ---------- */
.ba-body {
	grid-column: 1;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 30px 28px 26px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.ba-t {
	margin: 0;
	/* main.css centres every h2; this one belongs to the form column and lines
	 * up with the copy under it, the way the card is composed */
	text-align: start;
	/* keeps a long title clear of the close chip on the far corner */
	padding-inline-end: 44px;
	font-family: var(--mg-font-display, "Arad", Tahoma, sans-serif);
	font-size: clamp(21px, 1.4vw + 11px, 28px);
	font-weight: 600;
	line-height: 1.45;
	letter-spacing: 0;
	color: var(--ink, #0a0a0a);
}

.ba-s {
	margin: 8px 0 18px;
	font-size: 13.5px;
	line-height: 1.9;
	color: #6a6a6a;
}

/* A floor under the height, so the card does not shrink and grow as the
 * visitor moves between steps: the code step is a little taller than the
 * phone step, and a dialog that changes size under the cursor reads as a
 * glitch. The floor is the phone step's own height (measured: 337px), so
 * that step sits snug with no dead space under its last line, and the steps
 * that carry more content grow to fit it. */
.ba-box {
	min-height: 340px;
}

.ba-step {
	display: none;
}

.ba-step.on {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
}

/* ---------- fields ---------- */
.ba-f {
	display: block;
	margin: 0 0 14px;
}

.ba-f > span {
	display: block;
	margin-bottom: 7px;
	font-size: 12.5px;
	font-weight: 500;
	color: #3a3a3a;
}

.ba-f > span i {
	font-style: normal;
	font-weight: 400;
	font-size: 11.5px;
	color: #8c8c8c;
}

/* The wrapper around a password input is a span too, and it must not pick up
 * the label's bottom margin — the field's own margin already separates rows. */
.ba-f > .ba-pw {
	margin-bottom: 0;
}

/* The sign-up step is the only one with five fields, and at the shared rhythm
 * it made the card half again as tall as the step it opens on. It gets a
 * tighter spacing of its own — and its two optional fields share a row — so
 * the card stays close to the height the dialog first appears at instead of
 * growing into a full-page panel. The step name is put on the overlay by
 * brand-auth.js, because a step that is display:none cannot be styled from
 * outside without :has(). */
.ba-ov[data-step="profile"] .ba-s {
	margin-bottom: 15px;
}

.ba-ov[data-step="profile"] .ba-f {
	margin-bottom: 10px;
}

.ba-ov[data-step="profile"] .ba-f input {
	height: 46px;
}

.ba-ov[data-step="profile"] .ba-pw input {
	padding-left: 46px;
}

.ba-ov[data-step="profile"] .ba-eye {
	width: 44px;
	height: 46px;
}

.ba-ov[data-step="profile"] .ba-btn {
	min-height: 46px;
	margin-top: 4px;
}

.ba-f input,
.ba-f select,
.ba-f textarea {
	width: 100%;
	height: 52px;
	padding: 0 14px;
	border: 1px solid #d5d5d5;
	border-radius: 0;
	background: #fff;
	color: inherit;
	font: inherit;
	font-size: 14.5px;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
	transition: border-color .16s ease, box-shadow .16s ease;
}

.ba-f input:hover {
	border-color: #b3b3b3;
}

.ba-f input:focus,
.ba-f select:focus,
.ba-f textarea:focus {
	outline: 0;
	border-color: var(--ink, #0a0a0a);
	box-shadow: 0 0 0 3px rgba(10, 10, 10, .10);
}

.ba-f input[dir=ltr] {
	text-align: left;
}

.ba-f input.ba-code {
	text-align: center;
	letter-spacing: .5em;
	font-size: 22px;
	font-weight: 600;
}

/* Two fields side by side — the pair of optional ones on the sign-up step.
 * flex-basis 0 keeps them equal even when their labels differ in length. */
.ba-row {
	display: flex;
	gap: 12px;
}

.ba-row .ba-f {
	flex: 1 1 0;
	min-width: 0;
}

/* ---------- primary button ---------- */
.ba-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 52px;
	margin-top: 6px;
	padding: 0 20px;
	border: 1px solid var(--ink, #0a0a0a);
	border-radius: 0;
	background: var(--ink, #0a0a0a);
	color: #fff;
	font: inherit;
	font-size: 14.5px;
	font-weight: 600;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color .18s ease, color .18s ease;
}

.ba-btn:hover {
	background: #fff;
	color: var(--ink, #0a0a0a);
}

.ba-btn:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 3px;
}

.ba-btn[disabled] {
	opacity: .5;
	cursor: default;
}

/* ---------- plain text buttons ---------- */
.ba-lnk {
	margin: 14px 0 0;
	padding: 0;
	min-height: 44px;
	border: 0;
	background: none;
	color: #3a3a3a;
	font: inherit;
	font-size: 12.5px;
	text-decoration: underline;
	text-underline-offset: 4px;
	cursor: pointer;
}

.ba-lnk + .ba-lnk {
	margin-inline-start: 16px;
}

.ba-lnk[disabled] {
	opacity: .6;
	cursor: default;
	text-decoration: none;
}

.ba-lnk--wide {
	display: block;
	width: 100%;
	margin-top: 10px;
	text-align: center;
	color: #8c8c8c;
	font-size: 13px;
}

.ba-lnk--wide:hover {
	color: var(--ink, #0a0a0a);
}

/* ---------- password field with a show/hide eye ---------- */
.ba-pw {
	position: relative;
	display: block;
}

.ba-pw input {
	padding-left: 52px;
}

.ba-eye {
	position: absolute;
	top: 0;
	left: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 50px;
	height: 52px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: #8c8c8c;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.ba-eye:hover {
	color: var(--ink, #0a0a0a);
}

.ba-eye:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: -3px;
}

/* The slash means "this eye is not seeing": it marks the hidden state, so the
 * icon reports what is on screen rather than what a click would do. */
.ba-eye::after {
	content: "";
	position: absolute;
	width: 26px;
	height: 1.7px;
	border-radius: 2px;
	background: currentColor;
	transform: rotate(-45deg);
	opacity: 1;
	transition: opacity .12s ease;
}

.ba-eye[aria-pressed="true"]::after {
	opacity: 0;
}

/* ---------- messages ---------- */
/* The slot collapses to nothing while there is no message, so the card closes
 * up under its last line; when a message does appear the card grows by one
 * line, which the centred overlay absorbs without a visible jump. */
.ba-err {
	margin: 0;
	color: #a33a3a;
	font-size: 13px;
	line-height: 1.7;
}

/* A real message gets the same upright rule the account notices use, so it
 * reads as a deliberate status line instead of loose red text at the foot of
 * the card. */
.ba-err:not(:empty) {
	margin-top: 14px;
	padding-inline-start: 10px;
	border-inline-start: 2px solid #a33a3a;
}

/* A message the customer cannot act on alone gets a way to reach the shop. */
.ba-sup {
	margin: 8px 0 0;
	color: #5b544c;
	font-size: 13px;
	line-height: 1.9;
}

.ba-sup a {
	color: var(--ink, #0a0a0a);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ba-sup a:hover {
	text-decoration-thickness: 2px;
}

/* ---------- the quiet second door ---------- */
.ba-alt {
	margin: 16px 0 0;
	font-size: 13px;
	line-height: 1.9;
	text-align: center;
}

.ba-alt a {
	color: #6a6a6a;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ba-alt a:hover {
	color: var(--ink, #0a0a0a);
}

/* Reads as a footnote, not as a second button: the phone route is the one new
 * customers need, and two equally loud options made them pause. The sentence
 * stays muted while the link keeps enough contrast to be readable as
 * something you can press. */
.ba-alt--quiet {
	margin-top: 10px;
	font-size: 12.5px;
	color: #8A8178;
}

.ba-alt--quiet a {
	color: #4A443D;
	font-weight: 500;
}

.ba-alt--quiet a:hover {
	color: var(--ink, #0a0a0a);
}

/* Local-development only: the code that would have gone out by SMS. */
.ba-dbg {
	margin: 0 0 12px;
	padding: 8px 10px;
	border-radius: 0;
	background: var(--yellow, #f8c13b);
	color: #000;
	font-size: 12px;
	line-height: 1.7;
	text-align: center;
}

/* ---------- checkout gate ---------- */
.ba-gate {
	padding: 48px 16px;
	text-align: center;
}

.ba-gate p {
	margin: 0 0 16px;
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
	.ba-ov {
		padding: 12px;
	}

	.ba-box {
		grid-template-columns: minmax(0, 1fr);
		/* Photo on top, form under it. Both axes are stated explicitly on both
		 * children; with row 1 claimed by the photo, auto-placement would put the
		 * form in row 2 anyway, but relying on that is what produced the empty
		 * photo column the first time this card was built. */
		grid-template-rows: 120px minmax(0, 1fr);
		width: 100%;
		/* the desktop floor is dropped here: on a phone the card is already
		 * close to the viewport height and a forced minimum would only push
		 * the bottom of the form under the on-screen keyboard */
		min-height: 0;
		max-height: calc(100vh - 24px);
		max-height: calc(100dvh - 24px);
	}

	/* The photograph becomes a banner instead of a side column.
	 *
	 * A share of the width was the desktop answer and it cannot survive here: at
	 * the desktop ratio the photo would be a ~140px column and would eat the
	 * form's line length. Hidden entirely — the previous answer — is why the card
	 * looked like a different product on a phone.
	 *
	 * 120px of the card's width at `cover` keeps the gold mark whole: the source
	 * is a square shot with the mark at ~46% of its height, so a centred crop
	 * that high (background-position below) frames the mark rather than cutting
	 * it. Measured on the rendered card, not guessed. */
	.ba-media {
		display: block;
		grid-column: 1;
		grid-row: 1;
		background-position: center 46%;
	}

	.ba-body {
		grid-column: 1;
		grid-row: 2;
		padding: 26px 18px 20px;
	}

	/* 16px is the threshold below which iOS zooms the whole page when a field
	 * takes focus, which on a login form looks like the layout breaking. */
	.ba-f input,
	.ba-f select,
	.ba-f textarea {
		height: 50px;
		font-size: 16px;
	}

	.ba-f input.ba-code {
		font-size: 21px;
	}

	.ba-pw input {
		padding-left: 50px;
	}

	.ba-eye {
		width: 48px;
		height: 50px;
	}

	.ba-btn {
		min-height: 50px;
		font-size: 15px;
	}

	/* On a phone the pair stacks: two 160px fields side by side would truncate
	 * both the label and the e-mail address. The sign-up step also gets its
	 * comfortable height back — the landscape has room, and a 46px target is
	 * under the size a thumb wants. These repeat the profile selectors exactly
	 * so they win on order alone, without an extra !important. */
	.ba-row {
		flex-direction: column;
		gap: 0;
	}

	.ba-ov[data-step="profile"] .ba-f {
		margin-bottom: 14px;
	}

	.ba-ov[data-step="profile"] .ba-f input {
		height: 50px;
	}

	.ba-ov[data-step="profile"] .ba-pw input {
		padding-left: 50px;
	}

	.ba-ov[data-step="profile"] .ba-eye {
		width: 48px;
		height: 50px;
	}

	.ba-ov[data-step="profile"] .ba-btn {
		min-height: 50px;
		margin-top: 6px;
	}

	.ba-x {
		inset-block-start: 10px;
		inset-inline-end: 10px;
	}

	.ba-t {
		padding-inline-end: 40px;
	}
}

/* -------------------------------------------------------------------------
 * PHONE: bring the card back to being a dialog
 *
 * Measured at 390x844 once the photo returned as a banner: 433px on the phone
 * step and 568px on the password step — two thirds of the screen for a
 * three-field form, which reads as a page rather than a dialog. Every trim here
 * is spacing or 4px off a control; nothing drops below the 44px touch floor, and
 * the banner goes 120 → 92px, which still frames the gold mark whole (the mark
 * sits at ~46% of the image height, so a 92px band centred there keeps it).
 *
 * The sign-up step states its own tighter rhythm earlier in this file with
 * selectors one class more specific than the base ones, so it is restated here
 * at the new sizes — otherwise it would keep the old ones and stay tall.
 * ---------------------------------------------------------------------- */
@media (max-width: 640px) {
	.ba-ov {
		padding: 16px;
	}

	.ba-box {
		grid-template-rows: 92px minmax(0, 1fr);
	}

	.ba-body {
		padding: 18px 18px 14px;
	}

	.ba-t {
		font-size: 19px;
	}

	.ba-s {
		margin: 6px 0 12px;
		font-size: 13px;
	}

	.ba-f {
		margin-bottom: 10px;
	}

	.ba-f > span {
		margin-bottom: 5px;
	}

	.ba-f input,
	.ba-f select,
	.ba-f textarea {
		height: 46px;
	}

	.ba-pw input {
		padding-left: 46px;
	}

	.ba-eye {
		width: 44px;
		height: 46px;
	}

	.ba-btn {
		min-height: 46px;
		margin-top: 4px;
	}

	.ba-ov[data-step="profile"] .ba-f {
		margin-bottom: 10px;
	}

	.ba-ov[data-step="profile"] .ba-f input {
		height: 46px;
	}

	.ba-ov[data-step="profile"] .ba-pw input {
		padding-left: 46px;
	}

	.ba-ov[data-step="profile"] .ba-eye {
		height: 46px;
	}

	.ba-ov[data-step="profile"] .ba-btn {
		min-height: 46px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ba-box {		-webkit-animation: none;
		animation: none;
	}

	.ba-btn,
	.ba-x,
	.ba-f input,
	.ba-eye::after {
		transition: none;
	}
}
