/* ==========================================================================
   Portfolio — Mathieu Taramarcaz — style « terminal »
   Organisation :
     1. Variables (couleurs, espacements) + thème clair
     2. Base (reset léger, typographie)
     3. Composants réutilisables (boutons, badges, tags)
     4. Sections de la page (header, hero, projets, à propos, contact, footer)
     5. Responsive (on écrit d'abord pour mobile, puis on élargit)
     6. Accessibilité (réduction des animations)
   ========================================================================== */


/* 1. VARIABLES -------------------------------------------------------------
   Toutes les couleurs passent par des variables. Pour changer de thème,
   on ne réécrit pas les règles : on change seulement la valeur des variables.
   Le thème SOMBRE est le thème par défaut (c'est l'ambiance terminal). */
:root {
  --bg: #0b0f0e;               /* fond de la page */
  --surface: #111816;          /* fond des fenêtres / cartes */
  --surface-2: #17201d;        /* barres de titre */
  --text: #d6e2dc;
  --text-muted: #7f938a;
  --border: #23302b;
  --accent: #4ade80;           /* vert terminal */
  --accent-contrast: #04140a;  /* texte posé sur le vert */
  --accent-2: #67e8f9;         /* cyan, pour les noms de commande */
  --wip: #fbbf24;              /* ambre pour « en cours » */
  --error: #f87171;

  --radius: 6px;               /* coins peu arrondis : plus « technique » */
  --max-width: 1100px;
  --gutter: 1rem;              /* marge latérale sur mobile */

  /* Police monospace système : aucun téléchargement, donc un site plus rapide.
     SF Mono sur Mac, Cascadia/Consolas sur Windows, etc. */
  --font: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

  color-scheme: dark;          /* barres de défilement et champs natifs en sombre */
}

/* Thème clair « papier », activé par le bouton (data-theme="light" sur <html>) */
:root[data-theme="light"] {
  --bg: #f4f2ea;
  --surface: #fbfaf5;
  --surface-2: #ebe8dc;
  --text: #1f2421;
  --text-muted: #5f6a64;
  --border: #d6d2c4;
  --accent: #15803d;           /* vert plus foncé : lisible sur fond clair (contraste WCAG AA) */
  --accent-contrast: #ffffff;
  --accent-2: #0e7490;
  --wip: #b45309;
  --error: #b91c1c;
  color-scheme: light;
}


/* 2. BASE ------------------------------------------------------------------ */

/* box-sizing: border-box → la largeur d'un élément inclut son padding et sa bordure */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;     /* défilement doux quand on clique sur #projets, etc. */
  scroll-padding-top: 4.5rem;  /* évite que le header fixe cache le titre de la section */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;          /* le monospace paraît plus gros : on réduit un peu */
  line-height: 1.7;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
}

/* Titres de section façon chemin de dossier : « ~/projets ».
   content: "~/" / "" → le texte après le « / » est l'alternative pour les lecteurs
   d'écran (ici vide) : ils lisent juste « Projets ». */
h2 {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  margin-bottom: 1.5rem;
  text-transform: lowercase;
}

h2::before {
  content: "~/" / "";
  color: var(--accent);
}

a {
  color: var(--accent);
}

img {
  max-width: 100%;   /* une image ne déborde jamais de son conteneur */
  display: block;
}

/* Sélection de texte aux couleurs du terminal */
::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Contour visible uniquement à la navigation clavier (pas au clic souris) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* L'attribut hidden doit toujours gagner, même sur un élément en display: flex */
[hidden] {
  display: none !important;
}

/* Chaque section principale est centrée avec une largeur maximale */
main > section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3.5rem var(--gutter);
}

/* Une ligne de commande : « $ whoami » (le « $ » est ajouté par le CSS) */
.cmd {
  margin: 0;
  color: var(--accent-2);
}

.cmd::before {
  content: "$ ";
  color: var(--accent);
}


/* 3. COMPOSANTS -------------------------------------------------------------- */

/* Boutons façon option de terminal : [ GitHub ] */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

/* En flex, un espace au bord d'un ::before est supprimé : on espace avec une marge */
.btn::before { content: "[" / ""; margin-right: 0.4em; color: var(--text-muted); }
.btn::after  { content: "]" / ""; margin-left: 0.4em; color: var(--text-muted); }

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.btn-primary::before,
.btn-primary::after {
  color: inherit;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Badge « en cours » façon statut de processus : [en cours] */
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: lowercase;
  white-space: nowrap;
}

.badge::before { content: "[" / ""; }
.badge::after  { content: "]" / ""; }

.badge-wip {
  color: var(--wip);
}


/* 4. SECTIONS ---------------------------------------------------------------- */

/* Lien d'évitement : hors de l'écran, il réapparaît quand il reçoit le focus clavier */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
}

.skip-link:focus {
  top: 1rem;
}

/* --- Header --- */
.site-header {
  position: sticky;              /* reste collé en haut quand on scrolle */
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem var(--gutter);
  /* color-mix : la couleur de fond à 85 % d'opacité, pour un léger effet de transparence */
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.logo-prompt {
  color: var(--accent);
}

.site-header nav {
  margin-left: auto;             /* pousse la navigation vers la droite */
}

.nav-list {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  color: var(--text-muted);
  text-decoration: none;
  text-transform: lowercase;
}

.nav-list a::before {
  content: "./" / "";
  color: var(--border);
  transition: color 0.15s;
}

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

.nav-list a:hover::before {
  color: var(--accent);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.header-actions button {
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.header-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Hero : une fenêtre de terminal --- */
.hero {
  padding-top: 4rem;
  padding-bottom: 4rem;
}

.terminal {
  max-width: 52rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  /* Halo vert très léger autour de la fenêtre */
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 6%, transparent),
              0 20px 60px -20px color-mix(in srgb, var(--accent) 18%, transparent);
  overflow: hidden;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* Les trois ronds façon fenêtre macOS */
.terminal-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: #ff5f57;
}
.terminal-dot:nth-child(2) { background: #febc2e; }
.terminal-dot:nth-child(3) { background: #28c840; }

.terminal-title {
  flex: 1;
  margin-right: 2.5rem;          /* compense les ronds pour centrer visuellement le titre */
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.terminal-body {
  padding: 1.5rem 1.25rem 1.75rem;
}

.hero h1 {
  margin: 0.15rem 0 1.25rem;
  font-size: clamp(1.9rem, 7vw, 3.25rem);
  letter-spacing: -0.03em;
}

.hero-role {
  margin: 0.15rem 0 1rem;
  font-weight: 700;
}

/* Curseur clignotant à la fin de la ligne */
.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 0.25em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-pitch {
  max-width: 40rem;              /* une ligne trop longue est difficile à lire */
  color: var(--text-muted);
}

/* Le texte du pitch est précédé d'un « # » comme un commentaire de code */
.hero-pitch::before {
  content: "# " / "";
  color: var(--border);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;               /* les boutons passent à la ligne s'il n'y a pas la place */
  gap: 0.6rem;
  margin-top: 1.75rem;
}

/* --- Projets --- */
/* Grille : 1 colonne sur mobile, puis plus de colonnes (voir partie 5) */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;              /* l'image respecte les coins arrondis */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s;
}

.project-card:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  transform: translateY(-2px);
}

.project-image,
.project-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;          /* hauteur réservée → la page ne « saute » pas au chargement */
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}

/* Remplace l'image tant que la capture d'écran n'existe pas :
   un écran noir avec « ./cub3d » et un curseur, comme si on lançait le programme */
.project-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Lignes horizontales très fines, façon vieil écran cathodique */
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, color-mix(in srgb, var(--accent) 4%, transparent) 3px 4px),
    var(--surface-2);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
}

.project-placeholder::before {
  content: "$" / "";
  margin-right: 0.6em;
  color: var(--text-muted);
}

.project-placeholder::after {
  content: "" / "";
  width: 0.55em;
  height: 1.1em;
  margin-left: 0.3em;
  background: var(--accent);
  opacity: 0.8;
}

.project-body {
  display: flex;
  flex-direction: column;
  flex: 1;                       /* toutes les cartes d'une rangée ont la même hauteur */
  padding: 1.1rem 1.15rem 1.25rem;
}

.project-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Le titre ressemble à un nom de dossier : « minishell/ » */
.project-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--accent-2);
}

.project-header h3::after {
  content: "/" / "";
  color: var(--text-muted);
}

.project-meta {
  margin: 0.15rem 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.project-description {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.65;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: auto 0 0;              /* margin-top: auto → les tags restent en bas de la carte */
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--accent);
}

/* Chaque tag ressemble à un hashtag : #docker */
.project-tags li::before {
  content: "#" / "";
  color: var(--text-muted);
}

.project-link {
  margin-top: 1rem;
  font-size: 0.85rem;
}

.project-link::before {
  content: "→ " / "";
}

.projects-loading,
.projects-error {
  color: var(--text-muted);
}

.other-projects {
  margin-top: 2rem;
  padding: 1rem 1.15rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- À propos --- */
#a-propos p {
  max-width: 44rem;
}

/* --- Contact --- */
.contact-links {
  display: flex;
  flex-wrap: wrap;               /* les boutons passent à la ligne sur petit écran */
  gap: 0.6rem;
  margin-top: 1.5rem;
}

/* --- Fenêtre du CV --- */
.cv-dialog {
  /* min() : prend la plus petite valeur → jamais plus large que l'écran moins une marge */
  width: min(900px, 100vw - 2rem);
  height: min(1100px, 100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

/* La fenêtre n'est en display:flex que lorsqu'elle est ouverte,
   sinon elle resterait visible (un <dialog> fermé est en display:none) */
.cv-dialog[open] {
  display: flex;
  flex-direction: column;
}

/* ::backdrop = le fond qui recouvre le site derrière la fenêtre */
.cv-dialog::backdrop {
  background: rgb(0 0 0 / 0.7);
  backdrop-filter: blur(3px);
}

.cv-dialog-bar {
  flex-shrink: 0;
}

/* On annule le style des titres de section (« ~/ » et minuscules) pour ce titre-là */
.cv-dialog-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: none;
  text-align: left;
}

.cv-dialog-title::before {
  content: none;
}

.cv-dialog-actions {
  display: flex;
  gap: 0.5rem;
}

.cv-dialog-actions form {
  margin: 0;
}

.cv-dialog-actions .btn {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
}

.cv-frame {
  flex: 1;                       /* l'iframe prend toute la hauteur restante */
  width: 100%;
  border: 0;
  background: #525659;           /* gris neutre derrière le PDF, comme les lecteurs PDF */
}

/* --- Footer --- */
.site-footer {
  padding: 2rem var(--gutter);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.footer-cmd {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

.footer-cmd::before {
  content: "$ " / "";
  color: var(--text-muted);
}


/* 5. RESPONSIVE ---------------------------------------------------------------
   Mobile-first : les règles au-dessus sont pour les petits écrans.
   On ajoute ici seulement ce qui change quand l'écran s'élargit. */

/* Très petits écrans : on cache la nav (les sections restent accessibles en scrollant) */
@media (max-width: 559px) {
  .site-header nav {
    display: none;
  }
  .header-actions {
    margin-left: auto;
  }
}

@media (min-width: 700px) {
  :root {
    --gutter: 2rem;
  }
  .terminal-body {
    padding: 2rem 2.25rem 2.25rem;
  }
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1050px) {
  .projects-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* 6. ACCESSIBILITÉ --------------------------------------------------------------
   Certaines personnes désactivent les animations dans leur système
   (mal des transports, troubles vestibulaires). On respecte ce réglage. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
