/* Statistics pages (/tilastot/joukkue/, /tilastot/peli/, ...): the markup comes from the
   floorball-stats project (stats/app), the look from the site. Loaded only on these pages. */

.stats {
	/* Names used by the statistics markup itself (charts, record modal) */
	--card-bg: var(--surface);
	--card-border: var(--border);
	--pill-bg: var(--surface);
	--pill-border: var(--border);
	--primary-accent: var(--red);
	--primary-text: var(--on-red);
	--text-main: var(--text);
	--text-muted: var(--muted);
	/* Chart series: the club, the other team / assists */
	--chart-own: var(--red);
	--chart-other: var(--muted);
	--row-hover: color-mix(in srgb, var(--red) 7%, transparent);
	--row-stripe: color-mix(in srgb, var(--text) 3%, transparent);

	min-height: 50vh;
	font-size: .95rem;
	line-height: 1.5;
}
.stats-section { padding-top: clamp(20px, 4vw, 36px); }

/* Loading, errors */
.stats-status { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px 0; color: var(--muted); font-weight: 600; text-align: center; }
.stats-status a { color: var(--red); }
.stats-spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--red); animation: stats-spin .8s linear infinite; }
@keyframes stats-spin { to { transform: rotate(360deg); } }

/* ---------- Links between the pages ---------- */
.stats-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: clamp(18px, 4vw, 28px); }
.stats-nav a, .stats p > a, .stats p:has(> a) > b, .stats h3 a, .stats table[border="1"] a, .stats table[border="1"] b {
	display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
	background: var(--surface); border: 1px solid var(--border); color: var(--text);
	font: 600 .86rem/1.2 var(--body); text-transform: none; letter-spacing: 0; font-style: normal; text-decoration: none;
	transition: border-color .15s, background .15s;
}
.stats-nav a:hover, .stats p > a:hover, .stats h3 a:hover, .stats table[border="1"] a:hover { border-color: var(--red); }
.stats-nav .stats-back { color: var(--muted); }
.stats-nav .stats-back::before { content: '←'; }
.stats p:has(> a) { display: flex; flex-wrap: wrap; gap: 8px; }

/* Season and league menus (tables of links); the current one is bold */
.stats table[border="1"] { display: flex; flex-wrap: wrap; gap: 8px; width: auto; margin: 0 0 18px; background: none; border: 0; }
.stats table[border="1"] tbody, .stats table[border="1"] tr, .stats table[border="1"] td { display: contents; }
.stats table[border="1"] b, .stats p:has(> a) > b { background: var(--red); border-color: var(--red); color: var(--on-red); }

/* Report tabs */
.stats .tabs-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.stats .tab-item {
	padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
	color: var(--muted); font-weight: 600; font-size: .86rem; text-decoration: none; transition: color .15s, border-color .15s;
}
.stats .tab-item:hover { color: var(--text); border-color: var(--red); }
.stats .tab-item.active { background: var(--red); border-color: var(--red); color: var(--on-red); }

.stats select {
	appearance: none; -webkit-appearance: none; cursor: pointer;
	padding: 8px 38px 8px 14px; border-radius: 999px; border: 1px solid var(--border); background-color: var(--surface); color: var(--text);
	font: 600 .9rem/1.2 var(--body);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e00000' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.stats select:hover { border-color: var(--red); }

/* ---------- Headings ---------- */
.stats h2 {
	font-size: clamp(1.9rem, 6vw, 2.8rem); font-style: italic; margin: 0 0 .5em;
}
.stats h2::before { content: ''; display: inline-block; width: 10px; height: .8em; margin-right: 12px; background: var(--red); transform: skewX(-18deg); }
.stats h2 a { color: inherit; text-decoration-color: var(--red); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.stats h3 {
	display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
	font-size: clamp(1.4rem, 4vw, 1.75rem); margin: 32px 0 12px;
}
.stats h4 { color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.stats p { margin: 0 0 14px; }

/* ---------- Tables ---------- */
.stats .table-responsive {
	overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 24px;
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.stats .table-responsive table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: .86rem; font-variant-numeric: tabular-nums; }
.stats th {
	text-align: left; padding: 10px 12px; background: var(--surface-2); color: var(--muted);
	font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
}
.stats td { padding: 8px 12px; border-top: 1px solid var(--border); }
.stats tbody tr:nth-child(even) { background: var(--row-stripe); }
.stats tbody tr:hover > td { background: var(--row-hover); }
.stats .l { text-align: left; }
.stats .r { text-align: right; }
.stats .center { text-align: center; }
.stats .top { vertical-align: top; }
.stats .bottom { vertical-align: bottom; }

.stats table a { color: var(--text); font-weight: 600; text-decoration: none; }
.stats table a:hover { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }

/* Sorting (tablesorter) */
.stats table.tablesorter thead th { cursor: pointer; user-select: none; }
.stats table.tablesorter thead th:hover { color: var(--text); }
.stats .tablesorter-headerAsc, .stats .tablesorter-headerDesc { color: var(--red) !important; }
.stats .tablesorter-header-inner { display: inline; }
.stats .tablesorter-headerAsc::after { content: ' ▲'; font-size: .8em; }
.stats .tablesorter-headerDesc::after { content: ' ▼'; font-size: .8em; }

/* Totals, the club's row in a league table */
.stats .total, .stats tr.total td { background: var(--surface-2) !important; font-weight: 700; }
.stats .save, .stats tr.save td { background: var(--red-soft) !important; font-weight: 700; }
.stats tr.save > td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.stats .playerTable .result, .stats .playerTable .sum { background: var(--surface-2); font-weight: 700; }

/* Results: won / lost / tie, like the chips of the site */
.stats .win { color: var(--live); font-weight: 700; }
.stats .loss { color: var(--red); font-weight: 700; }
.stats .tie { color: var(--gold); font-weight: 700; }
.stats td.win a.black, .stats td.loss a.black, .stats td.tie a.black {
	display: inline-block; min-width: 54px; padding: 3px 10px; border-radius: 999px; text-align: center; text-decoration: none; font-weight: 700;
}
.stats td.win a.black { color: var(--live); background: var(--live-bg); }
.stats td.loss a.black { color: var(--red); background: var(--red-soft); }
.stats td.tie a.black { color: var(--gold); background: var(--gold-bg); }

/* Goals and penalties of a game: the period rows, own goals */
.stats td.period { padding-top: 14px; background: var(--surface-2); color: var(--red); font: italic 800 1.05rem/1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
/* The club's own goals and penalties */
.stats tr.own > td { font-weight: 600; }
.stats tr.own > td:first-child { box-shadow: inset 4px 0 0 var(--red); }

/* Records: the groups and record names */
.stats .recordTable { background: none; border: 0; box-shadow: none; }
.stats .recordTable td { white-space: normal; }
.stats td.recordsettype1 { padding: 22px 12px 8px; background: none !important; border: 0; font: italic 800 1.6rem/1 var(--display); text-transform: uppercase; color: var(--text); }
.stats td.recordsettype2 { padding: 14px 12px 8px; background: none !important; color: var(--red); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }

/* Charts (Google Charts draw at a fixed size; wide ones scroll) */
.stats .google-chart { max-width: 100%; border-radius: var(--radius-sm) !important; box-shadow: var(--shadow) !important; backdrop-filter: none !important; }

/* Record modal (ennatykset): the site's card look */
.stats .record-modal { border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stats .record-modal-content h2 { font-size: 1.6rem; }

@media (max-width: 640px) {
	.stats { font-size: .9rem; }
	.stats th { padding: 9px 8px; }
	.stats td { padding: 7px 8px; }
	.stats .table-responsive table { font-size: .8rem; }
	.stats-nav a, .stats p > a, .stats p:has(> a) > b, .stats h3 a, .stats table[border="1"] a, .stats table[border="1"] b { padding: 6px 12px; font-size: .8rem; }
}
