/**
 * ============================================
 * POLARBEAR CONCEPT - Stylesheet Principal
 * @version 2.0
 * @author PolarBear Concept
 * ============================================
 */

/* ====================================== */
/* VARIABLES CSS (Custom Properties) */
/* ====================================== */

:root {
    /* Couleurs Principales */
    --primary-color: #0066cc;
    --primary-dark: #004c99;
    --primary-light: #3385d6;
    
    --secondary-color: #1a1a2e;
    --secondary-dark: #0f0f1a;
    --secondary-light: #2a2a3e;
    
    --accent-color: #ff6b35;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    
    /* Nuances de gris */
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* Typographie */
    --font-primary: 'Montserrat', sans-serif;
    --font-secondary: 'Roboto', sans-serif;
    
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-sm: 0.875rem;
    --font-size-xs: 0.75rem;
    
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-black: 900;
    
    /* Espacements */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    /* Décalage par défaut pour le stats overlay (peu visible, ajustable) */
    --stats-offset-x: 12px; /* move slightly right from center */
    --stats-offset-y: -12px; /* move slightly up from default lower position */
    /* Hauteur calculée du texte hero (sera définie par JS) */
    --hero-text-height: auto;
}

/* ====================================== */
/* RESET & BASE STYLES */
/* ====================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-secondary);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--gray-800);
    background-color: #fff;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-bold);
    line-height: 1.3;
    color: var(--secondary-color);
    margin-bottom: var(--spacing-sm);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.5rem, 3.5vw, 2rem); }
h4 { font-size: clamp(1.25rem, 3vw, 1.5rem); }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-sm);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    display: block;
}

ul, ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* ====================================== */
/* PRELOADER */
/* ====================================== */

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-in-out;
}

.preloader-content {
    text-align: center;
}

/* ====================================== */
/* NAVIGATION */
/* ====================================== */

.navbar {
    background: transparent;
    padding: var(--spacing-md) 0;
    transition: all var(--transition-base);
}

.navbar-scrolled {
    background: rgba(26, 26, 46, 0.95) !important;
    /* backdrop-filter removed for compatibility */
    box-shadow: var(--shadow-md);
    padding: var(--spacing-sm) 0;
}

.navbar-brand {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: #fff !important;
}

.navbar-logo {
    height: 50px;
    margin-right: var(--spacing-sm);
    transition: transform var(--transition-base);
}

.navbar-brand:hover .navbar-logo {
    transform: scale(1.1);
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8) !important;
    font-weight: var(--font-weight-medium);
    font-family: var(--font-primary);
    padding: var(--spacing-xs) var(--spacing-md);
    margin: 0 var(--spacing-xs);
    position: relative;
    transition: color var(--transition-base);
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transform: translateX(-50%);
    transition: width var(--transition-base);
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    color: #fff !important;
}

.navbar-nav .nav-link:hover::after,
.navbar-nav .nav-link.active::after {
    width: 80%;
}

/* ====================================== */
/* HERO SECTION */
/* ====================================== */

.hero-section {
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('../images/hero-bg.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    padding: 200px 0 150px;
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;    
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 50%;
    background: rgba(26, 26, 46, 0.7);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    color: #fff;
}

.hero-section h1 {
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-section .lead {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
}

.hero-buttons .btn {
    margin: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scroll-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.scroll-down {
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    color: #fff;
    font-size: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: bounce 2s infinite;
    transition: all var(--transition-base);
}

.scroll-down:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-5px);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* ====================================== */
/* SECTIONS */
/* ====================================== */

.section-padding {
    padding: var(--spacing-xxl) 0;
}

.section-header h6 {
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    letter-spacing: 1px;
    margin-bottom: var(--spacing-xs);
}

.section-header h2 {
    color: var(--secondary-color);
    margin-bottom: var(--spacing-md);
}

/* ====================================== */
/* ABOUT SECTION */
/* ====================================== */

.about-image-wrapper {
    position: relative;
    /* Forcer la hauteur à la hauteur du texte hero (définie dynamiquement) — limite image et overlay */
    height: var(--hero-text-height, auto);
    max-height: var(--hero-text-height, none);
    /* autoriser le débordement pour que l'overlay ne soit pas coupé */
    overflow: visible;
    display: block;
}

/* Image améliorée : réserve l'espace (aspect-ratio) pour réduire le CLS et reste responsive */
.about-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-width: 680px;
    border-radius: var(--border-radius-lg);
    display: block;
}

.stats-overlay {
    position: absolute;
    /* Positionner l'overlay de sorte que son centre vertical corresponde au bas de la photo
       - top:100% place le haut de l'overlay au bas de l'image
       - translateY(-50%) remonte de la moitié de la hauteur de l'overlay -> centre aligné sur le bas */
    top: 100%;
    left: calc(50% + var(--stats-offset-x));
    transform: translate(calc(-50%), calc(-50% + var(--stats-offset-y)));
    width: calc(100% - 40px);
    max-width: 520px;
    /* fond semi-transparent (backdrop-filter retiré pour compatibilité) */
    background: linear-gradient(135deg, rgba(0,102,204,0.92), rgba(0,76,153,0.88));
    color: #fff;
    padding: var(--spacing-lg);
    border-radius: calc(var(--border-radius-lg) * 1.25);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    z-index: 2;
}

/* ajustements pour petits écrans */
@media (max-width: 768px) {
    .stats-overlay {
        width: calc(100% - 24px);
        padding: var(--spacing-md);
        /* ajuster les variables pour petits écrans plutôt que forcer un transform */
        --stats-offset-x: 6px;
        --stats-offset-y: 8px;
        border-radius: var(--border-radius-md);
    }

    .stats-overlay {
        /* Sur petits écrans, rapprocher l'overlay à l'intérieur de l'image */
        top: 100%;
        transform: translate(calc(-50%), calc(-45% + var(--stats-offset-y)));
    }
}

/* si les données sont sémantiques, cibler le texte pour accessibilité */
.stats-overlay .stat-item h3,
.stats-overlay .stat-item p {
    color: #fff;
}

/* option : prévenir animations lourdes si user préfère moins de mouvement */
@media (prefers-reduced-motion: reduce) {
    .stats-overlay { transition: none; transform: none; bottom: -12px; }
}

.stat-item h3 {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 0;
}

.stat-item p {
    font-size: var(--font-size-sm);
    margin-bottom: 0;
}

/* ====================================== */
/* SERVICE CARDS */
/* ====================================== */

.service-card {
    background: #fff;
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all var(--transition-base);
    border: 1px solid var(--gray-200);
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.service-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 50%;
    font-size: 2rem;
    color: #fff;
    box-shadow: var(--shadow-md);
}

.service-card h4 {
    color: var(--secondary-color);
    margin-top: var(--spacing-md);
}

.service-card p {
    color: var(--gray-600);
}

/* ====================================== */
/* PROJECT CARDS */
/* ====================================== */

.project-card {
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.project-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-5px);
}

.project-image {
    position: relative;
    overflow: hidden;
    height: 300px;
}

.project-image { cursor: pointer; }

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

/* ensure image stays behind the overlay even when transformed */
.project-image img { position: relative; z-index: 1; }

.project-card:hover .project-image img {
    transform: scale(1.1);
}

.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    padding: var(--spacing-lg);
    z-index: 2; /* ensure overlay sits above transformed images */
    pointer-events: auto; /* make buttons clickable by default */
}

/* gradient handled by pseudo-element so children (button) stay visible */
.project-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(26, 26, 46, 0.95), transparent);
    opacity: 0;
    transition: opacity var(--transition-base);
    z-index: 1;
}

.project-overlay .project-info { z-index: 2; }

.project-card:hover .project-overlay::before {
    opacity: 1;
}

.project-info h5 {
    color: #fff;
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
}

.project-info p {
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-xs);
}

/* ====================================== */
/* CLIENTS SECTION */
/* ====================================== */

.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-lg);
    align-items: center;
}

.client-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-md);
    background: #fff;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    height: 120px;
}

.client-logo:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.client-logo img {
    max-height: 80px;
    width: auto;
    filter: grayscale(100%);
    opacity: 0.6;
    transition: all var(--transition-base);
}

.client-logo:hover img {
    filter: grayscale(0%);
    opacity: 1;
}

/* ====================================== */
/* TEAM SECTION */
/* ====================================== */

.team-member {
    background: #fff;
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
}

.member-photo img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    margin: 0 auto;
    border: 5px solid var(--primary-color);
}

.team-member h4 {
    color: var(--secondary-color);
}

.team-member .text-primary {
    font-weight: var(--font-weight-semibold);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
}

.social-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    color: var(--gray-700);
    border-radius: 50%;
    transition: all var(--transition-base);
}

.social-icon:hover {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-3px);
}

/* ====================================== */
/* TESTIMONIALS SECTION */
/* ====================================== */

.testimonials-section {
    position: relative;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark)),
                url('../images/testimonial-bg.jpg') center/cover no-repeat;
    background-attachment: fixed;
}

.testimonials-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.9);
}
.testimonial-card {
    background: rgba(255, 255, 255, 0.1);
    /* backdrop-filter removed for compatibility */
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-base);
}

.testimonial-card:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-5px);
}

.testimonial-text {
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
    font-size: 1.125rem;
    line-height: 1.8;
}

.testimonial-card h6 {
    color: #fff;
    margin-bottom: 0;
}

.testimonial-card small {
    color: rgba(255, 255, 255, 0.7);
}

/* ====================================== */
/* CONTACT SECTION */
/* ====================================== */

.contact-section {
    position: relative;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark)),
                url('../images/contact-bg.jpg') center/cover no-repeat;
    background-attachment: fixed;
}

.contact-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.85);
}

.contact-info-card {
    background: rgba(255, 255, 255, 0.1);
    /* backdrop-filter removed for compatibility */
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.contact-info-item .icon-wrapper {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 50%;
    font-size: 1.5rem;
    color: #fff;
}

.contact-info-item h5 {
    color: #fff;
}

.contact-info-item p,
.contact-info-item a {
    color: rgba(255, 255, 255, 0.8);
}

.contact-info-item a:hover {
    color: var(--primary-light);
}

.contact-form-wrapper {
    background: #fff;
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
}

.form-label {
    font-weight: var(--font-weight-semibold);
    color: var(--secondary-color);
    margin-bottom: var(--spacing-xs);
}

.form-control {
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    transition: all var(--transition-base);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.invalid-feedback {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--danger-color);
}

.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ====================================== */
/* BUTTONS */
/* ====================================== */

.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-primary);
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-outline-light {
    border: 2px solid #fff;
    color: #fff;
    background: transparent;
}

.btn-outline-light:hover {
    background: #fff;
    color: var(--primary-color);
}

/* ====================================== */
/* FOOTER */
/* ====================================== */

footer {
    background-color: var(--dark-color);
}

footer .social-icons a {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

footer .social-icons a:hover {
    background-color: var(--primary-color);
}

footer a:hover {
    color: var(--primary-color) !important;
}

footer .col-lg-3 h5 {
    color: #fff;
    margin-bottom: var(--spacing-sm);
}

/* ====================================== */
/* MODAL DETAILS - PROJETS (responsive: keep image, buttons, and text visible) */
/* Contrainte de taille pour que l'image et le contenu tiennent dans la fenêtre active */
/* ====================================== */

#projetModal .modal-dialog {
    width: 95%;
    max-width: 900px;
    margin: 0.5rem auto;
    max-height: 100vh; /* ensure dialog never exceeds viewport height */
}

#projetModal .modal-content {
    border-radius: calc(var(--border-radius-lg) * 0.9);
    max-height: calc(100vh - 20px); /* leave small margin around modal */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#projetModal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 120px);
    overflow: hidden; /* seul le texte défilera */
}

.modal-image-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#modalProjetImage {
    width: 100%;
    height: auto;
    max-height: 45vh; /* desktop/tablette */
    object-fit: contain;
}

/* description prend le reste et défile */
#modalProjetDescription {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 4rem;
}

/* Small screens: réduire la hauteur de l'image pour garantir visibilité texte + boutons */
@media (max-width: 576px) {
    #modalProjetImage {
        max-height: 30vh; /* réduit sur petits écrans */
    }
    #projetModal .modal-content {
        max-height: calc(100vh - 20px);
    }
}

@media (min-width: 1200px) {
    #projetModal .modal-dialog { max-width: 1100px; }
    #projetModal .modal-body { max-height: calc(80vh - 140px); }
}

/* Keep Bootstrap centering/behavior for the modal dialog.
   Add only a subtle transition + shadow to modal content. */
#projetModal .modal-content {
    transition: all 240ms ease-in-out;
    box-shadow: 0 20px 40px rgba(0,0,0,0.35);
}

/* Image wrapper with enforced aspect ratio (16:9) but contain so it never crops */
.modal-image-wrapper {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #f6f7fb;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

.modal-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.modal-image-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.6);
    z-index: 5;
}

/* Truncate description to 4 lines with 'Voir plus' */
.truncated {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#modalVoirPlus {
    display: inline-block;
    margin-top: 0.5rem;
    color: var(--primary-color);
    cursor: pointer;
}

/* Expanded state */
.expanded {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

@media (max-width: 767px) {
    .modal-image-wrapper { aspect-ratio: 4/3; }
    #projetModal .modal-dialog { width: calc(100% - 24px); }
}

/* Services Styles */
.service-card {
    border: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.service-card .service-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
}