/* === EFERUS Nova — Design System === */
/* Tokens extraits de exvibris.com — couleurs, typo, espacements */
/* WCAG 2.1 AA — contraste minimum 4.5:1 texte normal, 3:1 texte large */

:root {
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-garamond: 'EB Garamond', 'Garamond', 'Cormorant Garamond', Georgia, serif;

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-6: 1.5rem; --space-8: 2rem;
  --space-12: 3rem; --space-16: 4rem;

  --radius-sm: 0.25rem; --radius-md: 0.5rem; --radius-lg: 0.75rem;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* === Thème Père (christian) — Parchemin, Garamond, chaleureux === */
[data-view="pere"] {
  --bg: #faf6f0;
  --surface: #fefcf8;
  --surface-2: #f5efe4;
  --border: #d4c5a9;
  --text: #2c2416;
  --text-muted: #5c4f3a;
  --text-faint: #9a8d75;
  --accent: #8b4513;
  --accent-dim: rgba(139, 69, 19, 0.1);
  --accent-hover: #7a3b0e;
  --green: #4a6d3a;
  --green-dim: rgba(90, 125, 74, 0.1);
  --red: #b33a30;
  --orange: #a8780a;
  --shadow: 0 2px 12px rgba(44, 36, 22, 0.12);
  --focus-ring: #8b4513;

  --font-display: var(--font-garamond);
  color-scheme: light;
}

/* === Thème Bougie (chandelle) — Veillée à la chandelle, sombre chaleureux === */
[data-view="bougie"] {
  --bg: radial-gradient(ellipse at 50% 30%, #1a0e04 0%, #0a0502 60%, #060301 100%);
  --surface: #1c1208;
  --surface-2: #24180c;
  --border: #8a6a30;
  --text: #e6d4a8;
  --text-muted: #8a7850;
  --text-faint: #5a4e30;
  --accent: #e8b020;
  --accent-dim: rgba(232, 176, 32, 0.12);
  --accent-hover: #f0c840;
  --green: #5a9a4a;
  --green-dim: rgba(90, 154, 74, 0.1);
  --red: #c84a3a;
  --orange: #d4900a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  --focus-ring: #e8b020;

  --font-display: var(--font-garamond);
  color-scheme: dark;
}
[data-view="tris"] {
  --bg: #0d0d0f;
  --surface: #131316;
  --surface-2: #18181c;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e2e2e8;
  --text-muted: #8e8e9e;
  --text-faint: #4a4a5a;
  --accent: #6b7af8;
  --accent-dim: rgba(107, 122, 248, 0.12);
  --accent-hover: #8b96fa;
  --green: #3ecf6e;
  --green-dim: rgba(62, 207, 110, 0.1);
  --red: #e55a5a;
  --orange: #f5a524;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --focus-ring: #6b7af8;

  --font-display: var(--font-body);
  color-scheme: dark;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Focus visible (WCAG 2.4.7) === */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* === Skip to content (WCAG 2.4.1) === */
.skip-link {
  position: absolute; top: -100%; left: var(--space-4);
  background: var(--accent); color: #fff; padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md); z-index: 1000; font-weight: 600;
}
.skip-link:focus { top: var(--space-4); }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.3; }

h1 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.75rem); }
h3 { font-size: 1.125rem; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

/* Layout utils */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

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

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow);
}

/* Button — min 44px touch target (WCAG 2.5.5) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-3) var(--space-6);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 0.9375rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }

/* Input — min 44px height */
.input {
  width: 100%; min-height: 44px; padding: var(--space-3) var(--space-4);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font-body); font-size: 1rem;
  transition: border-color var(--transition);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: var(--text-faint); }

/* Tag / Badge */
.badge {
  display: inline-block; padding: 0.1875rem var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
  background: var(--accent-dim); color: var(--accent);
}

/* Theme toggle */
.theme-toggle {
  display: flex; gap: 1px;
  background: var(--surface-2); border-radius: var(--radius-md);
  padding: 2px;
}
.theme-toggle button {
  min-height: 36px; padding: var(--space-2) var(--space-4);
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  font-family: var(--font-body); font-size: 0.8125rem; cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle button.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Search bar */
.search-bar {
  display: flex; gap: var(--space-3); width: 100%; max-width: 680px;
}
.search-bar input { flex: 1; }
.search-bar .btn { flex-shrink: 0; }

/* Result list */
.result-item {
  display: block; padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
  transition: background var(--transition);
}
.result-item:hover { background: var(--surface-2); }
.result-item .badge { margin-right: var(--space-2); }
.result-item .snippet { font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-1); }
.result-item .snippet b { color: var(--accent); }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: var(--space-2); padding: var(--space-6) 0;
}
.pagination .page-link {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid transparent; text-decoration: none;
  transition: all var(--transition);
}
.pagination .page-link:hover { border-color: var(--border); }
.pagination .page-link.active {
  background: var(--accent-dim); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.pagination .page-link.disabled {
  color: var(--text-faint); pointer-events: none;
}

/* Document detail */
.doc-header { margin-bottom: var(--space-8); }
.doc-meta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.doc-body { max-width: 80ch; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-8);
}
.site-header .logo { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--text); text-decoration: none; }
.site-header .logo span { color: var(--accent); }

/* === Responsive breakpoints === */

/* Mobile: <= 640px */
@media (max-width: 640px) {
  .container { padding: 0 var(--space-3); }

  .site-header { flex-direction: column; gap: var(--space-3); padding: var(--space-3) 0; }
  .site-header .logo { font-size: 1.1rem; }

  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }

  .card { padding: var(--space-4); }

  .result-item { padding: var(--space-3) var(--space-4); }

  .doc-meta { gap: var(--space-2); }

  .pagination { gap: var(--space-1); }
  .pagination .page-link { min-width: 36px; min-height: 36px; font-size: 0.8125rem; }

  .cdo-grid { grid-template-columns: 1fr !important; }
}

/* Tablet: 641px – 960px */
@media (min-width: 641px) and (max-width: 960px) {
  .cdo-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Large: 1200px+ */
@media (min-width: 1200px) {
  .container { padding: 0; }
}

/* === Reduced motion (WCAG 2.3.3) === */
@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;
  }
}

/* === Print styles === */
@media print {
  .theme-toggle, .btn, .pagination, .search-bar { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
