/*
 * Systeme de design — extrait des maquettes de design/.
 *
 * Trois couleurs portent le sens, et une seule chacune :
 *   bleu  = action (boutons, liens actifs, onglet courant) ;
 *   vert  = points et reussite (jamais un bouton) ;
 *   rouge = erreur et mauvais pronostic.
 *
 * Tout le reste est une nuance de bleu-noir. Les cartes se distinguent du fond
 * par la clarte, pas par la bordure : celle-ci reste a peine visible, elle
 * borne sans decouper.
 */

:root {
	/* fonds, du plus profond au plus clair */
	--bg: #070d17;
	--bg-2: #0a121e;
	--surface: #101a28;
	--surface-2: #16212f;
	--surface-3: #1d2937;

	--border: #1d2836;
	--border-2: #2a3748;

	--text: #eaf0f8;
	--muted: #8695ab;
	--muted-2: #64748b;

	/* bleu d'action */
	--accent: #2b52ec;
	--accent-2: #4a72ff;
	--accent-soft: rgba(43, 82, 236, 0.16);

	/* vert des points */
	--positive: #5fdf29;
	--positive-dim: #3fa81c;
	--positive-soft: rgba(95, 223, 41, 0.13);

	--danger: #e5455c;
	--danger-soft: rgba(229, 69, 92, 0.13);
	--warn: #e8a33c;
	--warn-soft: rgba(232, 163, 60, 0.12);
	--upset: #7c6bf0;

	/* podium */
	--gold: #f4b004;
	--silver: #ccd4dc;
	--bronze: #e0975c;

	--radius: 16px;
	--radius-sm: 10px;
	--radius-lg: 22px;

	--shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	--shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);

	/*
	 * Titres : une grotesque condensee si le systeme en a une, sinon la police
	 * d'interface resserree a la main. Aucune @font-face — la CSP n'autorise
	 * aucune origine externe, et une police manquante ne doit rien casser.
	 */
	--font-display: 'Inter Tight', 'Archivo', 'Roboto Condensed', 'Helvetica Neue', system-ui,
		sans-serif;

	--nav-h: 60px;
	--bottom-h: 62px;

	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family:
		system-ui,
		-apple-system,
		'Segoe UI',
		Roboto,
		sans-serif;
	font-size: 16px;
	-webkit-text-size-adjust: 100%;
}

a {
	color: inherit;
	text-decoration: none;
}

/*
 * Accessibilite : le focus doit rester visible partout, y compris sur les
 * elements qui redefinissent leur bordure (equipes, splits, onglets). Un
 * `outline` decale, pose sur tout ce qui est focalisable au clavier.
 */
:focus-visible {
	outline: 2px solid var(--accent-2);
	outline-offset: 2px;
	border-radius: 4px;
}

h1,
h2,
h3 {
	margin: 0 0 0.6rem;
	line-height: 1.15;
	font-family: var(--font-display);
	font-weight: 800;
	letter-spacing: -0.03em;
}

h1 {
	font-size: 1.6rem;
}
h2 {
	font-size: 1.2rem;
}
h3 {
	font-size: 1rem;
	letter-spacing: -0.02em;
}

.app {
	max-width: 1140px;
	margin: 0 auto;
	padding: 0 1rem calc(var(--bottom-h) + 2rem);
}

/* Le bas de page n'a besoin de degager la barre mobile que si elle existe. */
@media (min-width: 860px) {
	.app {
		padding-bottom: 3rem;
	}
}

/* --- navigation haute (desktop) ------------------------------------------ */

.nav {
	position: sticky;
	top: 0;
	z-index: 20;
	background: rgba(7, 13, 23, 0.88);
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--border);
	margin: 0 -1rem 1.1rem;
	padding: 0 1rem;
	height: var(--nav-h);
	display: flex;
	align-items: center;
	gap: 1rem;
}

.nav__brand {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-family: var(--font-display);
	font-weight: 800;
	font-size: 1.05rem;
	letter-spacing: -0.03em;
	white-space: nowrap;
}
.nav__brand span {
	color: var(--accent-2);
}

.nav__links {
	display: flex;
	gap: 0.15rem;
	overflow-x: auto;
	scrollbar-width: none;
	flex: 1;
}
.nav__links::-webkit-scrollbar {
	display: none;
}

/*
 * Onglet courant souligne d'un trait bleu plutot que rempli : la maquette
 * garde la barre tres sobre, et le remplissage est reserve aux boutons.
 */
.nav__link {
	position: relative;
	display: flex;
	align-items: center;
	padding: 0 0.7rem;
	height: var(--nav-h);
	color: var(--muted);
	font-size: 0.92rem;
	font-weight: 500;
	white-space: nowrap;
}
.nav__link:hover {
	color: var(--text);
}
.nav__link[aria-current='page'] {
	color: var(--text);
	font-weight: 600;
}
.nav__link[aria-current='page']::after {
	content: '';
	position: absolute;
	left: 0.5rem;
	right: 0.5rem;
	bottom: 0;
	height: 3px;
	border-radius: 3px 3px 0 0;
	background: var(--accent-2);
}

/* La barre du haut disparait sur mobile : la barre du bas prend le relais. */
@media (max-width: 859px) {
	.nav__links {
		display: none;
	}
	.nav {
		justify-content: space-between;
	}
}

/* --- navigation basse (mobile, PWA) --------------------------------------- */

.bottom-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 30;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	background: rgba(4, 9, 17, 0.96);
	backdrop-filter: blur(12px);
	border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.2rem;
	height: var(--bottom-h);
	color: var(--muted);
	font-size: 0.68rem;
	font-weight: 500;
	letter-spacing: 0.01em;
}
.bottom-nav__item[aria-current='page'] {
	color: var(--accent-2);
	font-weight: 700;
}

@media (min-width: 860px) {
	.bottom-nav {
		display: none;
	}
}

/* --- blocs --------------------------------------------------------------- */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.1rem;
	margin-bottom: 0.85rem;
}

/* Panneau interieur : une liste posee dans une carte, un cran plus sombre. */
.panel {
	background: var(--bg-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

.section-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.9rem;
}
.section-head h2,
.section-head h3 {
	margin: 0;
}

.muted {
	color: var(--muted);
}
.small {
	font-size: 0.85rem;
}
.tiny {
	font-size: 0.75rem;
}
.center {
	text-align: center;
}
.row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.between {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
}
.wrap {
	flex-wrap: wrap;
}
.grow {
	flex: 1;
}
.stack > * + * {
	margin-top: 0.75rem;
}
.num {
	font-variant-numeric: tabular-nums;
}
.pts {
	color: var(--positive);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* --- pastilles ------------------------------------------------------------ */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.15rem 0.5rem;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 600;
	background: var(--surface-2);
	color: var(--muted);
	border: 1px solid var(--border);
	white-space: nowrap;
}
.badge--open {
	color: var(--positive);
	border-color: var(--positive-dim);
	background: var(--positive-soft);
}
.badge--locked {
	color: var(--warn);
	border-color: #5a4520;
}
.badge--live {
	color: var(--danger);
	border-color: #5a2530;
	background: var(--danger-soft);
}
.badge--upset {
	color: var(--upset);
	border-color: #3d3577;
}
.badge--accent {
	color: var(--accent-2);
	border-color: #2b3d7a;
	background: var(--accent-soft);
}

/*
 * Semaine de test. Volontairement la plus voyante des pastilles : elle doit se
 * remarquer sans lire, pour qu'un classement ou une grille de bac a sable ne
 * soit jamais pris pour la vraie saison.
 */
.badge--test {
	color: var(--warn);
	background: #3a2c12;
	border-color: var(--warn);
	letter-spacing: 0.06em;
}

/* Etat du systeme. Le libelle textuel accompagne toujours la couleur. */
.badge--sain {
	color: var(--positive);
	border-color: var(--positive-dim);
}
.badge--attention {
	color: var(--warn);
	border-color: #5a4520;
}
.badge--probleme {
	color: var(--danger);
	border-color: #5a2530;
}

/* Chip d'information : « 6 matchs restants ». Plus doux qu'une pastille. */
.chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.35rem 0.75rem;
	border-radius: 999px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--muted);
	font-size: 0.8rem;
	font-weight: 500;
	white-space: nowrap;
}
.chip--positive {
	color: var(--positive);
	background: var(--positive-soft);
	border-color: transparent;
}

.day-heading {
	margin: 1.5rem 0 0.5rem;
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	color: var(--muted-2);
	font-weight: 700;
}

/* --- boutons -------------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	padding: 0.6rem 1rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border-2);
	background: transparent;
	color: var(--text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition:
		background 0.14s ease,
		border-color 0.14s ease;
}
.btn:hover {
	background: var(--surface-2);
	border-color: #35455a;
}
.btn--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
.btn--primary:hover {
	background: var(--accent-2);
	border-color: var(--accent-2);
}
.btn--danger {
	color: var(--danger);
	border-color: #5a2530;
}
.btn--sm {
	padding: 0.4rem 0.7rem;
	font-size: 0.85rem;
}
.btn--block {
	width: 100%;
}
.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.btn:disabled:hover {
	background: transparent;
	border-color: var(--border-2);
}

/* Lien de pied de carte : « Voir tous les matchs › ». */
.more-link {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	padding: 0.7rem;
	color: var(--muted);
	font-size: 0.9rem;
	font-weight: 500;
}
.more-link:hover {
	color: var(--text);
}

/* --- hero ----------------------------------------------------------------- */

/*
 * Degrade seul, sans image : la maquette montre une photo de stade, mais
 * l'heberger localement alourdirait le conteneur et une source externe
 * violerait la CSP. Les deux halos radiaux en tiennent lieu.
 */
.hero {
	position: relative;
	overflow: hidden;
	border-radius: var(--radius-lg);
	border: 1px solid var(--border);
	padding: 2.4rem 1.5rem;
	margin-bottom: 1.1rem;
	background:
		radial-gradient(120% 140% at 85% 15%, rgba(43, 82, 236, 0.28) 0%, transparent 55%),
		radial-gradient(90% 120% at 10% 90%, rgba(95, 223, 41, 0.1) 0%, transparent 50%),
		linear-gradient(160deg, #12203a 0%, #0a1220 45%, #070d17 100%);
}

.hero__title {
	font-family: var(--font-display);
	font-weight: 800;
	letter-spacing: -0.04em;
	font-size: clamp(2rem, 7vw, 3.4rem);
	line-height: 1;
	margin: 0 0 0.7rem;
}
.hero__title span {
	color: var(--accent-2);
	display: block;
}
.hero__sub {
	color: #b9c6d8;
	max-width: 34rem;
	margin: 0 0 1.4rem;
	font-size: 1rem;
	line-height: 1.5;
}
.hero__actions {
	display: flex;
	gap: 0.7rem;
	flex-wrap: wrap;
}

@media (max-width: 520px) {
	.hero {
		padding: 1.7rem 1.15rem;
	}
	.hero__actions .btn {
		width: 100%;
	}
}

/* --- avatar --------------------------------------------------------------- */

.avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--surface-3);
	color: var(--text);
	font-weight: 700;
	font-family: var(--font-display);
	letter-spacing: -0.02em;
	overflow: hidden;
	flex: none;
	user-select: none;
}
.avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* --- listes de lignes ----------------------------------------------------- */

/*
 * Lignes separees par un filet, sans filet sous la derniere : le motif revient
 * sur les matchs, l'activite et le classement.
 */
.rows > * + * {
	border-top: 1px solid var(--border);
}

.line {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.8rem 0.9rem;
}
.line--link:hover {
	background: var(--surface-2);
}

/* --- tableaux ------------------------------------------------------------- */

.table-wrap {
	overflow-x: auto;
	margin: 0 -0.25rem;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}
th,
td {
	padding: 0.55rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
th {
	color: var(--muted);
	font-weight: 600;
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}
td.num,
th.num {
	text-align: right;
	font-variant-numeric: tabular-nums;
}
tr.me td {
	background: var(--accent-soft);
}

/* --- onglets -------------------------------------------------------------- */

.tabs {
	display: flex;
	gap: 0.35rem;
	overflow-x: auto;
	scrollbar-width: none;
	margin-bottom: 0.9rem;
	padding-bottom: 0.2rem;
}
.tabs::-webkit-scrollbar {
	display: none;
}
.tab {
	padding: 0.45rem 0.85rem;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--muted);
	font-size: 0.85rem;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	font: inherit;
	font-size: 0.85rem;
}
.tab:hover {
	color: var(--text);
}
.tab--active {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
	font-weight: 600;
}

/* --- match --------------------------------------------------------------- */

.game {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 0.95rem;
	margin-bottom: 0.7rem;
	/* La barre collante du haut ne doit pas recouvrir une carte visee par ancre. */
	scroll-margin-top: calc(var(--nav-h) + 0.75rem);
}
.game--locked {
	opacity: 0.9;
}

.game__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.8rem;
	font-size: 0.8rem;
	color: var(--muted);
}

.teams {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 0.5rem;
	align-items: stretch;
}

/*
 * Le bouton d'equipe porte l'enjeu — c'est l'element central du jeu, il ne
 * quitte jamais la carte. Selectionne, il passe au bleu (c'est une action) et
 * son enjeu au vert (ce sont des points).
 */
.team {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.4rem;
	padding: 0.7rem 0.4rem;
	border-radius: var(--radius-sm);
	border: 1.5px solid var(--border);
	background: var(--surface-2);
	color: var(--text);
	cursor: pointer;
	font: inherit;
	transition:
		border-color 0.12s ease,
		background 0.12s ease;
}
.team:disabled {
	cursor: default;
}
.team:not(:disabled):hover {
	border-color: var(--border-2);
}
.team--selected {
	border-color: var(--accent);
	background: var(--accent-soft);
}
.team--winner {
	border-color: var(--positive-dim);
}
.team__logo {
	width: 36px;
	height: 36px;
	object-fit: contain;
}
.team__abbr {
	font-weight: 700;
	font-size: 0.95rem;
	font-family: var(--font-display);
	letter-spacing: -0.01em;
}
.team__stake {
	font-size: 0.8rem;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}
.team--selected .team__stake {
	color: var(--positive);
}

.vs {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.2rem;
	color: var(--muted-2);
	font-size: 0.8rem;
	min-width: 3rem;
}

/*
 * Saisie de l'ecart : « Match nul », un champ libre avec le bonus annonce a
 * cote, et des raccourcis vers les ecarts les plus courants.
 */
.ecart {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-top: 0.6rem;
}

.ecart__saisie {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.ecart__courants {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(3.2rem, 1fr));
	gap: 0.35rem;
}

/*
 * Le bonus annonce. Vert parce que ce sont des points, et assez gros pour se
 * lire pendant qu'on tape : c'est lui qui transforme le choix d'un ecart en
 * arbitrage plutot qu'en devinette.
 */
.bonus {
	display: flex;
	align-items: baseline;
	gap: 0.35rem;
	color: var(--positive);
	font-variant-numeric: tabular-nums;
}
.bonus strong {
	font-size: 1.15rem;
	font-family: var(--font-display);
	letter-spacing: -0.02em;
}
.bonus .tiny {
	color: var(--muted);
}
.bonus--vide {
	color: var(--muted);
}

.split {
	padding: 0.55rem 0.3rem;
	border-radius: var(--radius-sm);
	border: 1.5px solid var(--border);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	cursor: pointer;
	transition:
		border-color 0.12s ease,
		background 0.12s ease;
}
.split:hover {
	border-color: var(--border-2);
}
.split--active {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent-2);
}
/* « Match nul » n'est pas un ecart : il occupe toute la largeur de sa ligne. */
.split--nul {
	grid-column: 1 / -1;
	font-weight: 500;
}

/* Raccourcis d'ecarts courants : plus discrets que la saisie elle-meme. */
.split--sm {
	padding: 0.35rem 0.3rem;
	font-size: 0.85rem;
}

.game--error {
	border-color: #5a2530;
}

/*
 * Barre d'enregistrement unique de la grille. Collee en bas de la fenetre : la
 * page fait seize matchs de haut, un bouton en fin de document serait hors de
 * vue pendant toute la saisie. Elle se pose au-dessus de la barre de
 * navigation mobile, jamais dessous.
 */
.barre-saisie {
	position: sticky;
	bottom: calc(var(--bottom-h) + 0.5rem);
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.8rem;
	flex-wrap: wrap;
	margin-top: 1rem;
	padding: 0.8rem 0.95rem;
	border: 1px solid var(--border-2);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
}
.barre-saisie__etat {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	min-width: 12rem;
	flex: 1;
}
.barre-saisie .btn {
	white-space: nowrap;
}

@media (min-width: 860px) {
	.barre-saisie {
		bottom: 0.75rem;
	}
}

/* --- champs --------------------------------------------------------------- */

input[type='number'],
input[type='text'],
input[type='email'],
select {
	width: 100%;
	padding: 0.6rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border-2);
	background: var(--bg-2);
	color: var(--text);
	font: inherit;
	text-align: center;
	font-variant-numeric: tabular-nums;
}
input:focus-visible,
select:focus-visible {
	outline: 2px solid var(--accent-2);
	outline-offset: 1px;
	border-color: var(--accent);
}
input:disabled {
	opacity: 0.55;
}

/* --- alertes -------------------------------------------------------------- */

.alert {
	padding: 0.75rem 0.9rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--surface-2);
	font-size: 0.9rem;
	margin-bottom: 0.75rem;
}
.alert--error {
	border-color: #5a2530;
	color: #ffb3bb;
	background: var(--danger-soft);
}
.alert--ok {
	border-color: var(--positive-dim);
	color: #c3f2a6;
	background: var(--positive-soft);
}
.alert--warn {
	border-color: #5a4520;
	color: #f0d29a;
	background: var(--warn-soft);
}

/* --- indicateurs ---------------------------------------------------------- */

.kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 0.6rem;
}
.kpi {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.75rem 0.85rem;
}
.kpi__label {
	font-size: 0.72rem;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}
.kpi__value {
	font-size: 1.4rem;
	font-weight: 800;
	font-family: var(--font-display);
	font-variant-numeric: tabular-nums;
	margin-top: 0.15rem;
	letter-spacing: -0.02em;
}

/* --- grilles de page ------------------------------------------------------ */

/* Accueil : une colonne sur telephone, deux sur grand ecran (2fr / 1fr). */
.grid-home {
	display: grid;
	gap: 0.85rem;
	grid-template-columns: 1fr;
}
.grid-3 {
	display: grid;
	gap: 0.85rem;
	grid-template-columns: 1fr;
}

@media (min-width: 860px) {
	.grid-home {
		grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
		align-items: start;
	}
	.grid-3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.sticky-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 30;
	background: rgba(7, 13, 23, 0.95);
	backdrop-filter: blur(10px);
	border-top: 1px solid var(--border);
	padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
}
.sticky-bar__inner {
	max-width: 1140px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

@media (max-width: 420px) {
	.team__logo {
		width: 30px;
		height: 30px;
	}
	.app {
		padding-left: 0.75rem;
		padding-right: 0.75rem;
	}
	.nav {
		margin-left: -0.75rem;
		margin-right: -0.75rem;
		padding: 0 0.75rem;
	}
	.card {
		padding: 0.9rem;
	}
}

/* Respect du reglage systeme : aucune animation superflue. */
@media (prefers-reduced-motion: reduce) {
	* {
		transition: none !important;
		animation: none !important;
	}
}
