/* ==========================================================================
   Portfolio — Matéo Grossi
   ========================================================================== */

/* Thème clair (par défaut) */
:root {
  color-scheme: light;

  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --border: #e1ded7;
  --border-hover: #c9c5bc;
  --text: #1b1a18;
  --text-soft: #3d3b37;
  --muted: #6a675f;
  --accent: #985a06;
  --accent-hover: #7d4a04;

  --header-bg: rgba(246, 245, 242, 0.85);
  --hover-bg: rgba(0, 0, 0, 0.05);
  --shadow: 0 14px 34px rgba(30, 25, 15, 0.12);

  --radius: 12px;
  --maxw: 1200px;
  --gutter: 24px;
  --header-h: 68px;
  --header-gutter: clamp(16px, 4vw, 56px);

  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading: "Merriweather", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* Thème sombre : choisi via le bouton, ou celui du système.
   L'accueil reste toujours sombre (texte blanc sur la vidéo). */
:root[data-theme="dark"],
.home {
  color-scheme: dark;

  --bg: #0e0e10;
  --surface: #16161a;
  --surface-2: #1e1e23;
  --border: #2a2a31;
  --border-hover: #3d3d46;
  --text: #ededf0;
  --text-soft: #c9c9cf;
  --muted: #9d9da6;
  --accent: #f0b54a;
  --accent-hover: #f6c76f;

  --header-bg: rgba(14, 14, 16, 0.85);
  --hover-bg: rgba(255, 255, 255, 0.07);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}

/* Sans JavaScript : on suit le thème du système */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0e0e10;
    --surface: #16161a;
    --surface-2: #1e1e23;
    --border: #2a2a31;
    --border-hover: #3d3d46;
    --text: #ededf0;
    --text-soft: #c9c9cf;
    --muted: #9d9da6;
    --accent: #f0b54a;
    --accent-hover: #f6c76f;

    --header-bg: rgba(14, 14, 16, 0.85);
    --hover-bg: rgba(255, 255, 255, 0.07);
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

/* Langue : chaque texte existe en français et en anglais, seule la langue
   choisie (attribut data-lang sur <html>) est affichée */
html[data-lang="fr"] [data-lang="en"],
html[data-lang="en"] [data-lang="fr"] {
  display: none !important;
}

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

/* --------------------------------------------------------------------------
   Icônes
   -------------------------------------------------------------------------- */

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.icon-fill {
  fill: currentColor;
}

.icon-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   En-tête et navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* Navigation centrée ; boutons thème / menu dans le coin droit */
.header-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 0 var(--header-gutter);
}

.site-nav {
  grid-column: 2;
}

.site-nav ul {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 8px 16px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: underline 2px transparent;
  text-underline-offset: 8px;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.site-nav a:hover {
  color: var(--text);
  text-decoration-color: var(--border-hover);
}

/* Onglet actif : souligné de la couleur du texte (blanc en thème sombre) */
.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration-color: var(--text);
}

/* Avec JavaScript, le soulignement de l'onglet actif est un trait séparé
   qui glisse depuis l'onglet de la page précédente (voir main.js) */
.site-nav ul {
  position: relative;
}

.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  pointer-events: none;
}

.nav-indicator.is-animated {
  transition: transform 0.4s ease, width 0.4s ease;
}

.js .site-nav a[aria-current="page"] {
  text-decoration-color: transparent;
}

.header-tools {
  display: flex;
  grid-column: 3;
  justify-self: end;
  gap: 8px;
}

.lang-toggle,
.theme-toggle,
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.lang-toggle:hover,
.theme-toggle:hover,
.nav-toggle:hover {
  border-color: var(--border-hover);
  background: var(--hover-bg);
}

/* Les boutons de langue et de thème n'ont de sens qu'avec JavaScript */
.lang-toggle,
.theme-toggle {
  display: none;
}

.js .lang-toggle,
.js .theme-toggle {
  display: inline-flex;
}

/* Bouton FR / EN : la langue active est en couleur normale, l'autre est atténuée */
.lang-toggle {
  width: auto;
  gap: 6px;
  padding: 0 10px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
}

.lang-opt {
  color: var(--muted);
}

html[data-lang="fr"] .lang-opt[data-opt="fr"],
html[data-lang="en"] .lang-opt[data-opt="en"] {
  color: var(--text);
}

/* Soleil en thème sombre (passer au clair), lune en thème clair */
.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 0 10px;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.25s, opacity 0.25s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 720px) {
  .js .nav-toggle {
    display: inline-flex;
  }

  .js .site-nav {
    display: none;
    grid-column: auto;
    position: absolute;
    top: calc(var(--header-h) - 1px);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .js .site-nav.is-open {
    display: block;
  }

  .js .site-nav ul {
    flex-direction: column;
    padding: 12px 16px 16px;
  }

  .js .site-nav a {
    padding: 12px 16px;
    border-radius: 10px;
  }

  /* Menu mobile vertical : soulignement classique, sans trait glissant */
  .nav-indicator {
    display: none;
  }

  .js .site-nav a[aria-current="page"] {
    text-decoration-color: var(--text);
  }
}

/* --------------------------------------------------------------------------
   Boutons et liens
   -------------------------------------------------------------------------- */

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.link-arrow:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.link-arrow .icon {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Accueil : vidéo plein écran
   -------------------------------------------------------------------------- */

/* Accueil, 3D et CV : barre de défilement masquée, le défilement reste possible */
html:has(body.home),
html:has(body.page-3d),
html:has(body.page-cv) {
  scrollbar-width: none;
}

html:has(body.home)::-webkit-scrollbar,
html:has(body.page-3d)::-webkit-scrollbar,
html:has(body.page-cv)::-webkit-scrollbar {
  display: none;
}

.home .site-header {
  position: fixed;
  inset: 0 0 auto;
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
  border-bottom: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.home .site-nav a:not([aria-current="page"]) {
  color: rgba(255, 255, 255, 0.82);
}

.home .lang-toggle,
.home .theme-toggle,
.home .nav-toggle {
  border-color: rgba(255, 255, 255, 0.3);
}

.hero-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: #000;
}

.hero-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Assombrit surtout le bas à gauche, là où se trouve le texte */
.hero-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 0% 100%, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.15) 100%);
}

.hero {
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--header-h) var(--header-gutter) clamp(32px, 8vh, 80px);
}

.hero-content {
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}

.hero-kicker {
  margin: 0 0 14px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  color: #fff;
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 6.5vw, 5.25rem);
  font-weight: 300;
  line-height: 1.1;
}

.hero h1 strong {
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Pages intérieures
   -------------------------------------------------------------------------- */

/* Pages 3D, Programmation et CV : pas de couleur d'accent dans le contenu,
   on utilise la couleur du texte (blanc en thème sombre, noir en thème clair) */
.page-3d main,
.page-code main,
.page-cv main {
  --accent: var(--text);
  --accent-hover: var(--text);
}

/* Pied de page collé en bas de l'écran, même quand la page est courte */
body:not(.home) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 56px var(--gutter) 88px;
}

.page-head {
  max-width: 720px;
  margin-bottom: 40px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.page-head h1 {
  margin: 0 0 14px;
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.2;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
}

.page-head .link-arrow {
  margin-top: 16px;
}

/* --------------------------------------------------------------------------
   Page 3D : galerie Masonry
   -------------------------------------------------------------------------- */

.masonry {
  column-count: 2;
  column-gap: 24px;
}

.work {
  break-inside: avoid;
  margin: 0 0 24px;
}

/* Sur grand écran, la galerie tient dans la hauteur de la fenêtre, sans défiler :
   SpaceDan occupe les deux premières colonnes de la 1re ligne, les 4 autres projets
   remplissent le reste.
   Images et vidéos sont recadrées (object-fit: cover) pour remplir chaque case. */
@media (min-width: 1001px) and (min-height: 600px) {
  .page-3d {
    height: 100vh;
    height: 100svh;
  }

  .page-3d .page {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
  }

  .page-3d .masonry {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  .page-3d .work {
    min-height: 0;
    margin: 0;
  }

  .page-3d .work:first-child {
    grid-column: span 2;
  }

  .page-3d .work-link {
    height: 100%;
  }

  .page-3d .work-media {
    height: 100%;
    aspect-ratio: auto;
  }
}

.work-link {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: transform 0.25s ease, border-color 0.25s, box-shadow 0.25s;
}

.work-link:hover,
.work-link:focus-visible {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.work-media {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ratio, 16 / 9);
  background: #000;
}

.work-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, center);
  transition: transform 0.6s ease;
}

.work-link:hover .work-media img {
  transform: scale(1.03);
}

.work-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, center);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.work-media.is-playing video {
  opacity: 1;
}

/* Dégradé sombre en bas de la carte, pour la lisibilité du titre */
.work-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 45%);
  pointer-events: none;
}

.work-title {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  margin: 0;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------------------------------------
   Page Code : une box par projet
   -------------------------------------------------------------------------- */

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.code-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.25s ease, border-color 0.25s, box-shadow 0.25s;
}

.code-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.code-card-body {
  flex: 1;
  padding: 24px 24px 20px;
}

.code-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
}

.code-card p {
  margin: 0 0 18px;
  color: var(--text-soft);
}

.code-card code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.85em;
}

.code-card-foot {
  display: flex;
  justify-content: center;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Page CV & Contact
   -------------------------------------------------------------------------- */

.cv-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.cv-aside,
.cv-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.cv-aside {
  position: sticky;
  top: calc(var(--header-h) + 24px);
}

.panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel h2 {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.skills-grid h3 {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.contact-list a:hover .contact-value {
  color: var(--accent);
}

.icon-box {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-soft);
  transition: color 0.2s, border-color 0.2s;
}

.contact-list a:hover .icon-box {
  color: var(--accent);
  border-color: var(--border-hover);
}

.contact-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.contact-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.contact-value {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.2s;
}

.lang-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.lang-list span {
  color: var(--muted);
}

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

.timeline li {
  position: relative;
  padding: 0 0 26px 26px;
  border-left: 2px solid var(--border);
}

.timeline li:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.timeline li::before {
  content: "";
  position: absolute;
  top: 5px;
  left: -8px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.tl-date {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.tl-title {
  margin: 2px 0 0;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
}

.tl-place {
  color: var(--muted);
  font-family: var(--font);
  font-weight: 400;
}

.tl-role {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-style: italic;
}

.tl-desc {
  margin: 4px 0 0;
  color: var(--text-soft);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chips li {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.925rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Pied de page
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px var(--gutter);
  color: var(--muted);
  font-size: 0.925rem;
}

.footer-inner p {
  margin: 0;
}

.socials {
  display: flex;
  gap: 6px;
}

.socials a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.2s, background-color 0.2s;
}

.socials a:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1000px) {
  .cv-layout {
    grid-template-columns: 1fr;
  }

  .cv-aside {
    position: static;
  }
}

@media (max-width: 800px) {
  .code-grid {
    grid-template-columns: 1fr;
  }

  .skills-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .masonry {
    column-count: 1;
  }

  .page {
    padding-top: 40px;
    padding-bottom: 64px;
  }

  .panel {
    padding: 20px;
  }

  .code-card-body {
    padding: 20px 18px 16px;
  }

  .code-card-foot {
    padding: 14px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
