/* ==========================================================================
   Haikal United v1.2.9 — responsive layout and uncropped imagery

   Loaded AFTER app.css on every public page. Keep responsive corrections here
   so they are easy to find without changing the animation or admin system.
   ========================================================================== */

/* 01. General sizing — never let a grid child force a wider mobile viewport. */
.hero-inner,
.hero-media,
.brand-focus > *,
.product-detail > *,
.product-media-column,
.product-card,
.project-card,
.contact > * {
  min-width: 0;
}

.hero-contact strong,
.product-card h2,
.product-card h3,
.project-content h3,
.product-info h1 {
  overflow-wrap: anywhere;
}

/* 02. Site logos stay entirely visible, independently of their proportions. */
.brand img,
.brand-tile img,
.brand-panel img,
.product-placeholder img {
  object-fit: contain;
}

/* 03. Product cards: contain the actual truck image instead of cropping it. */
.product-card > a {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background: #f4f6f8;
}

.product-card > a > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: contain;
  padding: clamp(8px, 1.4vw, 16px);
  background: transparent;
}

/* Existing zoom was enlarging and visually cutting off truck photographs. */
.product-card:hover > a > img,
.product-card.motion-tilt:hover > a > img {
  transform: none;
}

/* 04. Projects: reveal the whole project photograph even when portrait. */
.project-image {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background: #f1f3f5;
}

.project-image > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  padding: 6px;
  background: #f1f3f5;
}

.project-card:hover .project-image img {
  transform: none;
}

/* 05. Single-truck gallery: the lightbox and cover never crop photos. */
.product-media.gallery-main {
  position: relative;
  display: block;
  max-width: 100%;
  overflow: hidden;
}

.gallery-main img,
.gallery-thumbnail img,
.lightbox-image {
  object-fit: contain;
}

.gallery-main img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(100dvh - 112px);
}

/* 06. SINOTRUK panel: show a modest badge over the background photo. */
.brand-panel {
  width: 100%;
  min-width: 0;
  min-height: clamp(260px, 30vw, 390px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  background-color: #18202a;
  padding: clamp(14px, 3vw, 28px);
}

.brand-panel > img {
  width: clamp(120px, 18vw, 185px);
  max-width: 48%;
  height: auto;
  max-height: 180px;
  padding: 10px;
  border-radius: 14px;
  background: #050505;
  object-fit: contain;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .24);
}

/* The optional banner remains visible rather than becoming nearly black. */
.brand-panel {
  background-image:
    linear-gradient(rgba(8, 12, 18, .06), rgba(8, 12, 18, .20)),
    var(--brand-photo, none);
}

/* 07. Medium screens / tablets: comfortable columns and breathing room. */
@media (max-width: 1180px) {
  .hero {
    gap: clamp(20px, 3vw, 36px);
  }

  .hero-contact {
    max-width: 100%;
  }

  .brand-stage {
    max-width: 580px;
  }
}

@media (max-width: 980px) {
  .hero,
  .section.split,
  .section.contact,
  .brand-focus,
  .product-detail {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-media,
  .brand-stage {
    width: 100%;
  }

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

  .brand-stage {
    max-width: 580px;
    margin-inline: auto;
  }

  .brand-focus > div,
  .product-info {
    min-width: 0;
  }

  .product-grid,
  .projects-section .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav nav {
    max-width: calc(100vw - 32px);
  }
}

/* 08. Phones: prevent tall stacked logos and horizontal clipping. */
@media (max-width: 680px) {
  .nav {
    gap: 9px;
    padding: 10px 12px;
  }

  .nav .brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  .nav .brand img {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
  }

  .nav .brand span {
    overflow: hidden;
    font-size: 11px;
    letter-spacing: .08em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-toggle {
    flex: 0 0 44px;
    margin-inline-start: 0;
  }

  .nav .lang {
    flex: 0 0 auto;
    padding: 8px 10px;
  }

  .hero {
    gap: 20px;
    padding: 42px 16px 44px;
  }

  .hero h1 {
    max-width: 100%;
    font-size: clamp(34px, 9vw, 46px);
    line-height: 1.19;
    letter-spacing: -.025em;
  }

  [dir="rtl"] .hero h1 {
    letter-spacing: 0;
    line-height: 1.25;
  }

  .hero-inner,
  .hero-media {
    width: 100%;
  }

  .hero-contact {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .hero-contact li,
  .hero-contact li:last-child {
    grid-column: auto;
    padding: 12px 14px;
  }

  .hero-contact strong {
    font-size: 15px;
    line-height: 1.4;
  }

  /* Preserve the full width of the hero background photograph on phones. */
  .hero > .hero-bg.has-photo,
  [dir="rtl"] .hero > .hero-bg.has-photo {
    background-image:
      linear-gradient(
        180deg,
        rgba(249, 247, 243, .47) 0%,
        rgba(249, 247, 243, .89) 46%,
        rgba(249, 247, 243, .98) 74%
      ),
      var(--hero-photo, none);
    background-size: 100% 100%, 100% auto;
    background-position: center, center top;
    background-repeat: no-repeat;
  }

  /* Side-by-side logos; no more giant SINOTRUK block below a second logo. */
  .brand-stage {
    padding: 14px;
    border-radius: 20px;
  }

  .brand-stage-head {
    gap: 6px;
    font-size: 10px;
    letter-spacing: .04em;
  }

  .brand-logos {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    margin: 12px 0;
  }

  .brand-tile {
    width: 100%;
    min-width: 0;
    min-height: 112px;
    aspect-ratio: 1 / 1;
    padding: 8px;
    border-radius: 14px;
  }

  .brand-tile img {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 92px;
    object-fit: contain;
  }

  .partner-x {
    display: block;
    font-size: 18px;
  }

  .brand-stage-foot {
    font-size: 11px;
    letter-spacing: .05em;
    overflow-wrap: anywhere;
  }

  .brand-panel {
    min-height: 220px;
    padding: 16px;
    border-radius: 20px;
    background-size: 100% 100%, contain;
    background-position: center, center;
    background-repeat: no-repeat;
  }

  .brand-panel > img {
    width: 124px;
    max-width: 48%;
    max-height: 124px;
    padding: 8px;
    border-radius: 12px;
  }

  /* All public product and project cards fit the available phone width. */
  .product-grid,
  .projects-section .project-grid,
  .location-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-card > a,
  .project-image {
    aspect-ratio: 4 / 3;
  }

  .product-card > a > img {
    padding: 10px;
  }

  .section,
  .catalog-hero {
    padding-inline: 16px;
  }

  .section-head,
  .project-content,
  .product-card-body {
    min-width: 0;
  }

  .catalog-filters select {
    min-width: 0;
    width: 100%;
  }

  .product-media.gallery-main {
    min-height: 0;
    aspect-ratio: 4 / 3;
    padding: 8px;
  }

  .gallery-main img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 100%;
  }

  .gallery-thumbnails {
    min-width: 0;
    max-width: 100%;
  }

  .gallery-thumbnail {
    flex-basis: 72px;
    width: 72px;
    height: 65px;
  }

  .truck-lightbox {
    padding: 62px 12px;
  }

  .lightbox-image {
    width: auto;
    height: auto;
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 130px);
  }
}

/* 09. Narrow phones: keep menu, logos and labels within 320px. */
@media (max-width: 360px) {
  .nav {
    gap: 6px;
    padding-inline: 9px;
  }

  .nav .brand img {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .nav .brand span {
    font-size: 10px;
  }

  .brand-stage {
    padding: 11px;
  }

  .brand-tile {
    min-height: 94px;
    padding: 6px;
  }

  .brand-tile img {
    max-height: 76px;
  }
}

/* 10. Touch devices: disable 3D cursor-only effects. */
@media (hover: none) and (pointer: coarse) {
  .motion-tilt,
  .magnetic {
    transform: none !important;
  }

  .product-card:hover > a > img,
  .project-card:hover .project-image img,
  .brand-panel:hover img {
    transform: none;
  }
}

/* 11. Respect device accessibility settings. */
@media (prefers-reduced-motion: reduce) {
  .product-card > a > img,
  .project-image img,
  .brand-panel img {
    transition: none;
  }
}
