/*
 * The account icon in the header and the window it opens.
 *
 * Ships with the block: the render callback emits these class names, so a theme
 * that does not know them would leave a login form lying in the header. Colours,
 * sizes and radii are theme.json tokens — the contract is written down in
 * docs/design/block-css-contract.md.
 */

.gsl-acct {
	display: flex;
	align-items: center;
}

/* The icon target keeps the shape the header already gave it: a bare 46 px
   square that only fills in on hover, next to the cart's filled pill. The two
   are deliberately not the same shape — the cart carries a number and has to be
   findable without reading, this one does not. */
.gsl-acct__link,
.gsl-acct__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--medium);
	background: transparent;
	color: var(--wp--preset--color--contrast);
	font: inherit;
	cursor: pointer;
}

.gsl-acct__link:hover,
.gsl-acct__btn:hover {
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--brand-action);
}

/* Exactly one of the two is shown. Without `popover` the attribute is ignored,
   the button opens nothing, and the account becomes unreachable — so the button
   only appears where the browser can actually open the window, and the plain
   link to /my-account/ carries everyone else. */
.gsl-acct__btn {
	display: none;
}

@supports selector(:popover-open) {
	.gsl-acct__btn {
		display: flex;
	}

	/* Only where there is a window to open. A customer who is already signed in
	   gets no window: the icon is a plain link to the cabinet, because a menu
	   of five items in front of the page those five items lead to is a tap
	   spent on nothing. So the link stays, and the modifier says which it is. */
	.gsl-acct:not(.gsl-acct--in) .gsl-acct__link {
		display: none;
	}
}

/* ---------------------------------------------------------------- window ---- */

/*
 * Centred rather than dropped under the icon, and that is not a style choice.
 * A dropdown has to be positioned against its button, which needs either anchor
 * positioning — not everywhere yet — or JavaScript measuring the header on every
 * scroll. Centred needs neither, is the same on a phone as on a desktop, and is
 * what the shops the owner compared us to do with their login.
 */
/* `box-sizing` is spelled out here and on the input below because the theme sets
   no global reset for plain elements a block renders itself: `width: 400px` plus
   36 px of padding measured 474 px wide, and `width: 100%` on a padded input
   overflows the grid it sits in. */
.gsl-acct__panel {
	box-sizing: border-box;
	width: min(400px, calc(100vw - 2 * var(--wp--preset--spacing--40)));
	max-height: calc(100dvh - 2 * var(--wp--preset--spacing--60));
	overflow-y: auto;
	padding: var(--wp--preset--spacing--60);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--medium);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	box-shadow: 0 24px 60px -20px color-mix(in srgb, var(--wp--preset--color--ink) 55%, transparent);
}

/* The same form in the body of the account page, for a guest. It wears the
   window's card so the two read as one thing, minus the shadow and the
   backdrop: here it is the page, not something over it. */
.gsl-acct--page {
	display: block;
	box-sizing: border-box;
	width: min(400px, 100%);
	margin: var(--wp--preset--spacing--40) auto var(--wp--preset--spacing--60);
	padding: var(--wp--preset--spacing--60);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--medium);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

.gsl-acct__panel::backdrop {
	background: color-mix(in srgb, var(--wp--preset--color--ink) 45%, transparent);
}

/*
 * The panel defends itself from the header.
 *
 * The theme draws its round icon buttons with `.gsl-head__acts a` (0,1,1), and
 * this block lives inside `.gsl-head__acts` — so every link inside the window
 * was given `border-radius: 50%` and the teal wash, which painted a pale oval
 * behind each menu row and behind the two legal links under the button. Two
 * classes and a type (0,2,1) give a link back the look of a link.
 */
.gsl-acct .gsl-acct__panel a {
	border-radius: 0;
	background: none;
}

.gsl-acct__close {
	position: absolute;
	top: var(--wp--preset--spacing--30);
	right: var(--wp--preset--spacing--30);
	display: flex;
	width: 36px;
	height: 36px;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--small);
	background: transparent;
	color: var(--wp--preset--color--muted);
	cursor: pointer;
}

.gsl-acct__close:hover {
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

.gsl-acct__title {
	margin: 0 0 var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--large);
	color: var(--wp--preset--color--ink);
}

.gsl-acct__form {
	display: grid;
	gap: var(--wp--preset--spacing--20);
}

.gsl-acct__label {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.gsl-acct__label + .gsl-acct__input {
	margin-bottom: var(--wp--preset--spacing--20);
}

.gsl-acct__input {
	box-sizing: border-box;
	width: 100%;
	height: 46px;
	padding-inline: var(--wp--preset--spacing--30);
	border: 1.5px solid var(--wp--preset--color--border-strong);
	border-radius: var(--wp--custom--radius--small);
	font: inherit;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

.gsl-acct__input:focus {
	border-color: var(--wp--preset--color--brand);
	outline: none;
}

.gsl-acct__remember {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--20);
	margin-bottom: var(--wp--preset--spacing--20);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.gsl-acct__go {
	height: 48px;
	border: 0;
	border-radius: var(--wp--custom--radius--small);
	background: var(--wp--preset--color--brand-action);
	color: var(--wp--preset--color--base);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.gsl-acct__go:hover {
	background: var(--wp--preset--color--brand-text);
}

.gsl-acct__links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--40);
	margin: var(--wp--preset--spacing--40) 0 0;
	font-size: var(--wp--preset--font-size--small);
}

.gsl-acct__links a {
	color: var(--wp--preset--color--brand-text);
}

/* ------------------------------------------------------------- customer ----- */

.gsl-acct__hi {
	margin: 0 0 var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
	color: var(--wp--preset--color--ink);
}

.gsl-acct__menu {
	list-style: none;
	margin: 0;
	padding: 0;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--medium);
	overflow: hidden;
}

.gsl-acct__menu li + li {
	border-top: 1px solid var(--wp--preset--color--hairline);
}

.gsl-acct__menu a {
	display: block;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.gsl-acct__menu a:hover {
	background: var(--wp--preset--color--surface-soft);
	color: var(--wp--preset--color--brand-text);
}

/* Same 44px circle as the phone and the cart beside it (theme's v2e). */
/* The same target as the three icons beside it. Wider would be better — the
   market median is a 24-pixel glyph in a 40-to-48-pixel target, and these are
   34 across — but the account control cannot be widened alone: four targets of
   44 plus the logo overflow a 360-pixel row, so that is a change to the whole
   header, not to this block. The link and the button are sized together
   because a signed-in customer gets the link and a guest gets the button, and
   the icon must not change size on signing in. */
@media (max-width: 640px) {
	.gsl-acct__btn,
	.gsl-acct__link {
		width: 34px;
		height: 44px;
		padding: 0;
	}
}

/* Line glyph, no disc — the header's onlymoms pass (theme v2f). */
@media (max-width: 640px) {
	.gsl-acct .gsl-acct__btn,
	.gsl-acct .gsl-acct__link {
		background: transparent;
		border: 0;
		color: var(--wp--preset--color--contrast);
	}

	.gsl-acct .gsl-acct__btn svg,
	.gsl-acct .gsl-acct__link svg {
		width: 27px;
		height: 27px;
	}
}

/* ---------------------------------------------------------------------------
   Вхід за кодом.

   Два кроки лежать в одній формі, другий схований: так браузер бачить поле коду
   як звичайне поле форми, а не як щось, що з'явилося потім, і пропонує в нього
   код із повідомлення. Ширина колонки одна для обох кроків, щоб вікно не
   стрибало, коли номер змінюється на код.
   --------------------------------------------------------------------------- */

.gsl-acct__lead {
	margin: 0 0 14px;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--base);
	line-height: 1.45;
}

.gsl-acct__login {
	display: block;
}

.gsl-acct__step {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.gsl-acct__input--code {
	/* Цифри коду читають по одній, звіряючи з повідомленням, тож вони йдуть
	   рівним моноширинним рядком із розрядкою — це та сама робота, яку інші
	   роблять шістьма окремими полями, але без їхньої ціни. */
	letter-spacing: 0.32em;
	font-size: var(--wp--preset--font-size--price);
}

.gsl-acct__legal {
	margin: 10px 0 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--label);
	line-height: 1.4;
}

.gsl-acct__legal a {
	color: inherit;
	text-decoration: underline;
}

.gsl-acct__note {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px;
	margin: 0;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--base);
}

.gsl-acct__change {
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brand-action);
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	text-decoration: underline;
	cursor: pointer;
}

.gsl-acct__change:hover {
	color: var(--wp--preset--color--brand-hover);
}

/* Поки йде відлік — сірий текст, після нього — клікабельне посилання. Різниця
   видно без читання, і людина не тисне те, що ще не працює. */
.gsl-acct__resend {
	min-height: 1.25rem;
	margin: 4px 0 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

.gsl-acct__hint {
	margin: 2px 0 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--label);
	line-height: 1.4;
}

.gsl-acct__err {
	margin: 10px 0 0;
	padding: 8px 10px;
	border-radius: var(--wp--custom--radius--small);
	background: var(--wp--preset--color--brand-wash);
	color: var(--wp--preset--color--sale);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.4;
}

/* ---------------------------------------------------------------------------
   Специфічність проти шапки.

   Тема фарбує будь-яку кнопку в блоці дій шапки — `.gsl-head__acts button` —
   круглою піктограмою на світлій заливці. Форма входу живе саме там, тож її
   кнопки діставалися того ж правила: «Продовжити» виходила блідим кружальцем,
   а текстові посилання «Змінити номер» і «Надіслати ще раз» — кнопками. Одного
   класу мало: у теми (0,1,1), тому тут (0,2,0).
   --------------------------------------------------------------------------- */

.gsl-acct .gsl-acct__go {
	width: 100%;
	border-radius: var(--wp--custom--radius--small);
	background: var(--wp--preset--color--brand-action);
	color: var(--wp--preset--color--base);
}

.gsl-acct .gsl-acct__go:hover {
	background: var(--wp--preset--color--brand-text);
	color: var(--wp--preset--color--base);
}

.gsl-acct .gsl-acct__change {
	width: auto;
	height: auto;
	border-radius: 0;
	background: none;
	color: var(--wp--preset--color--brand-action);
}

.gsl-acct .gsl-acct__change:hover {
	background: none;
	color: var(--wp--preset--color--brand-hover);
}

/* Крок, який зараз не потрібен, має зникати: `display: flex` вище сильніший за
   атрибут hidden, і без цього рядка обидва кроки видно разом. */
.gsl-acct__step[hidden] {
	display: none;
}

/* Намистина, що тримає зачіску в іконці того, хто увійшов: золото магазину,
   те саме, що й у піктограмах каталогу. Єдина деталь інтерфейсу, яка каже
   «вас упізнали» ще до того, як прочитано хоч слово. */
.gsl-acct__bead {
	fill: var(--wp--preset--color--gold-icon);
}

/* Кільце кольору тла під намистиною: без нього на заливці «ховера» вона
   зливається з піктограмою, а на тёмному тлі шапки — зникає зовсім. */
.gsl-acct__ring {
	fill: var(--wp--preset--color--base);
}

/* ------------------------------------------------------------- telegram ---- */

/* «або» between the two ways in: a hairline with the word on it. */
.gsl-acct__or {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 6px 0 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--label);
}

.gsl-acct__or::before,
.gsl-acct__or::after {
	content: "";
	flex: 1;
	border-top: 1px solid var(--wp--preset--color--border);
}

/*
 * The second way in is outlined, not filled: the phone stays the main door,
 * Telegram is the one next to it. Three classes because the header paints
 * every link inside it (0,1,1) and the window resets them again (0,2,1) —
 * this has to win over both, on the account page and in the window alike.
 */
.gsl-acct .gsl-acct__login .gsl-acct__tg {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	box-sizing: border-box;
	width: 100%;
	height: 48px;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--small);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-weight: 700;
	text-decoration: none;
}

.gsl-acct .gsl-acct__login .gsl-acct__tg:hover {
	border-color: var(--wp--preset--color--brand-action);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

.gsl-acct__tgicon {
	flex: none;
	color: var(--wp--preset--color--brand-action);
}

.gsl-acct__tghead {
	margin: 0;
	color: var(--wp--preset--color--ink);
	font-weight: 700;
}

.gsl-acct__tgsteps {
	margin: 0;
	padding-left: 1.3em;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--base);
	line-height: 1.45;
}

.gsl-acct__wait {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 4px 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--base);
}

.gsl-acct__spin {
	flex: none;
	width: 16px;
	height: 16px;
	border: 2px solid var(--wp--preset--color--border);
	border-top-color: var(--wp--preset--color--brand-action);
	border-radius: 50%;
	animation: gsl-acct-spin 0.9s linear infinite;
}

@keyframes gsl-acct-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.gsl-acct__spin {
		animation-duration: 3s;
	}
}
