/* ============================================
   MOBILE RESPONSIVE - DATA WORLDS
   Optimisations complètes pour mobile et tablette
   ============================================ */

/* ========================================
   BREAKPOINTS & UTILITIES MOBILE
   ======================================== */

/* Touch targets minimum 44x44px */
@media (pointer: coarse) {
  button, a, input, select, textarea,
  .btn, .form-button, .nav-link {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
  .btn:hover,
  .form-button:hover,
  .project-card:hover {
    transform: none;
  }
}

/* ========================================
   GLOBAL MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
  
  /* Container adjustments */
  .container,
  .container-portefolio {
    width: 100%;
    padding: 0 1.25rem;
  }

  /* Typography scaling */
  body {
    font-size: 15px;
  }

  h1 { font-size: clamp(1.75rem, 7vw, 2.25rem); }
  h2 { font-size: clamp(1.5rem, 5vw, 2rem); }
  h3 { font-size: clamp(1.25rem, 4vw, 1.5rem); }
  
  /* Spacing reductions */
  section {
    padding: 2.5rem 0;
  }

  /* Images responsive */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Hide overflow on mobile */
  body {
    overflow-x: hidden;
  }

  /* Hide desktop nav */
  .header-nav,
  .header-cta,
  .header-right {
    display: none !important;
  }

  /* Show burger */
  .burger,
  .mobile-menu-btn,
  #hamburger-btn {
    display: flex !important;
  }

  /* Adjust header height */
  .site-header,
  header {
    height: 64px;
  }

  .header-logo img {
    height: 36px;
  }

  /* Adjust container padding */
  .header-container {
    padding: 0 1.5rem;
  }

  /* Mobile sheet */
  .mobile-sheet,
  #mobile-sheet {
    padding: 2rem 1.5rem;
    max-height: 80vh;
  }

  .mobile-sheet-nav a {
    padding: 1rem;
    font-size: 1.125rem;
  }
}

/* ========================================
   TABLET BREAKPOINT
   ======================================== */

@media (min-width: 769px) and (max-width: 980px) {
  
  /* Hide desktop navigation */
  .header-nav,
  .header-right {
    display: none !important;
  }

  /* Show burger menu */
  .burger,
  .mobile-menu-btn,
  #hamburger-btn {
    display: flex !important;
  }

  header,
  .site-header {
    height: 64px;
  }

  .header-container {
    padding: 0 1.5rem;
  }

  .header-logo img {
    height: 38px;
  }

  .mobile-sheet,
  #mobile-sheet {
    padding: 2rem 1.5rem;
    max-height: 75vh;
  }
}

/* ========================================
   SMALL MOBILE
   ======================================== */

@media (max-width: 480px) {
  
  .mobile-sheet,
  #mobile-sheet {
    padding: 1.5rem 1rem;
    max-height: 85vh;
  }

  .mobile-sheet-nav a {
    padding: 0.75rem;
    font-size: 1rem;
  }

  /* Burger slightly smaller */
  .burger,
  #hamburger-btn {
    width: 36px;
    height: 36px;
  }
}

/* ========================================
   HERO SECTIONS MOBILE
   ======================================== */

@media (max-width: 980px) {
  
  /* Portfolio Hero */
  .portfolio-hero {
    padding: 2rem 0;
  }

  .portfolio-hero-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 2rem;
  }

  .hero-left {
    text-align: center;
  }

  .hero-badge {
    justify-content: center;
  }

  .hero-ctas {
    flex-direction: column;
    gap: 0.75rem;
  }

  .hero-ctas .form-button,
  .hero-ctas .form-button-secondary {
    width: 100%;
    justify-content: center;
  }

  .hero-right {
    width: 100%;
  }

  .hero-stats {
    flex-direction: row;
    gap: 0.75rem;
  }

  .portefolio-stat-card {
    flex: 1;
    min-width: 0;
    padding: 0.75rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .portefolio-stat-icon {
    width: 35px;
    height: 35px;
    font-size: 0.95rem;
  }

  .hero-visual {
    margin-top: 1rem;
  }

  .hero-visual img {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
  }
}

@media (max-width: 480px) {
  
  .portfolio-hero {
    padding: 1.5rem 0;
  }

  .hero-title {
    font-size: 1.75rem;
    line-height: 1.15;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .hero-stats {
    flex-direction: column;
    gap: 0.6rem;
  }

  .portefolio-stat-card {
    padding: 0.6rem 0.8rem;
  }
}

/* ========================================
   CV PAGE MOBILE (DiegoNegrier.html)
   ======================================== */

@media (max-width: 980px) {
  
  /* CV Hero */
  .cv-hero {
    min-height: auto;
    padding: 2rem 0;
  }

  .cv-hero-content {
    padding: 1.5rem;
  }

  .cv-profile-section {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .cv-floating-photo {
    position: static;
    transform: none;
    margin-bottom: 1.5rem;
    width: 140px;
    height: 140px;
  }

  .cv-profile-info {
    margin-bottom: 1.5rem;
  }

  .cv-name {
    font-size: 1.75rem;
  }

  .cv-job-title {
    font-size: 1.125rem;
  }

  .cv-social-links {
    justify-content: center;
  }

  .cv-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .cv-actions a {
    width: 100%;
    justify-content: center;
  }

  /* Skills grid */
  .cv-skills-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  /* Expertise grid */
  .cv-expertise-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Timeline */
  .cv-timeline-item {
    padding-left: 2.5rem;
  }

  .cv-timeline-marker {
    left: 0;
  }

  .cv-timeline-content {
    margin-left: 0;
  }

  .cv-timeline-with-image {
    flex-direction: column;
  }

  .cv-timeline-image {
    width: 100%;
    margin-bottom: 1rem;
  }

  .cv-logo {
    max-width: 120px;
    margin: 0 auto;
    display: block;
  }

  .cv-timeline-header-compact {
    text-align: center;
  }

  /* Projects section */
  .cv-projects-timeline {
    padding-left: 1.5rem;
  }
}

@media (max-width: 480px) {
  
  .cv-floating-photo {
    width: 120px;
    height: 120px;
  }

  .cv-name {
    font-size: 1.5rem;
  }

  .cv-job-title {
    font-size: 1rem;
  }

  .cv-card-title {
    font-size: 1.125rem;
  }

  .cv-timeline-company {
    font-size: 1rem;
  }
}

/* ========================================
   PORTFOLIO PAGE MOBILE
   ======================================== */

@media (max-width: 980px) {
  
  /* Section headers */
  .section-header {
    text-align: center;
    margin-bottom: 2rem;
  }

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

  .section-description {
    font-size: 0.95rem;
  }

  /* Filter bar */
  .filter-bar {
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .filter-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
  }

  /* Projects grid */
  .projects-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .project-card {
    min-height: auto;
  }

  .project-image {
    height: 200px;
  }

  .project-overlay {
    opacity: 1;
  background: var(--gradient-accent-transparent);
  }

  .project-actions {
    position: absolute;
    bottom: 10px;
    right: 10px;
  }

  .project-content {
    padding: 1rem;
  }

  .project-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .tech-stack {
    margin-left: 0;
  }

  .project-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .project-meta {
    flex-wrap: wrap;
  }

  /* CTA Section */
  .cta-content {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }

  .cta-icon {
    margin: 0 auto 1rem;
  }

  .cta-buttons {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .cta-buttons .form-button,
  .cta-buttons .form-button-secondary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  
  .projects-grid {
    gap: 1rem;
  }

  .project-image {
    height: 180px;
  }

  .tech-badge {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
  }
}

/* ========================================
   HOME PAGE MOBILE
   ======================================== */

@media (max-width: 980px) {
  
  /* Hero section */
  .home-hero {
    padding: 2rem 0;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  /* Services grid */
  .services-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  /* Stats section */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* Testimonials */
  .testimonials-slider {
    padding: 0 1rem;
  }

  .testimonial-card {
    padding: 1.25rem;
  }
}

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

/* ========================================
   FOOTER MOBILE
   ======================================== */

@media (max-width: 900px) {
  
  .fw-top {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  .fw-about {
    grid-column: span 2;
  }

  .fw-newsletter {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  
  .fw-top {
    grid-template-columns: 1fr;
  }

  .fw-about,
  .fw-links,
  .fw-contact,
  .fw-newsletter {
    grid-column: span 1;
    text-align: center;
  }

  .fw-logo {
    margin: 0 auto 1rem;
  }

  .fw-social {
    justify-content: center;
  }

  .fw-bottom {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
  }

  .fw-legal {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    align-items: center;
  }

  .fw-newsletter-form {
    flex-direction: column;
  }

  .fw-newsletter-form button {
    width: 100%;
  }
}

/* ========================================
   FORMS & BUTTONS MOBILE
   ======================================== */

@media (max-width: 768px) {
  
  /* Forms */
  .form-group {
    margin-bottom: 1.25rem;
  }

  input, textarea, select {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Buttons */
  .btn,
  .form-button,
  .form-button-secondary {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
  }

  /* Button groups */
  .button-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .button-group .btn,
  .button-group .form-button {
    width: 100%;
  }
}

/* ========================================
   MODALS MOBILE
   ======================================== */

@media (max-width: 768px) {
  
  .modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    margin: auto auto 0;
  }

  .modal-body {
    padding: 1.25rem;
  }

  .modal-close {
    right: 8px;
    top: 8px;
    width: 36px;
    height: 36px;
  }
}

/* ========================================
   TABLES MOBILE
   ======================================== */

@media (max-width: 768px) {
  
  /* Make tables scrollable */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* Or stack table rows */
  .table-responsive thead {
    display: none;
  }

  .table-responsive tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
  }

  .table-responsive td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
  }

  .table-responsive td:before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 1rem;
  }

  .table-responsive td:last-child {
    border-bottom: none;
  }
}

/* ========================================
   SCROLL ANIMATIONS MOBILE
   ======================================== */

@media (max-width: 768px) {
  
  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }

  /* Back to top button */
  .back-to-top,
  .cv-scroll-top {
    right: 1rem;
    bottom: 1rem;
    width: 44px;
    height: 44px;
  }
}

/* ========================================
   LANDSCAPE MODE (MOBILE)
   ======================================== */

@media (max-width: 980px) and (orientation: landscape) {
  
  /* Reduce vertical spacing */
  section {
    padding: 1.5rem 0;
  }

  .cv-hero {
    padding: 1rem 0;
  }

  .portfolio-hero {
    padding: 1.5rem 0;
  }

  /* Make modals scrollable */
  .modal-content {
    max-height: 85vh;
  }

  /* Mobile sheet en grille */
  .mobile-sheet,
  #mobile-sheet {
    max-height: 90vh;
  }

  .mobile-sheet-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

/* ========================================
   ACCESSIBILITY MOBILE
   ======================================== */

@media (max-width: 768px) {
  
  /* Larger focus indicators */
  *:focus-visible {
    outline-width: 3px;
    outline-offset: 4px;
  }

  /* Skip to content link */
  .skip-to-content {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--accent);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0 0 8px 8px;
    z-index: 1100;
    transition: transform 0.3s ease;
    text-decoration: none;
    font-weight: 600;
  }

  .skip-to-content:focus {
    transform: translateX(-50%) translateY(0);
  }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

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

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  
  /* Hide unnecessary elements */
  header,
  .site-header,
  .burger,
  #hamburger-btn,
  .mobile-sheet,
  #mobile-sheet,
  .mobile-sheet-overlay,
  #mobile-sheet-overlay,
  footer,
  .site-footer,
  .back-to-top,
  .cv-scroll-top,
  .project-overlay,
  .cta-section,
  .fw-social,
  .fw-newsletter,
  .fw-legal {
    display: none !important;
  }

  /* Optimize for printing */
  body {
    font-size: 12pt;
    color: black !important;
    background: white !important;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  /* Page breaks */
  h1, h2, h3 {
    page-break-after: avoid;
  }

  .project-card,
  .cv-timeline-item {
    page-break-inside: avoid;
  }

  .fw-top {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* ========================================
   UTILITIES MOBILE
   ======================================== */

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  
  .show-mobile {
    display: block !important;
  }
  
  .text-center-mobile {
    text-align: center !important;
  }
  
  .text-left-mobile {
    text-align: left !important;
  }
  
  .stack-mobile {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .stack-mobile > * {
    width: 100% !important;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }
  
  .show-mobile {
    display: none !important;
  }
  
  .hide-mobile {
    display: block !important;
  }
}