/***
 * Mängude loend.
 *
 * Varem oli see paljas andmetabel, kus kõige rasvasem veerg oli ID ehk
 * sisemine võti. Mäng ei olnud asi, vaid rida. Nüüd on iga mäng plaat:
 * nimi ees, teemad all, numbrid paremal, ID kõige vaiksem.
 ***/

.gamelist-head {
	display: flex;
	align-items: flex-end;
	gap: 18px;
	flex-wrap: wrap;
	margin: 34px 0 22px 0;
}

.gamelist-head h1 {
	margin: 0;
	font-size: clamp(26px, 3vw, 38px);
	line-height: 1;
	font-weight: 700;
	letter-spacing: -.02em;
}

.gamelist-count {
	font-family: var(--font-numeric);
	font-size: 18px;
	color: var(--text-muted);
	padding-bottom: 2px;
}

.gamelist-head .btn-new {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	border: 0;
	border-radius: 11px;
	background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
	color: var(--accent-dark) !important;
	font-family: var(--font-ui);
	font-size: 16px;
	font-weight: 700;
	padding: 13px 22px;
	cursor: pointer;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 8px 22px rgba(255, 140, 26, .32);
	transition: filter var(--transition-time) ease, transform var(--transition-time) ease;
}
/* AI-märk (site.css): vahe tuleb nupu gap-ist */
.gamelist-head .btn-new .ai-mark { margin: 0; font-size: 13px; }
.gamelist-head .btn-new:hover {
	filter: brightness(1.08);
	transform: translateY(-2px);
	color: var(--accent-dark) !important;
}

/* Suurtele / Väikestele (list.html): nähtav on ainult selle tüübi
   uue mängu nupp, mille loend parajasti näitab */
.gamelist-head:not(.is-kids) .btn-new-kids,
.gamelist-head.is-kids .btn-new:not(.btn-new-kids) { display: none; }

/* Sama lüliti mis avalehel (home.css .home-mode), siin pealkirja real */
.gamelist-mode {
	display: inline-flex;
	gap: 4px;
	padding: 4px;
	margin-bottom: -3px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: var(--surface);
}
.gamelist-mode-option {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	height: 36px;
	padding: 0 16px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--text-dim);
	font-family: var(--font-ui);
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: background var(--transition-time) ease, color var(--transition-time) ease;
}
.gamelist-mode-option:hover { background: var(--surface-strong); color: var(--text); }
.gamelist-mode-option[aria-checked="true"] {
	background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 6px 16px -6px rgba(255, 140, 26, .6);
	color: var(--accent-dark);
	cursor: default;
}
.gamelist-mode-option[data-mode="kids"] {
	font-family: var(--font-kids);
	font-size: 15px;
	font-weight: 600;
}
.gamelist-mode-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Ikoonid: suurtel laud (3x2 lahtrit), väikestel kolm värvilist varianti */
.gamelist-mode-icon { display: inline-grid; }
.gamelist-mode-grid {
	grid-template-columns: repeat(3, 8px);
	gap: 2px;
}
.gamelist-mode-grid i {
	height: 6px;
	border-radius: 2px;
	background: currentColor;
	opacity: .85;
}
.gamelist-mode-grid i:nth-child(5) { opacity: .3; }
.gamelist-mode-shapes {
	grid-auto-flow: column;
	gap: 3px;
}
.gamelist-mode-shapes i {
	width: 9px;
	height: 9px;
	border-radius: 2px;
}
.gamelist-mode-shapes i:nth-child(1) { background: var(--kids-opt-0); }
.gamelist-mode-shapes i:nth-child(2) { background: var(--kids-opt-1); border-radius: 50%; }
.gamelist-mode-shapes i:nth-child(3) { background: var(--kids-opt-2); transform: rotate(45deg) scale(.85); }

/* --- Filter: kaks vahekaarti, mitte hõljuv pill --- */

.gamelist-bar {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 18px;
	border-bottom: 1px solid var(--border-dim);
}

.gamelist-bar a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 11px 16px;
	color: var(--text-muted) !important;
	font-size: 14px;
	font-weight: 600;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	transition: color var(--transition-time) ease, border-color var(--transition-time) ease;
}
.gamelist-bar a:hover { color: var(--text) !important; }
.gamelist-bar a.active {
	color: var(--text) !important;
	border-bottom-color: var(--gold);
}
.gamelist-bar .star { width: 15px; height: auto; }

/* Teises keeles mängu keelekood nime kõrval */
.gamelist-langtag {
	text-transform: uppercase;
	letter-spacing: .06em;
}

/* Külalisele: mängud on näha, mängimiseks tuleb sisse logida */
#MyGameListData.is-guest .col-label { display: none; }
.gamelist-guest a {
	color: var(--accent-light) !important;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: nowrap;
}

/* Otsinguväli tõstame vahekaartide reale paremale */
#MyGameListData_filter {
	float: none !important;
	margin-left: auto;
	padding-bottom: 6px;
}
#MyGameListData_filter label {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--text-muted);
	font-size: 14px;
	margin: 0;
}
#MyGameListData_filter input {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	color: var(--text);
	font-family: var(--font-ui);
	font-size: 14px;
	/* paremal ruum otsinguvälja ristile (site.css) */
	padding: 8px 36px 8px 12px;
	min-width: 220px;
}
#MyGameListData_filter input:focus {
	outline: none;
	border-color: rgba(245, 196, 81, .6);
}
/* Metro pakib otsinguvälja oma raami sisse ja lisab nupurühma - koos
   minu raamiga andis see kaks kasti kõrvuti. */
#MyGameListData_filter .input,
#MyGameListData_filter .form-control {
	background: transparent;
	border: 0;
	box-shadow: none;
	padding: 0;
	margin: 0;
	min-height: 0;
}
#MyGameListData_filter .prepend { margin: 0 !important; }

/* --- Loend --- */

#MyGameListData {
	border-spacing: 0 8px;
	width: 100% !important;
	table-layout: fixed;
}

#MyGameListData thead { display: none; }   /* pealkirjad on plaatidel endal */

#MyGameListData tbody tr { cursor: pointer; }

#MyGameListData tbody td {
	background: var(--surface);
	border-top: 1px solid var(--border-dim);
	border-bottom: 1px solid var(--border-dim);
	padding: 16px 18px;
	vertical-align: middle;
	transition: background var(--transition-time) ease, border-color var(--transition-time) ease;
}
#MyGameListData tbody tr:hover td {
	background: var(--surface-strong);
	border-color: var(--border);
}

.gamelist-name {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 17px;
	font-weight: 600;
	color: var(--text);
	margin-bottom: 4px;
}

.gamelist-topics {
	font-size: 14px;
	color: var(--text-muted);
	line-height: 1.4;
}
.gamelist-topics.is-empty { color: var(--text-faint); font-style: italic; }

.gamelist-label {
	display: inline-block;
	border-radius: 999px;
	padding: 3px 10px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	border: 1px solid var(--border);
	color: var(--text-muted);
	white-space: nowrap;
}
.gamelist-label.is-mine {
	border-color: rgba(245, 196, 81, .45);
	color: var(--gold);
}
.gamelist-label.is-suggested {
	border-color: rgba(255, 140, 26, .5);
	color: var(--accent-light);
}
.gamelist-label.private {
	border-color: rgba(255, 255, 255, .18);
	color: var(--text-muted);
}

/* Numbrid paremal: väärtus kullas, silt vaikselt alla */
.gamelist-number {
	text-align: right;
	white-space: nowrap;
}
.gamelist-number b {
	display: block;
	font-family: var(--font-numeric);
	font-size: 22px;
	font-weight: 600;
	line-height: 1;
	color: var(--gold);
}
.gamelist-number span {
	display: block;
	margin-top: 3px;
	font-size: 12px;
	color: var(--text-muted);
}
.gamelist-number.is-empty b,
.gamelist-number b.is-empty { color: var(--text-faint); }

/* Soovituste vaate selgitus vahekaartide all */
.gamelist-hint {
	margin: -4px 0 18px;
	max-width: 62ch;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--text-muted);
}

.gamelist-id {
	text-align: right;
	font-family: var(--font-numeric);
	font-size: 13px;
	color: var(--text-faint);
	white-space: nowrap;
}

.col-label   { width: 12%; }
.col-number { width: 11%; }
.col-id     { width: 6%; }
.col-date   { width: 10%; }

/* Kuupäev ei ole punkt - kuld jääb punktidele (theme.css), kuupäev on
   tavalises tekstivärvis ja väiksem */
.gamelist-date b {
	font-size: 17px;
	color: var(--text-dim);
}
.gamelist-date-inner { display: block; }
.col-delete { width: 64px; }

/* --- Kustutamine (ainult admin) ---
   Prügikast on vaikne, kuni rida pole hiire all - see on koristustööriist,
   mitte mängu osa. Esimene klõps paneb ta valvesse: nupp venib laiaks,
   läheb punaseks ja küsib «Kustuta?». Alles teine klõps kustutab. */

#MyGameListData tbody td.gamelist-delete-cell {
	padding-left: 0;
	padding-right: 12px;
	text-align: right;
	white-space: nowrap;
}

.gamelist-delete {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0;
	height: 36px;
	min-width: 36px;
	padding: 0 9px;
	border: 1px solid transparent;
	border-radius: 999px;
	background: transparent;
	color: var(--text-faint);
	font-family: var(--font-ui);
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
	opacity: .55;
	transition: opacity var(--transition-time) ease,
	            color var(--transition-time) ease,
	            background var(--transition-time) ease,
	            border-color var(--transition-time) ease,
	            gap var(--transition-time) var(--transition-curve);
}
.gamelist-delete svg { flex: 0 0 auto; }

#MyGameListData tbody tr:hover .gamelist-delete { opacity: 1; }
.gamelist-delete:hover,
.gamelist-delete:focus-visible {
	opacity: 1;
	color: var(--wrong);
	border-color: var(--border);
	outline: none;
}

.gamelist-delete-confirm {
	display: inline-block;
	max-width: 0;
	overflow: hidden;
	white-space: nowrap;
	transition: max-width .22s var(--transition-curve);
}

.gamelist-delete.is-armed {
	opacity: 1;
	gap: 7px;
	padding: 0 14px 0 11px;
	color: var(--wrong);
	background: var(--wrong-bg);
	border-color: var(--wrong);
}
.gamelist-delete.is-armed .gamelist-delete-confirm { max-width: 90px; }

.gamelist-delete.is-busy {
	opacity: 1;
	color: var(--wrong);
	pointer-events: none;
	animation: gamelist-delete-pulse .8s ease-in-out infinite alternate;
}
.gamelist-delete.is-failed {
	opacity: 1;
	color: var(--wrong);
	animation: gamelist-delete-shake .36s ease;
}

@keyframes gamelist-delete-pulse { from { opacity: 1; } to { opacity: .35; } }
@keyframes gamelist-delete-shake {
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

/* Kustutatud rida vajub enne tabeli uuesti laadimist ära, et oleks näha,
   mis kadus - muidu vahetub loend lihtsalt välja. */
#MyGameListData tbody tr.is-deleted td {
	opacity: 0;
	transform: translateX(24px);
	transition: opacity .3s ease, transform .3s var(--transition-curve);
}

/* --- Lehekülgede nupud ja tühi olek --- */

#MyGameListData_paginate { padding-top: 18px; }
#MyGameListData_wrapper .dataTables_empty {
	background: transparent !important;
	border: 1px dashed var(--border) !important;
	border-radius: var(--radius-lg) !important;
	color: var(--text-muted);
	text-align: center;
	padding: 46px 20px !important;
	font-size: 15px;
}

@media screen and (max-width: 900px) {
	.col-label, .col-id { display: none; }
	.col-number { width: 84px; }
	.gamelist-head { margin-top: 22px; }
	.gamelist-head .btn-new { margin-left: 0; width: 100%; justify-content: center; }
	.gamelist-mode { margin-bottom: 0; }
	#MyGameListData tbody td { padding: 13px 14px; }
	#MyGameListData_filter input { min-width: 0; width: 100%; }
	.gamelist-bar { flex-wrap: wrap; }
	#MyGameListData_filter { margin-left: 0; width: 100%; }
}

/* Telefonis mahub ridadele ainult nimi, teemad ja üks number. Ülejäänu
   ei kao ära, vaid kolib nime alla teemade kõrvale. */
@media screen and (max-width: 640px) {
	#MyGameListData { table-layout: auto; }
	.col-number:nth-of-type(4),
	#MyGameListData tbody td:nth-child(4),
	.col-date,
	#MyGameListData tbody td.col-date { display: none; }
	#MyGameListData tbody td { padding: 12px; }
	.gamelist-name { font-size: 16px; flex-wrap: wrap; gap: 7px; }
	.gamelist-topics { font-size: 13px; }
	.gamelist-number b { font-size: 18px; }
	.gamelist-number span { font-size: 11px; }
}

/* Telefonis ei mahu otsinguväli vahekaartide kõrvale: väli kahanes 55 px
   peale ja silt jäi sellest välja. Omaette rida, terve laius. */
@media screen and (max-width: 700px) {
	#MyGameListData_filter {
		margin-left: 0;
		/* flex-basis, mitte width: filtril on flex: 1 1 0%, mis tühistab
		   width: 100% ära ja jätab talle vaid osa ülejäänud ruumist
		   (mõõdetult 95 px 346-st). */
		flex: 0 0 100%;
		width: 100%;
		padding-bottom: 12px;
	}
	#MyGameListData_filter label { width: 100%; }
	#MyGameListData_filter input { min-width: 0; width: 100%; }
}
