/* ================================================================
   SmartGym · app.css — the design system
   Consumes tokens from brand.css only. No brand values here.
   ================================================================ */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
img, svg { display: block; max-width: 100%; }

html, body, #app { height: 100%; }

body {
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.55;
	color: var(--ink);
	background: var(--surface-page);
	-webkit-font-smoothing: antialiased;
}

/* --- Type --- */
h1, h2, h3, .display {
	font-family: var(--font-display);
	font-stretch: var(--display-stretch);
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.015em;
	line-height: 1.05;
	text-wrap: balance;
}

h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); }
h2 { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.35rem); }
h3 { font-size: 1.02rem; }

.eyebrow {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.14em;
	color: var(--primary);
}

a { color: var(--primary-strong); }

:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
	border-radius: 6px;
}

::selection { background: var(--primary-soft); }

/* --- Page scaffold --- */
.page {
	max-width: 1180px;
	margin-inline: auto;
	padding: clamp(16px, 3vw, 36px);
	display: grid;
	gap: clamp(16px, 2vw, 26px);
	animation: page-rise 0.45s ease both;
}

@keyframes page-rise {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: none; }
}

/* --- The swell: dark hero band every page opens with --- */
.swell {
	position: relative;
	overflow: hidden;
	border-radius: var(--r-card);
	padding: clamp(22px, 3.5vw, 40px);
	background: var(--hero-grad);
	color: var(--hero-ink);
}

.swell .eyebrow { color: var(--glow); }
.swell p { color: var(--hero-ink-2); }
.swell h1, .swell h2 { color: var(--hero-ink); }

.swell__wave {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	color: var(--glow);
}

.swell__content { position: relative; }

/* --- Cards --- */
.card {
	background: var(--surface-card);
	border: 1px solid var(--hairline);
	border-radius: var(--r-card);
	box-shadow: var(--shadow-card);
	padding: clamp(16px, 2.4vw, 26px);
}

.card-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

.card-subtitle { color: var(--ink-3); font-size: 0.85rem; }

/* --- Buttons --- */
.btn {
	font-family: var(--font-body);
	font-size: 0.9rem;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 20px;
	border-radius: 8px;
	border: 1px solid transparent;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
	background: var(--primary);
	color: #ffffff;
}

.btn--primary:hover { background: var(--primary-strong); }

.btn--accent {
	background: var(--accent);
	color: var(--accent-ink);
}

.btn--accent:hover { filter: brightness(1.05); }

.btn--ghost {
	background: transparent;
	border-color: var(--hairline);
	color: var(--ink);
}

.btn--ghost:hover { background: var(--surface-sunken); border-color: var(--ink-3); }

/* Ghost button placed on the dark swell band */
.swell .btn--ghost {
	border-color: rgba(255, 255, 255, 0.35);
	color: var(--hero-ink);
}

.swell .btn--ghost:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.6); }

.btn--subtle {
	background: var(--primary-soft);
	color: var(--primary-strong);
}

.btn--subtle:hover { background: var(--primary); color: #fff; }

.btn--block { width: 100%; }

.btn[disabled], .btn.disabled { opacity: 0.55; cursor: not-allowed; }

/* Icon-only button (nav toggles, calendar arrows) */
.btn--icon {
	padding: 8px;
	border-radius: 10px;
	background: transparent;
	border-color: var(--hairline);
	color: var(--ink-2);
}

.btn--icon:hover { background: var(--surface-sunken); color: var(--ink); }

/* --- Form fields --- */
.field { display: grid; gap: 6px; text-align: left; }

.field__label {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--ink-2);
}

.control {
	font-family: var(--font-body);
	font-size: 0.95rem;
	color: var(--ink);
	width: 100%;
	padding: 10px 14px;
	background: var(--surface-card);
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.control:focus-visible {
	border-color: var(--primary);
	box-shadow: var(--focus-ring);
	outline: none;
}

.control::placeholder { color: var(--ink-3); }

.control[readonly] { background: var(--surface-sunken); color: var(--ink-2); }

textarea.control { resize: vertical; min-height: 68px; }

select.control { appearance: none; }

.field--select { position: relative; }

.field--select::after {
	content: "";
	position: absolute;
	right: 14px;
	bottom: 17px;
	width: 8px;
	height: 8px;
	border-right: 2px solid var(--ink-3);
	border-bottom: 2px solid var(--ink-3);
	transform: rotate(45deg);
	pointer-events: none;
}

/* Blazor validation */
.invalid, .control.invalid { border-color: var(--danger); }
.validation-message { color: var(--danger); font-size: 0.82rem; }

/* --- Chips & badges --- */
.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border-radius: var(--r-pill);
	font-size: 0.78rem;
	font-weight: 700;
	background: var(--primary-soft);
	color: var(--primary-strong);
}

.chip--accent { background: var(--accent); color: var(--accent-ink); }

.chip--outline {
	background: transparent;
	border: 1px solid var(--hairline);
	color: var(--ink-2);
}

/* --- Progress: the crest gradient --- */
.progress-track {
	height: 10px;
	border-radius: var(--r-pill);
	background: rgba(255, 255, 255, 0.16);
	overflow: hidden;
}

.card .progress-track { background: var(--surface-sunken); }

.progress-fill {
	height: 100%;
	border-radius: var(--r-pill);
	background: linear-gradient(90deg, var(--primary) 0%, var(--glow) 100%);
	transition: width 0.6s ease;
}

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }

.table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}

.table th {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--ink-3);
	text-align: left;
	padding: 10px 12px;
	border-bottom: 1px solid var(--hairline);
	white-space: nowrap;
}

.table td {
	padding: 12px;
	border-bottom: 1px solid var(--viz-grid);
	font-variant-numeric: tabular-nums;
}

.table tr:last-child td { border-bottom: none; }

/* --- Empty states --- */
.empty-state {
	padding: 28px;
	border: 1px dashed var(--hairline);
	border-radius: var(--r-card);
	color: var(--ink-2);
	text-align: center;
	font-size: 0.92rem;
}

/* --- Spinner --- */
.spinner {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 3px solid var(--primary-soft);
	border-top-color: var(--primary);
	animation: spin 0.7s linear infinite;
}

.spinner--sm { width: 18px; height: 18px; border-width: 2px; }

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

.loader {
	display: grid;
	place-items: center;
	min-height: 40vh;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* --- Blazor boot & error UI --- */
/* Boot screen: "loading the bar". Blazor sets --blazor-load-percentage on
   <html> while resources download; each plate pair drops onto the barbell
   once the load passes its --at threshold. All colors come from brand.css. */
.boot {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	background: var(--hero-grad);
}

.boot__stage {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.4rem;
}

.boot__stage::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 26rem;
	height: 26rem;
	transform: translate(-50%, -58%);
	background: radial-gradient(closest-side, color-mix(in srgb, var(--glow) 13%, transparent), transparent 72%);
	animation: boot-glow 3.4s ease-in-out infinite;
	pointer-events: none;
}

.boot__barbell {
	position: relative;
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: min(21rem, 78vw);
	height: 5.4rem;
	animation: boot-bob 2.6s ease-in-out infinite;
}

.boot__bar {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 0.5rem;
	transform: translateY(-50%);
	border-radius: var(--r-pill);
	background: linear-gradient(180deg, var(--hero-ink), var(--hero-ink-2));
}

.boot__side {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.22rem;
}

.boot__collar {
	width: 0.32rem;
	height: 1.15rem;
	border-radius: 0.16rem;
	background: var(--hero-ink-2);
}

.boot__plate {
	--at: 0%;
	border-radius: 0.28rem;
	box-shadow: inset 0 2px 0 color-mix(in srgb, #fff 22%, transparent);
	opacity: clamp(0%, calc((var(--blazor-load-percentage, 0%) - var(--at)) * 8), 100%);
	transform: translateY(clamp(-140%, calc((var(--blazor-load-percentage, 0%) - var(--at)) * 11.2 - 140%), 0%));
	transition: opacity 0.3s ease-out, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.boot__plate--fortyfive {
	--at: 5%;
	width: 0.85rem;
	height: 4.7rem;
	background: var(--primary);
}

.boot__plate--twentyfive {
	--at: 38%;
	width: 0.75rem;
	height: 3.4rem;
	background: var(--glow);
}

.boot__plate--ten {
	--at: 68%;
	width: 0.65rem;
	height: 2.2rem;
	background: var(--accent);
}

.loading-progress-text {
	margin-top: 0.6rem;
	font-family: var(--font-display);
	font-stretch: var(--display-stretch);
	font-size: 1.9rem;
	font-weight: 750;
	color: var(--hero-ink);
	font-variant-numeric: tabular-nums;
}

.loading-progress-text::after {
	content: var(--blazor-load-percentage-text, "Loading");
}

.boot__hint {
	font-family: var(--font-body);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.24em;
	text-transform: uppercase;
	color: var(--hero-ink-2);
}

@keyframes boot-bob {
	0%,
	100% {
		transform: translateY(0);
	}

	50% {
		transform: translateY(4px);
	}
}

@keyframes boot-glow {
	0%,
	100% {
		opacity: 0.7;
	}

	50% {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.boot__barbell,
	.boot__stage::before {
		animation: none;
	}

	.boot__plate {
		transform: none;
		transition: opacity 0.2s linear;
	}
}

#blazor-error-ui {
	background: var(--ink);
	color: #fff;
	bottom: 0;
	box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.25);
	display: none;
	left: 0;
	padding: 0.7rem 2.5rem 0.7rem 1.25rem;
	position: fixed;
	width: 100%;
	z-index: 1000;
}

#blazor-error-ui .dismiss {
	cursor: pointer;
	position: absolute;
	right: 0.75rem;
	top: 0.5rem;
}

/* --- Tabs --- */
.tabs {
	display: flex;
	gap: 6px;
	padding: 6px;
	background: var(--surface-card);
	border: 1px solid var(--hairline);
	border-radius: var(--r-pill);
	width: fit-content;
	max-width: 100%;
	overflow-x: auto;
}

.tab {
	font-family: var(--font-body);
	font-size: 0.88rem;
	font-weight: 700;
	padding: 8px 18px;
	border: none;
	border-radius: var(--r-pill);
	background: transparent;
	color: var(--ink-2);
	cursor: pointer;
	white-space: nowrap;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.tab:hover { background: var(--surface-sunken); color: var(--ink); }

.tab--active,
.tab--active:hover {
	background: var(--primary);
	color: #ffffff;
}

/* --- Admin console --- */
.admin-hero__description { max-width: 52ch; }

.admin-form { display: grid; gap: 16px; max-width: 560px; }

.admin-form__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.admin-colour { display: flex; align-items: center; gap: 12px; }

.admin-colour__swatch {
	width: 44px;
	height: 34px;
	padding: 2px;
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
	background: var(--surface-card);
	cursor: pointer;
}

.admin-colour__value { font-size: 0.88rem; color: var(--ink-2); }

.admin-settings__hint { font-size: 0.82rem; color: var(--ink-3); }
.admin-settings__error { color: var(--danger); font-size: 0.88rem; }
.admin-settings__saved { color: var(--ok); font-size: 0.88rem; }

.admin-invite__hint { font-size: 0.88rem; color: var(--ink-2); }
.admin-invite__result { display: flex; gap: 10px; align-items: center; }
.admin-invite__expiry { font-size: 0.82rem; color: var(--ink-3); }

/* Exercise library */
.exercise-list {
	display: grid;
	gap: 10px;
	margin-top: 20px;
	border-top: 1px solid var(--hairline);
	padding-top: 20px;
}

.exercise-row {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 14px;
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
	background: var(--surface-card);
}

.exercise-row__thumb {
	flex: none;
	width: 76px;
	height: 48px;
	display: grid;
	place-items: center;
	border-radius: 8px;
	overflow: hidden;
	background: var(--surface-sunken);
	color: var(--ink-3);
}

.exercise-row__thumb img { width: 100%; height: 100%; object-fit: cover; }

.exercise-row__body { flex: 1; min-width: 0; display: grid; gap: 2px; justify-items: start; }
.exercise-row__body p { font-size: 0.85rem; color: var(--ink-2); }

.exercise-row__actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.exercise-edit {
	padding: 14px;
	border: 1px dashed var(--hairline);
	border-radius: var(--r-ctl);
	background: var(--surface-sunken);
}

.exercise-video iframe {
	width: 100%;
	aspect-ratio: 16 / 9;
	border: none;
	border-radius: var(--r-ctl);
	background: #000;
}

/* Workout schedules */
.schedule-list { display: grid; gap: 10px; }

.schedule-row {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	padding: 14px;
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
}

.schedule-row__body { flex: 1; min-width: 0; display: grid; gap: 6px; justify-items: start; }
.schedule-row__body p { font-size: 0.85rem; color: var(--ink-2); }
.schedule-row__meta { display: flex; gap: 8px; flex-wrap: wrap; }
.schedule-row__actions { display: flex; gap: 8px; }

.schedule-day {
	display: grid;
	gap: 6px;
	padding: 10px 12px;
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
	background: var(--surface-sunken);
}

.schedule-day__name {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--primary-strong);
}

.schedule-slot {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 10px;
	border-radius: 10px;
	background: var(--surface-card);
	border: 1px solid var(--hairline);
}

.schedule-slot__name { flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 600; }
.schedule-slot__dose { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.schedule-add {
	display: grid;
	grid-template-columns: 1fr 2fr 72px 72px auto;
	gap: 10px;
	align-items: end;
}

/* Start / finish date pair in the schedule editor */
.schedule-dates {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

@media (max-width: 480px) {
	.schedule-dates { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
	.schedule-add { grid-template-columns: 1fr 1fr; }
}

.assign-all {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.92rem;
	cursor: pointer;
}

.member-picks {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 8px;
	padding: 12px;
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
	background: var(--surface-sunken);
	max-height: 260px;
	overflow-y: auto;
}

.member-pick {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.9rem;
	cursor: pointer;
}

/* Trailing cell of a member row: admin chip + open button together */
.member-row__end {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
}

/* Chips in the member page's details header */
.member-chips {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* Coach review stats — Admin member page */
.coach-review__stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 10px;
	margin: 14px 0;
}

.coach-review__stat {
	display: grid;
	gap: 2px;
	padding: 10px 12px;
	border: 1px solid var(--hairline);
	border-radius: var(--r-ctl);
	background: var(--surface-sunken);
}

	.coach-review__stat span {
		color: var(--ink-3);
		font-size: 0.75rem;
	}

	.coach-review__stat strong {
		font-size: 1.05rem;
	}

/* --- Motion --- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
