/* =====================================================
   Mobile & tablet responsive enhancements
   Loaded after style.css — fixes overflow, header,
   touch targets, safe areas, and small-screen polish
   ===================================================== */

/* --- Global overflow & safe areas --- */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  overflow-x: clip;
}

body.menu-open {
  overflow: hidden;
  touch-action: none;
}

body.menu-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 98;
  background: rgba(10, 23, 34, 0.48);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}

/* Prevent iOS input zoom on focus */
.form-group input,
.form-group textarea,
.form-group select {
  font-size: 16px;
}

/* Word wrapping for long text (EN brand, emails, policies) */
.brand-text,
.brand-text strong,
.brand-text span,
.footer-bottom span,
.policy-card p,
.brand-note,
.contact-card a,
h1, h2, h3, p {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* --- Mobile header grid --- */
@media (max-width: 1023px) {
  .header-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "brand actions menu";
    align-items: center;
    gap: 0.35rem 0.5rem;
    flex-wrap: nowrap;
  }

  .brand {
    grid-area: brand;
    min-width: 0;
    flex: unset;
  }

  .header-actions {
    grid-area: actions;
    flex-shrink: 0;
  }

  .menu-btn {
    grid-area: menu;
    flex-shrink: 0;
  }

  .nav {
    position: absolute;
    top: calc(100% + 0.35rem);
    inset-inline: 0;
    z-index: 200;
    max-height: min(70vh, 28rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .nav.show {
    display: flex;
    animation: navSlideIn 0.28s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1)) both;
  }

  .nav a::after {
    display: none;
  }

  .lang-btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.8125rem;
  }

  .language-switch {
    padding: 0.2rem;
  }
}

@keyframes navSlideIn {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Hero & decorative elements — prevent horizontal scroll --- */
.hero-visual,
.about-media,
.about-page-image,
.products-intro-image,
.hero-card {
  overflow: hidden;
  max-width: 100%;
}

.hero-card {
  transform: none;
}

html[dir="ltr"] .hero-card {
  transform: none;
}

.hero-card::before {
  inset: 1rem -0.5rem -0.5rem 1rem;
}

.about-media::after {
  inset: 0.75rem;
  transform: translate(0.5rem, 0.5rem);
}

.hero-visual {
  margin-inline: auto;
  width: 100%;
}

/* --- Section spacing on phones --- */
@media (max-width: 767px) {
  .container {
    width: min(100% - 1rem, 73.75rem);
  }

  .section {
    padding: clamp(1.5rem, 6vw, 2.5rem) 0;
  }

  .hero-content {
    padding: clamp(1.5rem, 6vw, 2rem) 0;
  }

  .hero h1 {
    font-size: clamp(1.65rem, 8.5vw, 2.25rem);
    line-height: 1.22;
  }

  .hero p {
    font-size: clamp(0.9rem, 3.8vw, 1rem);
  }

  .hero-buttons {
    margin: 1.25rem 0 1rem;
  }

  /* ── Option 2: compact mobile layout ── */

  /* 1. Hero: text only — hide large image */
  .hero-visual {
    display: none;
  }

  .hero-content {
    gap: 0;
  }

  /* 2. Stats: 3 in one row */
  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 100%;
  }

  .hero-stats div {
    padding: 0.625rem 0.375rem;
    text-align: center;
    border-radius: 0.875rem;
  }

  .hero-stats strong {
    font-size: 0.8125rem;
    line-height: 1.25;
  }

  .hero-stats span {
    display: block;
    font-size: 0.625rem;
    line-height: 1.35;
    margin-top: 0.125rem;
  }

  /* 3. About preview: text only on homepage */
  .about-preview .about-media {
    display: none;
  }

  .about-preview {
    padding-top: clamp(1.5rem, 6vw, 2.25rem);
  }

  .about-preview .about-text p {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .about-preview .check-list {
    margin: 1rem 0;
    gap: 0.5rem;
  }

  .about-preview .check-list div {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
  }

  /* 4. Products: compact 2×2 grid */
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .product-card {
    border-radius: 1rem;
  }

  .product-card > img {
    aspect-ratio: 1 / 1;
    min-height: unset;
  }

  .product-content {
    padding: 0.625rem 0.5rem 0.75rem;
  }

  .product-content h3 {
    font-size: 0.75rem;
    line-height: 1.35;
    margin-bottom: 0;
  }

  .product-content p {
    display: none;
  }

  /* Product details page: same compact 2×2 */
  .product-details-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .product-detail-card {
    border-radius: 1rem;
  }

  .product-detail-image img {
    aspect-ratio: 1 / 1;
    min-height: unset;
  }

  .product-detail-card .lang-content {
    padding: 0.625rem 0.5rem 0.75rem;
  }

  .product-detail-card h3 {
    font-size: 0.75rem;
    line-height: 1.35;
    margin-bottom: 0.25rem;
  }

  .product-detail-card p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.6875rem;
    margin-bottom: 0.375rem;
  }

  .product-detail-card ul {
    display: none;
  }

  /* Products page intro: hide side image */
  .products-intro-image {
    display: none;
  }

  .products-intro-grid {
    gap: 0;
  }

  /* 5. Brands: 2-column grid — all logos visible at once */
  .brands-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
    overflow: visible;
  }

  .brand-box {
    flex: unset;
    aspect-ratio: 3 / 2;
    min-height: 4.25rem;
    padding: 0.625rem;
    border-radius: 1rem;
  }

  .brand-box img {
    width: 100%;
    height: 100%;
    max-height: 3.5rem;
    object-fit: contain;
    object-position: center;
  }

  /* Center the 5th brand when count is odd */
  .brand-box:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 0.3125rem);
  }

  .brand-note {
    display: none;
  }

  /* Why section: 2-column features */
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .feature-card {
    padding: 0.75rem 0.625rem;
    font-size: 0.75rem;
    line-height: 1.45;
    border-radius: 0.875rem;
  }

  .feature-card::before {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.6875rem;
    margin-inline-end: 0.375rem;
  }

  .features-grid .feature-card:nth-child(n + 5) {
    display: none;
  }

  .mission-card {
    padding: 1rem;
  }

  .mission-card h3 {
    font-size: 1.0625rem;
  }

  .mission-card p {
    font-size: 0.8125rem;
  }

  .goals-list div div {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
  }

  /* Services grid on products page */
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .service-card {
    padding: 1rem 0.75rem;
    border-radius: 1rem;
  }

  .service-card h3 {
    font-size: 0.875rem;
  }

  .service-card p {
    font-size: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* About page: smaller image, text first */
  .about-page-grid {
    gap: 1.25rem;
  }

  .about-page-image img {
    aspect-ratio: 16 / 9;
    min-height: unset;
    max-height: 11rem;
    object-fit: cover;
  }

  .section-heading {
    margin-bottom: 1.25rem;
  }

  .why-text p {
    display: none;
  }

  .about-page-image {
    display: none;
  }

  .section-heading p {
    display: none;
  }

  .inner-hero p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ── end compact layout ── */

  .inner-hero {
    padding: clamp(2.75rem, 12vw, 4rem) 0;
  }

  .inner-hero h1 {
    font-size: clamp(1.65rem, 8.5vw, 2.25rem);
  }

  /* Shorter blue CTA strip on phones */
  .cta {
    padding: 1.6rem 0;
  }

  .cta-content {
    gap: 1rem;
  }

  .cta-content span {
    font-size: 0.75rem;
  }

  .cta-content h2 {
    font-size: clamp(1.2rem, 5.5vw, 1.55rem);
    line-height: 1.3;
    margin: 0.25rem 0;
  }

  .cta-content p {
    font-size: 0.8125rem;
  }

  .cta-actions {
    gap: 0.5rem;
  }

  .compact-policy-cta {
    padding: 1.6rem 0;
  }

  /* Reveal animations move only vertically on phones — this removes
     any chance of horizontal overflow / RTL text being clipped. */
  .reveal-left,
  .reveal-right,
  html[dir="rtl"] .reveal-left,
  html[dir="rtl"] .reveal-right,
  html[dir="ltr"] .reveal-left,
  html[dir="ltr"] .reveal-right {
    transform: translateY(2rem) scale(0.97);
  }

  .reveal-left.visible,
  .reveal-right.visible,
  html[dir="rtl"] .reveal-left.visible,
  html[dir="rtl"] .reveal-right.visible,
  html[dir="ltr"] .reveal-left.visible,
  html[dir="ltr"] .reveal-right.visible {
    transform: translateY(0) scale(1);
  }

  .mission-card,
  .contact-form-card,
  .policy-card,
  .policy-summary-card {
    padding: 1.25rem 1rem;
  }

  .mission-card h3 {
    font-size: 1.25rem;
  }

  .about-page-text {
    order: 1;
  }

  .about-page-image {
    order: 2;
  }

  .about-page-text p,
  .activity-box p {
    font-size: 0.9375rem;
  }

  .about-page-text h2,
  .section-side-title h2,
  .activity-box h2 {
    font-size: clamp(1.45rem, 6.5vw, 1.85rem);
  }

  .map-placeholder {
    min-height: 14rem;
    padding: 1.25rem 1rem;
    border-radius: 1.25rem;
  }

  .footer {
    padding-top: 2.5rem;
  }

  .footer-logo {
    width: 4.5rem;
    height: 4.5rem;
  }

  .footer-bottom {
    padding: 1rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.6;
  }

  .policies-sidebar {
    position: static;
    top: auto;
  }

  .policy-card {
    scroll-margin-top: 5.5rem;
  }

  .brand-note {
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
  }

  .quick-actions {
    flex-direction: column;
  }

  .quick-actions .btn {
    width: 100%;
  }

  .policy-contact-strip {
    padding: 1.125rem 1rem;
  }

  .policy-contact-actions .btn {
    width: 100%;
  }

  .map-section {
    display: none;
  }

  .contact-section .contact-info-side > .lang-content p {
    display: none;
  }

  .contact-card {
    padding: 0.875rem;
    gap: 0.75rem;
  }

  .contact-number {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 0.875rem;
    border-radius: 0.75rem;
  }

  .contact-card h3 {
    font-size: 1rem;
  }

  .values-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .value-card {
    padding: 1rem 0.75rem;
  }

  .value-card h3 {
    font-size: 0.875rem;
  }

  /* Disable hover lift on touch — avoids sticky hover states */
  .product-card:hover,
  .service-card:hover,
  .value-card:hover,
  .mission-card:hover,
  .policy-summary-card:hover,
  .brand-box:hover,
  .map-placeholder:hover,
  .hero-stats div:hover {
    transform: none;
  }

  .product-card:hover > img,
  .product-detail-card:hover .product-detail-image img {
    transform: none;
  }
}

/* --- Extra-small screens (320px) --- */
@media (max-width: 374px) {
  .container {
    width: min(100% - 0.75rem, 73.75rem);
  }

  .brand-logo {
    width: 2.625rem;
    height: 2.625rem;
  }

  .brand-text strong {
    font-size: 0.875rem;
  }

  .brand-text span {
    font-size: 0.5625rem;
    line-height: 1.35;
  }

  .menu-btn {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    font-size: 1.25rem;
  }

  .lang-btn {
    min-width: 2.5rem;
    min-height: 2.5rem;
    font-size: 0.75rem;
  }

  .whatsapp-float {
    bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
    inset-inline-end: calc(0.625rem + env(safe-area-inset-right, 0px));
    padding: 0.6875rem 0.875rem;
    font-size: 0.8125rem;
  }

  .values-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .eyebrow,
  .section-tag {
    font-size: 0.75rem;
    padding: 0.35rem 0.625rem;
  }
}

/* --- WhatsApp float safe area --- */
.whatsapp-float {
  bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
  inset-inline-end: calc(0.875rem + env(safe-area-inset-right, 0px));
  z-index: 90;
  max-width: calc(100vw - 1.75rem);
  white-space: nowrap;
}

/* --- Tablet fine-tuning --- */
@media (min-width: 768px) and (max-width: 1023px) {
  .products-grid,
  .product-details-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .brands-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .values-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .policy-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-grid > div:first-child {
    grid-column: 1 / -1;
  }
}

/* --- Landscape phones --- */
@media (max-width: 1023px) and (orientation: landscape) {
  .inner-hero,
  .compact-policy-hero {
    padding: 2rem 0;
  }

  .hero-content {
    padding: 1.5rem 0;
  }

  .nav {
    max-height: min(55vh, 16rem);
  }
}

/* --- Reduced motion on mobile --- */
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  .hero-stats div {
    animation: none;
  }

  .hero-visual {
    will-change: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav.show {
    animation: none;
  }
}
