/* ---------- Thème ---------- */
:root {
  --bg: #f6f5fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --border: rgba(20, 18, 40, 0.09);
  --text: #16142a;
  --text-muted: #5b5873;
  --brand: #7c5cff;
  --brand-2: #ff6fae;
  --shadow: 0 1px 2px rgba(20, 18, 40, 0.06), 0 8px 24px -12px rgba(20, 18, 40, 0.18);
  --shadow-hover: 0 2px 4px rgba(20, 18, 40, 0.06), 0 24px 48px -20px rgba(20, 18, 40, 0.35);
  --topbar: rgba(246, 245, 251, 0.75);
  --chip: rgba(20, 18, 40, 0.05);
  --tag: rgba(20, 18, 40, 0.06);

  --st-wip: #4f46e5;
  --st-almost: #b45309;
  --st-done: #15803d;
  --st-abandoned: #6b7280;

  --radius: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', var(--font);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0b14;
    --bg-elev: #14121f;
    --surface: #15131f;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f1f0f7;
    --text-muted: #a3a0b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -14px rgba(0, 0, 0, 0.7);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.4), 0 30px 60px -24px rgba(0, 0, 0, 0.9);
    --topbar: rgba(12, 11, 20, 0.7);
    --chip: rgba(255, 255, 255, 0.06);
    --tag: rgba(255, 255, 255, 0.07);
    --st-wip: #818cf8;
    --st-almost: #fbbf24;
    --st-done: #4ade80;
    --st-abandoned: #9ca3af;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0b14;
  --bg-elev: #14121f;
  --surface: #15131f;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1f0f7;
  --text-muted: #a3a0b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -14px rgba(0, 0, 0, 0.7);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.4), 0 30px 60px -24px rgba(0, 0, 0, 0.9);
  --topbar: rgba(12, 11, 20, 0.7);
  --chip: rgba(255, 255, 255, 0.06);
  --tag: rgba(255, 255, 255, 0.07);
  --st-wip: #818cf8;
  --st-almost: #fbbf24;
  --st-done: #4ade80;
  --st-abandoned: #9ca3af;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

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

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.02em; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 6px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid transparent;
  font: 600 14px/1.2 var(--font); text-decoration: none; white-space: nowrap;
  transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-lg { padding: 13px 22px; font-size: 15px; }

.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--brand); }

.btn-ghost { border-color: var(--border); background: var(--chip); }
.btn-ghost:hover { border-color: var(--text-muted); }

.btn-x { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.btn-x:hover { transform: translateY(-1px); border-color: var(--text-muted); }

.btn-disabled { border: 1px dashed var(--border); color: var(--text-muted); cursor: default; font-weight: 500; }

.btn-icon {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 999px; border: 1px solid var(--border); background: var(--chip);
  color: var(--text); cursor: pointer; transition: border-color .2s ease, transform .2s ease;
}
.btn-icon:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.btn-icon svg { width: 18px; height: 18px; }

.x-logo { width: 15px; height: 15px; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--topbar);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 18px var(--font-display); }
.brand img { width: 32px; height: 32px; border-radius: 50%; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

#theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) #theme-toggle .icon-moon { display: none; }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: 88px 0 72px; overflow: hidden; }
.hero-glow {
  position: absolute; inset: -40% -10% auto; height: 640px; pointer-events: none;
  background:
    radial-gradient(40% 50% at 25% 45%, color-mix(in srgb, var(--brand) 32%, transparent), transparent 70%),
    radial-gradient(35% 45% at 70% 35%, color-mix(in srgb, var(--brand-2) 24%, transparent), transparent 70%),
    radial-gradient(30% 40% at 55% 75%, color-mix(in srgb, #22b8cf 18%, transparent), transparent 70%);
  filter: blur(20px);
  animation: drift 18s ease-in-out infinite alternate;
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(60% 70% at 50% 40%, #000, transparent);
  -webkit-mask-image: radial-gradient(60% 70% at 50% 40%, #000, transparent);
}
@keyframes drift { to { transform: translate3d(3%, 4%, 0) scale(1.05); } }

.hero-inner { position: relative; z-index: 1; display: flex; align-items: center; gap: 48px; }

.avatar {
  flex: none; display: block; width: 168px; height: 168px; border-radius: 50%; padding: 4px;
  background: conic-gradient(from 210deg, var(--brand), var(--brand-2), #ffc94d, #22b8cf, var(--brand));
  box-shadow: 0 20px 50px -20px var(--brand);
  transition: transform .4s cubic-bezier(.2, .8, .2, 1);
}
.avatar:hover { transform: rotate(-4deg) scale(1.03); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; border: 4px solid var(--bg); object-fit: cover; }

.eyebrow {
  margin: 0 0 12px; font: 600 13px var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted);
}
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.8rem); font-weight: 700; }
.gradient-text {
  background: linear-gradient(100deg, var(--brand), var(--brand-2) 60%, #ffb347);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.donut { display: inline-block; animation: wobble 4s ease-in-out infinite; transform-origin: 50% 60%; }
@keyframes wobble { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-14deg); } 92% { transform: rotate(10deg); } }

.lead { max-width: 620px; margin: 18px 0 28px; font-size: 1.08rem; color: var(--text-muted); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }

.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; list-style: none; padding: 0; margin: 32px 0 0; color: var(--text-muted); font-size: 14px; }
.stats strong { color: var(--text); font: 700 1.25rem var(--font-display); margin-right: 4px; }

/* ---------- Projets ---------- */
.projects { padding-bottom: 96px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.section-head h2 { font-size: 2rem; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--chip); color: var(--text-muted); font: 500 14px var(--font); cursor: pointer;
  transition: all .2s ease;
}
.chip span { font-size: 12px; opacity: .7; }
.chip:hover { color: var(--text); border-color: var(--text-muted); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.grid { display: grid; gap: 24px; grid-template-columns: 1fr; grid-auto-flow: dense; }
@media (min-width: 680px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s ease, border-color .35s ease;
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 0%, transparent);
  transition: box-shadow .35s ease;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover), 0 18px 50px -28px var(--accent); }
.card:hover::before { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); }

.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: color-mix(in srgb, var(--accent) 20%, var(--bg)); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.card:hover .card-media img { transform: scale(1.05); }

/* Images de la tuile : empilées, celle qui est active apparaît en fondu */
.slide { position: absolute; inset: 0; overflow: hidden; }
.carousel .slide { opacity: 0; transition: opacity .9s ease; }
.carousel .slide.is-active { opacity: 1; animation: drift-in 7s ease-out both; }
/* Léger zoom lent sur l'image affichée */
@keyframes drift-in { from { transform: scale(1.06); } to { transform: scale(1); } }

/* Carrousel : flèches (au survol) et points ; le point actif se remplit puis passe à l'image suivante */
.carousel { --car-interval: 5s; }
.car-nav {
  position: absolute; top: 50%; z-index: 3; display: grid; place-items: center;
  width: 36px; height: 36px; margin-top: -18px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(12, 11, 20, .55); color: #fff; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .25s ease, background-color .2s ease, transform .2s ease;
}
.car-nav svg { width: 18px; height: 18px; }
.car-prev { left: 10px; }
.car-prev svg { transform: rotate(180deg); }
.car-next { right: 10px; }
.car-nav:hover { background: color-mix(in srgb, var(--accent) 80%, #000); transform: scale(1.08); }
.card:hover .car-nav, .carousel:focus-within .car-nav { opacity: 1; }
@media (hover: none) { .car-nav { display: none; } }

.car-dots {
  position: absolute; left: 50%; bottom: 10px; z-index: 3; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 5px 8px; border-radius: 999px;
  background: rgba(12, 11, 20, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.car-dot {
  position: relative; width: 8px; height: 8px; padding: 0; border: 0; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, .45); cursor: pointer; transition: width .3s ease, background-color .2s ease;
}
.car-dot:hover { background: rgba(255, 255, 255, .8); }
.car-dot.is-active { width: 26px; background: rgba(255, 255, 255, .35); }
.car-dot.is-active::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: #fff;
  transform-origin: left; animation: car-progress var(--car-interval) linear var(--car-delay, 0s) both;
}
@keyframes car-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.carousel.is-paused .car-dot.is-active::after,
.carousel.is-paused .slide.is-active { animation-play-state: paused; }
@media (hover: hover) {
  .card:hover .car-dot.is-active::after { animation-play-state: paused; }
}
.card-media::after {
  content: ""; position: absolute; inset: auto 0 0; height: 40%;
  background: linear-gradient(transparent, color-mix(in srgb, var(--surface) 55%, transparent));
  pointer-events: none;
}

.status {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px; border-radius: 999px;
  background: rgba(12, 11, 20, .72); color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font: 600 12px var(--font); letter-spacing: .02em;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--wip::before { background: #818cf8; box-shadow: 0 0 0 3px rgba(129, 140, 248, .3); animation: pulse 1.8s ease-in-out infinite; }
.status--almost::before { background: #fbbf24; }
.status--done::before { background: #4ade80; }
.status--abandoned::before { background: #9ca3af; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(129, 140, 248, 0); } }

.card-body { display: flex; flex-direction: column; flex: 1; padding: 20px 22px 22px; }
.card-kicker { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--accent); filter: saturate(1.1); }
.card-title { font-size: 1.4rem; margin-bottom: 10px; }
.card-desc { margin: 0 0 16px; color: var(--text-muted); font-size: 15px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 20px; }
.tags li { padding: 3px 10px; border-radius: 999px; background: var(--tag); font-size: 12.5px; color: var(--text-muted); }

.card-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.card-actions .btn-primary { background: var(--accent); color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.card-actions .btn-primary:hover { box-shadow: 0 10px 24px -10px var(--accent); }
.card-actions .btn-primary svg { transition: transform .2s ease; }
.card-actions .btn-primary:hover svg { transform: translate(2px, -2px); }
/* Toute la tuile est cliquable vers le projet ; le lien GitHub reste au-dessus */
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card-actions .btn-icon { position: relative; z-index: 3; }

/* Téléchargements par OS */
.downloads { margin: 0 0 16px; }
.downloads-title { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.downloads-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dl {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 6px 10px; border-radius: 12px; text-decoration: none; text-align: center;
  border: 1px solid var(--border); background: var(--chip);
  transition: transform .2s ease, border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.dl svg { width: 24px; height: 24px; margin-bottom: 4px; color: var(--text); transition: color .2s ease; }
.dl:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 8px 20px -12px var(--accent);
}
.dl:hover svg { color: var(--accent); }
.dl-os { font-weight: 600; font-size: 14px; line-height: 1.2; }
.dl-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.2; }
.downloads-more { margin: 8px 0 0; font-size: 12.5px; color: var(--text-muted); }
.downloads-more a { color: var(--text-muted); text-underline-offset: 2px; }
.downloads-more a:hover { color: var(--text); }

.card-hint { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); opacity: .85; }

/* Tuile vedette : l'image est affichée en entier, le vide autour est comblé par la même image floutée */
.card--featured .slide::before {
  content: ""; position: absolute; inset: -24px;
  background: var(--media-bg) center / cover no-repeat;
  filter: blur(22px) saturate(1.1) brightness(.7);
}
.card--featured .slide img { position: relative; object-fit: contain; }
@media (max-width: 679px) {
  .card--featured .card-media { aspect-ratio: 1 / 1; }
}

/* Tuile mise en avant (hors filtre) :
   - sur 2 colonnes : pleine largeur, image à gauche
   - sur 3 colonnes : bloc 2x2, grande image au-dessus */
@media (min-width: 680px) {
  .grid:not(.is-filtered) .card--featured { grid-column: span 2; }
  .grid:not(.is-filtered) .card--featured .card-title { font-size: 2rem; }
  .grid:not(.is-filtered) .card--featured .card-desc { font-size: 16px; max-width: 62ch; }
}
@media (min-width: 680px) and (max-width: 1079px) {
  .grid:not(.is-filtered) .card--featured { flex-direction: row; }
  .grid:not(.is-filtered) .card--featured .card-media { flex: 1.1; aspect-ratio: auto; min-height: 340px; }
  .grid:not(.is-filtered) .card--featured .card-media::after { display: none; }
  .grid:not(.is-filtered) .card--featured .card-body { flex: 1; padding: 28px; justify-content: center; }
}
@media (min-width: 1080px) {
  .grid:not(.is-filtered) .card--featured { grid-row: span 2; }
  .grid:not(.is-filtered) .card--featured .card-media { flex: 1; aspect-ratio: auto; min-height: 360px; }
  .grid:not(.is-filtered) .card--featured .card-media img { object-position: 50% 30%; }
  .grid:not(.is-filtered) .card--featured .card-body { flex: none; padding: 28px 32px 32px; }
}

/* Apparition au défilement */
.reveal { opacity: 0; transform: translateY(24px); }
.reveal.is-visible { opacity: 1; transform: none; transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1), box-shadow .35s ease; }
.reveal.is-visible:hover { transform: translateY(-6px); }

.noscript { color: var(--text-muted); }

/* ---------- Pied de page ---------- */
.footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--text-muted); font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer p { margin: 0; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .hero { padding: 48px 0 40px; }
  .hero-inner { flex-direction: column; align-items: flex-start; gap: 24px; }
  .avatar { width: 112px; height: 112px; }
  .hide-sm { display: none; }
  .section-head h2 { font-size: 1.6rem; }
  .card-body { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
