/* ==========================================================================
   STYLE.CSS - Styles de base du site
   ========================================================================== */

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

/* Variables */
:root {
  /* Palette perso */
  --color-ivory-mist: #f8f4e3;
  --color-dust-grey: #d4cdc3;
  --color-dust-grey-2: #d5d0cd;
  --color-ash-grey: #a2a392;
  --color-grey-olive: #9a998c;

  /* Couleurs de thème */
  --text-light: var(--color-dust-grey-2);
  --text-dark: #1e1e1e;
  --bg-light: var(--color-ivory-mist);
  --bg-dark: #1f2738;

  /* Code */
  --text-code-light: #575279;
  --text-code-dark: #E0DEF4;
  --bg-code-light: var(--color-ivory-mist);
  --bg-code-dark: #232136;
}

/* Base */
:root, body {
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  line-height: 1.5;
  background: var(--bg-light);
  color: var(--text-dark);
}

/* Dark mode */
html[data-theme="dark"] body {
  background: var(--bg-dark);
  color: var(--text-light);
}

/* Main content */
#content {
  padding: 2rem clamp(1rem, 5vw, 3rem);
}

/* Links */
a {
  color: inherit;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-grey-olive);
}

/* Code */
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--color-dust-grey);
  border-radius: 3px;
}

html[data-theme="dark"] code {
  background: rgba(255, 255, 255, 0.1);
}

pre {
  background: var(--bg-code-light);
  color: var(--text-code-light);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

html[data-theme="dark"] pre {
  background: var(--bg-code-dark);
  color: var(--text-code-dark);
}

pre code {
  padding: 0;
  background: transparent;
  font-size: inherit;
}

/* Theme toggle button */
.theme-toggle {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--color-dust-grey);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--color-dust-grey);
}

html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   FULLSCREEN IMAGE VIEWER
   ========================================================================== */

#fullscreen {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  cursor: zoom-out;
}

#fullscreen.active {
  opacity: 1;
  visibility: visible;
}

#fullscreen img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

/* ==========================================================================
   LAYOUT AVEC SIDEBAR
   ========================================================================== */

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--bg-light);
  border-right: 1px solid var(--color-dust-grey);
  z-index: 100;
  overflow-y: auto;
}

html[data-theme="dark"] .sidebar {
  background: var(--bg-dark);
  border-right-color: rgba(255, 255, 255, 0.1);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  min-height: 100%;
}

/* Logo sidebar */
.sidebar-logo {
  margin-bottom: 2rem;
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: transform 0.2s ease;
}

.sidebar-logo a:hover .sidebar-logo-icon {
  transform: scale(1.05);
}

.sidebar-logo-text {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.sidebar-logo-text .sep {
  opacity: 0.4;
}

/* Labels sidebar */
.sidebar-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-grey-olive);
  margin-bottom: 0.5rem;
}

/* Section courante */
.sidebar-current {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-dust-grey);
}

html[data-theme="dark"] .sidebar-current {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.sidebar-current-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dark);
  line-height: 1.4;
}

html[data-theme="dark"] .sidebar-current-title {
  color: var(--text-light);
}

/* TOC sidebar */
.sidebar-toc {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-dust-grey);
}

html[data-theme="dark"] .sidebar-toc {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.sidebar-toc nav > ul,
.sidebar-toc > ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-toc li {
  margin-bottom: 0.4rem;
}

.sidebar-toc a {
  font-size: 0.8rem;
  color: var(--color-grey-olive);
  text-decoration: none;
  transition: color 0.2s;
  display: block;
  line-height: 1.4;
}

.sidebar-toc a:hover {
  color: var(--text-dark);
}

html[data-theme="dark"] .sidebar-toc a:hover {
  color: var(--text-light);
}

/* Navigation sidebar */
.sidebar-nav {
  flex: 1;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  margin-bottom: 0.3rem;
}

.sidebar-nav a {
  font-size: 0.9rem;
  color: var(--color-grey-olive);
  text-decoration: none;
  transition: color 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--text-dark);
}

html[data-theme="dark"] .sidebar-nav a:hover,
html[data-theme="dark"] .sidebar-nav a.active {
  color: var(--text-light);
}

/* Footer sidebar */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1.5rem;
}

.sidebar-rss {
  font-size: 0.75rem;
  color: var(--color-grey-olive);
  text-decoration: none;
}

.sidebar-rss:hover {
  color: var(--text-dark);
}

html[data-theme="dark"] .sidebar-rss:hover {
  color: var(--text-light);
}

.sidebar .theme-toggle {
  padding: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

/* Bouton mobile */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-light);
  border: 1px solid var(--color-dust-grey);
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
}

html[data-theme="dark"] .sidebar-toggle {
  background: var(--bg-dark);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
}

/* Contenu principal */
.main-content {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
  padding: 3rem 4rem;
  max-width: 900px;
}

/* ==========================================================================
   PROSE / ARTICLE TYPOGRAPHY
   ========================================================================== */

.prose {
  line-height: 1.7;
  color: var(--text-dark);
}

html[data-theme="dark"] .prose {
  color: var(--text-light);
}

/* Headings */
.prose h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 2.25rem;
  font-weight: 400;
  margin: 0 0 1.5rem 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.prose h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  font-weight: 400;
  margin: 2.5rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-dust-grey);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

html[data-theme="dark"] .prose h2 {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.prose h3 {
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem 0;
  color: var(--text-dark);
  line-height: 1.4;
}

html[data-theme="dark"] .prose h3 {
  color: var(--text-light);
}

.prose h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 500;
  margin: 1.5rem 0 0.5rem 0;
  color: var(--color-grey-olive);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.4;
}

/* Premier heading après le titre de page */
.prose > h2:first-child {
  margin-top: 0;
}

/* Paragraphs */
.prose p {
  margin: 0 0 1.25rem 0;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* Links */
.prose a {
  color: var(--text-dark);
  text-decoration: underline;
  text-decoration-color: var(--color-dust-grey);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.prose a:hover {
  text-decoration-color: var(--text-dark);
}

html[data-theme="dark"] .prose a {
  color: var(--text-light);
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

html[data-theme="dark"] .prose a:hover {
  text-decoration-color: var(--text-light);
}

/* Lists */
.prose ul,
.prose ol {
  margin: 0 0 1.25rem 0;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose li:last-child {
  margin-bottom: 0;
}

/* Blockquotes */
.prose blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--color-grey-olive);
  background: rgba(0, 0, 0, 0.02);
  font-style: italic;
  color: var(--color-grey-olive);
}

html[data-theme="dark"] .prose blockquote {
  background: rgba(255, 255, 255, 0.03);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

/* Code inline */
.prose code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  background: var(--bg-code-light);
  border-radius: 4px;
  color: var(--text-code-light);
}

html[data-theme="dark"] .prose code {
  background: var(--bg-code-dark);
  color: var(--text-code-dark);
}

/* Code blocks */
.prose pre {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-code-light);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

html[data-theme="dark"] .prose pre {
  background: var(--bg-code-dark);
}

.prose pre code {
  padding: 0;
  background: none;
  border-radius: 0;
  font-size: inherit;
}

/* Horizontal rule */
.prose hr {
  margin: 2.5rem 0;
  border: none;
  border-top: 1px solid var(--color-dust-grey);
}

html[data-theme="dark"] .prose hr {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* Tables */
.prose table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.prose th,
.prose td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-dust-grey);
}

html[data-theme="dark"] .prose th,
html[data-theme="dark"] .prose td {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.prose th {
  font-weight: 600;
  color: var(--color-grey-olive);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Images */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

/* Strong & em */
.prose strong {
  font-weight: 600;
}

.prose em {
  font-style: italic;
}

/* ==========================================================================
   ARCHIVE (Blog & Notes groupés par année)
   ========================================================================== */

.archive-container {
  max-width: 700px;
}

.archive-header {
  margin-bottom: 3rem;
}

.archive-header h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 2.5rem;
  font-weight: 400;
  margin: 0;
}

.archive-year {
  margin-bottom: 2.5rem;
}

.archive-year-title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-grey-olive);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-dust-grey);
}

html[data-theme="dark"] .archive-year-title {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.archive-item:hover {
  border-bottom-color: var(--color-dust-grey);
}

html[data-theme="dark"] .archive-item:hover {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.archive-item time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--color-grey-olive);
  flex-shrink: 0;
  width: 50px;
}

.archive-item a {
  flex: 1;
  color: var(--text-dark);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.archive-item a:hover {
  color: var(--color-grey-olive);
}

html[data-theme="dark"] .archive-item a {
  color: var(--text-light);
}

html[data-theme="dark"] .archive-item a:hover {
  color: var(--color-dust-grey);
}

.archive-arrow {
  color: var(--color-grey-olive);
  opacity: 0.4;
  font-size: 0.9rem;
}

.archive-empty {
  color: var(--color-grey-olive);
  font-style: italic;
}

/* ==========================================================================
   MAIN HEADER (avec logo)
   ========================================================================== */

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-dust-grey);
}

html[data-theme="dark"] .main-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.main-header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.main-header-logo img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.main-header-logo:hover img {
  transform: scale(1.05);
}

.main-header-logo span {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.main-header-logo .sep {
  opacity: 0.4;
}

.main-header .theme-toggle {
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.main-header .theme-toggle:hover {
  opacity: 1;
}

/* ==========================================================================
   SIDEBAR OVERLAY (Mobile)
   ========================================================================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
  .main-content {
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.visible {
    pointer-events: auto;
  }

  .sidebar-toggle {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 4rem 1.5rem 2rem;
  }
  
  .main-header {
    margin-bottom: 2rem;
  }
}


/* Accessibilité: lien d’évitement */
.skip-link{
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  background: var(--card, rgba(0,0,0,.85));
  color: var(--text, #fff);
  transform: translateY(-200%);
  transition: transform .2s ease;
  z-index: 9999;
}

.skip-link:focus{
  transform: translateY(0);
  outline: none;
}

@media (prefers-reduced-motion: reduce){
  .skip-link{ transition:none; }
}
