/*
 * Calculator pages (page/aspectratio.php, screensize.php, contrast.php, colorconverter.php, monitortest.php).
 * Builds on /assets/site/base.css (colour tokens, header) and /assets/v2/site.css (body, cards, buttons, tools, footer).
 */

[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.calc { max-width: 760px; }
.calc h1 { font-size: 28px; line-height: 1.15; margin: 6px 0; }
.calc .lead { margin: 0 0 16px; color: var(--muted); }
.calc .card h2 { font-size: 18px; }
.calc .card h3 { font-size: 15px; margin: 16px 0 8px; }
.calc .about h2 { margin-top: 4px; }
.calc .about h3 { font-size: 16px; margin: 14px 0 6px; }
.calc .about ul { margin: 0 0 10px; padding-left: 20px; }
.calc .about li { margin-bottom: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0 !important; }

/* ---------- inputs ---------- */

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: block; min-width: 0; }
.field > span, .field-label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }

.num {
	width: 100%;
	min-width: 0;
	min-height: 48px;
	padding: 6px 12px;
	font: inherit;
	font-size: 20px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	color: var(--text);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	-moz-appearance: textfield;
}
.num::-webkit-inner-spin-button, .num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.num.invalid { border-color: var(--warn); }
.num-sm { font-size: 17px; min-height: 44px; padding: 6px 10px; }
.mono-in { font-family: var(--mono); font-size: 17px; }

/* "16 : 9" - two inputs with a colon between them */
.ratio-in { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; }
.ratio-in b { font-size: 20px; color: var(--muted); }

/* segmented control (units) */
.seg {
	display: inline-grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	gap: 4px;
	padding: 3px;
	background: var(--surface-2);
	border-radius: var(--radius-sm);
}
.seg button {
	min-height: 36px;
	min-width: 56px;
	padding: 0 12px;
	border: 0;
	border-radius: 8px;
	background: none;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* quick values */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button {
	min-height: 34px;
	padding: 0 12px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
}
.chips button:hover { border-color: var(--accent); }
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.row-gap { margin-top: 12px; }
.diag-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- results ---------- */

.out {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px dashed var(--border);
}
.big {
	margin: 0;
	font-size: clamp(30px, 9vw, 44px);
	font-weight: 800;
	letter-spacing: -0.01em;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}
.big.empty { font-size: 18px; font-weight: 600; color: var(--muted); }
.big-sub { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.big-sub b { color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; }
.stat dt { font-size: 13px; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat dd small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }

/* list of standard resolutions */
.res-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.res-list button {
	min-height: 34px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	font: 14px var(--mono);
	cursor: pointer;
}
.res-list button:hover { border-color: var(--accent); }
.res-list small { font-family: var(--font); color: var(--muted); }

/* proportional rectangle */
.shape-box { display: flex; align-items: center; justify-content: center; height: 170px; margin-top: 14px; }
.shape {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 100%;
	border: 2.5px solid var(--accent);
	border-radius: 6px;
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	transition: width .2s, height .2s;
}

/* two screens drawn over each other */
.compare-svg { display: block; width: 100%; height: auto; max-height: 260px; margin-top: 12px; }
.compare-svg .s-a { fill: var(--accent-soft); stroke: var(--accent); }
.compare-svg .s-b { fill: none; stroke: var(--warn); stroke-dasharray: 6 4; }
.compare-svg text { font: 700 20px var(--font); }   /* SVG units: the drawing is scaled to the card width */
.compare-svg .t-a { fill: var(--accent); }
.compare-svg .t-b { fill: var(--warn); }
.diff { margin: 10px 0 0; padding: 0; list-style: none; }
.diff li { padding: 6px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.diff li:last-child { border-bottom: 0; }
.tag-a, .tag-b { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; font-size: 13px; font-weight: 700; text-align: center; }
.tag-a { background: var(--accent-soft); color: var(--accent); }
.tag-b { background: var(--surface-2); color: var(--warn); }

/* ---------- colours ---------- */

.color-in { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; }
.picker {
	width: 52px;
	height: 48px;
	padding: 0;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	cursor: pointer;
	overflow: hidden;
}
.picker::-webkit-color-swatch-wrapper { padding: 3px; }
.picker::-webkit-color-swatch { border: 0; border-radius: 7px; }
.picker::-moz-color-swatch { border: 0; border-radius: 7px; }

.swap-row { display: flex; justify-content: center; margin: 8px 0; }

.preview {
	margin-top: 14px;
	padding: 18px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
}
.preview p { margin: 0 0 8px; }
.preview .p-large { font-size: 24px; font-weight: 700; line-height: 1.25; }
.preview .p-small { font-size: 13px; }
.preview .p-ui { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.preview .p-btn { padding: 8px 14px; border: 2px solid currentColor; border-radius: 8px; font-weight: 600; }
.preview .p-icon { width: 24px; height: 24px; }

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.check { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.check b { display: block; font-size: 14px; }
.check span { display: block; font-size: 13px; color: var(--muted); }
.check .verdict { margin-top: 4px; font-weight: 700; font-size: 14px; }
.check.pass { background: var(--good-soft); }
.check.pass .verdict { color: var(--good); }
.check.pass .verdict::before { content: "✓ "; }
.check.fail .verdict { color: var(--warn); }
.check.fail .verdict::before { content: "✗ "; }

.suggest { margin-top: 12px; }
.suggest-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.suggest-btn { gap: 8px; font-family: var(--mono); font-weight: 600; }
.dot-swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border); flex: none; }

.swatch-big { height: 96px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 12px; }

.conv-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.conv-row:last-of-type { border-bottom: 0; }
.conv-row > b { align-self: center; font-size: 15px; }
.conv-row .copy { align-self: end; min-height: 44px; }
.conv-css { grid-column: 2 / -1; margin: -2px 0 0; font: 13px var(--mono); color: var(--muted); overflow-wrap: anywhere; }

.strip { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.strip button { height: 40px; padding: 0; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.strip button[aria-current="true"] { outline: 2px solid var(--text); outline-offset: 1px; }

.vs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.vs a { display: block; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); text-decoration: none; font-weight: 600; }
.vs a small { display: block; font-weight: 500; opacity: .85; }

/* ---------- monitor test (page/monitortest.php) ---------- */

.mt-browser-name { font-weight: 600; }
.mt-notes { margin: 8px 0 0; padding-left: 20px; }
.mt-notes li { margin-bottom: 6px; }
.mt-notes li.warn { color: var(--warn); font-weight: 600; }
.mt-out { margin-top: 0; padding-top: 0; border-top: 0; }
.mt-graph { display: block; width: 100%; height: 90px; margin-top: 12px; border-radius: var(--radius-sm); }
.mt-warn { color: var(--warn); font-weight: 600; }
.mt-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.mt-colors button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 34px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}
.mt-colors button:hover { border-color: var(--accent); }
.mt-colors button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.mt-colors .dot-swatch { width: 14px; height: 14px; border-radius: 50%; }
.mt-motion { display: block; width: 100%; height: 200px; margin-top: 12px; border-radius: var(--radius-sm); }
.mt-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-top: 12px; }
.mt-chips { margin-top: 0; }

/* full-screen colour: nothing but the colour, controls fade out when the pointer rests */
.px-lock, .px-lock body { overflow: hidden; }
.px-test { position: fixed; inset: 0; z-index: 1000; outline: none; cursor: pointer; }
.px-test.idle { cursor: none; }
.px-hint {
	position: absolute;
	left: 50%;
	bottom: calc(24px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	max-width: calc(100% - 32px);
	margin: 0;
	padding: 8px 14px;
	border-radius: 999px;
	background: rgba(0, 0, 0, .72);
	color: #fff;
	font-size: 14px;
	text-align: center;
	transition: opacity .3s;
}
.px-exit {
	position: absolute;
	top: calc(14px + env(safe-area-inset-top));
	right: 14px;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .72);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	transition: opacity .3s;
}
.px-test.idle .px-hint, .px-test.idle .px-exit { opacity: 0; pointer-events: none; }

/* ---------- toast ---------- */

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(18px + env(safe-area-inset-bottom));
	transform: translate(-50%, 20px);
	max-width: calc(100% - 32px);
	padding: 10px 16px;
	border-radius: 999px;
	background: var(--text);
	color: var(--bg);
	font-size: 14px;
	font-weight: 600;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s, transform .2s;
	z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- wider screens ---------- */

@media (max-width: 420px) {
	.fields-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.conv-row { grid-template-columns: minmax(0, 1fr) auto; }
	.conv-row > b { grid-column: 1 / -1; }
	.conv-css { grid-column: 1 / -1; }
}

@media (min-width: 640px) {
	.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.shape-box { height: 220px; }
	.calc h1 { font-size: 32px; }
}
