/*
 * The header's sign-in dialog and the expired-link alert (planner-451, assets/js/header-signin.js, docs/CLAUDE-header-account.md).
 * The overlay, dialog, title, form and button classes are the capture modal's (style.css); this file is only what that does not cover.
 * Colors are the theme's roles, so it follows light and dark. Loaded on every front-end page when omorphos-studio is active.
 */

.header-signin__mail {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	margin: 0 0 var(--space-3);
	padding: var(--space-3);
	border: 1px solid var(--color-border);
	border-radius: var(--border-radius);
	background: var(--color-stone-50);
	color: var(--color-text-strong);
	font-size: var(--font-size-sm);
}
.header-signin__mail svg {
	display: block;
	color: var(--color-muted);
}
.header-signin__mail strong {
	font-weight: 500;
	color: var(--color-text);
	overflow-wrap: anywhere;
}

.header-signin__help {
	margin: var(--space-3) 0 0;
	text-align: center;
	font-size: var(--font-size-sm);
	color: var(--color-muted);
}
.header-signin__help a,
.header-alert__help {
	color: var(--color-coffee);
	text-decoration: underline;
	text-decoration-color: rgba(74, 59, 49, .35);
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
}
.header-signin__help a:hover,
.header-alert__help:hover { text-decoration-color: currentColor; }

.header-signin__alt {
	display: block;
	margin: var(--space-3) 0 0;
	text-align: center;
	font-size: var(--font-size-sm);
}

.header-signin__wrong {
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-coffee);
	font: inherit;
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
	text-decoration-color: var(--color-link-underline, rgba(74, 59, 49, 0.35));
	cursor: pointer;
}
.header-signin__wrong:hover {
	text-decoration-color: var(--color-coffee);
}
.header-signin__wrong:focus-visible {
	outline: 2px solid var(--color-coffee);
	outline-offset: 3px;
}

/* The resend while it is waiting: a quiet disabled state, not a faded primary. */
.header-signin__resend[disabled] {
	background: var(--color-stone-50);
	border-color: var(--color-border);
	color: var(--color-muted);
	cursor: default;
}

.header-signin__status {
	min-height: 1.4em;
	margin: var(--space-2) 0 0;
	font-size: var(--font-size-sm);
	color: var(--color-muted);
	text-align: center;
}

.header-signin h2:focus {
	outline: none; /* the heading takes programmatic focus only; nothing to see */
}

/* The alert under the header: neutral fill, a full hairline, an icon, no colored side bar. */
.header-alert {
	background: var(--color-stone-50);
	border-bottom: 1px solid var(--color-border);
	color: var(--color-text-strong);
	font-size: var(--font-size-sm);
}
.header-alert__inner {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding-block: var(--space-3);
}
.header-alert__inner > span {
	flex: none;
	color: var(--color-muted);
}
.header-alert__inner > span svg {
	display: block;
}
.header-alert__text {
	flex: 1;
	margin: 0;
}
.header-alert__text strong {
	font-weight: 500;
	color: var(--color-text);
}
.header-alert__go {
	flex: none;
	padding: 7px 12px;
	font-size: var(--font-size-sm);
}
.header-alert__x {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--color-muted);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}
.header-alert__x:hover {
	background: var(--color-border);
}
.header-alert__x:focus-visible {
	outline: 2px solid var(--color-coffee);
	outline-offset: 3px;
}

/* A phone: the text takes the full width, the button and the dismiss drop to the next line. */
@media ( max-width: 639.98px ) {
	.header-alert__inner {
		flex-wrap: wrap;
		gap: var(--space-2) var(--space-3);
	}
	.header-alert__text {
		flex: 1 1 calc(100% - 40px);
	}
}

/*
 * The signed-in popper and the first-render animation (planner-451, assets/js/header-account.js).
 * Shown once when the reader signs in in another tab: the avatar pops, one soft ring leaves the button, and a small popper attached to
 * the button says so. The popper takes the INVERSE of the page: the text color as its fill and the page color as its text, so it
 * stands out from the header in light (dark popper) and in dark (light popper). The sitewide prefers-reduced-motion rule in style.css
 * zeroes every animation, so with reduced motion on it simply appears.
 */
.header-account__popper {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	z-index: 111;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	width: min(250px, calc(100vw - 2 * var(--container-padding)));
	padding: 12px 36px 12px 12px;
	border-radius: 8px;
	background: var(--color-text);
	color: var(--color-page);
	box-shadow: 0 8px 24px rgba(28, 25, 23, 0.28);
	font-size: 13px;
	line-height: 1.45;
	animation: omo-popper-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1.2) 0.35s both;
}
.header-account__popper::before {
	content: "";
	position: absolute;
	top: -5px;
	right: 28px;
	width: 10px;
	height: 10px;
	background: var(--color-text);
	transform: rotate(45deg);
}
.header-account__popper.is-leaving {
	opacity: 0;
	transition: opacity 0.2s ease;
}
.header-account__popper-icon {
	flex: none;
	display: inline-flex;
}
.header-account__popper-text strong {
	display: block;
	font-size: var(--font-size-sm);
	font-weight: 500;
}
.header-account__popper-x {
	position: absolute;
	top: 2px;
	right: 2px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--color-page);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}
.header-account__popper-x:hover {
	background: rgba(127, 127, 127, 0.35);
}
.header-account__popper-x:focus-visible {
	outline: 2px solid var(--color-page);
	outline-offset: 1px;
}

.header-account--flip .header-account__avatar {
	animation: omo-avatar-pop 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.3) 0.1s both;
}
.header-account--flip .header-account__button {
	animation: omo-ring 1.1s ease-out 0.1s 1;
}

@keyframes omo-popper-in {
	from { opacity: 0; transform: translateY(-6px) scale(0.96); }
	to   { opacity: 1; transform: none; }
}
@keyframes omo-avatar-pop {
	0%   { transform: scale(0.5); opacity: 0.2; }
	60%  { transform: scale(1.18); opacity: 1; }
	100% { transform: scale(1); }
}
@keyframes omo-ring {
	0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-text) 35%, transparent); }
	100% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--color-text) 0%, transparent); }
}

/* The account menu's items carry an icon each (the approved mockup: library, settings, sign out). The icon is decorative; the label is the name. */
.header-account__list a,
.header-account__list button {
	display: flex;
	align-items: center;
	gap: 10px;
}
.header-account__item-icon {
	flex: none;
	color: var(--color-muted);
}

/* A phone: the dismiss sits at the far end of the second line, under the text's edge, not beside the button. */
@media ( max-width: 639.98px ) {
	.header-alert__x {
		margin-left: auto;
	}
}

/*
 * No layout shift when a signed-in reader's control swaps in (planner-451, found on production). The signed-in button used to be as
 * wide as its name, the Sign in link a different width, so the nav jumped left by about 110px when the region was replaced.
 * Now the signed-in button has ONE width, and while a signed-in reader's page is waiting for that swap (html.omo-regions-pending,
 * set before first paint from the signed-in marker cookie) the printed Sign in link, which is hidden then, reserves exactly that
 * width. A visitor has no marker, so no pending class: their Sign in link keeps its natural width. The name is cut with an ellipsis
 * (the menu's first line shows it in full); on a phone the name is not shown at all and the button is avatar plus caret.
 */
:root {
	--header-account-w: 68px;
}
@media ( min-width: 640px ) {
	:root {
		--header-account-w: 200px;
	}
}
.header-account__button {
	box-sizing: border-box;
	width: var(--header-account-w);
}
.header-account__name {
	flex: 1;
	min-width: 0;
	max-width: none;
	text-align: left;
	white-space: nowrap;
}
html.omo-regions-pending .header-account--out {
	box-sizing: border-box;
	width: var(--header-account-w);
	padding-inline: 0;
	justify-content: center;
}

/*
 * One height for both states (planner-451). The signed-in button was 40px and the Sign in link 35px; the header row is 38px (the nav and
 * search), so signing in made the header 2px taller and pushed the page down. Both are now 36px, the same as the search trigger and the
 * mobile menu toggle, so neither can make the row taller than it already is.
 */
.header-account--out {
	box-sizing: border-box;
	height: 36px;
	padding-block: 0;
}
.header-account__button {
	box-sizing: border-box;
	height: 36px;
	padding-block: 4px;
	padding-inline-start: 4px;
}
.header-account__avatar {
	width: 26px;
	height: 26px;
}

/*
 * The account menu on the dark roles (planner-451, found on production). In light the menu is white on a white page and holds its edge
 * with a soft shadow. In dark the page, the header and the menu were all the page color and a dark shadow on a dark ground disappears,
 * so the menu merged with the content behind it. The menu now takes the RAISED surface role (--color-surface: #22201e in dark, the
 * same white as the page in light, so light is unchanged), and in dark it gets a deeper shadow plus a faint light rim (the one thing
 * that reads on a dark ground). The two dark selectors mirror the theme's two ways of being dark: a stored choice, and the device
 * setting when nothing is stored (docs/CLAUDE-theming.md).
 */
.header-account__menu {
	background: var(--color-surface);
}
:root[data-modes="on"][data-theme="dark"] .header-account__menu {
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 14px 36px rgba(0, 0, 0, 0.65);
}
@media ( prefers-color-scheme: dark ) {
	:root[data-modes="on"]:not([data-theme]) .header-account__menu {
		box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 14px 36px rgba(0, 0, 0, 0.65);
	}
}

/*
 * The screens beside the email form (planner-533; claude/signin-copy-mockup.html; docs/CLAUDE-header-account.md, "The screens beside the
 * form"). The dialog is the capture modal's; while the email form shows it gains .header-signin--wide: no padding of its own, the screens
 * on the left (above the form under 720px) and the form on the right. "Check your inbox" is the plain narrow dialog again.
 * The panel is a quiet Stone-50 surface with a full hairline and no colored side bar. Previous and Next are the shared advance control
 * (the .asset-carousel__nav treatment in style.css, same geometry, states and focus ring), hung in the panel's side gutters.
 */
.header-signin--wide {
	padding: 0;
}
.header-signin--wide .header-signin__content {
	padding: var(--space-8) var(--space-6) var(--space-6);
}
.signin-panel {
	display: flex;
	flex-direction: column;
	min-height: 264px;
	padding: var(--space-6) var(--space-4) var(--space-3);
	background: var(--color-stone-50);
	border-bottom: 1px solid var(--color-border);
}
.signin-panel[hidden] {
	display: none;
}
.signin-panel__stage {
	position: relative;
	display: flex;
	flex: 1;
	align-items: center;
	padding-inline: 34px;
}
.signin-panel__body {
	flex: 1;
	min-width: 0;
	text-align: center;
}
.signin-panel__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0 auto var(--space-3);
	border: 1px solid var(--color-stone-400);
	border-radius: 50%;
	background: var(--color-surface);
	color: var(--color-text-strong);
}
.signin-panel__icon svg {
	display: block;
}
.signin-panel__title {
	margin: 0 0 var(--space-2);
	font-family: var(--font-serif);
	font-size: var(--font-size-lg);
	font-weight: 400;
	line-height: 1.3;
	color: var(--color-text);
}
.signin-panel__text {
	margin: 0;
	font-size: var(--font-size-sm);
	line-height: 1.5;
	color: var(--color-text-strong);
}
.signin-panel__dots {
	display: flex;
	justify-content: center;
	gap: 6px;
	padding-top: var(--space-3);
}
.signin-panel__dots span {
	width: 8px;
	height: 8px;
	border: 1px solid var(--color-muted); /* the inactive dots carry meaning: 3:1 or better against the panel */
	border-radius: 50%;
}
.signin-panel__dots span.is-on {
	background: var(--color-text);
	border-color: var(--color-text);
}

.header-signin__adv {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 88px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--color-text);
	cursor: pointer;
	transition: background var(--transition), box-shadow var(--transition);
}
.header-signin__adv--prev {
	left: -6px;
}
.header-signin__adv--next {
	right: -6px;
}
.header-signin__adv:hover,
.header-signin__adv:focus-visible {
	background: var(--color-surface);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}
.header-signin__adv:focus-visible {
	outline: 2px solid var(--color-coffee);
	outline-offset: 2px;
}
.header-signin__adv[aria-disabled='true'] {
	opacity: 0.35;
	cursor: default;
	box-shadow: none;
	pointer-events: none;
}
.header-signin__adv svg {
	display: block;
}

/* Wide enough to sit beside the form. */
@media ( min-width: 720px ) {
	.header-signin--wide {
		max-width: 780px;
	}
	.header-signin--wide .header-signin__grid {
		display: grid;
		grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
	}
	.signin-panel {
		min-height: 0;
		padding: var(--space-8) var(--space-6) var(--space-4);
		border-bottom: 0;
		border-right: 1px solid var(--color-border);
	}
	.signin-panel__stage {
		padding-inline: 40px;
	}
	.signin-panel__icon {
		width: 44px;
		height: 44px;
		margin-bottom: var(--space-4);
	}
	.signin-panel__title {
		font-size: var(--font-size-xl);
	}
	.signin-panel__text {
		font-size: var(--font-size-base);
	}
	.header-signin__adv {
		width: 32px;
	}
	.header-signin__adv--prev {
		left: -8px;
	}
	.header-signin__adv--next {
		right: -8px;
	}
}
