/* David Theme - Jekyll Adaptation */
/* Elegant typography and clean layout */

:root {
  --primary-color: #1a1a1a;
  --link-color: #0066cc;
  --link-hover: #003d7a;
  --border-color: #e0e0e0;
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --gray-light: #666;
  --gray-medium: #999;
  --code-bg: #f8f8f8;
  --code-border: #e5e5e5;
  --button-bg: #f5f5f5;
  --button-hover: #e8e8e8;
  --accent-color: #0066cc;
}

/* Mode sombre */
[data-theme="dark"] {
  --primary-color: #e8e8e8;
  --link-color: #6ba4ff;
  --link-hover: #9bc2ff;
  --border-color: #333;
  --bg-color: #0d0d0d;
  --text-color: #e8e8e8;
  --gray-light: #aaa;
  --gray-medium: #888;
  --code-bg: #1a1a1a;
  --code-border: #333;
  --button-bg: #1a1a1a;
  --button-hover: #2a2a2a;
  --accent-color: #6ba4ff;
}

/* Détection automatique de la préférence système */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary-color: #e8e8e8;
    --link-color: #6ba4ff;
    --link-hover: #9bc2ff;
    --border-color: #333;
    --bg-color: #0d0d0d;
    --text-color: #e8e8e8;
    --gray-light: #aaa;
    --gray-medium: #888;
    --code-bg: #1a1a1a;
    --code-border: #333;
    --button-bg: #1a1a1a;
    --button-hover: #2a2a2a;
    --accent-color: #6ba4ff;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Typographie principale - Style David avec Serif */
body {
  font-family: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif;
  font-size: 20px;
  line-height: 1.7;
  color: var(--text-color);
  background-color: var(--bg-color);
  max-width: 680px;
  margin: 0 auto;
  padding: 60px 30px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Skip link pour accessibilité */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 1em;
  background-color: var(--accent-color);
  color: white;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  left: 0;
  top: 0;
}

/* En-têtes avec style élégant */
h1, h2, h3, h4, h5, h6 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.2;
  font-weight: 600;
  margin: 2em 0 0.75em;
  color: var(--primary-color);
}

h1 {
  font-size: 2.2em;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0;
}

h2 {
  font-size: 1.6em;
  margin-top: 2.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-color);
}

h3 {
  font-size: 1.3em;
}

h1:first-child,
h2:first-child {
  margin-top: 0;
}

/* Liens élégants avec soulignement */
a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

/* Header minimaliste - style blog de référence */
header {
  margin-bottom: 2em;
}

.header-container {
  position: relative;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

header h1 {
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 0.5em;
  letter-spacing: -0.02em;
  flex: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

header h1 a {
  color: var(--primary-color);
  border-bottom: none;
  text-decoration: none;
}

header h1 a:hover {
  color: var(--link-color);
}

/* Clean navigation - reference blog style */
header nav {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.85em;
  text-align: center;
  margin-top: 0.5em;
  margin-bottom: 1.5em;
  color: var(--gray-medium);
}

header nav a {
  margin: 0 0.5em;
  color: var(--gray-medium);
  border-bottom: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
  text-decoration: none;
}

header nav a:hover {
  color: var(--text-color);
}

header nav::after {
  content: '';
  display: block;
  width: 100%;
  height: 1px;
  background: var(--border-color);
  margin-top: 1.5em;
}

/* Paragraphes spacieux */
p {
  margin: 1.4em 0;
  text-align: justify;
  hyphens: auto;
}

/* Listes élégantes */
ul, ol {
  margin: 1.5em 0;
  padding-left: 2em;
}

li {
  margin: 0.6em 0;
}

/* Images full-width élégantes */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2.5em auto;
  border-radius: 4px;
}

/* Lazy loading optimization */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.4s ease-in;
}

img[loading="lazy"].loaded,
img:not([loading="lazy"]) {
  opacity: 1;
}

/* Galeries d'images */
.gallery-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5em;
  margin: 2.5em 0;
}

.gallery-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1em;
  margin: 2.5em 0;
}

.gallery-four {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1em;
  margin: 2.5em 0;
}

.gallery-two img,
.gallery-three img,
.gallery-four img {
  margin: 0;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Code élégant */
code {
  font-family: "SF Mono", "Monaco", "Cascadia Code", "Roboto Mono", monospace;
  font-size: 0.85em;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 6px;
  border-radius: 3px;
}

pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1.5em;
  overflow-x: auto;
  border-radius: 4px;
  margin: 2em 0;
  line-height: 1.5;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.9em;
}

/* Tables élégantes */
table {
  width: 100%;
  margin: 2em 0;
  border-collapse: collapse;
  font-size: 0.9em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

th, td {
  padding: 0.8em 1em;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--primary-color);
  border-bottom: 2px solid var(--border-color);
}

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

/* Notes de bas de page */
.footnotes {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 1px solid var(--border-color);
  font-size: 0.9em;
  color: var(--gray-light);
}

/* Blockquotes */
blockquote {
  margin: 2em 0;
  padding-left: 1.5em;
  border-left: 3px solid var(--accent-color);
  color: var(--gray-light);
  font-style: italic;
}

/* Séparateur */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 3em 0;
}

.separator {
  border-bottom: 1px solid var(--border-color);
  margin: 1.5em 0 2em;
}

/* Articles */
article {
  margin-bottom: 3em;
}

section {
  margin-bottom: 3.5em;
}

section h2 {
  margin-top: 0;
  font-size: 1.5em;
}

section h2 a {
  color: var(--primary-color);
  border-bottom: none;
}

section h2 a:hover {
  color: var(--link-color);
}

/* Métadonnées article */
.post-meta {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--gray-medium);
  font-size: 0.8em;
  margin-bottom: 2em;
  letter-spacing: 0.03em;
}

.post-meta time {
  font-variant-numeric: oldstyle-nums;
}

/* Table des matières */
.table-of-contents {
  background-color: var(--code-bg);
  border-left: 3px solid var(--accent-color);
  padding: 1.5em 2em;
  margin: 2em 0 2.5em;
  border-radius: 4px;
}

.table-of-contents h2 {
  font-size: 1em;
  margin: 0 0 1em 0;
  padding: 0;
  border: none;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.table-of-contents ul {
  margin: 0;
  padding-left: 1.5em;
  list-style-type: none;
}

.table-of-contents li {
  margin: 0.6em 0;
  position: relative;
}

.table-of-contents li::before {
  content: "→";
  position: absolute;
  left: -1.5em;
  color: var(--accent-color);
}

.table-of-contents a {
  color: var(--text-color);
  border-bottom: 1px solid transparent;
  font-size: 0.95em;
}

.table-of-contents a:hover {
  color: var(--link-color);
  border-bottom-color: var(--link-color);
}

/* Navigation between posts */
.post-navigation {
  display: flex;
  justify-content: space-between;
  margin: 4em 0 2em;
  padding-top: 2em;
  border-top: 1px solid var(--border-color);
  gap: 2em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.post-navigation .nav-previous,
.post-navigation .nav-next {
  flex: 1;
}

.post-navigation .nav-next {
  text-align: right;
}

.post-navigation .nav-label {
  display: block;
  font-size: 0.75em;
  color: var(--gray-medium);
  margin-bottom: 0.5em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.post-navigation a {
  font-size: 0.95em;
  font-weight: 500;
  border-bottom: none;
}

.post-navigation a:hover {
  border-bottom: 1px solid var(--link-hover);
}

/* Page d'accueil - style minimaliste */
.home-section-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9em;
  color: var(--gray-medium);
  margin: 1em 0 1.5em;
  font-weight: normal;
}

.home-posts {
  margin: 0 0 4em;
}

.home-post-item {
  margin: 0.8em 0;
  line-height: 1.8;
}

.home-post-link {
  display: inline-block;
  color: var(--text-color);
  text-decoration: none;
  border-bottom: none;
  transition: color 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1em;
}

.home-post-link:hover {
  color: var(--link-color);
}

.home-post-link strong {
  font-weight: 600;
  color: var(--primary-color);
}

.home-post-link:hover strong {
  color: var(--link-color);
}

.home-post-separator {
  color: var(--gray-medium);
  margin: 0 0.3em;
  font-weight: normal;
}

.home-post-date {
  color: var(--gray-medium);
  font-weight: normal;
  font-variant-numeric: oldstyle-nums;
}

/* Pagination */
.pagination {
  text-align: center;
  margin: 4em 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9em;
}

.pagination a {
  border-bottom: none;
  padding: 0 1em;
}

.home-pagination {
  margin-top: 3em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.home-pagination .pagination-next {
  margin-left: auto;
}

/* Archives */
.archive-year {
  margin-top: 3em;
  font-size: 1.3em;
  color: var(--gray-light);
}

.archive-item {
  margin: 1.2em 0;
  display: flex;
  gap: 1.5em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.archive-date {
  color: var(--gray-medium);
  font-size: 0.85em;
  min-width: 90px;
  flex-shrink: 0;
  font-variant-numeric: oldstyle-nums;
}

.archive-item a {
  border-bottom: none;
}

.archive-item a:hover {
  border-bottom: 1px solid var(--link-hover);
}

/* Footer */
footer {
  margin-top: 5em;
  padding-top: 2em;
  border-top: 1px solid var(--border-color);
  font-size: 0.8em;
  color: var(--gray-medium);
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Page 404 */
.page-content {
  text-align: center;
  padding: 4em 0;
}

/* Dark mode toggle button - integrated in header but fixed on scroll */
.header-container .theme-toggle {
  position: fixed;
  top: 30px;
  right: 30px;
  background: var(--button-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 100;
  margin: 0;
  padding: 0;
}

.header-container .theme-toggle:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.header-container .theme-toggle:active {
  transform: translateY(0);
}

.theme-toggle .theme-icon {
  display: block;
  line-height: 1;
}

/* Dark mode toggle button - clean style (fallback if created dynamically) */
.theme-toggle {
  position: fixed;
  top: 30px;
  right: 30px;
  background: var(--button-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  transition: all 0.3s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
}

.theme-toggle:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.theme-toggle:active {
  transform: translateY(0);
}

/* Breadcrumbs */
.breadcrumbs {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.85em;
  color: var(--gray-medium);
  margin: 3em 0 2em 0;
  padding-top: 1.5em;
  border-top: 1px solid var(--border-color);
}

.breadcrumbs a {
  color: var(--gray-medium);
  border-bottom: none;
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--link-color);
}

.breadcrumb-separator {
  margin: 0 0.5em;
  color: var(--gray-light);
}

.breadcrumb-current {
  color: var(--text-color);
  font-weight: 500;
}

/* Back to top button - same style as theme toggle button */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--button-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
  padding: 0;
  margin: 0;
  opacity: 0;
  visibility: hidden;
}

.back-to-top.visible {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.back-to-top svg {
  width: 20px;
  height: 20px;
  color: var(--text-color);
  stroke: currentColor;
  transition: color 0.3s ease;
}

.back-to-top:hover {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.back-to-top:hover svg {
  color: var(--text-color);
}

.back-to-top:active {
  transform: translateY(0);
}

.back-to-top:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Support MathJax */
.MathJax {
  font-size: 1.1em !important;
}

mjx-container {
  margin: 1.5em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    font-size: 18px;
    padding: 40px 20px;
  }
  
  h1 { font-size: 1.8em; }
  h2 { font-size: 1.4em; }
  h3 { font-size: 1.2em; }
  
  p {
    text-align: left;
    hyphens: none;
  }
  
  .gallery-three,
  .gallery-four {
    grid-template-columns: 1fr 1fr;
  }
  
  .post-navigation {
    flex-direction: column;
    gap: 2em;
  }
  
  .post-navigation .nav-next {
    text-align: left;
  }
  
  .archive-item {
    flex-direction: column;
    gap: 0.3em;
  }
  
  .header-container .theme-toggle {
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    font-size: 1em;
  }
  
  .theme-toggle {
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    font-size: 1.1em;
  }
  
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
  
  .back-to-top svg {
    width: 18px;
    height: 18px;
  }
  
  nav a {
    margin: 0 0.5em;
  }
  
  .breadcrumbs {
    font-size: 0.8em;
    margin: -1.5em 0 1.5em 0;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 17px;
    padding: 30px 15px;
  }
  
  .gallery-two {
    grid-template-columns: 1fr;
  }
}
