/**
 * Judo Competition Results — front-end styles.
 *
 * Self-contained CSS scoped to .jcr-results.
 * Does not depend on theme styles — works consistently across any WordPress theme.
 *
 * @package JudoCompetitionResults
 */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
	/* Typography */
	--jcr-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--jcr-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	--jcr-base-size: 15px;
	--jcr-line-height: 1.5;

	/* Colors — neutral */
	--jcr-color-text: #1e293b;
	--jcr-color-text-secondary: #64748b;
	--jcr-color-text-muted: #94a3b8;
	--jcr-color-border: #e2e8f0;
	--jcr-color-border-strong: #cbd5e1;
	--jcr-color-bg: #ffffff;
	--jcr-color-bg-subtle: #f8fafc;
	--jcr-color-bg-hover: #f1f5f9;

	/* Colors — accent */
	--jcr-color-primary: #2563eb;
	--jcr-color-primary-light: rgba(37, 99, 235, 0.08);
	--jcr-color-focus: #2563eb;

	/* Colors — medals */
	--jcr-badge-gold: #ca8a04;
	--jcr-badge-silver: #9ca3af;
	--jcr-badge-bronze: #b45309;

	/* Colors — filters */
	--jcr-filter-bg: #f8fafc;
	--jcr-filter-bg-active: #fffbeb;
	--jcr-filter-border-active: #f59e0b;
	--jcr-filter-status-color: #b45309;

	/* Colors — header */
	--jcr-header-bg: #f0fdf4;
	--jcr-header-border: #bbf7d0;

	/* Colors — points badge */
	--jcr-points-bg: #eff6ff;
	--jcr-points-color: #3b82f6;

	/* Colors — reset button */
	--jcr-reset-bg: #f1f5f9;
	--jcr-reset-color: #475569;
	--jcr-reset-hover-bg: #ef4444;
	--jcr-reset-hover-color: #ffffff;

	/* Radius */
	--jcr-radius-sm: 4px;
	--jcr-radius: 6px;
	--jcr-radius-lg: 10px;
	--jcr-radius-xl: 14px;

	/* Shadows */
	--jcr-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
	--jcr-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);

	/* Transitions */
	--jcr-transition: 0.15s ease;
}

/* ============================================================
   2. SCOPED RESET
   ============================================================ */
.jcr-results {
	font-family: var(--jcr-font);
	font-size: var(--jcr-base-size);
	line-height: var(--jcr-line-height);
	color: var(--jcr-color-text);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

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

.jcr-results h1,
.jcr-results h2,
.jcr-results h3,
.jcr-results p,
.jcr-results ul,
.jcr-results li,
.jcr-results table,
.jcr-results thead,
.jcr-results tbody,
.jcr-results tr,
.jcr-results th,
.jcr-results td {
	margin: 0;
	padding: 0;
}

.jcr-results ul {
	list-style: none;
}

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

/* ============================================================
   4. HEADER
   ============================================================ */
.jcr-header {
	background: var(--jcr-header-bg);
	border: 1px solid var(--jcr-header-border);
	border-radius: var(--jcr-radius-xl);
	padding: 1.25rem 1.5rem;
	margin-bottom: 0;
}

.jcr-header h1 {
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--jcr-color-text);
	margin: 0 0 0.25rem 0;
}

.jcr-header p {
	font-size: 0.875rem;
	color: var(--jcr-color-text-secondary);
	margin: 0;
	line-height: 1.4;
}

/* ============================================================
   5. FILTERS
   ============================================================ */
.jcr-filters {
	display: flex;
	gap: 0.625rem;
	align-items: center;
	flex-wrap: wrap;
	margin: 0.75rem 0 0 0;
	padding: 0.75rem 1rem;
	background: var(--jcr-filter-bg);
	border: 1px solid var(--jcr-color-border);
	border-radius: var(--jcr-radius-xl);
	transition: background var(--jcr-transition), border-color var(--jcr-transition);
}

.jcr-filters select,
.jcr-filters input[type="search"] {
	height: 2.375rem;
	padding: 0 0.75rem;
	border-radius: var(--jcr-radius);
	border: 1px solid var(--jcr-color-border-strong);
	font-family: var(--jcr-font);
	font-size: 0.8125rem;
	line-height: 2.375rem;
	color: var(--jcr-color-text);
	background: var(--jcr-color-bg);
	outline: none;
	transition: border-color var(--jcr-transition), box-shadow var(--jcr-transition);
	-webkit-appearance: none;
	appearance: none;
}

.jcr-filters select {
	padding-right: 2rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 10px 6px;
	cursor: pointer;
}

.jcr-filters input[type="search"] {
	padding-left: 2.125rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M10 2a8 8 0 105.293 14.293l4.707 4.707 1.414-1.414-4.707-4.707A8 8 0 0010 2zm0 2a6 6 0 110 12 6 6 0 010-12z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: 0.625rem center;
	background-size: 14px;
}

.jcr-filters select:focus,
.jcr-filters input[type="search"]:focus {
	border-color: var(--jcr-color-focus);
	box-shadow: 0 0 0 3px var(--jcr-color-primary-light);
}

.jcr-filters select:focus-visible,
.jcr-filters input[type="search"]:focus-visible {
	outline: 2px solid var(--jcr-color-focus);
	outline-offset: 1px;
}

/* Reset button */
#jcr-reset-filters {
	margin-left: auto;
	height: 2.375rem;
	padding: 0 0.875rem;
	border-radius: var(--jcr-radius);
	border: 1px solid var(--jcr-color-border-strong);
	background: var(--jcr-reset-bg);
	color: var(--jcr-reset-color);
	font-family: var(--jcr-font);
	font-size: 0.8125rem;
	font-weight: 500;
	cursor: pointer;
	transition: all var(--jcr-transition);
}

#jcr-reset-filters:hover {
	background: var(--jcr-reset-hover-bg);
	border-color: var(--jcr-reset-hover-bg);
	color: var(--jcr-reset-hover-color);
}

#jcr-reset-filters:focus-visible {
	outline: 2px solid var(--jcr-color-focus);
	outline-offset: 2px;
}

/* Filter active state */
body.jcr-has-filter .jcr-filters {
	background: var(--jcr-filter-bg-active);
	border-color: var(--jcr-filter-border-active);
}

/* Filter status indicator */
.jcr-filter-status {
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--jcr-filter-status-color);
	margin: 0;
	padding: 0.375rem 0.5rem 0;
	min-height: 1.5rem;
	opacity: 0;
	transform: translateY(-2px);
	transition: opacity 0.3s ease, transform 0.2s ease;
}

body.jcr-has-filter .jcr-filter-status {
	opacity: 1;
	transform: translateY(0);
}

/* ============================================================
   6. CATEGORY SECTIONS
   ============================================================ */
.jcr-category {
	margin-top: 1.75rem;
}

.jcr-category h2 {
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--jcr-color-text);
	padding-bottom: 0.5rem;
	margin-bottom: 0.75rem;
	border-bottom: 2px solid var(--jcr-color-primary);
	line-height: 1.3;
}

/* ============================================================
   7. RANKING TABLE (individual)
   ============================================================ */
.jcr-ranking {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var(--jcr-color-border);
	border-radius: var(--jcr-radius-lg);
	overflow: hidden;
	box-shadow: var(--jcr-shadow-sm);
}

/* Head */
.jcr-ranking thead th {
	background: var(--jcr-color-bg-subtle);
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--jcr-color-text-secondary);
	padding: 0.625rem 0.875rem;
	text-align: left;
	border-bottom: 1px solid var(--jcr-color-border);
}

.jcr-ranking thead th:first-child {
	text-align: center;
	width: 5.5rem;
}

/* Body cells */
.jcr-ranking tbody td {
	padding: 0.5rem 0.875rem;
	font-size: 0.875rem;
	color: var(--jcr-color-text);
	border-bottom: 1px solid var(--jcr-color-border);
	vertical-align: middle;
}

.jcr-ranking tbody tr:last-child td {
	border-bottom: none;
}

.jcr-ranking tbody td:first-child {
	text-align: center;
	font-weight: 600;
	white-space: nowrap;
}

/* Zebra striping */
.jcr-ranking tbody tr:nth-child(even) {
	background: var(--jcr-color-bg-subtle);
}

/* Hover */
.jcr-ranking tbody tr {
	transition: background var(--jcr-transition);
}

.jcr-ranking tbody tr:hover {
	background: var(--jcr-color-bg-hover);
}

/* Focus within (keyboard navigation) */
.jcr-ranking tbody tr:focus-within {
	outline: 2px solid var(--jcr-color-focus);
	outline-offset: -2px;
}

/* Rank suffix */
.jcr-ranking tbody td:first-child small {
	font-size: 0.6875rem;
	font-weight: 400;
	color: var(--jcr-color-text-muted);
}

/* ============================================================
   8. MEDALS / BADGES
   ============================================================ */
.jcr-badge {
	font-size: 1.125em;
	vertical-align: middle;
	margin-right: 0.125rem;
}

.jcr-badge.gold {
	color: var(--jcr-badge-gold);
}

.jcr-badge.silver {
	color: var(--jcr-badge-silver);
}

.jcr-badge.bronze {
	color: var(--jcr-badge-bronze);
}

/* ============================================================
   9. POINTS BADGE (GRCH)
   ============================================================ */
.jcr-points {
	display: inline-block;
	font-size: 0.6875rem;
	font-weight: 600;
	color: var(--jcr-points-color);
	background: var(--jcr-points-bg);
	padding: 0.0625rem 0.4375rem;
	border-radius: 1rem;
	margin-left: 0.375rem;
	vertical-align: middle;
	white-space: nowrap;
}

/* ============================================================
   10. TEAM BLOCKS
   ============================================================ */
.jcr-team-block {
	background: var(--jcr-color-bg);
	border: 1px solid var(--jcr-color-border);
	border-radius: var(--jcr-radius-lg);
	padding: 1rem 1.25rem;
	margin-bottom: 0.75rem;
	box-shadow: var(--jcr-shadow-sm);
	transition: box-shadow var(--jcr-transition);
}

.jcr-team-block:hover {
	box-shadow: var(--jcr-shadow);
}

.jcr-team-block h3 {
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.4;
	color: var(--jcr-color-text);
	margin: 0 0 0.625rem 0;
}

.jcr-team-block h3 small {
	font-size: 0.8125rem;
	font-weight: 400;
	color: var(--jcr-color-text-secondary);
}

.jcr-team-block ul {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
	gap: 0.25rem;
}

.jcr-team-block li {
	font-size: 0.875rem;
	padding: 0.375rem 0.625rem;
	border-radius: var(--jcr-radius);
	transition: background var(--jcr-transition);
}

.jcr-team-block li:hover {
	background: var(--jcr-color-bg-hover);
}

.jcr-team-block li small {
	font-size: 0.75rem;
	color: var(--jcr-color-text-muted);
	margin-left: 0.25rem;
}

/* ============================================================
   11. EMPTY STATE
   ============================================================ */
.jcr-results p {
	font-size: 0.875rem;
	color: var(--jcr-color-text-secondary);
	margin: 0;
}

.jcr-category > p {
	padding: 1rem;
	background: var(--jcr-color-bg-subtle);
	border-radius: var(--jcr-radius);
	text-align: center;
	font-style: italic;
}

/* ============================================================
   12. RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
	.jcr-header {
		padding: 1rem;
	}

	.jcr-header h1 {
		font-size: 1.25rem;
	}

	.jcr-filters {
		flex-direction: column;
		align-items: stretch;
	}

	#jcr-reset-filters {
		margin-left: 0;
		width: 100%;
	}

	/* Horizontal scroll for tables on small screens */
	.jcr-category {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.jcr-ranking {
		min-width: 28rem;
	}

	.jcr-team-block ul {
		grid-template-columns: 1fr;
	}
}

/* ============================================================
   13. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {

	.jcr-results *,
	.jcr-results *::before,
	.jcr-results *::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
