/**
 * Staff portal — the front-end door at /staff/.
 *
 * Two states share this file. Signed out is a locked door: one narrow centred
 * panel, nothing about what is behind it, no marketing. Signed in is a working
 * desk: who you are, what the funds stand at, then the registers grouped under
 * quiet headings.
 *
 * The theme supplies --phwo-color-primary / --phwo-color-accent / --phwo-color-ink
 * / --phwo-color-mist. Every use carries the organisation's own colours as the
 * fallback, because this page must stay on-brand and legible if it is ever
 * rendered outside the theme — a maintenance page, a plugin conflict, or a
 * future theme that drops one of the variables.
 *
 * Conventions follow accounts.css: one accent, tabular figures on anything that
 * is money, and no decoration that does not carry information.
 */

.phwo-portal {
	--pt-ink: var(--phwo-color-ink, #14262b);
	--pt-primary: var(--phwo-color-primary, #0d5c63);
	--pt-accent: var(--phwo-color-accent, #e8a33d);
	--pt-mist: var(--phwo-color-mist, #f6f8f8);
	--pt-ground: #fbfcfc;
	--pt-surface: #fff;
	--pt-line: #dfe4e6;
	--pt-line-strong: #b9c2c5;
	--pt-muted: #5b6b71;
	--pt-radius: 8px;
	--pt-shadow: 0 1px 2px rgba(20, 38, 43, .06), 0 1px 3px rgba(20, 38, 43, .04);
	--pt-shadow-lift: 0 2px 4px rgba(20, 38, 43, .07), 0 8px 20px rgba(20, 38, 43, .07);
	--pt-focus: #0d5c63;

	/* The portal paints its own ground rather than inheriting the theme's,
	   so the panel and cards always sit on something. */
	background: var(--pt-ground);
	color: var(--pt-ink);
	font-size: 16px;
	line-height: 1.55;
	padding: 1px 1rem 3rem;
}

.phwo-portal *,
.phwo-portal *::before,
.phwo-portal *::after {
	box-sizing: border-box;
}

/* ============================================================ Shared bits */

.phwo-portal-eyebrow {
	margin: 0 0 .5rem;
	font-size: .69rem;
	font-weight: 700;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--pt-muted);
}

.phwo-portal-meta,
.phwo-portal-hint {
	color: var(--pt-muted);
	font-size: .88rem;
	line-height: 1.6;
}

.phwo-portal-btn {
	display: inline-block;
	padding: .6rem 1.25rem;
	border: 1px solid var(--pt-primary);
	border-radius: 6px;
	background: var(--pt-primary);
	color: #fff;
	font-size: .9rem;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.phwo-portal-btn:hover,
.phwo-portal-btn:focus {
	background: #0a474d;
	border-color: #0a474d;
	color: #fff;
}

/* The secondary action next to it — same footprint, no fill, so the primary
   action stays the obvious one. */
.phwo-portal-btn--quiet {
	background: transparent;
	border-color: var(--pt-line-strong);
	color: var(--pt-primary);
}

.phwo-portal-btn--quiet:hover,
.phwo-portal-btn--quiet:focus {
	background: var(--pt-mist);
	border-color: var(--pt-primary);
	color: var(--pt-primary);
}

/* One ring for the whole portal, on the ink-side colour so it clears contrast
   against both the white surface and the mist. */
.phwo-portal a:focus-visible,
.phwo-portal button:focus-visible,
.phwo-portal input:focus-visible,
.phwo-portal [tabindex]:focus-visible {
	outline: 2px solid var(--pt-focus);
	outline-offset: 3px;
	border-radius: 4px;
}

/* ================================================================ The door
   Signed out, and the signed-in-but-no-access variant. Centred, narrow, and
   nothing above it: it should read as a locked door, not a hero. */

.phwo-portal-door {
	max-width: 27rem;
	margin: 4rem auto;
	padding: 2.25rem 2rem;
	background: var(--pt-surface);
	border: 1px solid var(--pt-line);
	border-top: 3px solid var(--pt-primary);
	border-radius: var(--pt-radius);
	box-shadow: var(--pt-shadow);
}

/* The no-access panel carries more prose than the sign-in form, and the gold
   edge separates "you are in the wrong place" from "sign in here". */
.phwo-portal-door--plain {
	max-width: 32rem;
	border-top-color: var(--pt-accent);
}

.phwo-portal-door__intro {
	margin: 0 0 1.75rem;
}

.phwo-portal-door__title {
	margin: 0 0 .55rem;
	font-size: 1.35rem;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: -.01em;
	color: var(--pt-ink);
}

.phwo-portal-door__lede {
	margin: 0;
	color: var(--pt-muted);
	font-size: .93rem;
	line-height: 1.6;
}

.phwo-portal-door--plain .phwo-portal-meta {
	margin: 1rem 0 0;
}

/* ---- The WordPress login form, which we do not control the markup of ---- */

.phwo-portal-door__form .login-username,
.phwo-portal-door__form .login-password {
	margin: 0 0 1rem;
}

.phwo-portal-door__form label {
	display: block;
	margin-bottom: .35rem;
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--pt-muted);
}

.phwo-portal-door__form input[type="text"],
.phwo-portal-door__form input[type="password"] {
	width: 100%;
	padding: .65rem .75rem;
	border: 1px solid var(--pt-line-strong);
	border-radius: 6px;
	background: var(--pt-surface);
	color: var(--pt-ink);
	font: inherit;
	font-size: 1rem;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.phwo-portal-door__form input[type="text"]:focus,
.phwo-portal-door__form input[type="password"]:focus {
	border-color: var(--pt-primary);
	box-shadow: 0 0 0 3px rgba(13, 92, 99, .12);
}

.phwo-portal-door__form .login-remember {
	margin: 0 0 1.25rem;
	font-size: .88rem;
	color: var(--pt-muted);
}

.phwo-portal-door__form .login-remember label {
	display: inline;
	margin: 0;
	font-size: .88rem;
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
}

.phwo-portal-door__form .login-submit {
	margin: 0;
}

.phwo-portal-door__form .login-submit input[type="submit"],
.phwo-portal-door__form .button-primary {
	width: 100%;
	padding: .75rem 1rem;
	border: 1px solid var(--pt-primary);
	border-radius: 6px;
	background: var(--pt-primary);
	color: #fff;
	font: inherit;
	font-size: .95rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease;
}

.phwo-portal-door__form .login-submit input[type="submit"]:hover,
.phwo-portal-door__form .button-primary:hover {
	background: #0a474d;
	border-color: #0a474d;
}

.phwo-portal-hint {
	margin: 1.1rem 0 0;
	font-size: .82rem;
}

.phwo-portal-door__foot {
	margin: 1.75rem 0 0;
	padding-top: 1.1rem;
	border-top: 1px solid var(--pt-line);
	font-size: .88rem;
	color: var(--pt-muted);
}

.phwo-portal-door__foot p {
	margin: 0;
}

.phwo-portal-door__foot a:not(.phwo-portal-btn) {
	color: var(--pt-primary);
}

/* ================================================================ The desk */

.phwo-portal-head {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem 1.5rem;
	align-items: flex-end;
	justify-content: space-between;
	max-width: 68rem;
	margin: 2.5rem auto 1.75rem;
	padding-bottom: 1.25rem;
	border-bottom: 2px solid var(--pt-line-strong);
}

.phwo-portal-head__who {
	min-width: 0;
}

.phwo-portal-head__name {
	margin: 0;
	font-size: 1.6rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: -.015em;
	color: var(--pt-ink);
}

/* The designation is a fact about the person, not a badge to celebrate, so it
   is set as a quiet outline rather than a filled chip. */
.phwo-portal-tag {
	display: inline-block;
	margin-left: .5rem;
	padding: .2rem .5rem;
	border: 1px solid var(--pt-line-strong);
	border-radius: 4px;
	background: var(--pt-mist);
	color: var(--pt-muted);
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	vertical-align: .3em;
	white-space: nowrap;
}

.phwo-portal-head__acts {
	display: flex;
	flex-wrap: wrap;
	gap: .6rem;
}

/* --------------------------------------------------------------- Figures */

/* One-pixel gaps over a ruled ground give hairline dividers between the
   figures without each cell carrying its own border and doubling up. */
.phwo-portal-figures {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	gap: 1px;
	max-width: 68rem;
	margin: 0 auto 2.5rem;
	background: var(--pt-line);
	border: 1px solid var(--pt-line);
	border-radius: var(--pt-radius);
	box-shadow: var(--pt-shadow);
	overflow: hidden;
}

.phwo-portal-figure {
	padding: 1.1rem 1.25rem;
	background: var(--pt-surface);
}

.phwo-portal-figure span {
	display: block;
	font-size: .69rem;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--pt-muted);
}

.phwo-portal-figure strong {
	display: block;
	margin-top: .35rem;
	font-size: 1.45rem;
	font-weight: 600;
	line-height: 1.15;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
	color: var(--pt-ink);
}

/* Total funds is the figure anyone opens this page to see. */
.phwo-portal-figure.is-total {
	box-shadow: inset 3px 0 0 var(--pt-accent);
}

.phwo-portal-figure.is-total strong {
	color: var(--pt-primary);
}

.phwo-portal-figures__note {
	grid-column: 1 / -1;
	margin: 0;
	padding: .65rem 1.25rem;
	background: var(--pt-mist);
	font-size: .76rem;
	line-height: 1.5;
	color: var(--pt-muted);
}

/* ----------------------------------------------------------------- Cards */

.phwo-portal-group {
	max-width: 68rem;
	margin: 0 auto 2.5rem;
}

.phwo-portal-group__title {
	margin: 0 0 .9rem;
	padding-bottom: .5rem;
	border-bottom: 1px solid var(--pt-line);
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--pt-muted);
}

.phwo-portal-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
	gap: 1rem;
}

.phwo-portal-card {
	position: relative;
	display: block;
	padding: 1.1rem 1.2rem;
	background: var(--pt-surface);
	border: 1px solid var(--pt-line);
	border-radius: var(--pt-radius);
	box-shadow: var(--pt-shadow);
	color: inherit;
	text-decoration: none;
	overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

/* Same hairline accent as the admin summary cards, so a register looks like
   the same object on both sides of the login. */
.phwo-portal-card::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 3px;
	background: var(--pt-primary);
	transition: background-color .15s ease;
}

.phwo-portal-card:hover,
.phwo-portal-card:focus-visible {
	transform: translateY(-1px);
	border-color: var(--pt-line-strong);
	box-shadow: var(--pt-shadow-lift);
}

.phwo-portal-card:hover::before,
.phwo-portal-card:focus-visible::before {
	background: var(--pt-accent);
}

/* A pressed state matters more than hover here: much of the office opens this
   on a phone, where hover never happens. */
.phwo-portal-card:active {
	transform: translateY(0);
	box-shadow: var(--pt-shadow);
}

.phwo-portal-card__icon {
	display: block;
	width: 22px;
	height: 22px;
	margin-bottom: .55rem;
	font-size: 22px;
	line-height: 22px;
	color: var(--pt-primary);
}

.phwo-portal-card__title {
	display: block;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--pt-ink);
}

.phwo-portal-card__blurb {
	display: block;
	margin-top: .35rem;
	font-size: .85rem;
	line-height: 1.5;
	color: var(--pt-muted);
}

/* An account with no registers assigned is a normal situation, not a fault. */
.phwo-portal-empty {
	max-width: 68rem;
	margin: 0 auto 2.5rem;
	padding: 1.5rem;
	background: var(--pt-mist);
	border: 1px dashed var(--pt-line-strong);
	border-radius: var(--pt-radius);
	color: var(--pt-muted);
	font-size: .9rem;
}

/* ============================================================ Dark scheme
   The theme may not follow the system scheme, so the portal repaints its own
   ground here rather than borrowing one it cannot see — otherwise a light-only
   theme leaves pale text on a white page. The system preference and an explicit
   data-theme="dark" are honoured, and the token block is identical in both. */

@media (prefers-color-scheme: dark) {

	/* Guarded on the root so a theme that explicitly asks for light still gets
	   light on a dark-preferring machine. */
	:root:not([data-theme="light"]) .phwo-portal {
		--pt-ink: #e7ecec;
		--pt-ground: #0f1416;
		--pt-surface: #161c1f;
		--pt-mist: #1b2326;
		--pt-line: #2a3438;
		--pt-line-strong: #3b474c;
		--pt-muted: #9aa8ac;
		--pt-primary: var(--phwo-color-primary, #3fa1a8);
		--pt-focus: #6fd2d9;
		--pt-shadow: 0 1px 2px rgba(0, 0, 0, .5);
		--pt-shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 8px 20px rgba(0, 0, 0, .45);
	}
}

[data-theme="dark"] .phwo-portal,
.is-dark .phwo-portal {
	--pt-ink: #e7ecec;
	--pt-ground: #0f1416;
	--pt-surface: #161c1f;
	--pt-mist: #1b2326;
	--pt-line: #2a3438;
	--pt-line-strong: #3b474c;
	--pt-muted: #9aa8ac;
	--pt-primary: var(--phwo-color-primary, #3fa1a8);
	--pt-focus: #6fd2d9;
	--pt-shadow: 0 1px 2px rgba(0, 0, 0, .5);
	--pt-shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 8px 20px rgba(0, 0, 0, .45);
}

/* Filled teal on a dark ground is muddy, so the buttons invert: the accent
   carries the primary action and ink supplies the label contrast. */
@media (prefers-color-scheme: dark) {

	.phwo-portal-btn,
	.phwo-portal-door__form .login-submit input[type="submit"],
	.phwo-portal-door__form .button-primary {
		background: var(--phwo-color-accent, #e8a33d);
		border-color: var(--phwo-color-accent, #e8a33d);
		color: #14262b;
	}

	.phwo-portal-btn:hover,
	.phwo-portal-btn:focus,
	.phwo-portal-door__form .login-submit input[type="submit"]:hover,
	.phwo-portal-door__form .button-primary:hover {
		background: #f2b95f;
		border-color: #f2b95f;
		color: #14262b;
	}

	.phwo-portal-btn--quiet {
		background: transparent;
		border-color: var(--pt-line-strong);
		color: var(--pt-ink);
	}

	.phwo-portal-btn--quiet:hover,
	.phwo-portal-btn--quiet:focus {
		background: var(--pt-mist);
		border-color: var(--pt-ink);
		color: var(--pt-ink);
	}

	.phwo-portal-door__form input[type="text"]:focus,
	.phwo-portal-door__form input[type="password"]:focus {
		box-shadow: 0 0 0 3px rgba(111, 210, 217, .18);
	}
}

[data-theme="dark"] .phwo-portal-btn,
.is-dark .phwo-portal-btn,
[data-theme="dark"] .phwo-portal-door__form .login-submit input[type="submit"],
.is-dark .phwo-portal-door__form .login-submit input[type="submit"],
[data-theme="dark"] .phwo-portal-door__form .button-primary,
.is-dark .phwo-portal-door__form .button-primary {
	background: var(--phwo-color-accent, #e8a33d);
	border-color: var(--phwo-color-accent, #e8a33d);
	color: #14262b;
}

[data-theme="dark"] .phwo-portal-btn:hover,
[data-theme="dark"] .phwo-portal-btn:focus,
.is-dark .phwo-portal-btn:hover,
.is-dark .phwo-portal-btn:focus {
	background: #f2b95f;
	border-color: #f2b95f;
	color: #14262b;
}

[data-theme="dark"] .phwo-portal-btn--quiet,
.is-dark .phwo-portal-btn--quiet {
	background: transparent;
	border-color: var(--pt-line-strong);
	color: var(--pt-ink);
}

[data-theme="dark"] .phwo-portal-btn--quiet:hover,
[data-theme="dark"] .phwo-portal-btn--quiet:focus,
.is-dark .phwo-portal-btn--quiet:hover,
.is-dark .phwo-portal-btn--quiet:focus {
	background: var(--pt-mist);
	border-color: var(--pt-ink);
	color: var(--pt-ink);
}

/* ================================================================== Small */

@media (max-width: 640px) {

	.phwo-portal {
		font-size: 15px;
		padding: 1px .85rem 2rem;
	}

	.phwo-portal-door {
		margin: 1.5rem auto;
		padding: 1.5rem 1.25rem;
	}

	.phwo-portal-head {
		align-items: flex-start;
		margin-top: 1.75rem;
	}

	.phwo-portal-head__name {
		font-size: 1.35rem;
	}

	.phwo-portal-head__acts {
		width: 100%;
	}

	.phwo-portal-head__acts .phwo-portal-btn {
		flex: 1 1 auto;
		text-align: center;
	}

	.phwo-portal-cards {
		grid-template-columns: 1fr;
	}
}

/* At 360px the tag can no longer sit beside a long name without wrapping into
   the baseline, so it drops to its own line. */
@media (max-width: 420px) {

	.phwo-portal {
		padding-left: .75rem;
		padding-right: .75rem;
	}

	.phwo-portal-tag {
		display: block;
		margin: .5rem 0 0;
		vertical-align: baseline;
		width: -moz-fit-content;
		width: fit-content;
	}

	.phwo-portal-figure,
	.phwo-portal-card {
		padding: .9rem 1rem;
	}

	.phwo-portal-head__acts {
		flex-direction: column;
	}
}

/* ====================================================== Reduced motion */

@media (prefers-reduced-motion: reduce) {

	.phwo-portal *,
	.phwo-portal *::before,
	.phwo-portal *::after {
		transition-duration: .01ms;
	}

	.phwo-portal-card:hover,
	.phwo-portal-card:focus-visible {
		transform: none;
	}
}

/* ================================================================== Print
   Nobody prints the portal deliberately, but if they do it should come out as
   a plain list of what the account can reach — no interactive furniture. */

@media print {

	.phwo-portal {
		background: none;
		padding: 0;
		color: #000;
	}

	.phwo-portal-head__acts,
	.phwo-portal-door__form,
	.phwo-portal-hint {
		display: none;
	}

	.phwo-portal-card,
	.phwo-portal-figures,
	.phwo-portal-door {
		box-shadow: none;
		border: 1pt solid #000;
	}

	.phwo-portal-card::before {
		display: none;
	}
}
