/* Project2 final layout hardening
   Purpose: normalize legacy templates without changing SEO/content structure. */

html{
  overflow-x:hidden;
}

body{
  overflow-x:hidden;
}

/* Core content axis */
main,
main.section,
section.section{
  box-sizing:border-box;
}

main > .container,
main.section > .container,
section.section > .container,
body > .container{
  width:min(1180px,calc(100% - 40px))!important;
  max-width:1180px!important;
  margin-left:auto!important;
  margin-right:auto!important;
  box-sizing:border-box!important;
}

/* Legacy containers with inline max-width:760/820/880 etc. */
main .container{
  margin-left:auto!important;
  margin-right:auto!important;
  box-sizing:border-box!important;
}

/* Main legacy article containers should use a readable centered width */
main.section > .container{
  width:min(960px,calc(100% - 40px))!important;
  max-width:960px!important;
}

/* Directory/index pages may use full shell width */
body:has(.p2-dir-grid) main.section > .container,
body:has(.p2-taxonomy-grid) main.section > .container,
body:has(.grid3) main.section > .container,
body:has(.grid4) main.section > .container{
  width:min(1180px,calc(100% - 40px))!important;
  max-width:1180px!important;
}

/* Added technical modules */
.p2-tech-body,
.p2-related,
.p2-user-questions,
.p2-question-section,
.p2-search-phrases{
  width:min(1180px,calc(100% - 40px))!important;
  max-width:1180px!important;
  margin-left:auto!important;
  margin-right:auto!important;
  box-sizing:border-box!important;
}

/* Grids */
.grid2,
.cols{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:18px!important;
}

.grid3{
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:18px!important;
}

.grid4{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:18px!important;
}

.p2-dir-grid,
.p2-taxonomy-grid,
.p2-tech-fact-grid,
.p2-related-grid{
  width:100%!important;
  box-sizing:border-box!important;
}

/* Prevent long technical strings from pushing layout sideways */
main *,
section.section *,
.p2-tech-body *,
.p2-related *{
  min-width:0;
}

main p,
main li,
main td,
main th,
main a,
section.section p,
section.section li{
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* Media/table/code cannot exceed content width */
main img,
main video,
main iframe,
section.section img,
section.section video{
  max-width:100%!important;
  height:auto;
}

main table,
section.section table{
  width:100%;
  max-width:100%;
}

main pre,
main code,
section.section pre{
  max-width:100%;
  overflow-x:auto;
}

/* Cards */
.card,
.p2-dir-card,
.p2-related-card,
.p2-tech-fact{
  box-sizing:border-box!important;
  height:100%;
}

/* Tablet */
@media (max-width:980px){
  .grid4,
  .grid3{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }

  .p2-related-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}

/* Mobile */
@media (max-width:760px){
  main > .container,
  main.section > .container,
  section.section > .container,
  body > .container,
  .p2-tech-body,
  .p2-related,
  .p2-user-questions,
  .p2-question-section,
  .p2-search-phrases{
    width:min(100% - 28px,1180px)!important;
    max-width:none!important;
    margin-left:auto!important;
    margin-right:auto!important;
    padding-left:0;
    padding-right:0;
  }

  .grid2,
  .grid3,
  .grid4,
  .cols,
  .p2-dir-grid,
  .p2-taxonomy-grid,
  .p2-tech-fact-grid,
  .p2-related-grid{
    grid-template-columns:1fr!important;
  }
}

/* ===== P2 taxonomy contrast fix 20261028 ===== */

.p2-taxonomy-section{
  width:min(1180px, calc(100% - 32px)) !important;
  margin:36px auto !important;
  padding:32px !important;
  border-radius:22px !important;
  background:#f6f8fb !important;
  border:1px solid #dce3ec !important;
  color:#172033 !important;
}

.p2-taxonomy-section > h2,
.p2-taxonomy-section .p2-taxonomy-head h2{
  color:#101828 !important;
  opacity:1 !important;
}

.p2-taxonomy-section > p,
.p2-taxonomy-section .p2-taxonomy-lead,
.p2-taxonomy-section .p2-taxonomy-head p{
  color:#475467 !important;
  opacity:1 !important;
}

.p2-taxonomy-grid{
  display:grid !important;
  grid-template-columns:repeat(3, minmax(0,1fr)) !important;
  gap:18px !important;
  margin-top:22px !important;
}

.p2-taxonomy-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  border-radius:18px !important;
  padding:22px !important;
  box-shadow:0 8px 24px rgba(16,24,40,.06) !important;
  color:#172033 !important;
  opacity:1 !important;
}

.p2-taxonomy-card h3{
  margin:0 0 10px !important;
  color:#101828 !important;
  opacity:1 !important;
}

.p2-taxonomy-card p{
  margin:0 !important;
  color:#344054 !important;
  line-height:1.75 !important;
  opacity:1 !important;
}

.p2-taxonomy-card a{
  color:#175cd3 !important;
  text-decoration:none !important;
}

.p2-taxonomy-card a:hover{
  text-decoration:underline !important;
}

.p2-taxonomy-card span,
.p2-taxonomy-card li,
.p2-taxonomy-card b,
.p2-taxonomy-card strong{
  color:#344054 !important;
  opacity:1 !important;
}

.p2-taxonomy-section *{
  text-shadow:none !important;
}

@media (max-width:900px){
  .p2-taxonomy-grid{
    grid-template-columns:1fr 1fr !important;
  }
}

@media (max-width:640px){
  .p2-taxonomy-section{
    width:min(100% - 20px,1180px) !important;
    padding:20px !important;
  }

  .p2-taxonomy-grid{
    grid-template-columns:1fr !important;
  }

  .p2-taxonomy-card{
    padding:18px !important;
  }
}

/* =========================================================
   P2 GLOBAL CARD CONTRAST FIX
   Fix gray background + invisible/low-opacity text
   ========================================================= */

/* ---------- 用户常见问法 ---------- */

.p2-intent-section{
  color:#172033 !important;
}

.p2-intent-section h2{
  color:#101828 !important;
  opacity:1 !important;
}

.p2-intent-section .p2-intent-lead{
  color:#475467 !important;
  opacity:1 !important;
}

.p2-intent-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  color:#172033 !important;
  opacity:1 !important;
  box-shadow:0 6px 18px rgba(16,24,40,.05) !important;
}

.p2-intent-card h3{
  color:#172033 !important;
  opacity:1 !important;
}

.p2-intent-card p{
  color:#475467 !important;
  opacity:1 !important;
}

.p2-intent-card span,
.p2-intent-card li,
.p2-intent-card b,
.p2-intent-card strong{
  color:#344054 !important;
  opacity:1 !important;
}


/* ---------- 技术深度卡片 ---------- */

.p2-depth-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  color:#172033 !important;
  opacity:1 !important;
}

.p2-depth-card h3,
.p2-depth-card h3 a{
  color:#172033 !important;
  opacity:1 !important;
}

.p2-depth-card p{
  color:#475467 !important;
  opacity:1 !important;
}

.p2-depth-card span,
.p2-depth-card div,
.p2-depth-card b,
.p2-depth-card strong{
  opacity:1 !important;
}

.p2-depth-meta{
  color:#475467 !important;
  opacity:1 !important;
}

.p2-depth-meta div{
  color:#475467 !important;
}

.p2-depth-meta b{
  color:#344054 !important;
}


/* ---------- 相关技术 ---------- */

.p2-related-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  color:#172033 !important;
  opacity:1 !important;
}

.p2-related-card b,
.p2-related-card strong{
  color:#172033 !important;
  opacity:1 !important;
}

.p2-related-card span{
  color:#475467 !important;
  opacity:1 !important;
}


/* ---------- 完整技术分类体系 ---------- */

.p2-taxonomy-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  color:#172033 !important;
  opacity:1 !important;
}

.p2-taxonomy-card h3{
  color:#172033 !important;
  opacity:1 !important;
}

.p2-taxonomy-card p,
.p2-taxonomy-card li,
.p2-taxonomy-card span{
  color:#475467 !important;
  opacity:1 !important;
}


/* ---------- Coverage / 分类覆盖卡片 ---------- */

.p2-cover-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  color:#172033 !important;
  opacity:1 !important;
}

.p2-cover-card h3{
  color:#172033 !important;
  opacity:1 !important;
}

.p2-cover-card p{
  color:#475467 !important;
  opacity:1 !important;
}

.p2-cover-card li,
.p2-cover-card span{
  opacity:1 !important;
}


/* ---------- Question cards / 用户问题矩阵 ---------- */

.p2-question-group,
.p2-question-card{
  background:#ffffff !important;
  border:1px solid #d8e0ea !important;
  color:#172033 !important;
  opacity:1 !important;
}

.p2-question-group h3,
.p2-question-card h3{
  color:#172033 !important;
  opacity:1 !important;
}

.p2-question-group li,
.p2-question-group p,
.p2-question-card li,
.p2-question-card p{
  color:#475467 !important;
  opacity:1 !important;
}


/* ---------- 通用卡片兜底 ---------- */

[class*="p2-"][class*="card"]{
  opacity:1 !important;
}

[class*="p2-"][class*="card"] h2,
[class*="p2-"][class*="card"] h3,
[class*="p2-"][class*="card"] h4{
  opacity:1 !important;
}

[class*="p2-"][class*="card"] p,
[class*="p2-"][class*="card"] li{
  opacity:1 !important;
}


/* ---------- 去除导致文字发白的继承 ---------- */

.p2-intent-section *,
.p2-taxonomy-section *,
.p2-related *,
.p2-tech-body *,
.p2-cover-section *{
  text-shadow:none !important;
}


/* ---------- 页面主体文字 ---------- */

main p,
main li{
  opacity:1 !important;
}


/* ---------- 防止浅灰文字落在灰底 ---------- */

.p2-intent-card p,
.p2-taxonomy-card p,
.p2-related-card span,
.p2-depth-card p,
.p2-question-group li{
  filter:none !important;
  -webkit-text-fill-color:currentColor !important;
}


/* ---------- 手机 ---------- */

@media (max-width:640px){

  .p2-intent-card,
  .p2-depth-card,
  .p2-related-card,
  .p2-taxonomy-card,
  .p2-cover-card,
  .p2-question-group{
    background:#ffffff !important;
    color:#172033 !important;
  }

}

