/**
 * iPad / 平板横竖屏适配
 * 竖屏常见宽度：768 / 820 / 834 / 1024
 * 横屏常见宽度：1024 / 1133 / 1180 / 1194 / 1366
 * 横屏常见高度：744 ~ 1024（Safari 工具栏会再占一部分）
 */

:root {
  /* 安全区：适配全面屏 iPad 底部横条与圆角 */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  /* JS 会把真实可视高度写入 --vh，避免 iOS 100vh 被地址栏撑破 */
  --vh: 1vh;
  --app-height: 100vh;
}

/* 禁止 iOS 自动放大字体，避免横竖屏切换后排版错乱 */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  padding-left: var(--sal);
  padding-right: var(--sar);
}

img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
}

/* 触控更跟手，减少 300ms 点击延迟与误缩放 */
a,
button,
.mobile-menu-btn,
.app-nav-item,
.tech-nav-btn,
.rd-nav-btn,
.rd-thumb,
.news-card {
  touch-action: manipulation;
}

/* 仅覆盖首页全屏英雄区，避免把新闻等页面的 60vh 首屏撑满 */
.hero,
.sticky-viewport {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
}

@supports (height: 100dvh) {
  .hero,
  .sticky-viewport {
    height: 100dvh;
  }
}

/* =========================================================
 * 平板通用（含 iPad 竖屏、大部分 iPad 横屏）
 * 1200px 覆盖：iPad mini/Air/Pro 11 横竖屏、iPad Pro 12.9 竖屏
 * ========================================================= */
@media (max-width: 1200px) {
  /* 顶部导航改为汉堡菜单，避免横屏 8 个栏目挤出屏幕 */
  .navbar {
    height: calc(64px + var(--sat));
    padding-top: var(--sat);
  }

  .nav-logo {
    font-size: 16px;
    gap: 8px;
  }

  .nav-logo img {
    height: 24px;
  }

  .nav-logo img:last-of-type {
    height: 32px !important;
    margin-left: 6px !important;
  }

  .mobile-menu-btn {
    display: flex !important;
    z-index: 110;
    width: 28px;
    height: 20px;
  }

  .nav-links {
    position: fixed !important;
    top: 0;
    right: -100%;
    width: min(420px, 100%);
    height: 100vh;
    height: 100dvh;
    background: rgba(5, 11, 20, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column !important;
    justify-content: center;
    align-items: center;
    gap: 0 !important;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 99;
    padding: 80px 40px calc(40px + var(--sab));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links.active {
    right: 0;
  }

  .nav-links li {
    margin: 12px 0;
    width: 100%;
    text-align: center;
  }

  .nav-links a {
    font-size: 22px !important;
    font-weight: 600;
    color: #fff !important;
    display: block;
    padding: 10px 0;
  }

  .nav-links a::after {
    display: none;
  }

  /* 标题允许换行，避免 iPad 竖屏被 nowrap 撑出屏幕 */
  .hero h1,
  #hero-title,
  .text_2 {
    white-space: normal !important;
    font-size: clamp(28px, 4.6vw, 48px) !important;
    line-height: 1.25 !important;
  }

  .hero h2,
  #hero-subtitle {
    white-space: normal !important;
    font-size: clamp(14px, 2vw, 18px) !important;
  }

  .section-title,
  .patents-header h2 {
    font-size: clamp(28px, 4vw, 40px) !important;
  }

  .container {
    padding-left: 32px;
    padding-right: 32px;
  }

  .section {
    padding: 72px 0;
  }

  /* 首页核心技术全屏轮播：跟真实可视高度走 */
  #core-tech.section,
  .tech-carousel-container {
    width: 100% !important;
    height: calc(var(--vh, 1vh) * 100) !important;
  }

  @supports (height: 100dvh) {
    #core-tech.section,
    .tech-carousel-container {
      height: 100dvh !important;
    }
  }

  .tech-slide {
    padding: 88px 8% 40px !important;
  }

  .tech-title {
    font-size: clamp(24px, 3.2vw, 36px) !important;
    white-space: normal !important;
  }

  /* 新闻手风琴在触控设备上始终展示文案（没有鼠标悬停） */
  .news-accordion-wrapper {
    height: auto !important;
    flex-wrap: wrap;
    gap: 16px;
  }

  .news-accordion-wrapper .news-card,
  .news-accordion-wrapper .news-card:hover {
    flex: 1 1 calc(50% - 16px) !important;
    min-height: 280px;
    height: 280px !important;
  }

  .news-accordion-wrapper .news-vertical-text {
    display: none !important;
  }

  .news-accordion-wrapper .news-content-overlay {
    opacity: 1 !important;
    transform: none !important;
  }

  .app-flip-box {
    height: auto !important;
    min-height: 520px;
  }

  /* 核心应用领域：标题禁止被挤成逐字换行 */
  .app-nav-item .nav-info h4,
  .app-nav-item .nav-info p {
    white-space: nowrap;
  }

  .app-slide h3 {
    font-size: clamp(28px, 4vw, 40px);
  }

  .innovation-highlight {
    font-size: 80px;
  }
}

/* =========================================================
 * iPad 竖屏：768–1024，用两列吃满宽度，不要整页单列
 * ========================================================= */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .hero {
    padding-bottom: 80px;
    align-items: flex-end;
  }

  .hero-content {
    margin-left: 4vw !important;
    margin-right: 4vw !important;
  }

  .grid-2,
  .about-split,
  .tech-split,
  .rd-panel,
  .poetic-layout,
  .feature-steps,
  .section_3 {
    grid-template-columns: 1fr 1fr !important;
  }

  .grid-3,
  .patents-grid,
  .footer-content,
  .news-wrapper {
    grid-template-columns: 1fr 1fr !important;
  }

  .grid-4 {
    grid-template-columns: 1fr 1fr !important;
  }

  .innovation-box {
    grid-template-columns: 1fr !important;
    padding: 48px !important;
    gap: 32px;
  }

  .tech-half {
    padding: 40px !important;
  }

  .app-matrix {
    grid-template-columns: 1fr 1fr !important;
  }

  .app-card.large,
  .app-card.wide {
    grid-column: span 2 !important;
    grid-row: auto !important;
  }

  /* 竖屏也保持左右分栏，不要把四个分类挤成顶栏 */
  .app-flip-box {
    flex-direction: row !important;
    height: 520px !important;
    min-height: 520px !important;
  }

  .app-nav {
    width: 220px !important;
    flex-direction: column !important;
    overflow: hidden;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: none;
  }

  .app-nav-item {
    flex: 1;
    flex-direction: row !important;
    align-items: center;
    text-align: left !important;
    padding: 0 16px !important;
    gap: 10px !important;
    min-width: 0;
  }

  .app-nav-item .nav-num {
    font-size: 18px !important;
    flex-shrink: 0;
  }

  .app-nav-item .nav-info {
    min-width: 0;
  }

  .app-nav-item .nav-info h4 {
    font-size: 14px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-nav-item .nav-info p {
    display: none !important;
  }

  .app-display {
    height: auto !important;
    flex: 1;
    min-height: 0;
  }

  .rd-panel {
    grid-template-rows: auto !important;
  }

  .mussel-section {
    grid-template-columns: 1fr !important;
    padding: 40px;
  }
}

/* =========================================================
 * iPad 横屏：宽度够用，但高度只有约 744–834
 * 重点压缩纵向间距，避免首屏和全屏模块被裁切
 * ========================================================= */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 900px) {
  .navbar {
    height: calc(56px + var(--sat));
  }

  .hero {
    padding-bottom: 48px !important;
    min-height: 0;
  }

  .hero-content {
    margin-left: 4vw !important;
  }

  .section {
    padding: 56px 0 !important;
  }

  .section-header {
    margin-bottom: 32px !important;
  }

  .section-title {
    font-size: 32px !important;
    margin-bottom: 12px !important;
  }

  #core-tech .section-header {
    top: 16px !important;
  }

  .tech-slide {
    padding: 72px 6% 24px !important;
  }

  .tech-visual-element {
    transform: scale(0.75);
  }

  .app-flip-box {
    height: 460px !important;
    min-height: 0;
  }

  .app-display {
    height: 460px !important;
  }

  .news-accordion-wrapper .news-card,
  .news-accordion-wrapper .news-card:hover {
    height: 240px !important;
    min-height: 240px;
  }

  .about-split {
    gap: 40px;
  }

  .innovation-box {
    padding: 40px !important;
    gap: 32px;
  }

  .innovation-highlight {
    font-size: 72px;
  }

  .sticky-viewport {
    height: calc(var(--vh, 1vh) * 100);
  }

  @supports (height: 100dvh) {
    .sticky-viewport {
      height: 100dvh;
    }
  }

  .login-section,
  .detail-page {
    min-height: 100dvh;
  }
}

/* iPad 横屏且宽度已够展示两列时，保持左右分栏 */
@media (orientation: landscape) and (min-width: 1024px) and (max-width: 1366px) {
  .grid-2,
  .about-split,
  .tech-split {
    grid-template-columns: 1fr 1fr !important;
  }

  .grid-3,
  .patents-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .footer-content {
    grid-template-columns: 1.4fr 1fr 1fr 1fr !important;
    gap: 24px;
  }

  .innovation-box {
    grid-template-columns: 1.4fr 1fr !important;
  }

  .app-matrix {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .rd-panel {
    grid-template-columns: 1.2fr 1fr !important;
  }
}

/* iPad Pro 12.9 横屏（1366）保留桌面导航，只把间距略微收紧 */
@media (min-width: 1201px) and (max-width: 1366px) and (orientation: landscape) {
  .nav-links {
    gap: 22px;
  }

  .nav-links a {
    font-size: 13px;
  }

  .container {
    padding-left: 28px;
    padding-right: 28px;
  }
}

/* 仅触控设备：去掉依赖 hover 才能看见的内容 */
@media (hover: none) and (pointer: coarse) {
  .news-accordion-wrapper .news-content-overlay {
    opacity: 1 !important;
    transform: none !important;
  }

  .news-accordion-wrapper .news-vertical-text {
    display: none !important;
  }

  .app-card .app-bg-img {
    filter: none;
  }
}

/* 超窄竖屏（iPad mini 竖屏 744 / 旧款 768） */
@media (max-width: 834px) and (orientation: portrait) {
  .container {
    padding-left: 20px;
    padding-right: 20px;
  }

  .hero h1,
  #hero-title {
    font-size: clamp(26px, 7vw, 36px) !important;
  }

  .tech-half {
    padding: 32px !important;
  }

  .grid-2,
  .tech-split,
  .about-split {
    gap: 24px;
  }

  .news-accordion-wrapper .news-card,
  .news-accordion-wrapper .news-card:hover {
    flex: 1 1 100% !important;
    width: 100%;
  }

  .nav-links {
    width: 100%;
  }
}
