/* ============================================
   COFAC Performance - Custom Styles
   Palette : Vert olive #4B5B3C | Orange #D97A2B
   ============================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- Base --- */
html {
  scroll-behavior: smooth;
  /* Les animations de reveal (.fade-right/.fade-left) decalent les blocs de
     +/-30px ; sur mobile cela peut depasser la largeur du viewport. On clippe
     a la racine pour eviter tout scroll horizontal parasite. */
  overflow-x: hidden;
}

body {
  font-family: 'Inter', sans-serif;
  color: #2D3A24;
  overflow-x: hidden;
}

code, .font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* --- Navigation --- */
.nav-link {
  position: relative;
  transition: color 0.3s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #D97A2B;
  transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link:hover,
.nav-link.active {
  color: #D97A2B;
}

/* --- Sticky header --- */
.header-scrolled {
  background-color: rgba(255, 255, 255, 0.97) !important;
  box-shadow: 0 1px 20px rgba(0, 0, 0, 0.08);
}

/* --- Hero gradient overlay --- */
.hero-gradient {
  background:
    linear-gradient(rgba(75, 91, 60, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 91, 60, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 15% 20%, rgba(217, 122, 43, 0.28) 0%, transparent 45%),
    radial-gradient(circle at 88% 25%, rgba(75, 91, 60, 0.24) 0%, transparent 50%),
    radial-gradient(circle at 55% 110%, rgba(217, 122, 43, 0.16) 0%, transparent 55%),
    linear-gradient(135deg, #fbf4ec 0%, #f0eee4 45%, #f6e6d2 100%);
  background-size: 64px 64px, 64px 64px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  position: relative;
}

/* Le hero est au-dessus de la ligne de flottaison : son contenu doit
   apparaitre immediatement, sans dependre du defilement (premiere impression). */
.hero-gradient .fade-up,
.hero-gradient .fade-right,
.hero-gradient .fade-left {
  opacity: 1;
  animation: heroReveal 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-gradient .fade-right { animation-delay: 0.15s; }

@keyframes heroReveal {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* --- Animated floating shapes --- */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33% { transform: translateY(-20px) rotate(5deg); }
  66% { transform: translateY(10px) rotate(-3deg); }
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(8deg); }
}

@keyframes floatReverse {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(25px) rotate(-6deg); }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes dash-move {
  to { stroke-dashoffset: -20; }
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.float-shape {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.float-shape-1 { animation: float 8s ease-in-out infinite; }
.float-shape-2 { animation: floatSlow 10s ease-in-out infinite; }
.float-shape-3 { animation: floatReverse 9s ease-in-out infinite; }
.float-shape-4 { animation: float 12s ease-in-out infinite 2s; }
.float-shape-5 { animation: floatSlow 11s ease-in-out infinite 1s; }

.blob-pulse {
  animation: pulse-glow 4s ease-in-out infinite;
}

.spin-slow {
  animation: spin-slow 30s linear infinite;
}

/* --- Grid pattern overlay --- */
.grid-pattern {
  background-image:
    linear-gradient(rgba(75, 91, 60, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 91, 60, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* --- Dot pattern --- */
.dot-pattern {
  background-image: radial-gradient(rgba(75, 91, 60, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* --- Browser mockup --- */
.browser-mockup {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.browser-mockup-bar {
  background: #f1f1f1;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #e5e5e5;
}

.browser-mockup-bar .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.browser-mockup-bar .url-bar {
  flex: 1;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.7rem;
  color: #888;
  margin-left: 8px;
  font-family: 'Inter', sans-serif;
}

/* --- Phone mockup --- */
.phone-mockup {
  background: #1a1a1a;
  border-radius: 36px;
  padding: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  width: 260px;
}

.phone-mockup-screen {
  background: #ffffff;
  border-radius: 26px;
  overflow: hidden;
  aspect-ratio: 9 / 19;
}

.phone-mockup-notch {
  width: 100px;
  height: 24px;
  background: #1a1a1a;
  border-radius: 0 0 16px 16px;
  margin: 0 auto;
}

/* --- Terminal mockup --- */
.terminal-mockup {
  background: #0d1117;
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.terminal-bar {
  background: #161b22;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-body {
  padding: 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.8;
  color: #c9d1d9;
}

.terminal-body .prompt {
  color: #58a6ff;
}

.terminal-body .success {
  color: #3fb950;
}

.terminal-body .warning {
  color: #d29922;
}

.terminal-body .info {
  color: #8b949e;
}

/* --- Typing cursor --- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background-color: #58a6ff;
  animation: blink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}

/* --- Glow effects --- */
.glow-orange {
  box-shadow: 0 0 60px rgba(217, 122, 43, 0.15), 0 0 120px rgba(217, 122, 43, 0.05);
}

.glow-green {
  box-shadow: 0 0 60px rgba(75, 91, 60, 0.15), 0 0 120px rgba(75, 91, 60, 0.05);
}

/* --- Gradient text --- */
.gradient-text {
  background: linear-gradient(135deg, #D97A2B 0%, #e58c42 50%, #D97A2B 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 4s ease infinite;
}

/* --- Section transitions --- */
.fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.fade-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-right.visible {
  opacity: 1;
  transform: translateX(0);
}

.scale-in {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.scale-in.visible {
  opacity: 1;
  transform: scale(1);
}

/* --- Cards --- */
.service-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4B5B3C, #D97A2B);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.service-card:hover::before {
  transform: scaleX(1);
}

.service-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 48px rgba(75, 91, 60, 0.12);
}

.project-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(75, 91, 60, 0.1);
}

/* --- Icon container with animated border --- */
.icon-box {
  position: relative;
}

.icon-box::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 16px;
  background: conic-gradient(from 0deg, #D97A2B, #4B5B3C, #D97A2B);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.service-card:hover .icon-box::after {
  opacity: 1;
}

/* --- Code block style --- */
.code-block {
  background: #1e1e2e;
  border-radius: 12px;
  padding: 1.5rem;
  color: #cdd6f4;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  overflow-x: auto;
}

.code-block .comment { color: #6c7086; }
.code-block .keyword { color: #cba6f7; }
.code-block .string { color: #a6e3a1; }
.code-block .function { color: #89b4fa; }
.code-block .operator { color: #f9e2af; }
.code-block .tag { color: #f38ba8; }

/* --- Buttons --- */
.btn-primary {
  background-color: #D97A2B;
  color: #ffffff;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  background-color: #c06a1f;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(217, 122, 43, 0.3);
}

.btn-secondary {
  background-color: #4B5B3C;
  color: #ffffff;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background-color: #3d4a2e;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(75, 91, 60, 0.3);
}

.btn-outline {
  border: 2px solid #4B5B3C;
  color: #4B5B3C;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
}

.btn-outline:hover {
  background-color: #4B5B3C;
  color: #ffffff;
  transform: translateY(-2px);
}

/* --- Tags / pills --- */
.tech-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #f0efe8;
  color: #4B5B3C;
  transition: all 0.2s ease;
}

.tech-pill:hover {
  background-color: #4B5B3C;
  color: #ffffff;
}

/* --- Skill bars animated --- */
.skill-bar-fill {
  height: 100%;
  border-radius: 9999px;
  width: 0;
  transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.skill-bar-fill.animated {
  /* width set inline */
}

/* --- Timeline --- */
.timeline-item {
  position: relative;
  padding-left: 2rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #D97A2B;
  border: 3px solid #fdf5ee;
  box-shadow: 0 0 0 2px #D97A2B;
}

.timeline-item::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 24px;
  width: 2px;
  height: calc(100% - 16px);
  background-color: #e5e2d8;
}

.timeline-item:last-child::after {
  display: none;
}

/* --- Form inputs --- */
.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid #e5e2d8;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  color: #2D3A24;
  background-color: #ffffff;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: #D97A2B;
  box-shadow: 0 0 0 3px rgba(217, 122, 43, 0.15);
}

.form-input::placeholder {
  color: #9ca38d;
}

/* Harmonisation des listes deroulantes avec les champs texte :
   on neutralise l'apparence native et on ajoute notre propre fleche. */
select.form-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%236f7f5c'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M6%209l6%206%206-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.1rem;
}

/* Affiche l'option vide (placeholder) en grise, comme les autres champs */
select.form-input:has(option[value=""]:checked) {
  color: #9ca38d;
}

/* --- Choix Particulier / Professionnel (controle segmente) --- */
.type-toggle {
  display: block;
  cursor: pointer;
}

.type-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-toggle-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 56px;
  padding: 0.75rem 1rem;
  border: 2px solid #e5e2d8;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  color: #6f7f5c;
  background-color: #ffffff;
  transition: border-color 0.25s ease, background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.type-toggle-box svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.type-toggle:hover .type-toggle-box {
  border-color: #b3bca2;
}

.type-toggle input:checked + .type-toggle-box {
  border-color: #D97A2B;
  background-color: #fdf5ee;
  color: #c06a1f;
}

.type-toggle input:focus-visible + .type-toggle-box {
  box-shadow: 0 0 0 3px rgba(217, 122, 43, 0.15);
}

/* --- Stat counter animation --- */
@keyframes countUp {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.stat-number {
  animation: countUp 0.6s ease forwards;
}

/* --- Hamburger menu --- */
.hamburger-line {
  width: 24px;
  height: 2px;
  background-color: #4B5B3C;
  transition: all 0.3s ease;
}

.menu-open .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.menu-open .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* --- Mobile menu --- */
.mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.mobile-menu.open {
  max-height: 400px;
}

/* --- Footer --- */
.footer-link {
  color: #9ca38d;
  transition: color 0.3s ease;
}

.footer-link:hover {
  color: #D97A2B;
}

/* --- Scroll to top --- */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #4B5B3C;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  cursor: pointer;
  z-index: 50;
  border: none;
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-top:hover {
  background-color: #D97A2B;
  transform: translateY(-3px);
}

/* --- Bouton flottant "Nous contacter" --- */
.contact-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 52px;
  padding: 0 1.35rem;
  border-radius: 9999px;
  background-color: #D97A2B;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 12px 28px -6px rgba(217, 122, 43, 0.55), 0 6px 10px -6px rgba(0, 0, 0, 0.25);
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  animation: fabPulse 2.8s ease-in-out infinite;
}

.contact-fab svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.contact-fab:hover {
  background-color: #c06a1f;
  transform: translateY(-3px);
  box-shadow: 0 18px 34px -6px rgba(217, 122, 43, 0.6), 0 6px 10px -6px rgba(0, 0, 0, 0.3);
}

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 12px 28px -6px rgba(217, 122, 43, 0.55), 0 0 0 0 rgba(217, 122, 43, 0.45); }
  50%      { box-shadow: 0 12px 28px -6px rgba(217, 122, 43, 0.55), 0 0 0 12px rgba(217, 122, 43, 0); }
}

/* Decale le bouton "retour en haut" au-dessus du bouton flottant,
   uniquement sur les pages qui contiennent ce bouton (zero impact ailleurs). */
body:has(.contact-fab) .scroll-top { bottom: 6rem; }

@media (max-width: 640px) {
  .contact-fab { bottom: 1.25rem; right: 1.25rem; height: 48px; padding: 0 1.15rem; font-size: 0.85rem; }
  body:has(.contact-fab) .scroll-top { bottom: 5rem; right: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .contact-fab { animation: none; }
}

/* --- Marquee tech --- */
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 30s linear infinite;
}

.marquee-track:hover {
  animation-play-state: paused;
}

/* --- Selection --- */
::selection {
  background-color: rgba(217, 122, 43, 0.2);
  color: #2D3A24;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.25rem !important;
  }

  .section-title {
    font-size: 1.75rem !important;
  }

  .float-shape {
    display: none;
  }

  .phone-mockup {
    width: 200px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.75rem !important;
  }
}
