/**
 * Base element styles and resets.
 */

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

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	/* Anchor targets clear the sticky header instead of hiding behind it. */
	scroll-padding-top: calc(var(--pct-header-height) + var(--pct-space-4));
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

body {
	margin: 0;
	background-color: var(--pct-bg);
	color: var(--pct-text);
	font-family: var(--pct-font-sans);
	font-size: var(--pct-text-base);
	line-height: var(--pct-leading-normal);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	margin: 0 0 var(--pct-space-4);
	color: var(--pct-heading);
	font-weight: 700;
	line-height: var(--pct-leading-tight);
	letter-spacing: -0.015em;
	text-wrap: balance;
}

h1 {
	font-size: clamp(2rem, 1.5rem + 2.2vw, var(--pct-text-5xl));
}

h2 {
	font-size: clamp(1.5rem, 1.25rem + 1.1vw, var(--pct-text-3xl));
}

h3 {
	font-size: clamp(1.25rem, 1.12rem + 0.5vw, var(--pct-text-2xl));
}

h4 {
	font-size: var(--pct-text-xl);
}

h5,
h6 {
	font-size: var(--pct-text-lg);
}

p {
	margin: 0 0 var(--pct-space-4);
	text-wrap: pretty;
}

a {
	color: var(--pct-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
	transition: color var(--pct-transition);
}

a:hover {
	color: var(--pct-accent-hover);
}

/* A visible, high-contrast focus ring in both themes. Never removed. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--pct-focus-ring);
	outline-offset: 2px;
	border-radius: var(--pct-radius-sm);
}

img,
picture,
video,
canvas,
svg {
	display: block;
	max-width: 100%;
	height: auto;
}

svg {
	fill: currentColor;
}

ul,
ol {
	margin: 0 0 var(--pct-space-4);
	padding-left: var(--pct-space-6);
}

li {
	margin-bottom: var(--pct-space-2);
}

blockquote {
	margin: var(--pct-space-6) 0;
	padding: var(--pct-space-4) var(--pct-space-6);
	border-left: 3px solid var(--pct-accent);
	background: var(--pct-bg-subtle);
	border-radius: 0 var(--pct-radius) var(--pct-radius) 0;
	color: var(--pct-text-muted);
	font-style: italic;
}

blockquote > :last-child {
	margin-bottom: 0;
}

code,
kbd,
pre,
samp {
	font-family: var(--pct-font-mono);
	font-size: 0.9em;
}

code {
	padding: 0.15em 0.4em;
	background: var(--pct-bg-muted);
	border: 1px solid var(--pct-border-subtle);
	border-radius: var(--pct-radius-sm);
	color: var(--pct-text);
}

pre {
	margin: 0 0 var(--pct-space-4);
	padding: var(--pct-space-4);
	overflow-x: auto;
	background: var(--pct-surface-sunken);
	border: 1px solid var(--pct-border);
	border-radius: var(--pct-radius);
	color: var(--pct-text);
	line-height: 1.55;
}

pre code {
	padding: 0;
	background: none;
	border: 0;
}

hr {
	margin: var(--pct-space-10) 0;
	border: 0;
	border-top: 1px solid var(--pct-border);
}

/* ---- Tables ---- */

table {
	width: 100%;
	margin: 0 0 var(--pct-space-6);
	border-collapse: collapse;
	font-size: var(--pct-text-sm);
}

th,
td {
	padding: var(--pct-space-3);
	border-bottom: 1px solid var(--pct-border);
	text-align: left;
	vertical-align: top;
}

thead th {
	background: var(--pct-bg-subtle);
	color: var(--pct-text-muted);
	font-size: var(--pct-text-xs);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}

tbody tr:last-child th,
tbody tr:last-child td {
	border-bottom: 0;
}

/* ---- Form elements ---- */

input,
select,
textarea,
button {
	font: inherit;
	color: inherit;
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="password"],
select,
textarea {
	width: 100%;
	padding: var(--pct-space-3) var(--pct-space-4);
	background-color: var(--pct-input-bg);
	border: 1px solid var(--pct-input-border);
	border-radius: var(--pct-radius);
	color: var(--pct-input-text);
	font-size: var(--pct-text-base);
	line-height: 1.4;
	transition: border-color var(--pct-transition), box-shadow var(--pct-transition);
	appearance: none;
}

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

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

input::placeholder,
textarea::placeholder {
	color: var(--pct-input-placeholder);
	opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
	background-color: var(--pct-input-disabled-bg);
	color: var(--pct-text-subtle);
	cursor: not-allowed;
}

/* The arrow is drawn inline so it takes its colour from the theme rather
   than from a fixed-colour browser default that vanishes in dark mode. */
select {
	padding-right: var(--pct-space-10);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--pct-space-4) center;
	cursor: pointer;
}

:root[data-theme="dark"] select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239fb0c9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) select {
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239fb0c9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	}
}

textarea {
	min-height: 8rem;
	resize: vertical;
}

label {
	display: block;
	margin-bottom: var(--pct-space-2);
	color: var(--pct-text);
	font-size: var(--pct-text-sm);
	font-weight: 600;
}

fieldset {
	margin: 0 0 var(--pct-space-6);
	padding: 0;
	border: 0;
}

legend {
	padding: 0;
	margin-bottom: var(--pct-space-3);
	font-size: var(--pct-text-sm);
	font-weight: 600;
}

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

input[type="range"] {
	width: 100%;
	height: 1.5rem;
	padding: 0;
	background: transparent;
	border: 0;
	accent-color: var(--pct-accent);
	cursor: pointer;
}

/* ---- Accessibility helpers ---- */

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.pct-skip-link {
	position: absolute;
	top: -100px;
	left: var(--pct-space-4);
	z-index: 200;
	padding: var(--pct-space-3) var(--pct-space-5);
	background: var(--pct-accent);
	border-radius: 0 0 var(--pct-radius) var(--pct-radius);
	color: var(--pct-accent-text);
	font-weight: 600;
	text-decoration: none;
	transition: top var(--pct-transition);
}

.pct-skip-link:focus {
	top: 0;
	color: var(--pct-accent-text);
}

[hidden] {
	display: none !important;
}
