/* ============================================
   Mobile Fixes - All Pages
   Only affects mobile (max-width: 768px)
   Does NOT override desktop styles
   ============================================ */

/* ── Footer: Acknowledgement of Country ── */
/* Replace long text with shorter version via CSS is not possible,
   but we fix the layout to prevent excessive line breaks */
.footer-section ._300-text {
  line-height: 1.7;
}

@media (max-width: 768px) {
  /* ── General container padding ── */
  .container {
    padding: 0 1rem;
  }

  /* Override all.css body { font-size: 2.5vw } which shrinks em-based containers */
  body {
    font-size: 14px !important;
  }

  /* ── Index: Hero video fix ── */
  .hero-section {
    min-height: 100svh;
    overflow: hidden;
  }

  .hero-section .video.video-embed {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
  }

  .hero-section .video.video-embed video {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* ── Index: Hero text ── */
  .hero-text-wrapper {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
  }

  .hero-text-wrapper h1 {
    font-size: 1.1rem !important;
    white-space: normal !important;
    line-height: 1.4 !important;
  }

  /* ── Index: Product cards grid ── */
  /* Top-level 2-col grid → single column */
  .section > .container > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* The nested 2x2 sub-grid → single column */
  div[style*="grid-template-columns: 1fr 1fr"][style*="gap"] > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Card text font size */
  .card-link .card-text h3,
  .card-link .card-text h4 {
    font-size: 0.9rem !important;
    line-height: 1.3 !important;
  }

  /* ── Index: 3D model section ── */
  #model3d-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  #model3d-grid model-viewer {
    height: 300px !important;
  }

  /* ── Index: Services grid ── */
  .top-bottom-padding-2em[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* ── About: Stats bar ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.5rem !important;
  }

  .stat-item .stat-num {
    font-size: 2rem !important;
  }

  .stat-item .stat-label {
    font-size: 0.75rem !important;
  }

  /* ── About: Intro grid ── */
  .about-intro {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    padding: 3rem 0 !important;
  }

  /* ── Our Work: Tab navigation ── */
  .tabs-nav {
    gap: 0.4rem !important;
    padding-bottom: 0.5rem;
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-button {
    padding: 0.5rem 0.8rem !important;
    font-size: 0.75rem !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ── Contact: Info grid ── */
  .contact-info-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }

  .contact-info-card,
  .qr-code-card {
    min-height: 200px !important;
    padding: 1.5rem 1rem !important;
    aspect-ratio: unset !important;
  }

  .contact-form-container {
    padding: 2rem 1.25rem !important;
  }

  /* ── Contact: Subscribe form ── */
  .subscribe-form-block-wrapper div[style*="display: flex"] {
    flex-direction: column !important;
  }

  .subscribe-form-block-wrapper .form-submit {
    width: 100% !important;
  }

  /* ── Chinese: Hero font sizes ── */
  .chinese-hero h1 {
    font-size: 1.6rem !important;
  }

  .chinese-hero p {
    font-size: 1rem !important;
  }

  /* Chinese page section headings */
  .chinese-hero ~ .section h2,
  .video-section h2,
  .section h2 {
    font-size: 1.6rem !important;
  }

  /* ── Footer: Acknowledgement layout ── */
  .footer-section .col.right-padding-5em {
    padding-right: 0 !important;
  }

  /* ── General: h1/h2 on mobile ── */
  h1 { font-size: 2rem !important; }
  h2 { font-size: 1.6rem !important; }
}

/* ── Our Work: Tab nav scrollable on small screens ── */
@media (max-width: 480px) {
  .tab-button {
    padding: 0.4rem 0.65rem !important;
    font-size: 0.7rem !important;
    letter-spacing: 0 !important;
  }
}

/* ── Index: Product cards precise targeting ── */
@media (max-width: 768px) {
  .product-cards-outer {
    grid-template-columns: 1fr !important;
  }

  .product-cards-inner {
    grid-template-columns: 1fr 1fr !important;
  }

  .product-cards-outer > .card-link img {
    max-height: 220px;
    object-fit: cover;
  }
}

/* ── Footer subscribe form: stack on mobile ── */
@media (max-width: 600px) {
  .form-block form > div {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .form-block .form-submit {
    width: 100% !important;
  }

  /* ── About: Stats numbers wrap properly ── */
  .stats-bar .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.5rem 1rem !important;
    padding: 0 0.5rem;
  }

  .stat-item .stat-num {
    font-size: 1.6rem !important;
    word-break: break-word;
  }

  .stat-item .stat-label {
    font-size: 0.7rem !important;
    letter-spacing: 0.5px !important;
  }

  /* ── Chinese: Feature grid single column ── */
  .feature-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Chinese: Section headings ── */
  .section h2,
  .video-section h2 {
    font-size: 1.5rem !important;
  }
}

/* ── Index: Our Services grid (desktop: auto-fit 3col, mobile: 2col) ── */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-md);
}

.service-title {
  font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
  font-size: 1rem;
}

.service-desc {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ── Index: About text col (remove text-indent on all screens) ── */
.about-text-col {
  line-height: 1.8;
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.about-text-col p {
  text-indent: 0;
  margin-bottom: 1.2rem;
}

@media (max-width: 768px) {
  /* Services: 2 columns on mobile */
  .services-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }

  .service-item {
    padding: 1rem !important;
  }

  .service-title {
    font-size: 0.85rem !important;
    margin-bottom: 10px !important;
  }

  .service-desc {
    font-size: 0.8rem !important;
    line-height: 1.6 !important;
  }

  /* About text: remove indent, normal font size */
  .about-text-col {
    font-size: 0.95rem !important;
    text-indent: 0 !important;
  }

  .about-text-col p {
    text-indent: 0 !important;
  }

  /* Force the about section grid to single column on mobile */
  .about-grid {
    grid-template-columns: 1fr !important;
    grid-row-gap: 1.5rem !important;
  }

  /* Restore body font-size to rem-based so text containers don't shrink */
  .about-text-col,
  .about-text-col p {
    font-size: 0.95rem !important;
    line-height: 1.75 !important;
    text-indent: 0 !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  /* Footer Acknowledgement: prevent excessive wrapping */
  .footer-section ._300-text {
    font-size: 0.85rem;
    line-height: 1.6;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
  }
}

/* ── Index: About section — two-image stack ── */

/* 图片列：flex 竖排，撑满整个 grid cell 高度 */
.about-img-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;        /* 与右侧文字列等高 */
}

/* 上方图片：固定比例，允许裁剪上下边 */
.about-img-top {
  flex: 1 1 0;         /* 占据剩余空间，与下方图片按比例分配 */
  min-height: 0;       /* 防止 flex 子项撑破容器 */
  overflow: hidden;
  border-radius: 6px;
}

.about-img-top img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;  /* 裁剪时保留中上部分，避免切掉主体 */
  display: block;
}

/* 下方图片：宽度较短（横幅型），固定高度 */
.about-img-bottom {
  flex: 0 0 auto;
  height: 140px;       /* 横幅图片固定高度 */
  overflow: hidden;
  border-radius: 6px;
}

.about-img-bottom img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* 确保 about-grid 两列等高对齐 */
.about-grid {
  align-items: stretch;
}

/* ── Menu button: always on top, never blocked by stacking contexts ── */
.menu-button {
  z-index: 9999 !important;
  /* 用 isolation: isolate 的反向操作：确保自身不被父级层叠上下文限制 */
  position: fixed !important;
}

/* ── About page: photo-masonry transform creates stacking context
   that can block the fixed menu button on scroll.
   Limit z-index so it stays below the menu button. ── */
.photo-masonry .photo-cell {
  z-index: 0;
  isolation: auto;
}

/* ── nav-menu: ensure display is controlled by JS, not overridden by CSS ── */
/* The all.css sets display:none at 767px which conflicts with JS display:flex */
/* We let JS fully control display via inline style, CSS only handles transition */
#nav-menu {
  transition: transform 0.5s ease !important;
}
