/*
 * base.css — design tokens, reset, base typography, accessibility.
 *
 * Token values are the locked design system. theme.json carries the same
 * palette and scales for the block editor; keep the two in sync when either
 * changes.
 */

/* -------------------------------------------------------------------------
 * 1. Design tokens
 * ---------------------------------------------------------------------- */

:root {
	/* Colour */
	--ifja-bg: #ffffff;
	--ifja-surface: #f8fafc;
	--ifja-text: #0f172a;
	--ifja-text-muted: #64748b;
	--ifja-border: #e2e8f0;
	--ifja-accent: #2563eb;
	--ifja-accent-hover: #1d4ed8;
	--ifja-success: #16a34a;
	--ifja-warning: #d97706;
	--ifja-error: #dc2626;
	--ifja-info: #0284c7;

	/* Tinted surfaces for badges and soft states. Kept subtle by design. */
	--ifja-accent-soft: #eff6ff;
	--ifja-success-soft: #f0fdf4;
	--ifja-warning-soft: #fffbeb;
	--ifja-error-soft: #fef2f2;
	--ifja-info-soft: #f0f9ff;
	--ifja-neutral-soft: #f1f5f9;

	/* Readable text colours to pair with the soft surfaces above. */
	--ifja-accent-strong: #1e40af;
	--ifja-success-strong: #15803d;
	--ifja-warning-strong: #b45309;
	--ifja-error-strong: #b91c1c;
	--ifja-info-strong: #0369a1;
	--ifja-neutral-strong: #334155;

	/* Typography */
	--ifja-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;
	--ifja-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

	--ifja-text-xs: 0.8125rem;
	--ifja-text-sm: 0.875rem;
	--ifja-text-base: 1rem;
	--ifja-text-lg: 1.125rem;
	--ifja-text-xl: 1.5rem;
	--ifja-text-2xl: 1.875rem;
	--ifja-text-3xl: 2.25rem;

	--ifja-leading-tight: 1.25;
	--ifja-leading-snug: 1.4;
	--ifja-leading-normal: 1.65;

	/* Spacing — 4px base scale */
	--ifja-space-1: 0.25rem;
	--ifja-space-2: 0.5rem;
	--ifja-space-3: 0.75rem;
	--ifja-space-4: 1rem;
	--ifja-space-5: 1.5rem;
	--ifja-space-6: 2rem;
	--ifja-space-7: 3rem;
	--ifja-space-8: 4rem;

	/* Radius — small to medium only */
	--ifja-radius-sm: 4px;
	--ifja-radius-md: 8px;
	--ifja-radius-lg: 12px;
	--ifja-radius-pill: 999px;

	/* Elevation — used sparingly */
	--ifja-shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 5%);
	--ifja-shadow-md: 0 1px 3px 0 rgb(15 23 42 / 8%), 0 1px 2px -1px rgb(15 23 42 / 6%);

	/* Layout */
	--ifja-container: 1200px;
	--ifja-content: 760px;
	--ifja-gutter: var(--ifja-space-4);
	--ifja-header-height: 60px;

	/* Focus */
	--ifja-focus-ring: 0 0 0 2px var(--ifja-bg), 0 0 0 4px var(--ifja-accent);

	/* Motion — minimal by design */
	--ifja-transition: 150ms ease;
}

@media (min-width: 768px) {
	:root {
		--ifja-gutter: var(--ifja-space-5);
	}
}

/* -------------------------------------------------------------------------
 * 2. Reset
 * ---------------------------------------------------------------------- */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	overflow-x: clip; /* clip = no horiz scroll, but does NOT create scroll container — keeps position:sticky working */
	max-width: 100vw;
}

body {
	overflow-x: clip; /* same reason — hidden would break sticky header */
	max-width: 100vw;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ol,
ul {
	margin: 0;
}

ol[class],
ul[class] {
	padding: 0;
	list-style: none;
}

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

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

button {
	background: none;
	border: 0;
	cursor: pointer;
}

table {
	border-collapse: collapse;
	width: 100%;
}

/* -------------------------------------------------------------------------
 * 3. Base elements
 * ---------------------------------------------------------------------- */

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

h1,
h2,
h3,
h4,
h5,
h6 {
	color: var(--ifja-text);
	font-weight: 700;
	line-height: var(--ifja-leading-tight);
	letter-spacing: -0.011em;
	text-wrap: balance;
}

h1 {
	font-size: var(--ifja-text-2xl);
}

h2 {
	font-size: var(--ifja-text-xl);
}

h3 {
	font-size: var(--ifja-text-lg);
}

h4,
h5 {
	font-size: var(--ifja-text-base);
}

h6 {
	color: var(--ifja-text-muted);
	font-size: var(--ifja-text-sm);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

@media (min-width: 768px) {
	h1 {
		font-size: var(--ifja-text-3xl);
	}
}

p {
	text-wrap: pretty;
}

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

a:hover,
a:focus {
	color: var(--ifja-accent-hover);
	text-decoration: underline;
}

strong,
b {
	font-weight: 600;
}

small {
	font-size: var(--ifja-text-sm);
}

code,
kbd,
pre,
samp {
	font-family: var(--ifja-font-mono);
	font-size: var(--ifja-text-sm);
}

hr {
	height: 0;
	margin: var(--ifja-space-6) 0;
	border: 0;
	border-top: 1px solid var(--ifja-border);
}

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

/* -------------------------------------------------------------------------
 * 4. Accessibility
 * ---------------------------------------------------------------------- */

:focus-visible {
	outline: 2px solid var(--ifja-accent);
	outline-offset: 2px;
}

/* Only suppress the default ring where a custom ring is provided. */
:focus:not(:focus-visible) {
	outline: none;
}

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

.skip-link:focus {
	position: fixed !important;
	z-index: 100;
	top: var(--ifja-space-2);
	left: var(--ifja-space-2);
	clip: auto;
	clip-path: none;
	width: auto;
	height: auto;
	padding: var(--ifja-space-3) var(--ifja-space-4);
	border-radius: var(--ifja-radius-md);
	background-color: var(--ifja-bg);
	box-shadow: var(--ifja-shadow-md);
	color: var(--ifja-accent);
	font-size: var(--ifja-text-sm);
	font-weight: 600;
	text-decoration: none;
}

/* The main landmark is focused programmatically by the skip link. */
#ifja-content:focus {
	outline: none;
}

@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;
		scroll-behavior: auto !important;
	}
}
