/* RZC storefront — the sign-in card (templates/storefront/auth.html), the
 * password and sign-out pages (templates/storefront/password.html,
 * signout.html) and the address book of the account page
 * (www/shop/account.html).
 *
 * Loaded by those two templates only, after rzc_storefront.css, whose --sf-*
 * tokens carry every colour: the tokens are redefined for the dark theme
 * there (prefers-color-scheme and html[data-theme="dark"]), so nothing here
 * names a colour of its own and both themes stay in step. Works down to a
 * 375px phone: one column, full-width controls, 16px gutters from the frame.
 */

/* ----------------------------------------------------------- sign-in card */

.sf-auth {
	display: grid;
	gap: 14px;
	justify-items: center;
	padding: 8px 0 24px;
}

.sf-auth-card {
	width: 100%;
	max-width: 460px;
	padding: 24px 22px 20px;
}

.sf-auth-head {
	margin-bottom: 16px;
}

.sf-auth-head .sf-page-title {
	margin: 0 0 6px;
}

.sf-auth-head .sf-muted {
	margin: 0;
}

/* tabs: Sign in / Sign up */

.sf-auth-tabs {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 4px;
	margin-bottom: 16px;
	padding: 4px;
	border: 1px solid var(--sf-border);
	border-radius: var(--sf-radius);
	background: var(--sf-ground-2);
}

.sf-auth-tab {
	padding: 9px 10px;
	border: 0;
	border-radius: var(--sf-radius-sm);
	background: transparent;
	color: var(--sf-ink-2);
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

.sf-auth-tab:hover {
	color: var(--sf-ink);
}

.sf-auth-tab.is-active,
.sf-auth-tab[aria-selected="true"] {
	background: var(--sf-ground);
	color: var(--sf-ink);
	box-shadow: var(--sf-shadow);
}

.sf-auth-tab:focus-visible,
.sf-auth-eye:focus-visible,
.sf-auth-provider:focus-visible,
.sf-auth-submit:focus-visible,
.sf-link-button:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--sf-focus-ring);
}

/* the one message region (status or alert) */

.sf-auth-message {
	margin: 0 0 14px;
	padding: 10px 12px;
	border: 1px solid var(--sf-border);
	border-left: 4px solid var(--sf-ok);
	border-radius: var(--sf-radius-sm);
	background: var(--sf-ground-2);
	color: var(--sf-ink);
	font-size: 14px;
	line-height: 1.45;
}

.sf-auth-message[hidden] {
	display: none;
}

.sf-auth-message.is-error {
	border-left-color: var(--sf-sale);
	background: var(--sf-sale-wash);
}

.sf-auth-message.is-ok {
	border-left-color: var(--sf-ok);
}

.sf-auth-message:focus {
	outline: none;
	box-shadow: 0 0 0 3px var(--sf-focus-ring);
}

/* forms */

.sf-auth-form {
	display: grid;
	gap: 14px;
}

.sf-auth-form .sf-muted,
.sf-auth-form .sf-section-title {
	margin: 0;
}

.sf-auth-field {
	display: grid;
	gap: 5px;
	font-size: 13px;
	font-weight: 600;
	color: var(--sf-ink-2);
}

.sf-auth-field input {
	width: 100%;
	min-width: 0;
	padding: 11px 12px;
	border: 1px solid var(--sf-border-strong);
	border-radius: var(--sf-radius);
	background: var(--sf-ground);
	color: var(--sf-ink);
	font: inherit;
	font-size: 15px;
	font-weight: 400;
}

.sf-auth-field input:focus {
	outline: none;
	border-color: var(--sf-accent);
	box-shadow: 0 0 0 3px var(--sf-focus-ring);
}

.sf-auth-field input[aria-invalid="true"] {
	border-color: var(--sf-sale);
}

.sf-auth-password {
	position: relative;
}

.sf-auth-password input {
	padding-right: 46px;
}

.sf-auth-eye {
	position: absolute;
	top: 50%;
	right: 6px;
	width: 34px;
	height: 34px;
	transform: translateY(-50%);
	display: grid;
	place-items: center;
	border: 0;
	border-radius: var(--sf-radius-sm);
	background: transparent;
	color: var(--sf-ink-2);
	cursor: pointer;
}

.sf-auth-eye svg {
	width: 18px;
	height: 18px;
}

.sf-auth-eye:hover,
.sf-auth-eye[aria-pressed="true"] {
	color: var(--sf-accent-ink);
	background: var(--sf-accent-wash);
}

.sf-auth-submit {
	width: 100%;
}

.sf-auth-submit[aria-busy="true"],
.sf-auth-form[aria-busy="true"] .sf-auth-submit {
	opacity: 0.75;
	cursor: progress;
}

.sf-auth-links {
	margin: 0;
	font-size: 13px;
	text-align: center;
}

.sf-auth-links .sf-link-button {
	cursor: pointer;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* provider and LDAP sign-in */

.sf-auth-providers {
	display: grid;
	gap: 10px;
	margin-top: 16px;
}

.sf-auth-or {
	position: relative;
	margin: 0;
	text-align: center;
	font-size: 12px;
	color: var(--sf-ink-3);
}

.sf-auth-or::before {
	content: "";
	position: absolute;
	inset: 50% 0 auto;
	height: 1px;
	background: var(--sf-border);
}

.sf-auth-or span {
	position: relative;
	padding: 0 10px;
	background: var(--sf-ground);
}

.sf-auth-provider {
	display: block;
	width: 100%;
	margin-top: 10px;
	padding: 11px 14px;
	border: 1px solid var(--sf-border-strong);
	border-radius: var(--sf-radius);
	background: var(--sf-ground);
	color: var(--sf-ink);
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
}

.sf-auth-providers .sf-auth-provider {
	margin-top: 0;
}

.sf-auth-provider:hover {
	border-color: var(--sf-accent);
	color: var(--sf-accent-ink);
}

.sf-auth-closed {
	margin: 16px 0 0;
	padding-top: 14px;
	border-top: 1px solid var(--sf-border);
}

.sf-auth-back {
	margin: 0;
	font-size: 13px;
}

.sf-auth-back a {
	color: var(--sf-accent-ink);
	font-weight: 600;
}

/* ------------------------------------------------- password and sign-out */

.sf-auth-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 16px 0 0;
}

.sf-auth-actions[hidden] {
	display: none;
}

.sf-auth-hint {
	margin: -6px 0 0;
	font-size: 12px;
}

.sf-password-strength {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: -6px;
	font-size: 12px;
	color: var(--sf-ink-2);
}

.sf-password-strength[hidden] {
	display: none;
}

.sf-password-meter {
	flex: 1;
	height: 6px;
	overflow: hidden;
	border-radius: var(--sf-radius-pill);
	background: var(--sf-ground-3);
}

.sf-password-meter > span {
	display: block;
	width: 0;
	height: 100%;
	border-radius: inherit;
	background: var(--sf-sale);
	transition: width 0.2s ease;
}

/* Score 0–4 from the ERP's password policy: the weak end in the sale colour,
 * the strong end in the confirmation colour, the middle in the accent. */
.sf-password-strength[data-score="0"] .sf-password-meter > span { width: 12%; }
.sf-password-strength[data-score="1"] .sf-password-meter > span { width: 30%; }
.sf-password-strength[data-score="2"] .sf-password-meter > span { width: 55%; background: var(--sf-accent); }
.sf-password-strength[data-score="3"] .sf-password-meter > span { width: 80%; background: var(--sf-ok); }
.sf-password-strength[data-score="4"] .sf-password-meter > span { width: 100%; background: var(--sf-ok); }

.sf-password-strength-text {
	min-width: 6em;
	text-align: right;
	font-weight: 600;
}

.sf-signout {
	display: grid;
	justify-items: center;
	gap: 12px;
	text-align: center;
}

.sf-signout .sf-page-title {
	margin: 0;
}

.sf-signout .sf-auth-message {
	width: 100%;
	margin: 0;
	text-align: left;
}

.sf-signout .sf-auth-actions {
	justify-content: center;
	margin: 0;
}

.sf-signout-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid var(--sf-border);
	border-top-color: var(--sf-accent);
	border-radius: 50%;
	animation: sf-signout-spin 0.8s linear infinite;
}

.sf-signout.is-failed .sf-signout-spinner {
	display: none;
}

@keyframes sf-signout-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sf-signout-spinner {
		animation: none;
	}

	.sf-password-meter > span {
		transition: none;
	}
}

/* ------------------------------------------------------------ address book */

.sf-address-list {
	display: grid;
	gap: 10px;
	margin: 0 0 14px;
	padding: 0;
	list-style: none;
}

.sf-address-item {
	padding: 12px 14px;
	border: 1px solid var(--sf-border);
	border-radius: var(--sf-radius);
	background: var(--sf-ground-2);
}

.sf-address-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
	margin-bottom: 6px;
}

.sf-address-head strong {
	font-size: 14px;
	overflow-wrap: anywhere;
}

.sf-address-flag {
	display: inline-block;
	padding: 2px 8px;
	border-radius: var(--sf-radius-pill);
	background: var(--sf-ground-3);
	color: var(--sf-ink-2);
	font-size: 11px;
	font-weight: 700;
	line-height: 1.6;
}

.sf-address-flag.is-default {
	background: var(--sf-accent-wash);
	color: var(--sf-accent-ink);
}

.sf-address-lines,
.sf-address-phone {
	margin: 0;
	font-size: 13px;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

.sf-address-phone {
	margin-top: 4px;
	color: var(--sf-ink-2);
}

.sf-address-new > summary {
	cursor: pointer;
	font-size: 14px;
	font-weight: 700;
	color: var(--sf-accent-ink);
}

/* the message region of the address form: a full row under the button,
 * spaced by the grid gap */
.sf-address-form .sf-auth-message {
	grid-column: 1 / -1;
	margin: 0;
}

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

@media (max-width: 640px) {
	.sf-auth {
		padding-top: 0;
	}

	.sf-auth-card {
		padding: 18px 14px 16px;
	}

	.sf-auth-field input {
		font-size: 16px; /* keeps iOS from zooming into the field */
	}

	.sf-address-form {
		grid-template-columns: minmax(0, 1fr);
	}
}
