/* The ui-* components (TagHelpers and Areas/Tasks/TagHelpers), loaded on every page by
   Views/Shared/_Layout.cshtml. The gallery at /ui shows each one in all its variants.
   Pages only place components (grid-area, margins); how they look lives here.

   Accent color: buttons and the weekday picker take --accent if set, else the child color
   (--child-color, set on the page wrapper), else the header color (--user-color), else blue. */

/* ---- Text input and select (class="input"; the page adds layout such as grid-area) ---- */

.input {
	box-sizing: border-box;
	height: 2.6rem;
	padding: 0 0.6rem;
	font-size: 1.05rem;
	border: 1px solid var(--border);
	border-radius: 0.6rem;
	background: Canvas;
	color: CanvasText;
}

select.input {
	padding-right: 0.3rem;
}

/* ---- Buttons: <ui-button>, <ui-delete-button> ---- */

.btn {
	--_accent: var(--accent, var(--child-color, var(--user-color, var(--c-primary))));
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	height: 2.8rem;
	padding: 0 1.2rem;
	font: inherit;
	font-size: 1.05rem;
	font-weight: 600;
	border: 1px solid transparent;
	border-radius: 0.7rem;
	text-decoration: none;
	cursor: pointer;
}

.btn:focus-visible {
	outline: 3px solid #000a;
	outline-offset: 2px;
}

.btn:active:not(:disabled) {
	transform: scale(0.97);
}

.btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.btn-primary {
	background: var(--_accent);
	color: white;
}

.btn-primary.btn-danger {
	background: var(--c-danger);
}

@media (hover: hover) {
	.btn-primary:hover:not(:disabled) {
		filter: brightness(1.08);
	}
}

.btn-outline {
	border-color: var(--border);
	background: Canvas;
	color: inherit;
	font-size: 1rem;
	font-weight: 400;
}

.btn-icon {
	width: 2.4rem;
	height: 2.6rem;
	padding: 0;
	border-color: var(--border-soft);
	border-radius: 0.6rem;
	background: Canvas;
	color: inherit;
	font-size: 1rem;
	font-weight: 400;
}

.btn-outline.btn-danger,
.btn-icon.btn-danger {
	color: var(--c-danger);
}

.btn-sm {
	height: 2.2rem;
	padding: 0 0.8rem;
	border-radius: 0.6rem;
	font-size: 0.9rem;
}

.btn-icon.btn-sm {
	padding: 0;
	font-size: 0.95rem;
}

.btn-lg {
	height: 3.2rem;
	border-radius: 0.75rem;
	font-size: 1.1rem;
}

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

/* ---- Notice: <ui-notice> ---- */

.notice {
	padding: 0.6rem 0.9rem;
	border-radius: 0.75rem;
	font-weight: 600;
}

.notice-ok {
	background: var(--c-ok-bg);
	color: var(--c-ok);
}

.notice-error {
	background: color-mix(in srgb, var(--c-danger) 12%, transparent);
	color: var(--c-danger);
}

/* ---- Status dot: <ui-status-dot> ---- */

.status-dot {
	box-sizing: border-box;
	flex: none;
	display: grid;
	place-items: center;
	width: 1.6rem;
	height: 1.6rem;
	border: 2px solid var(--border-strong);
	border-radius: 50%;
	font-size: 1rem;
	font-weight: 700;
}

.status-dot.lg {
	width: 2.2rem;
	height: 2.2rem;
	font-size: 1.4rem;
}

.status-dot.marked {
	border-color: var(--c-pending);
	background: var(--c-pending);
	color: white;
}

.status-dot.signed {
	border-color: var(--c-ok);
	background: var(--c-ok);
	color: white;
}

/* ---- Points field: <ui-points-input> ---- */

.pts-input {
	position: relative;
	display: block;
	width: var(--pts-width, auto);
}

.pts-input input {
	width: 100%;
	box-sizing: border-box;
	height: 2.6rem;
	padding: 0 1.6rem 0 0.25rem;
	text-align: right;
	font-size: 1.05rem;
	border: 1px solid var(--border);
	border-radius: 0.6rem;
	background: Canvas;
	color: CanvasText;
	appearance: textfield;
	-moz-appearance: textfield;
}

.pts-input input::-webkit-inner-spin-button,
.pts-input input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.pts-input span {
	position: absolute;
	right: 0.35rem;
	top: 50%;
	transform: translateY(-50%);
	font-size: 0.65rem;
	opacity: 0.6;
	pointer-events: none;
}

/* ---- Weekday picker: <ui-weekday-picker> ---- */

/* Phone: the seven days share the width. Wider: each day keeps a fixed size. */
.weekday-picker {
	--_accent: var(--accent, var(--child-color, var(--user-color, var(--c-primary))));
	display: flex;
	gap: 0.25rem;
}

.weekday-picker label {
	position: relative;
	flex: 1;
}

/* The whole tile is the checkbox; the real input stays focusable for the keyboard. */
.weekday-picker input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.weekday-picker span {
	display: block;
	padding: 0.6rem 0;
	text-align: center;
	font-size: 0.75rem;
	border: 1px solid var(--border);
	border-radius: 0.5rem;
	background: Canvas;
	user-select: none;
}

.weekday-picker input:checked + span {
	background: var(--_accent);
	border-color: transparent;
	color: white;
	font-weight: 600;
}

.weekday-picker input:focus-visible + span {
	outline: 3px solid #000a;
	outline-offset: 2px;
}

@media (min-width: 48rem) {
	.weekday-picker label {
		flex: none;
	}

	.weekday-picker span {
		min-width: 2.7rem;
		padding: 0.6rem 0.2rem;
		font-size: 0.8rem;
	}
}

/* ---- Switch: <ui-switch> ---- */

/* The real checkbox stays focusable for the keyboard; the track is what you see.
   "~" not "+": an off-value hidden field may sit between the checkbox and the track. */
.switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	min-height: 2.75rem;
	cursor: pointer;
	user-select: none;
}

.switch input {
	position: absolute;
	opacity: 0;
}

.switch .track {
	flex: none;
	position: relative;
	width: 3rem;
	height: 1.7rem;
	border-radius: 999px;
	background: #8886;
	transition: background 0.15s;
}

.switch .track::after {
	content: '';
	position: absolute;
	top: 0.2rem;
	left: 0.2rem;
	width: 1.3rem;
	height: 1.3rem;
	border-radius: 50%;
	background: white;
	transition: transform 0.15s;
}

.switch input:checked ~ .track {
	background: var(--c-ok);
}

.switch input:checked ~ .track::after {
	transform: translateX(1.3rem);
}

.switch input:focus-visible ~ .track {
	outline: 3px solid #000a;
	outline-offset: 2px;
}
