/* FishMMO Control Panel — reset, typography and form primitives. */

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

html,
body {
	height: 100%;
}

body {
	margin: 0;
	font-family: var(--font-ui);
	font-size: var(--fs-base);
	line-height: 1.5;
	color: var(--text-default);
	background: var(--surface-page);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
	margin: 0;
	color: var(--text-strong);
	font-weight: 600;
	line-height: 1.25;
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

a {
	color: var(--accent);
	text-decoration: none;
}

a:hover { text-decoration: underline; }

code,
kbd,
pre,
.mono {
	font-family: var(--font-mono);
	font-size: 0.92em;
}

code {
	padding: 1px 5px;
	border-radius: var(--radius-sm);
	background: var(--surface-inset);
	color: var(--text-strong);
}

pre {
	margin: 0;
	padding: var(--sp-3);
	overflow-x: auto;
	border-radius: var(--radius);
	background: var(--surface-inset);
	color: var(--text-strong);
}

hr {
	height: 1px;
	margin: var(--sp-5) 0;
	border: 0;
	background: var(--line-default);
}

img { max-width: 100%; }
[hidden] { display: none !important; }

/* Focus is never removed, only restyled. Operators use this panel by keyboard. */
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: var(--radius-sm);
}

::selection {
	background: var(--accent-soft);
	color: var(--accent-soft-text);
}

/* ── Scrollbars ──────────────────────────────────────────────── */

* {
	scrollbar-width: thin;
	scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }

*::-webkit-scrollbar-thumb {
	background: var(--line-strong);
	border: 3px solid transparent;
	border-radius: var(--radius-pill);
	background-clip: content-box;
}

/* ── Forms ───────────────────────────────────────────────────── */

label {
	display: block;
	margin-bottom: var(--sp-1);
	color: var(--text-muted);
	font-size: var(--fs-sm);
	font-weight: 500;
}

input,
select,
textarea {
	width: 100%;
	padding: 7px 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface-raised);
	color: var(--text-strong);
	font-family: inherit;
	font-size: var(--fs-base);
	transition: border-color 0.12s, box-shadow 0.12s;
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
	border-color: var(--accent);
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

input:disabled,
select:disabled,
textarea:disabled {
	background: var(--surface-inset);
	color: var(--text-faint);
	cursor: not-allowed;
}

input::placeholder,
textarea::placeholder { color: var(--text-faint); }

textarea {
	min-height: 76px;
	resize: vertical;
}

select {
	cursor: pointer;
	appearance: none;
	padding-right: 30px;
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}

input[type="checkbox"],
input[type="radio"] {
	width: auto;
	margin: 0;
	accent-color: var(--accent);
	cursor: pointer;
}

.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }

.field-hint {
	margin-top: var(--sp-1);
	color: var(--text-faint);
	font-size: var(--fs-sm);
}

.field-error {
	margin-top: var(--sp-1);
	color: var(--danger);
	font-size: var(--fs-sm);
}

.field-row {
	display: flex;
	gap: var(--sp-4);
	flex-wrap: wrap;
}

.field-row > * {
	flex: 1 1 200px;
	min-width: 0;
}

.check-row {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	margin-bottom: var(--sp-2);
}

.check-row label {
	margin: 0;
	color: var(--text-default);
	font-weight: 400;
	cursor: pointer;
}

/* ── Utilities ───────────────────────────────────────────────── */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.strong { color: var(--text-strong); font-weight: 600; }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.tnum { font-variant-numeric: tabular-nums; }

.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-5); }

.row {
	display: flex;
	align-items: center;
	gap: var(--sp-2);
}

.row-between {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-3);
	flex-wrap: wrap;
}

.grow { flex: 1 1 auto; min-width: 0; }

/*
 * The descriptive half of a .row-between whose other half is a control. A basis of zero, not
 * auto: .row-between wraps, and wrapping is decided on each item's base size, so a paragraph
 * with basis auto measures its whole unbroken line, never fits beside the button, and pushes
 * the button onto a line of its own at any width. Zero lets the button keep its place and the
 * text take what is left; only on a narrow screen does the text claim the full line.
 */
.row-between > .row-text { flex: 1 1 0; min-width: 0; }

@media (max-width: 480px) {
	.row-between > .row-text { flex-basis: 100%; }
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

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