/* ── NAVIGATION — MOBILE FIRST ── */
@supports (padding: max(0px)) {
  body { padding-left: max(0px, env(safe-area-inset-left)); padding-right: max(0px, env(safe-area-inset-right)); }
}

@media (max-width: 900px) {
  /* ── NAV BAR MOBILE ── */
  nav {
    height: 60px !important;
    background: rgba(10, 31, 18, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(200, 168, 75, 0.15) !important;
    box-shadow: 0 2px 16px rgba(0,0,0,0.3) !important;
  }
  .nav-inner {
    padding: 0 16px !important;
    height: 60px !important;
    max-width: 100% !important;
  }
  .nav-logo {
    font-size: 0.9rem !important;
  }
  .nav-logo img {
    height: 34px !important;
    padding: 2px !important;
  }
  .nav-logo-text { line-height: 1.1 !important; }
  .nav-logo-text span { font-size: 0.5rem !important; }

  /* Hide desktop nav links and CTA on mobile */
  .nav-links, .nav-cta { display: none !important; }

  /* ── HAMBURGER — PROPERLY VISIBLE ON MOBILE ── */
  .hamburger {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px !important;   /* larger tap target */
    opacity: 0.9;
    border-radius: 6px;
    transition: background 0.2s, transform 0.2s;
    z-index: 10005;
    position: relative;
    /* Make sure it's always on top */
    margin-left: auto;
  }
  .hamburger:hover { background: rgba(255,255,255,0.1) !important; opacity: 1 !important; }
  .hamburger span {
    width: 22px !important;
    height: 2.5px !important;
    background: white !important;
    border-radius: 2px !important;
    transition: transform 0.3s, opacity 0.3s !important;
    display: block !important;
    margin: 2px 0 !important;
    box-shadow: none !important;
  }
  /* Hamburger → X animation */
  .hamburger.active span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg) !important;
  }
  .hamburger.active span:nth-child(2) {
    opacity: 0 !important;
    transform: scaleX(0) !important;
  }
  .hamburger.active span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg) !important;
  }

  /* ── MOBILE SIDEBAR NAV ── */
  .mobile-nav {
    position: fixed !important;
    top: 0 !important;
    right: -85vw !important;
    width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;   /* dynamic viewport height for mobile browsers */
    background: #0a1f12 !important;
    z-index: 10001 !important;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: -8px 0 40px rgba(0,0,0,0.5) !important;
    overflow: hidden;
  }
  .mobile-nav.nav-open { right: 0 !important; }

  .mobile-nav-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0,0,0,0.65) !important;
    z-index: 10000 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s, visibility 0.3s !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
  }
  .mobile-nav-overlay.overlay-open { opacity: 1 !important; visibility: visible !important; }

  .mobile-nav-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 18px 20px !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    flex-shrink: 0;
    padding-top: max(18px, env(safe-area-inset-top)) !important;
  }
  .mobile-nav-logo {
    color: white !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    letter-spacing: 0.06em !important;
  }
  .mobile-nav-close {
    background: rgba(255,255,255,0.08) !important;
    border: none !important;
    color: white !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s !important;
    padding: 0 !important;
    flex-shrink: 0;
  }
  .mobile-nav-close:hover { background: rgba(255,255,255,0.15) !important; }

  .mobile-nav-links {
    list-style: none !important;
    padding: 12px 0 !important;
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-nav-links li a {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 15px 20px !important;
    color: rgba(255,255,255,0.85) !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    transition: background 0.2s, color 0.2s, padding-left 0.2s !important;
  }
  .mobile-nav-links li a::before {
    content: '';
    width: 4px;
    height: 4px;
    background: var(--gold);
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.2s;
  }
  .mobile-nav-links li a:hover {
    background: rgba(255,255,255,0.07) !important;
    color: var(--gold-light) !important;
    padding-left: 28px !important;
  }
  .mobile-nav-links li a:hover::before {
    transform: scale(1.5);
  }

  .mobile-nav-cta {
    display: block !important;
    margin: 16px 20px 24px !important;
    padding: 14px !important;
    background: var(--gold) !important;
    color: var(--green-dark) !important;
    text-align: center !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    border-radius: var(--radius-sm) !important;
    text-decoration: none !important;
    transition: background 0.2s !important;
    flex-shrink: 0;
  }
  .mobile-nav-cta:hover { background: #b8922f !important; }

  body.nav-lock { overflow: hidden !important; }
}

/* ── 600px AND BELOW ── */
@media (max-width: 600px) {
  nav { height: 56px !important; }
  .nav-inner { padding: 0 12px !important; }
  .nav-logo { font-size: 0.82rem !important; }
  .nav-logo img { height: 30px !important; }
  .hamburger { padding: 6px !important; }
  .hamburger span { width: 20px !important; height: 2px !important; }
  .hamburger.active span:nth-child(1) { transform: translateY(6.5px) rotate(45deg) !important; }
  .hamburger.active span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg) !important; }
  .mobile-nav { width: 90vw !important; right: -90vw !important; }
}

/* ── LANDSCAPE MOBILE ── */
@media (max-width: 900px) and (orientation: landscape) {
  nav { height: 52px !important; }
  .mobile-nav { width: 50vw !important; right: -50vw !important; }
  .mobile-nav-header { padding: 12px 16px !important; }
  .mobile-nav-links li a { padding: 10px 16px !important; font-size: 0.9rem !important; }
}

/* ── GLOBAL ── */
/* ================================================
   永佳環保 — Mobile First Responsive Fixes
   加在各页面 <style> 标签最底部 </style> 之前
   ================================================ */

/* ── GLOBAL MOBILE RESET ── */
*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
}

/* ── SAFE AREA FOR NOTCH PHONES ── */
@supports (padding: max(0px)) {
  body { padding-left: max(0px, env(safe-area-inset-left)); padding-right: max(0px, env(safe-area-inset-right)); }
}

/* ── MOBILE OVERRIDES (max-width: 768px) ── */
@media (max-width: 768px) {

  /* Global */
  html { font-size: 15px; }
  body { overflow-x: hidden; }
  img { max-width: 100%; height: auto; }
  section { padding: 64px 0; }

  /* Hero - compact for mobile */
  .hero-content { padding: 100px 0 48px; }
  .hero-content h1 { font-size: clamp(2.2rem, 10vw, 3.5rem) !important; }
  .hero-sub { font-size: 0.95rem !important; line-height: 1.6; }
  .hero-actions { gap: 10px; margin-bottom: 40px; }
  .hero-actions .btn-primary,
  .hero-actions .btn-outline { padding: 12px 20px; font-size: 0.85rem; }
  .hero-stats { grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 32px; }
  .hero-stat-num { font-size: 1.8rem !important; }
  .hero-scroll { bottom: 20px; }

  /* Shapes - hide on mobile for performance */
  .hero-shapes { display: none; }

  /* Stats bar */
  .stats-bar { padding: 40px 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-item { padding: 20px 12px; }
  .stat-num { font-size: 1.8rem !important; }
  .stat-label { font-size: 0.72rem; }

  /* About */
  .about-preview-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
  .about-preview-img { margin: 0 8px; }
  .about-preview-img img { transform: none !important; }
  .about-year { right: -8px !important; bottom: -16px !important; transform: translateZ(0) rotate(-4deg) !important; font-size: 1.5rem !important; padding: 14px 20px !important; }
  .about-features { grid-template-columns: 1fr !important; gap: 10px !important; }
  .about-preview-text .section-title { font-size: 1.6rem !important; }

  /* Services */
  .services-preview-header .section-title { font-size: 1.6rem !important; }
  .services-grid-2 { grid-template-columns: 1fr !important; gap: 16px !important; }
  .service-card { padding: 24px 20px !important; }
  .service-card .service-icon { font-size: 2rem !important; }

  /* Certs */
  .certs-logos { gap: 10px; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
  .cert-logo-item { min-width: 100px; padding: 14px 16px; flex-shrink: 0; }

  /* Equipment gallery */
  .equip-showcase { grid-template-columns: 1fr !important; gap: 12px !important; }
  .eq-img { height: 200px !important; min-height: auto !important; }
  .eq-big { grid-row: span 1 !important; }

  /* Why us */
  .whyus-header .section-title { font-size: 1.6rem !important; }
  .whyus-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .whyus-card { padding: 28px 20px !important; }

  /* Process */
  .process-preview-header .section-title { font-size: 1.6rem !important; }
  .process-steps { flex-direction: column !important; align-items: center; gap: 28px; }
  .process-steps::before { display: none !important; }
  .process-step { padding: 0 !important; }
  .process-step-num { width: 72px !important; height: 72px !important; font-size: 1.5rem !important; }

  /* CTA */
  .cta-section { padding: 72px 0 !important; }
  .cta-section h2 { font-size: 1.6rem !important; }
  .cta-phone { font-size: 1.6rem !important; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
  .footer-brand { margin-bottom: 0; }

  /* Page hero (inner pages) */
  .page-hero { padding: 110px 0 64px !important; }
  .page-hero h1 { font-size: clamp(1.8rem, 8vw, 2.8rem) !important; }
  .page-hero p { font-size: 0.9rem !important; }
}

/* ── EXTRA SMALL SCREENS (max-width: 400px) ── */
@media (max-width: 400px) {
  .hero-stat-num { font-size: 1.5rem !important; }
  .stat-num { font-size: 1.5rem !important; }
  .hero-actions { flex-direction: column; }
  .hero-actions a { width: 100%; justify-content: center; }
}

/* ── MOBILE NAV FULL SCREEN FIX ── */
@media (max-width: 768px) {
  .mobile-nav {
    width: 85vw !important;
    right: -85vw !important;
    box-shadow: -8px 0 40px rgba(0,0,0,0.4) !important;
  }
  .mobile-nav-overlay {
    backdrop-filter: blur(4px) !important;
  }
  .nav-cta {
    display: none !important;
  }

  /* Table horizontal scroll */
  .equip-table, .compare-table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .equip-table th, .equip-table td,
  .compare-table th, .compare-table td {
    white-space: nowrap;
    font-size: 0.8rem !important;
  }

  /* Contact form */
  .contact-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
  .contact-form-wrap { padding: 24px 20px !important; }
  .team-grid { grid-template-columns: 1fr !important; }

  /* Service detail blocks */
  .service-block { grid-template-columns: 1fr !important; gap: 24px !important; padding: 40px 0 !important; }
  .service-block:nth-child(even) { direction: ltr !important; }
  .service-block-img { max-height: 240px; overflow: hidden; }
  .service-block-img img { height: 200px; object-fit: cover; }

  /* Cert cards */
  .certs-card-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .cert-card-full { grid-template-columns: 1fr !important; text-align: center; padding: 24px !important; }
  .cert-badge { margin: 0 auto !important; width: 64px !important; height: 64px !important; font-size: 1.2rem !important; }

  /* Values grid */
  .values-grid { grid-template-columns: 1fr !important; }
}

/* ── LANDSCAPE MOBILE ── */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-content { padding: 80px 0 32px; }
  .hero-stats { grid-template-columns: repeat(4, 1fr); }
}

/* ── FIX OVERFLOW FOR ALL SECTIONS ── */
@media (max-width: 768px) {
  section, div {
    max-width: 100vw;
    overflow-x: hidden;
  }
  .container {
    padding: 0 16px !important;
    max-width: 100% !important;
  }
  .section-title {
    font-size: clamp(1.5rem, 6vw, 2.2rem) !important;
  }
}
