/* ============================================
   lgpix.ch — The Toolbox
   Design System — main.css
   ============================================ */

/* --- Police Inter Variable (locale) --- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/InterVariable.woff2') format('woff2');
}
/* --- Reset minimal --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Variables — Light (défaut) --- */
:root {
  /* Typographie */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tracking-tight: -0.025em;
  --tracking-normal: -0.011em;

  /* Fond */
  --bg-primary: #fafafa;
  --bg-secondary: #f0f0f2;
  --bg-tertiary: #e4e4e8;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafe;
  --bg-card-subtle: rgba(99, 102, 241, 0.02);
  --bg-input: #ffffff;
  --bg-overlay: rgba(0, 0, 0, 0.4);

  /* Texte */
  --text-primary: #0c0c0e;
  --text-secondary: #64648a;
  --text-tertiary: #8585a0;
  --text-inverse: #ffffff;

  /* Accent — Indigo */
  --accent: #6366f1;
  --accent-hover: #5558e6;
  --accent-light: rgba(99, 102, 241, 0.08);
  --accent-border: rgba(99, 102, 241, 0.25);

  /* Bordures */
  --border-light: #e8e8ee;
  --border-medium: #d4d4dc;
  --border-card: rgba(0, 0, 0, 0.06);

  /* Ombres */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-card: none;
  --shadow-card-hover: 0 4px 16px rgba(99, 102, 241, 0.06);

  /* Badges catégories */
  --badge-boardgame: #10b981;
  --badge-boardgame-bg: rgba(16, 185, 129, 0.1);
  --badge-minigame: #f59e0b;
  --badge-minigame-bg: rgba(245, 158, 11, 0.1);
  --badge-tool: #3b82f6;
  --badge-tool-bg: rgba(59, 130, 246, 0.1);
  --badge-geek: #8b5cf6;
  --badge-geek-bg: rgba(139, 92, 246, 0.1);
  --badge-gaming: #ef4444;
  --badge-gaming-bg: rgba(239, 68, 68, 0.1);

  /* Divers */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms cubic-bezier(0.16, 1, 0.3, 1);
  --header-height: 64px;
  --max-width: 1360px;
  --gap-grid: 1.25rem;
  --gap-grid-lg: 1.5rem;
}

/* --- Variables — Dark --- */
[data-theme="dark"] {
  --bg-primary: #0a0a0c;
  --bg-secondary: #141418;
  --bg-tertiary: #1e1e24;
  --bg-card: #16161b;
  --bg-card-hover: #1c1c24;
  --bg-card-subtle: rgba(129, 140, 248, 0.02);
  --bg-input: #16161b;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --text-primary: #ededf0;
  --text-secondary: #9e9eb0;
  --text-tertiary: #8a8a9e;
  --text-inverse: #0c0c0e;

  --accent: #818cf8;
  --accent-hover: #939eff;
  --accent-light: rgba(129, 140, 248, 0.1);
  --accent-border: rgba(129, 140, 248, 0.25);

  --border-light: #222230;
  --border-medium: #32323e;
  --border-card: rgba(255, 255, 255, 0.06);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-card: none;
  --shadow-card-hover: 0 4px 16px rgba(129, 140, 248, 0.06);

  --badge-boardgame-bg: rgba(16, 185, 129, 0.15);
  --badge-minigame-bg: rgba(245, 158, 11, 0.15);
  --badge-tool-bg: rgba(59, 130, 246, 0.15);
  --badge-geek-bg: rgba(139, 92, 246, 0.15);
  --badge-gaming-bg: rgba(239, 68, 68, 0.15);
}

/* --- Base --- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  letter-spacing: var(--tracking-normal);
  min-height: 100vh;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Dot pattern subtil en fond (style Notion) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(circle, var(--border-light) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.35;
  pointer-events: none;
}

[data-theme="dark"] body::before {
  opacity: 0.12;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* --- Typographie --- */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: var(--tracking-tight);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

/* --- Layout utilitaires --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-card);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
}

[data-theme="dark"] .site-header {
  background-color: rgba(10, 10, 12, 0.8);
}

[data-theme="light"] .site-header,
:root:not([data-theme]) .site-header {
  background-color: rgba(250, 250, 250, 0.8);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-shrink: 0;
}

.header-brand .brand-name {
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.header-brand .brand-name::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--accent);
  border-radius: 50%;
  margin-left: 2px;
  vertical-align: super;
}

.header-brand .brand-sub {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Sélecteur de langue --- */
.lang-switcher {
  display: flex;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 2px;
}

.lang-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  text-transform: uppercase;
  transition: all var(--transition-fast);
  letter-spacing: 0.02em;
}

.lang-btn:hover {
  color: var(--text-secondary);
}

.lang-btn.active {
  background-color: var(--accent);
  color: var(--text-inverse);
}

[data-theme="dark"] .lang-btn.active {
  color: #111114;
}

/* --- Toggle dark/light --- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  transition: background-color var(--transition-fast);
}

.theme-toggle:hover {
  background-color: var(--bg-tertiary);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

/* --- Barre de recherche --- */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-wrapper svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  background-color: var(--bg-card);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  background-color: var(--bg-input);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

/* --- Section filtres --- */
.filters-bar {
  padding: 1.25rem 0;
  border-bottom: none;
}

.filter-pills {
  display: inline-flex;
  gap: 0.25rem;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.filter-pill {
  padding: 0.45rem 1rem;
  font-size: 0.78rem;
  font-weight: 520;
  border-radius: calc(var(--radius-lg) - 2px);
  border: none;
  color: var(--text-tertiary);
  background-color: transparent;
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.filter-pill:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.filter-pill:active {
  transform: scale(0.95);
}

.filter-pill.active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 580;
}

[data-theme="dark"] .filter-pill.active {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* --- Grille d'outils --- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap-grid);
  padding: 2rem 0;
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-card);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.78rem;
}

.site-footer a {
  color: var(--text-tertiary);
}

.site-footer a:hover {
  color: var(--text-primary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 0.75rem;
}

/* --- Message vide --- */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- Scrollbar personnalisée --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--border-medium);
  border-radius: 3px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background-color: var(--border-light);
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .site-header {
    height: auto;
  }

  .search-wrapper {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }

  .header-brand .brand-sub {
    display: none;
  }

  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  h1 { font-size: 1.4rem; }
}

@media (max-width: 600px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }

  .filter-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .lang-btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
  }

  /* Modale mobile */
  .modal {
    width: 95%;
    padding: 1.25rem;
    max-height: 85vh;
  }
}

/* Large desktop */
@media (min-width: 1200px) {
  .tools-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap-grid-lg);
  }

  .container {
    padding: 0 2rem;
  }
}

/* --- Page outil (tool-shell) --- */
.tool-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 50;
}

[data-theme="dark"] .tool-header {
  background-color: rgba(15, 15, 17, 0.9);
}

.tool-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tool-back {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.tool-back:hover {
  color: var(--accent);
}

.tool-back svg {
  width: 16px;
  height: 16px;
}

.tool-title {
  font-size: 1rem;
  font-weight: 600;
}

.tool-content {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

/* --- Boutons utilitaires pour outils --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--text-inverse);
}

[data-theme="dark"] .btn-primary {
  color: #111114;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-medium);
}

.btn-danger {
  background-color: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Inputs pour outils --- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-group input,
.input-group select {
  padding: 0.55rem 0.75rem;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--bg-card-hover);
}

/* --- Tabs pour outils --- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  gap: 0;
}

.tab {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Toggle switch --- */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background-color: var(--border-medium);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* --- Alertes / Messages --- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-info {
  background-color: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* --- Modale --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  transition: background-color var(--transition-fast);
}

.modal-close:hover {
  background-color: var(--bg-tertiary);
}

/* --- Auth header --- */
.auth-user {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-card);
}

.auth-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.auth-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.auth-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 620;
  border-radius: var(--radius-full);
  background: #5865F2;
  color: white;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.auth-login-btn:hover {
  background: #4752c4;
  color: white;
}

@media (max-width: 480px) {
  .auth-name { display: none; }
  .auth-login-btn span { display: none; }
}

/* --- Accessibilité --- */

/* Focus visible pour clavier */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tool-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Touch targets minimum 44px */
.lang-btn {
  min-height: 36px;
  min-width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle {
  min-width: 44px;
  min-height: 44px;
}

.filter-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

.modal-close {
  min-width: 44px;
  min-height: 44px;
}
