/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg: #0a0e1a;
  --bg-elevated: #0f1526;
  --surface: #141b2e;
  --surface-hover: #1a2338;
  --border: #253148;
  --border-strong: #34445f;

  --text: #e8ecf4;
  --text-muted: #a7b1c4;
  --text-faint: #6b7690;

  --accent: #4fa8f5;
  --accent-strong: #7cc0ff;
  --accent-contrast: #04101f;
  --accent-soft: rgba(79, 168, 245, 0.12);

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);

  --container: 1080px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--accent-strong);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; font-weight: 700; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.75em 1.25em;
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ==========================================================================
   Layout helpers
   ========================================================================== */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
}

section { padding: 4.5rem 0; border-top: 1px solid var(--border); }
section:first-of-type { border-top: none; }

.section-head { margin-bottom: 2.5rem; max-width: 640px; }
.section-head .eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 0.75rem;
}
.section-head h2 { font-size: clamp(1.5rem, 2.5vw, 2rem); }
.section-head p { color: var(--text-muted); margin: 0; }

/* ==========================================================================
   Header / Nav
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  max-width: var(--container);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
}
.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
}
.nav-links a[aria-current="page"] { color: var(--accent-strong); }

.nav-actions { display: flex; align-items: center; gap: 1rem; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }

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

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding: 5rem 0 4rem;
  border-top: none;
}
.hero-inner { max-width: 720px; }
.hero .eyebrow {
  font-family: var(--font-mono);
  color: var(--ok);
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--ok-soft);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}
.hero .eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
}
.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-bottom: 0.75rem;
}
.hero h1 span { color: var(--accent-strong); }
.hero .role {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.hero .pitch {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }

/* ==========================================================================
   Cards / grids
   ========================================================================== */
.grid {
  display: grid;
  gap: 1.25rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.card:hover { border-color: var(--border-strong); }

.card-link {
  display: block;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card-link:hover {
  text-decoration: none;
  color: var(--text);
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card-link-homelab { border-top: 3px solid var(--accent); }
.card-link-projects { border-top: 3px solid var(--ok); }
.card-link-projects .card-icon { background: var(--ok-soft); color: var(--ok); }
.card-link-projects:hover { border-color: var(--ok); }

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-weight: 700;
}

.card h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.card p { color: var(--text-muted); font-size: 0.95rem; margin: 0; }

/* ==========================================================================
   Skills
   ========================================================================== */
.skill-group h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-bottom: 0.9rem;
}
.skill-desc { color: var(--text-muted); font-size: 0.88rem; margin: 0 0 0.9rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
}
.tag.tag-accent { border-color: rgba(79,168,245,0.4); color: var(--accent-strong); }

/* ==========================================================================
   Timeline (expérience / formation)
   ========================================================================== */
.track-head { margin-bottom: 1.5rem; }
.track-head h3 { font-size: 1.25rem; margin-bottom: 0.4rem; }
.track-head p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }

.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 2rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -2rem;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent-strong);
  margin-bottom: 0.25rem;
  display: block;
}
.timeline-item h3 { font-size: 1.05rem; margin-bottom: 0.15rem; }
.timeline-item .org { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem; display: block; }
.timeline-item p { color: var(--text-muted); font-size: 0.95rem; }

.placeholder-note {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--warn);
  background: var(--warn-soft);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Homelab
   ========================================================================== */
.env-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.env-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
}
.env-badge.prod { background: var(--ok-soft); color: var(--ok); }
.env-badge.lab { background: var(--warn-soft); color: var(--warn); }
.env-badge.mixed { background: var(--accent-soft); color: var(--accent-strong); }
.env-badge.sm { font-size: 0.68rem; padding: 0.15rem 0.55rem; margin-bottom: 0.5rem; }

.device-card { display: flex; gap: 1rem; }
.device-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.device-body h3 { font-size: 1rem; margin-bottom: 0.15rem; }
.device-role { color: var(--accent-strong); font-size: 0.82rem; font-family: var(--font-mono); margin-bottom: 0.6rem; display: block; }
.spec-list { font-size: 0.88rem; color: var(--text-muted); }
.spec-list li { padding: 0.15rem 0; display: flex; gap: 0.5rem; }
.spec-list li::before { content: "›"; color: var(--accent); font-family: var(--font-mono); }

.diagram-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 3rem;
  overflow-x: auto;
}
.diagram-wrap svg { min-width: 640px; margin: 0 auto; }

.diagram-hint {
  display: none;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
  margin: 0.75rem 0 0;
}
@media (max-width: 720px) {
  .diagram-hint { display: block; }
}

/* ==========================================================================
   Projects
   ========================================================================== */

/* Featured project — CSS Grid, fixed proportions, no flex-wrap surprises */
.project-featured {
  display: grid;
  grid-template-columns: 9fr 11fr;
  gap: 2.5rem;
  align-items: center;
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-bottom: 3rem;
  color: var(--text);
}
.project-featured:hover { text-decoration: none; color: var(--text); border-color: var(--accent); }

.featured-text { min-width: 0; }
.featured-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-left: 0.6rem;
}
.featured-text h3 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); margin: 0.9rem 0 0.85rem; line-height: 1.3; }
.featured-text .featured-desc { color: var(--text-muted); font-size: 1.08rem; margin-bottom: 1.5rem; }

.featured-diagram {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.featured-diagram svg { width: 100%; max-width: 420px; height: auto; display: block; }

@media (max-width: 860px) {
  .project-featured { grid-template-columns: 1fr; padding: 2rem; gap: 2rem; }
  .featured-diagram svg { max-width: 360px; margin: 0 auto; }
}

/* Shared meta block (Contexte / Technologies / Résultat) */
.project-meta { margin: 1.1rem 0 1.25rem; }
.project-meta p { margin: 0 0 0.55rem; font-size: 1rem; color: var(--text-muted); }
.meta-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-strong);
  margin-right: 0.5rem;
}
.project-link-cta { font-weight: 600; font-size: 0.98rem; }

/* Secondary projects grid */
.grid-projects { gap: 1.75rem; }

.project-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.85rem;
}
.project-status {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 1rem;
  background: var(--ok-soft);
  color: var(--ok);
}
.project-status.wip { background: var(--warn-soft); color: var(--warn); }
.project-card h3 { font-size: 1.3rem; margin-bottom: 0.65rem; }
.project-card > p { color: var(--text-muted); font-size: 1rem; flex-grow: 1; margin-bottom: 0; }
.project-card .project-meta { flex-grow: 0; }
.project-card .project-link-cta { margin-top: 0.75rem; }

/* Project detail pages */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.back-link:hover { color: var(--accent-strong); text-decoration: none; }

.detail-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }

.detail-block { max-width: 760px; margin-bottom: 3rem; }
.detail-block:last-of-type { margin-bottom: 0; }
.detail-block h2 { font-size: clamp(1.25rem, 2vw, 1.5rem); margin-bottom: 0.9rem; }
.detail-block p { color: var(--text-muted); font-size: 1rem; }
.detail-block ol, .detail-block ul.plain-list { padding-left: 1.25rem; color: var(--text-muted); }
.detail-block ol li, .detail-block ul.plain-list li { margin-bottom: 0.6rem; padding-left: 0.35rem; list-style-position: outside; }
.detail-block ol { list-style: decimal; }
.detail-block ul.plain-list { list-style: disc; }

.diagram-wrap-sm { max-width: 480px; }
.project-links { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.project-links a { font-size: 0.88rem; font-weight: 600; }

/* ==========================================================================
   Blog widget (accueil)
   ========================================================================== */
.blog-loading {
  color: var(--text-muted);
  grid-column: 1 / -1;
}
.blog-loading a { color: var(--accent-strong); }
.blog-cta { margin-top: 2rem; text-align: center; }

/* ==========================================================================
   CTA banner
   ========================================================================== */
.cta-banner {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
}
.cta-banner h2 { margin-bottom: 0.5rem; }
.cta-banner p { color: var(--text-muted); margin-bottom: 1.5rem; }
.cta-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  color: var(--text-faint);
  font-size: 0.9rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.social-links { display: flex; gap: 1.25rem; }
.social-links a { color: var(--text-muted); font-weight: 500; }
.social-links a:hover { color: var(--accent-strong); }

.footer-legal {
  margin: 1.25rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ==========================================================================
   404
   ========================================================================== */
.error-page {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1.5rem;
}
.error-page .code {
  font-family: var(--font-mono);
  font-size: 4rem;
  color: var(--accent-strong);
  font-weight: 700;
}

/* ==========================================================================
   Back to top
   ========================================================================== */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, background 0.15s ease;
  box-shadow: var(--shadow-md);
  z-index: 90;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--accent-strong); }

@media (max-width: 640px) {
  .back-to-top { right: 1rem; bottom: 1rem; width: 42px; height: 42px; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.5rem 1.5rem;
    gap: 1rem;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-actions .btn span { display: none; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  section { padding: 3rem 0; }
  .device-card { flex-direction: column; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
