/* DPDJ – Ludothèque : design system */
:root {
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-lg: 0 10px 40px rgb(10 25 60 / .30);
  --danger: #c0392b;
  --warn: #b45309;
}

/* ========== Thème 1 : Bleu & jaune (par défaut) ========== */
:root, :root[data-theme="michelin"] {
  --bg: #f2f5fb;
  --surface: #ffffff;
  --surface-2: #e8eef9;
  --text: #14213d;
  --muted: #53627f;
  --border: #d3dcee;
  --primary: #27509b;
  --primary-hover: #1f4080;
  --primary-contrast: #ffffff;
  --accent: #27509b;
  --shadow: 0 1px 2px rgb(20 33 61 / .06), 0 6px 20px rgb(39 80 155 / .10);
  /* action principale : jaune */
  --cta: #fce500;
  --cta-hover: #ffee4d;
  --cta-ink: #1a3a7a;
  --cta-border: #e0cc00;
  /* éléments décoratifs */
  --header-bg: linear-gradient(135deg, #1b3a78, #27509b 55%, #3a66b8);
  --header-rule: #fce500;
  --nav-current-bg: #fce500;
  --nav-current-ink: #1a3a7a;
  --badge-bg: #fce500;
  --badge-ink: #1a3a7a;
  --vip-bg: #fce500;
  --vip-ink: #1a3a7a;
  --year-bg: #1b3a78;
  --toast-bg: #14264f;
  --toast-accent: #fce500;
  --backdrop: rgb(8 18 45 / .6);
  --h1-color: #27509b;
  --h1-rule: #fce500;
}

/* ========== Thème 2 : Vert (version précédente) ========== */
:root[data-theme="vert"] {
  --bg: #f4f7f3;
  --surface: #ffffff;
  --surface-2: #eef3ec;
  --text: #1c2a1f;
  --muted: #5b6b5f;
  --border: #dbe4d8;
  --primary: #2f7d3b;
  --primary-hover: #276a32;
  --primary-contrast: #ffffff;
  --accent: #2b7de9;
  --danger: #c0392b;
  --warn: #d97706;
  --shadow: 0 1px 2px rgb(20 40 25 / .06), 0 6px 20px rgb(20 40 25 / .07);
  --cta: #2f7d3b;
  --cta-hover: #276a32;
  --cta-ink: #ffffff;
  --cta-border: #2f7d3b;
  --header-bg: linear-gradient(135deg, #1f5e2a, #2f7d3b 55%, #3f9a4d);
  --header-rule: transparent;
  --nav-current-bg: rgb(255 255 255 / .25);
  --nav-current-ink: #ffffff;
  --badge-bg: #ffffff;
  --badge-ink: #1f5e2a;
  --vip-bg: #f6c945;
  --vip-ink: #4a3600;
  --year-bg: rgb(0 0 0 / .6);
  --toast-bg: #20352a;
  --toast-accent: #2f7d3b;
  --backdrop: rgb(8 20 12 / .55);
  --h1-color: #1c2a1f;
  --h1-rule: transparent;
}

/* ========== Modes sombres (automatiques) ========== */
@media (prefers-color-scheme: dark) {
  :root, :root[data-theme="michelin"] {
    --bg: #0b1630;
    --surface: #122247;
    --surface-2: #1a2f5c;
    --text: #eef3ff;
    --muted: #a7b6d6;
    --border: #26407a;
    --primary: #8fb4ff;
    --primary-hover: #b0cbff;
    --primary-contrast: #0b1630;
    --accent: #8fb4ff;
    --danger: #ff8a7a;
    --warn: #ffb454;
    --shadow: 0 1px 2px rgb(0 0 0 / .35), 0 6px 20px rgb(0 0 0 / .35);
    --h1-color: #8fb4ff;
  }
  :root[data-theme="vert"] {
    --bg: #111a14;
    --surface: #18251c;
    --surface-2: #213127;
    --text: #e8f0ea;
    --muted: #9bb0a0;
    --border: #2c3f32;
    --primary: #4caf5a;
    --primary-hover: #5cc06a;
    --primary-contrast: #0c1a10;
    --accent: #6aa6f5;
    --danger: #ef7a6c;
    --warn: #f0a548;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .3);
    --cta: #4caf5a;
    --cta-hover: #5cc06a;
    --cta-ink: #0c1a10;
    --cta-border: #4caf5a;
    --h1-color: #e8f0ea;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.container { width: min(1200px, 100% - 2rem); margin-inline: auto; }
main.container { padding-block: 1.5rem 4rem; }

/* ---------- Header ---------- */
.site-header {
  background: var(--header-bg);
  border-bottom: 4px solid var(--header-rule);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgb(0 0 0 / .2);
}
.header-inner { display: flex; align-items: center; gap: 1rem; padding-block: .6rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-logo { height: 44px; width: auto; border-radius: 10px; background: #fff; padding: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { opacity: .85; font-size: .8rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: #fff; text-decoration: none; padding: .4rem .8rem; border-radius: 999px; font-size: .92rem;
  opacity: .9;
}
.nav a:hover { background: rgb(255 255 255 / .15); opacity: 1; }
.nav a[aria-current="page"] { background: var(--nav-current-bg); color: var(--nav-current-ink); font-weight: 700; opacity: 1; }
.header-actions { display: flex; gap: .5rem; align-items: center; margin-left: auto; }
.nav + .header-actions { margin-left: 0; }

/* ---------- Hero / toolbar ---------- */
.page-title { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-title h1 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0; padding-bottom: .15em; border-bottom: 4px solid var(--h1-rule); color: var(--h1-color); }
.page-title .count { color: var(--muted); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.toolbar .grow { flex: 1 1 220px; }

/* ---------- Form controls ---------- */
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .75rem; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); }
input[type="checkbox"] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--primary); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; }

.field { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.field > span { color: var(--muted); font-weight: 600; }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; }
.field.inline > span { color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.form-error { color: var(--danger); margin: .5rem 0 0; min-height: 1.4em; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--cta); border-color: var(--cta-border); color: var(--cta-ink); }
.btn.primary:hover:not(:disabled) { background: var(--cta-hover); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: .25rem .8rem; font-size: .85rem; }
.btn.on-dark { background: rgb(255 255 255 / .16); border-color: transparent; color: #fff; }
.btn.on-dark:hover:not(:disabled) { background: rgb(255 255 255 / .28); }
.badge-count {
  background: var(--badge-bg); color: var(--badge-ink); font-weight: 700; border-radius: 999px; font-size: .75rem;
  min-width: 1.5rem; height: 1.5rem; display: inline-grid; place-items: center; padding: 0 .35rem;
}

/* ---------- Cards / catalogue ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.1rem; }
.game {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.game:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* .game-cover { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; position: relative; } */
/* .game-cover img { width: 100%; height: 100%; object-fit: contain; padding: .6rem; transition: opacity .3s; } */

.game-cover {
    height: 250px;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
}
/* .game-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: .6rem;
} */
.game-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.game-initial {
  width: 55%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 20%, var(--surface)); color: var(--primary);
  font-size: 3rem; font-weight: 800;
}
.game.unavailable .game-cover img { opacity: .4; filter: grayscale(.6); }
.game-year {
  position: absolute; top: .5rem; right: .5rem; background: var(--year-bg); color: #fff;
  border-radius: 999px; font-size: .72rem; padding: .1rem .55rem;
}
.game-body { padding: .8rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.game-title { font-weight: 700; font-size: .98rem; margin: 0; }
.game-sub { color: var(--muted); font-size: .85rem; margin: 0; }
.status { font-size: .82rem; font-weight: 600; color: var(--primary); }
.unavailable .status { color: var(--warn); }
.game-actions { margin-top: auto; display: flex; gap: .4rem; padding-top: .5rem; }
.game-actions .btn { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; grid-column: 1 / -1; }

/* ---------- Lists (admin) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-contrast); font-weight: 700; font-size: .95rem; object-fit: cover;
}
.avatar.off { background: var(--danger); }
.row-main { flex: 1 1 220px; min-width: 0; }
.row-title { font-weight: 600; }
.row-meta { color: var(--muted); font-size: .88rem; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.panel { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; border-bottom: 1px solid var(--border); font-weight: 700; }

.tag {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .55rem;
  border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.tag.vip { background: var(--vip-bg); color: var(--vip-ink); border-color: transparent; }
.tag.ok { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); border-color: transparent; }
.tag.ko { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); border-color: transparent; }

/* ---------- Gate ---------- */
.gate { max-width: 420px; margin: 3rem auto; display: grid; gap: 1rem; }
.gate h2 { margin: 0; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: var(--radius); color: var(--text); background: var(--surface);
  width: min(720px, calc(100% - 1.5rem)); max-height: calc(100dvh - 2rem); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-body { padding: 1.25rem; display: grid; gap: 1rem; }
.dialog-body h2 { margin: 0; font-size: 1.2rem; }
.dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .25rem; }
.cart-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.cart-item { display: flex; align-items: center; gap: .75rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .75rem; }
.cart-item img { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: var(--surface); }
.cart-item span { flex: 1; font-weight: 600; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 1rem; right: 1rem; display: grid; gap: .5rem; z-index: 100; max-width: min(360px, calc(100% - 2rem)); }
.toast {
  background: var(--toast-bg); color: #fff; padding: .75rem 1rem; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); animation: pop .2s ease; border-left: 4px solid var(--toast-accent);
}
.toast.error { border-left-color: var(--danger); }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }
.eventbrite-frame { min-height: 600px; }

@media (max-width: 640px) {
  .nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .brand-text small { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Bouton désactivé (jeu prêté) : gris net, sans jaune */
.btn.primary:disabled { background: var(--surface-2); border-color: var(--border); color: var(--muted); opacity: 1; }
.game.unavailable .game-initial { opacity: .5; filter: grayscale(.8); }

/* ---------- Sélecteur de thème ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.theme-switch { display: inline-flex; align-items: center; }
.theme-switch select {
  width: auto; min-height: 36px; padding: .2rem .8rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: rgb(255 255 255 / .16); color: #fff; border: 1px solid transparent; cursor: pointer;
}
.theme-switch select:hover { background: rgb(255 255 255 / .28); }
.theme-switch option { color: #14213d; background: #fff; }
