/* ==========================================================================
   品度主题 - 移动端适配
   --------------------------------------------------------------------------
   本文件在 style.css / pages.css / home-v2.css 之后加载，全部规则都包裹在
   @media (max-width: ...) 内，因此不会影响 PC 端（>1100px）的任何表现。
   断点约定：
     1100px  平板 / 窄屏：补齐左右安全边距、修正 grid 溢出
      820px  小平板 / 大手机：多列区块收敛为单列、移动端导航面板
      560px  手机：字号收敛、表单与卡片单列
      380px  小屏手机：进一步压缩
   ========================================================================== */

/* ==========================================================================
   1. 左右安全边距（≤1100px）
   pages.css / style.css 中的页面容器都是 max-width:var(--max) + padding:x 0，
   在窄屏下会紧贴屏幕两侧，这里统一补上水平内边距。
   ========================================================================== */

@media (max-width: 1100px) {
  :root {
    --page-gutter: 20px;
  }

  .section,
  .business-section,
  .problem-section,
  .contact-section,
  .problem-page,
  .problem-category-page,
  .article-page,
  .contact-page,
  .credentials-page,
  .credential-detail-page,
  .about-page,
  .ip-page,
  .ip-detail-page,
  .detail-breadcrumb,
  .detail-hero,
  .detail-body,
  .footer-v2__inner {
    padding-left: var(--page-gutter);
    padding-right: var(--page-gutter);
  }

  /* 面包屑在这些容器内部时不重复缩进 */
  .article-page .detail-breadcrumb,
  .problem-category-page .detail-breadcrumb,
  .credential-detail-page .detail-breadcrumb,
  .ip-detail-page .detail-breadcrumb {
    padding-left: 0;
    padding-right: 0;
  }

  /* 通栏文字 Banner 的文案同样需要安全边距 */
  .page-banner--text {
    padding-left: var(--page-gutter);
    padding-right: var(--page-gutter);
  }

  /* 详情页正文与侧边栏之间的分隔线在有内边距时更贴合 */
  .detail-body {
    padding-bottom: 40px;
  }
}

/* ==========================================================================
   2. 栅格溢出修正（≤1100px）
   pages.css 在窄屏把多列栅格改成 `1fr`，而 `1fr` 的最小尺寸是 auto，
   遇到宽表格 / 长代码 / 不可断行文本时会把整页撑宽出现横向滚动。
   统一换成 minmax(0,1fr) 并给栅格子项 min-width:0。
   ========================================================================== */

@media (max-width: 1100px) {
  .home-hero,
  .footer-v2__inner,
  .news-page__layout,
  .news-article,
  .detail-hero,
  .detail-body,
  .article-page__layout,
  .problem-category-page__layout,
  .article-page--news .article-page__layout,
  .article-page--problem .article-page__layout,
  .article-page--founder .article-page__layout,
  .article-page__recommend-list,
  .about-page__founder,
  .founder-detail__header,
  .credentials-card,
  .credentials-page__stats,
  .ip-page__stats,
  .ip-page__intro,
  .ip-detail-page__layout,
  .ip-detail-page__header,
  .credential-detail-page__layout,
  .credential-detail-page__head,
  .problem-category-page__main .news-article--compact {
    grid-template-columns: minmax(0, 1fr);
  }

  .news-page__layout > *,
  .news-article > *,
  .detail-hero > *,
  .detail-body > *,
  .article-page__layout > *,
  .article-page__main > *,
  .problem-category-page__layout > *,
  .credential-detail-page__layout > *,
  .ip-detail-page__layout > *,
  .detail-gallery > *,
  .contact-page__layout > *,
  .article-page__sidebar > *,
  .detail-related__stack > * {
    min-width: 0;
  }

  .problem-panel__link {
    grid-template-columns: 42px minmax(0, 1fr) 20px;
  }

  .article-page__main,
  .detail-gallery,
  .article-page__body,
  .detail-gallery__stack {
    max-width: 100%;
  }
}

/* ==========================================================================
   3. 头部与移动端导航面板（≤1024px）
   style.css 只在 ≤820px 收起导航，821~1024px 之间导航条 + 电话号码放不下，
   会把整个页面撑出横向滚动（导航项由后台配置，数量不可控）。
   这里把汉堡菜单的断点提升到 1024px，PC（≥1025px）完全不受影响。
   ========================================================================== */

@media (max-width: 1024px) {
  /* 只保证 44px 触摸面积，外观沿用主题原有样式 */
  .menu-button {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .main-nav {
    position: fixed;
    z-index: 40;
    display: none;
    border: 1px solid #f3d4c4;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 52px rgba(20, 32, 51, .16);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-nav.is-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  /* 定位相关的属性需要与 home-v2.css 同权重才能覆盖 */
  .page-home-v2 .main-nav,
  .page-site-v2 .main-nav {
    top: 80px;
    right: 16px;
    left: auto;
    width: min(320px, calc(100vw - 32px));
    max-height: calc(100vh - 112px);
    gap: 4px;
    padding: 10px;
    font-size: 16px;
  }

  .page-home-v2 .main-nav a,
  .page-site-v2 .main-nav a {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: flex-start;
    border-radius: 8px;
    padding: 0 12px;
  }

  .page-home-v2 .main-nav a.is-active,
  .page-site-v2 .main-nav a.is-active {
    background: #fff3ed;
  }

  /* 首页顶部导航为了压在深色 Hero 上被设成白色文字，
     展开为白底下拉面板后会白字白底不可读，这里改回深色 */
  .page-home-v2 .site-header--home .main-nav a,
  .page-home-v2 .site-header--home.is-scrolled .main-nav a {
    color: var(--home-text);
  }

  .page-home-v2 .site-header--home .main-nav a.is-active,
  .page-home-v2 .site-header--home .main-nav a:hover {
    color: var(--orange);
  }

  /* 汉堡按钮在透明头部上保持可见 */
  .page-home-v2 .site-header--home .menu-button {
    color: #fff;
  }

  .page-home-v2 .site-header--home.is-scrolled .menu-button {
    color: var(--home-text);
  }

  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 767px) {
  .page-home-v2 .main-nav,
  .page-site-v2 .main-nav {
    top: 64px;
    max-height: calc(100vh - 96px);
  }
}

/* 品牌副标题在窄屏挤占导航空间 */
@media (max-width: 430px) {
  .page-home-v2 .brand-text,
  .page-site-v2 .brand-text {
    font-size: 12px;
  }
}

@media (max-width: 359px) {
  .page-home-v2 .brand-text,
  .page-site-v2 .brand-text {
    display: none;
  }
}

/* ==========================================================================
   4. 通栏 Banner（≤820px / ≤560px）
   ========================================================================== */

@media (max-width: 820px) {
  .page-banner--text {
    min-height: 200px;
  }

  .page-banner__title {
    font-size: 32px;
  }

  .page-banner__desc {
    margin-top: 10px;
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .page-banner--text {
    min-height: 170px;
  }

  .page-banner__title {
    font-size: 26px;
  }

  .page-banner__desc {
    font-size: 14px;
    line-height: 1.6;
  }
}

/* ==========================================================================
   5. 列表 / 卡片（≤820px、≤560px）
   ========================================================================== */

@media (max-width: 820px) {
  .channel-page {
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .news-page {
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .channel-page__grid {
    gap: 18px;
  }

  .news-page__list {
    gap: 22px;
  }
}

@media (max-width: 560px) {
  .ui-filter {
    gap: 12px 16px;
  }

  .ui-filter__list {
    gap: 8px 8px;
  }

  .ui-filter__chip {
    height: 34px;
    padding: 0 14px;
    font-size: 14px;
  }

  .channel-card__media {
    height: auto;
    aspect-ratio: 382 / 230;
  }

  .channel-card__title {
    font-size: 19px;
  }

  .channel-card__body {
    padding: 16px;
  }

  .news-article {
    padding-bottom: 22px;
  }

  .news-article__media {
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .news-article__title {
    font-size: 20px;
  }

  .news-article__desc {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.75;
  }

  .news-article__footer {
    gap: 12px;
    padding-top: 14px;
  }

  .news-article__action {
    width: auto;
    min-width: 104px;
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
  }

  .news-page__sidebar,
  .article-widget {
    padding: 18px;
  }

  .news-page__sidebar-title,
  .article-widget__title {
    font-size: 19px;
  }
}

/* ==========================================================================
   6. 详情页（≤820px、≤560px）
   ========================================================================== */

@media (max-width: 820px) {
  .detail-hero {
    gap: 24px;
    padding-top: 20px;
    padding-bottom: 28px;
  }

  .detail-hero__media img {
    width: 100%;
    max-width: 100%;
  }

  .detail-gallery {
    padding-top: 28px;
  }

  .detail-related {
    padding-top: 28px;
  }

  .article-page--founder .article-page__main,
  .article-page__main {
    padding: 20px;
  }

  .article-page--news .article-page__main,
  .article-page--problem .article-page__main {
    padding: 0;
  }
}

@media (max-width: 560px) {
  .detail-breadcrumb {
    margin-top: 16px;
    font-size: 13px;
  }

  .detail-hero__title {
    font-size: 26px;
    line-height: 1.3;
  }

  .detail-hero__intro p,
  .detail-hero__desc {
    font-size: 14px;
    line-height: 1.8;
  }

  .detail-hero__btn,
  .detail-related__btn,
  .article-widget__btn,
  .about-page__founder-btn {
    width: 100%;
    justify-content: center;
  }

  .detail-gallery__title {
    margin-bottom: 16px;
    font-size: 19px;
  }

  .detail-gallery__stack {
    gap: 16px;
  }

  /* 文章 / 问题详情标题（模板中为无 class 的 h1） */
  .article-page__header h1,
  .article-page__title,
  .article-page--news .article-page__title,
  .article-page--problem .article-page__title,
  .founder-detail__title {
    font-size: 24px;
    line-height: 1.35;
  }

  .article-page__meta,
  .article-page--news .article-page__meta,
  .article-page--problem .article-page__meta {
    margin-top: 10px;
    font-size: 13px;
  }

  .article-page__body {
    margin-top: 20px;
    font-size: 15px;
    line-height: 1.85;
  }

  /* 关联内容卡片：窄屏纵向排列，按钮占满一行 */
  .article-ref-card {
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }

  .article-ref-card__title {
    font-size: 16px;
  }

  .article-ref-card__btn {
    width: 100%;
    margin-left: 0;
  }

  /* 上一篇 / 下一篇 纵向排列，避免长标题挤压 */
  .article-page__nav {
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
    padding-top: 18px;
    font-size: 14px;
  }

  .article-page__nav a,
  .article-page__nav span,
  .article-page__nav > div {
    max-width: 100%;
  }

  .article-page__recommend-head h2 {
    font-size: 20px;
  }

  .founder-detail__header {
    padding-bottom: 20px;
  }

  .founder-detail__roles li,
  .founder-detail__summary {
    font-size: 15px;
  }
}

/* ==========================================================================
   7. 问题地图（≤820px / ≤560px）
   ========================================================================== */

@media (max-width: 560px) {
  .problem-panel__head {
    min-height: 56px;
    padding: 0 16px;
  }

  .problem-panel__title {
    font-size: 18px;
  }

  .problem-panel__link {
    gap: 10px;
    padding: 14px 16px;
  }

  .problem-panel__text {
    font-size: 15px;
  }
}

/* ==========================================================================
   8. 联系页（≤820px、≤560px）
   pages.css 中 .contact-page__form-card / __map-card 是固定两列，
   窄屏下从未收敛，表单被压成竖条，这里补齐。
   ========================================================================== */

@media (max-width: 820px) {
  .contact-page {
    padding-top: 28px;
    padding-bottom: 40px;
  }

  .contact-page__form-card,
  .contact-page__map-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }

  .contact-page__card {
    padding: 20px;
  }

  .contact-page__map {
    max-width: 100%;
    height: auto;
    aspect-ratio: 880 / 320;
  }

  .contact-page__channels {
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .contact-page__form-intro h1,
  .contact-page__map-copy h2 {
    font-size: 24px;
  }

  .contact-page__form-intro p,
  .contact-page__map-copy p {
    font-size: 15px;
    line-height: 1.75;
  }

  .contact-page .contact-form {
    grid-template-columns: minmax(0, 1fr);
  }

  /* iOS 上 <16px 的输入框会触发自动缩放 */
  .contact-page .contact-form input,
  .contact-page .contact-form select,
  .contact-page .contact-form textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .contact-page .contact-form .primary-button {
    width: 100%;
    justify-self: stretch;
  }

  .contact-page__channels {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-page__channel {
    padding: 18px 16px;
  }

  .contact-page__channel-desc {
    margin-top: 10px;
    font-size: 14px;
  }

  .contact-page__channels .contact-page__channel:nth-child(3) .contact-page__channel-desc {
    margin-top: 10px;
  }
}

/* ==========================================================================
   9. 关于品度（≤560px）
   ========================================================================== */

@media (max-width: 560px) {
  .about-page {
    padding-top: 28px;
    padding-bottom: 48px;
  }

  .about-page__title,
  .about-page__views-title {
    margin-bottom: 20px;
    padding-bottom: 12px;
    font-size: 26px;
  }

  .about-page__intro p {
    font-size: 15px;
    line-height: 1.9;
  }

  .about-page__founder {
    padding: 20px 16px;
    margin-bottom: 36px;
  }

  .about-page__founder-name {
    font-size: 22px;
  }

  .about-page__founder-role,
  .about-page__founder-copy p {
    font-size: 15px;
  }

  .about-page__views {
    gap: 18px;
  }

  .about-view {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
    padding: 20px 16px;
  }

  .about-view__quote {
    font-size: 40px;
  }

  .about-view__title {
    margin-bottom: 12px;
    font-size: 18px;
  }

  .about-view__body p {
    font-size: 15px;
    line-height: 1.9;
  }
}

/* ==========================================================================
   10. 分页（≤560px）
   ========================================================================== */

/* partials/pagination.html 输出的是不带 class 的 <a>/<span>，
   pages.css 的 .ui-pagination__item 样式命中不到，触摸目标过小。
   这里按元素兜底，保证移动端可点击面积 ≥36px。
   （彻底方案是给模板补上 .ui-pagination__item class，会同时改变 PC 外观，故未改动） */
@media (max-width: 1100px) {
  .ui-pagination > a,
  .ui-pagination > span {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--text);
    font-size: 15px;
    line-height: 1;
  }

  .ui-pagination > .is-active {
    border-color: var(--orange);
    background: var(--orange);
    color: #fff;
  }

  .ui-pagination > .is-disabled {
    color: var(--muted);
  }
}

@media (max-width: 560px) {
  .ui-pagination {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 28px;
  }

  .ui-pagination > a,
  .ui-pagination > span {
    min-width: 34px;
    min-height: 34px;
    padding: 0 10px;
    font-size: 14px;
  }

  .ui-pagination__item {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    font-size: 14px;
  }

  .ui-pagination__item--wide {
    min-width: 64px;
    padding: 0 14px;
  }
}

/* ==========================================================================
   11. 富文本正文（≤560px）
   宽表格 / 代码块保持自身横向滚动，不撑破页面
   ========================================================================== */

@media (max-width: 1100px) {
  .rich-text table,
  .rich-text pre {
    max-width: 100%;
  }

  /* 专家详情等未套 .rich-text 的正文，同样兜底防止撑破页面 */
  .article-page__body pre,
  .article-page__body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  .article-page__body img,
  .article-page__body video,
  .article-page__body iframe {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 560px) {
  .rich-text th,
  .rich-text td {
    min-width: 96px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .rich-text h2 {
    padding-left: 10px;
  }

  .rich-text pre {
    padding: 14px 16px;
    font-size: 13px;
  }

  .rich-text ul,
  .rich-text ol {
    padding-left: 1.3em;
  }
}

/* ==========================================================================
   12. 首页（≤560px / ≤380px）
   home-v2.css 本身是移动优先的，这里只做小屏微调
   ========================================================================== */

/* 首页区块副标题在 home-v2.css 里 ≥768px 是强制不换行的，
   768~900px 的平板宽度放不下，会造成整页横向滚动 */
@media (max-width: 900px) {
  .home-v2-section__head--single-line p {
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .home-v2-hero {
    height: auto;
    min-height: 440px;
    padding-top: 96px;
    padding-bottom: 48px;
  }

  .home-v2-hero__title {
    font-size: 30px;
  }

  .home-v2-hero__subtitle {
    font-size: 17px;
  }

  .home-v2-hero__desc,
  .home-v2-hero__slogan {
    font-size: 14px;
  }

  .home-v2-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
  }

  .home-v2-section,
  .home-v2-contact {
    padding: 48px 0;
  }

  #viewpoint {
    padding-top: 48px;
  }

  .home-v2-section__head {
    margin-bottom: 24px;
  }

  .home-v2-section__head h2 {
    font-size: 26px;
  }

  .home-v2-section__head p {
    font-size: 15px;
    line-height: 1.7;
  }

  .home-v2-about {
    gap: 32px;
  }

  .home-v2-about__copy p {
    font-size: 15px;
    line-height: 1.85;
  }

  .home-v2-about__checks {
    gap: 14px;
  }

  .home-v2-about__checks li {
    font-size: 15px;
  }

  .home-v2-founder {
    padding: 28px 20px;
  }

  .home-v2-founder__avatar {
    width: 128px;
    height: 128px;
  }

  .home-v2-founder h3 {
    font-size: 24px;
  }

  .home-v2-founder__desc {
    font-size: 15px;
    line-height: 1.85;
  }

  .home-v2-service-grid,
  .home-v2-case-grid,
  .home-v2-quote-grid {
    gap: 20px;
  }

  .home-v2-service-card,
  .home-v2-quote-card {
    padding: 24px 20px;
  }

  .home-v2-case-card img {
    height: auto;
    aspect-ratio: 16 / 10;
  }

  .home-v2-case-card__body {
    padding: 20px;
  }

  .home-v2-case-card__body h3 {
    font-size: 20px;
  }

  .home-v2-quote-card .home-v2-quote-card__lead {
    font-size: 18px;
  }

  .home-v2-contact__form {
    padding: 24px 20px;
  }

  /* iOS 上 <16px 的输入框会触发自动缩放 */
  .home-v2-contact__field input,
  .home-v2-contact__field select,
  .home-v2-contact__field textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .home-v2-contact__icon {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 17px;
  }

  .home-v2-footer__grid {
    gap: 24px;
    margin-bottom: 24px;
  }
}

@media (max-width: 380px) {
  .home-v2-hero__title {
    font-size: 26px;
  }

  .home-v2-section__head h2 {
    font-size: 24px;
  }
}
