/* ===============================================
   MOBILE CRITICAL FIXES - PRIORITY
   Load this AFTER mobile.css
   =============================================== */

/* ===============================================
   CRITICAL: FIX INVISIBLE CONTENT ON MOBILE
   The JS sets opacity:0 for scroll animations,
   but on mobile we want content always visible
   =============================================== */

@media (max-width: 768px) {
  /* Force visibility of all content that JS hides for animations */
  .card,
  .section-header,
  .alert,
  .slide-up,
  .slide-in-left,
  .slide-in-right {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}

/* ===============================================
   PREVENT OVERFLOW & LAYOUT ISSUES
   =============================================== */

@media (max-width: 768px) {
  /* Critical: Prevent horizontal scroll */
  html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  * {
    max-width: 100%;
  }

  /* Container mobile adjustments */
  .container,
  .container-fluid {
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
  }

  /* Section backgrounds full width */
  .section {
    width: 100%;
    overflow-x: hidden;
  }

  /* ===============================================
     HEADER MOBILE FIX
     =============================================== */

  .header {
    width: 100%;
    padding: 0.75rem 0;
  }

  .navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1rem;
  }

  .logo {
    font-size: 1.125rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .logo span:last-child {
    display: none;
  }

  .logo-icon {
    font-size: 1.75rem;
  }

  /* Menu toggle always visible */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1050;
    order: 3;
  }

  /* Language switcher compact */
  .language-switcher {
    order: 2;
    margin-left: auto;
  }

  .language-button {
    padding: 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  /* ===============================================
     HERO SECTION MOBILE
     =============================================== */

  .hero {
    padding: 1.5rem 0;
    min-height: auto;
  }

  .hero-title {
    font-size: 1.5rem !important;
    line-height: 1.3;
    margin-bottom: 1rem;
    text-align: center;
  }

  /* ===============================================
     LIGHTHOUSE MOBILE PRIORITY FIX
     =============================================== */

  .lighthouse-container {
    max-width: 260px !important;
    margin: 1rem auto;
    height: auto;
  }

  #lighthouse-svg {
    width: 100%;
    height: auto;
    max-height: 350px;
  }

  /* ===============================================
     GRID MOBILE FIX
     =============================================== */

  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  /* ===============================================
     CARD MOBILE FIX - VERTICAL STACKED LAYOUT
     =============================================== */

  .card,
  .card.card-link,
  a.card-link {
    width: 100%;
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
    /* Force vertical stacked layout - override any inline-flex */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
    flex-shrink: 0;
    order: 1;
  }

  .card-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    order: 2;
    /* Prevent ugly word breaks in titles */
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    white-space: normal;
  }

  .card-description {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    order: 3;
  }

  /* Button inside card - centered, not full width */
  .card .btn {
    margin-top: auto;
    width: auto !important;
    min-width: 160px;
    order: 4;
  }

  /* ===============================================
     BUTTON MOBILE FIX
     =============================================== */

  /* Standalone buttons are full width */
  .btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    text-align: center;
    box-sizing: border-box;
  }

  /* But buttons inside cards stay centered and auto-width */
  .card .btn,
  .card-link .btn {
    width: auto !important;
    display: inline-flex !important;
    min-width: 150px;
    margin-top: 0.5rem;
  }

  .btn-sm {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }

  .btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
  }

  /* ===============================================
     ALERT MOBILE FIX
     =============================================== */

  .alert {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
  }

  .alert-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .alert .btn {
    margin-top: 0.75rem;
    margin-left: 0 !important;
  }

  /* ===============================================
     SECTION TITLE MOBILE
     =============================================== */

  .section-title {
    font-size: 1.5rem !important;
    text-align: center;
  }

  .section-subtitle {
    font-size: 0.875rem;
    text-align: center;
  }

  .section-title::after {
    width: 40%;
  }

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

  .footer {
    padding: 2rem 0 1rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
  }

  .footer-link {
    padding: 0.5rem;
    text-align: center;
  }

  .footer-copyright {
    text-align: center;
    font-size: 0.75rem;
  }

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

  .text-center {
    text-align: center !important;
  }

  p {
    font-size: 1rem;
    line-height: 1.6;
  }

  /* ===============================================
     PAGE HEADER MOBILE
     =============================================== */

  .page-header {
    padding: 1rem 0;
  }

  .page-icon {
    font-size: 3rem !important;
    display: block;
    margin-bottom: 0.5rem;
  }

  .page-title {
    font-size: 1.75rem !important;
    margin-bottom: 0.5rem;
  }
}

/* ===============================================
   SMALL MOBILE (< 480px) EXTRA FIXES
   =============================================== */

@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem;
  }

  .hero-title {
    font-size: 1.25rem !important;
  }

  .lighthouse-container {
    max-width: 220px !important;
  }

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

  .card {
    padding: 0.875rem;
  }

  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
  }
}

/* ===============================================
   LANDSCAPE MOBILE FIX
   =============================================== */

@media (max-width: 768px) and (orientation: landscape) {
  .lighthouse-container {
    max-width: 180px !important;
  }

  .hero {
    padding: 1rem 0;
  }

  .section {
    padding: 1.5rem 0;
  }
}
