@import url('https://fonts.googleapis.com/css2?family=Exo:wght@300;400;500;600;700&family=Source+Sans+3:wght@300;400;500;600&family=Roboto+Mono:wght@400;500&display=swap');

/* ─── Design Tokens ────────────────────────────────────────────────── */
:root {
  /* Fond et surfaces */
  --bg:           #F4F6F9;
  --surface:      #FFFFFF;
  --surface-2:    #EEF1F7;
  --surface-3:    #E4E9F2;
  --border:       #D8DFEC;
  --border-hover: #A8B4C8;

  /* Couleur primaire : bleu académique */
  --primary:      #1A4E8C;
  --primary-dim:  rgba(26, 78, 140, 0.08);
  --primary-glow: none;

  /* Accent : bleu moyen */
  --accent:       #2171B5;
  --accent-dim:   rgba(33, 113, 181, 0.10);

  /* Texte */
  --ink:          #1C2B3A;
  --ink-muted:    #546880;
  --ink-faint:    #99AABB;

  /* États */
  --success:      #16A34A;
  --error:        #DC2626;
  --warning:      #B45309;

  /* Typographie */
  --font-heading: 'Exo', system-ui, sans-serif;
  --font-body:    'Source Sans 3', system-ui, sans-serif;
  --font-mono:    'Roboto Mono', 'Courier New', monospace;

  /* Espacement (base 4px) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px;

  /* Radius */
  --r-sm: 5px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Ombres (légères pour fond clair) */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 28px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);

  /* Transitions */
  --t-fast: 120ms ease;
  --t:      200ms ease;
  --t-slow: 300ms ease;
}

/* ─── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}

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

img { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { cursor: pointer; font-family: var(--font-body); }

/* ─── Skip link accessibilité ─────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -999px;
  left: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border-radius: var(--r-sm);
  z-index: 9999;
}
.skip-link:focus { top: var(--sp-2); }

/* ─── Layout ──────────────────────────────────────────────────────── */
.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}
@media (max-width: 600px) { .wrap { padding: 0 var(--sp-4); } }

/* ─── Header (conserve l'image astro, contraste intentionnel) ─────── */
.site-header {
  position: relative;
  overflow: hidden;
  min-height: 180px;
  display: flex;
  align-items: flex-end;
}

.site-header__bg {
  position: absolute;
  inset: 0;
  background: url('/images/ESOMilkyWay.jpg') center / cover no-repeat;
  filter: brightness(0.45);
  z-index: 0;
}

.site-header__content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
}

.site-header h1 {
  font-size: clamp(20px, 3.5vw, 34px);
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.site-header__sub {
  margin-top: var(--sp-1);
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-family: var(--font-body);
}

.site-header__stats {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  flex-wrap: wrap;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--r-xl);
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  font-family: var(--font-heading);
  backdrop-filter: blur(4px);
}

/* ─── Nav ─────────────────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.site-nav__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-6);
  max-width: 1440px;
  margin: 0 auto;
}

.nav-link {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: var(--primary-dim);
}

.nav-spacer { flex: 1; }

.nav-admin-link {
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  font-size: 12px;
  font-family: var(--font-heading);
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.nav-admin-link:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-dim);
}

/* ─── Sections ────────────────────────────────────────────────────── */
.section { padding: var(--sp-8) 0; }

.section-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Catalogue cards ─────────────────────────────────────────────── */
.catalogues-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-4);
}

.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t), box-shadow var(--t);
}
.cat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.cat-card__title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--sp-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.cat-card__list { display: flex; flex-direction: column; gap: var(--sp-2); }

.cat-entry {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
}
.cat-entry a {
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  transition: color var(--t-fast);
}
.cat-entry a:hover { color: var(--primary); }
.cat-entry svg { flex-shrink: 0; opacity: 0.5; }
.cat-entry--missing { color: var(--ink-faint); font-style: italic; }

/* ─── Search bar ──────────────────────────────────────────────────── */
.search-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
}

.search-input {
  flex: 1;
  max-width: 380px;
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-input::placeholder { color: var(--ink-faint); }

.search-count {
  font-size: 13px;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ─── Galaxy grid ─────────────────────────────────────────────────── */
.galaxy-group { margin-bottom: var(--sp-10); }

.group-header {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--border);
}

.group-id {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--primary);
}

.group-amused {
  font-size: 11px;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--accent);
  border-radius: var(--r-xl);
  color: var(--accent);
  font-family: var(--font-heading);
  transition: background var(--t-fast), color var(--t-fast);
}
.group-amused:hover {
  background: var(--accent-dim);
  color: var(--primary);
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}
@media (max-width: 1200px) { .tiles-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .tiles-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px)  { .tiles-grid { grid-template-columns: 1fr; } }

/* ─── Galaxy card ─────────────────────────────────────────────────── */
.galaxy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.galaxy-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.galaxy-card__img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--surface-2);
}

.galaxy-card__no-img {
  width: 100%;
  height: 140px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
}
.galaxy-card__no-img svg { width: 36px; height: 36px; }

.galaxy-card__body {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.galaxy-card__name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  word-break: break-all;
}

.galaxy-card__files { display: flex; flex-direction: column; gap: 3px; }

.galaxy-card__file a {
  font-size: 11px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  font-family: var(--font-mono);
  transition: color var(--t-fast);
}
.galaxy-card__file a:hover { color: var(--primary); }

.galaxy-card__more { font-size: 11px; color: var(--ink-faint); }

.galaxy-card__folder {
  margin-top: auto;
  padding-top: var(--sp-2);
  font-size: 11px;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--t-fast);
}
.galaxy-card__folder:hover { color: var(--primary); }

/* ─── Empty / no results ──────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: var(--sp-10);
  color: var(--ink-muted);
  font-family: var(--font-heading);
}

/* ─── Footer ──────────────────────────────────────────────────────── */
.site-footer {
  margin-top: var(--sp-12);
  padding: var(--sp-8) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-8);
  flex-wrap: wrap;
}

.site-footer img {
  max-height: 48px;
  max-width: 110px;
  width: auto;
  object-fit: contain;
  opacity: 0.75;
  transition: opacity var(--t);
}
.site-footer img:hover { opacity: 1; }

@media (max-width: 600px) {
  .site-footer { gap: var(--sp-5); }
  .site-footer img { max-height: 34px; max-width: 80px; }
}

/* ─── Boutons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-sm);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  border: none;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(26,78,140,0.3);
}
.btn-primary:hover { background: #153f70; color: #fff; }
.btn-primary:disabled { background: var(--border); color: var(--ink-faint); box-shadow: none; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-2); }

.btn-danger {
  background: rgba(220,38,38,0.08);
  color: var(--error);
  border: 1px solid rgba(220,38,38,0.25);
}
.btn-danger:hover { background: rgba(220,38,38,0.15); }

/* ─── Accessibilité — focus ───────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Recherche sticky ────────────────────────────────────────────── */
.search-sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding: var(--sp-3) 0 var(--sp-4);
  margin-bottom: var(--sp-2);
}

/* ─── Bouton retour en haut ───────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--t), transform var(--t);
  pointer-events: none;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover { background: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
