/* ————————————————————————————————————————————————————————————————
   Global Reset & Theme Variables
   ———————————————————————————————————————————————————————————————— */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand Colors */
  --primary: #3a7afe;
  --primary-light: #5f8dff;
  --bg-light: #f6f8fa;
  --bg-dark: #1c1e23;
  --text-light: #2d2d32;
  --text-dark: #e4e6eb;

  /* Semantic Colors */
  --color-error: #f44336;
  --color-warning-start: #ff9900; /* 与按钮主题一致 */
  --color-warning-border: #ffa500;
  --color-warning-text: #856404;
  --color-warning-bg: #fff3cd;

  /* Spacing & Sizing */
  --gap-base: 20px;
  --radius-base: 8px;
  --shadow-light: rgba(0,0,0,.04);
  --shadow-strong: rgba(0,0,0,.08);
  --transition-base: 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-light: var(--bg-dark);
    --text-light: var(--text-dark);
  }
}

/* ————————————————————————————————————————————————————————————————
   Layout: Two-by-Two Grid (“田字形”)
   ———————————————————————————————————————————————————————————————— */
.product-detail-box {
  display: grid;
  grid-template:
    "gallery info" auto
    "color   buy"    auto / 1fr 1fr;
  gap: 2rem 40px;
  margin-bottom: 3rem;
  padding: var(--gap-base);
  background: #fff;
  border: 1px solid #eee;
  border-radius: var(--radius-base);
  width: 100%;
}

/* ————————————————————————————————————————————————————————————————
   Component: Product Gallery (Left-Top)
   ———————————————————————————————————————————————————————————————— */
.product-gallery { grid-area: gallery; text-align: center; }
.main-img {
  width: 100%; max-width: 420px;
  height: 420px;
  margin: 0 auto var(--gap-base);
  overflow: hidden;
  border-radius: var(--radius-base);
}
.main-img img {
  width: 100%; height: 100%; object-fit: contain;
}

/* ————————————————————————————————————————————————————————————————
   Component: Product Info (Right-Top)
   ———————————————————————————————————————————————————————————————— */
.product-info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 420px;
}
.product-title {
  font-size: 1.625rem;
  color: var(--text-light);
  margin-bottom: .75rem;
}
.product-price span {
  color: var(--color-error);
  font-size: 1.375rem;
}
.product-price_ori span {
  color: #999;
  font-size: 1rem;
  text-decoration: line-through;
}
.product-stock {
  color: #555;
  margin-top: .5rem;
}
.tips-box {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border-left: 5px solid var(--color-warning-border);
  padding: .75rem;
  margin: 1.25rem 0;
  border-radius: 6px;
  font-size: .875rem;
}

/* ————————————————————————————————————————————————————————————————
   Component: Tags Lines (与按钮主题一致)
   ———————————————————————————————————————————————————————————————— */
.product-ProductTags {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: .875rem;
  perspective: 300px;
}
.tag-line {
  position: relative;
  padding: 10px 16px;
  font-size: .15px
  font-weight: bold;
  line-height: 1.6;
  color: #a63600;
  background: #fff;
  border-left: 4px solid var(--color-warning-start);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow-light);
  transition: transform var(--transition-base),
              box-shadow var(--transition-base);
  overflow: hidden;
}
.tag-line::before {
  content: "";
  position: absolute;
  top: -40%; left: -20px;
  width: 120%; height: 180%;
  background: radial-gradient(circle at left,
    var(--color-warning-start) 0%, transparent 70%
  );
  opacity: .12;
  filter: blur(22px);
  transform: skewX(-15deg);
  pointer-events: none;
}
.tag-line:hover {
  transform: rotateX(6deg) translateY(-2px);
  box-shadow: 0 6px 18px var(--shadow-strong);
}

/* ————————————————————————————————————————————————————————————————
   Component: Color Selector (Left-Bottom)
   ———————————————————————————————————————————————————————————————— */
.color-select { grid-area: color; }
.color-title {
  margin-top: 1.25rem;
  font-size: 1rem;
  font-weight: bold;
}
.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  margin-top: .5rem;
}
.color-btn {
  background: var(--bg-light);
  border: 1px solid #ccc;
  padding: .5rem .875rem;
  font-size: .875rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-base);
}
.color-btn:hover,
.color-btn.active {
  background: #355571;
  color: #fff;
}

/* ————————————————————————————————————————————————————————————————
   Component: Buy Area (Right-Bottom)
   ———————————————————————————————————————————————————————————————— */
.buy-area {
  grid-area: buy;
  display: flex;
  flex-direction: column;
  gap: var(--gap-base);
}
.buy-btn {
  padding: .875rem 2.5rem;
  background: linear-gradient(to right,
    var(--color-warning-start), var(--color-error)
  );
  color: #fff;
  font-size: 1.125rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-base);
}
.buy-btn:hover {
  background: #ce372c;
}
.buy-links {
  display: none;
  flex-wrap: wrap;
  gap: 1.25rem;
}
.buy-links a {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 72px;
  font-size: .875rem;
  color: var(--text-light);
}
.buy-links a img {
  width: 40px; height: 40px;
  margin-bottom: .25rem;
}

/* ————————————————————————————————————————————————————————————————
   Component: Rich Text Description Card
   ———————————————————————————————————————————————————————————————— */
.product-desc-card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: var(--radius-base);
  padding: 2.5rem;
  font-size: 1rem;
  line-height: 1.8;
  box-shadow: 0 4px 12px var(--shadow-light);
  margin-bottom: 3rem;
  overflow-wrap: break-word;
}
.product-desc-card img,
.product-desc-card iframe,
.product-desc-card table {
  max-width: 100%;
  width: 100% !important;
  height: auto;
}
.product-desc-card pre,
.product-desc-card code {
  overflow-x: auto;
}

/* ————————————————————————————————————————————————————————————————
   Responsive: Mobile (<=768px)
   ———————————————————————————————————————————————————————————————— */
@media (max-width: 768px) {
  .product-detail-box {
    display: flex;
    flex-direction: column;
    padding: 1rem;
  }

  .product-gallery { order: 1; margin-bottom: 2rem; }
  .color-select   { order: 2; margin-bottom: 2rem; }
  .product-info   { order: 3; margin-bottom: 2rem; }
  .buy-area       { order: 4; margin-bottom: 2rem; }

  .main-img {
    max-width: 100%;
    height: auto;
    margin-bottom: 1rem;
  }

  .buy-btn {
    font-size: 1rem;
    padding: .75rem 1.5rem;
  }
  .buy-links a {
    width: 60px;
    font-size: .75rem;
  }
  .buy-links a img {
    width: 32px;
    height: 32px;
  }
}
/* =========================================================
   富文本卡片：产品详情描述 (.product-desc-card)
   ========================================================= */
.product-desc-card{
  background:#fff;
  border:1px solid #eee;
  border-radius:var(--radius-base);
  padding:2.5rem;
  font-size:1rem;
  line-height:1.8;
  box-shadow:0 4px 12px var(--shadow-light);
  margin-bottom:3rem;
  overflow-wrap:break-word;
}

/* ————— 通用媒体元素 ————— */
.product-desc-card img,
.product-desc-card iframe,
.product-desc-card video,
.product-desc-card table{
  max-width:100%;
  width:100% !important;   /* 覆盖富文本里写死的 width */
  height:auto !important;  /* 同理覆盖 height，消除空白占位 */
}

/* 图片本身：消除行内空隙、拉伸、默认 margin */
.product-desc-card img{
  display:block;
  object-fit:contain;
  margin:0;                /* 彻底归零，交由父元素控制垂直距 */
}

/* 只含图片的 <p> / <figure> / <div> 去掉外边距，避免双重空隙 */
.product-desc-card p:has(> img:first-child:last-child),
.product-desc-card figure:has(> img:first-child:last-child),
.product-desc-card div:has(> img:first-child:last-child){
  margin:0;
}

/* 常规段落默认上下 1rem，可按需调小/调大 */
.product-desc-card p,
.product-desc-card figure,
.product-desc-card div{
  margin:1rem 0;
}

/* 多图之间留一小段距离（0.5rem） */
.product-desc-card img + img,
.product-desc-card figure + figure,
.product-desc-card p + p:has(> img:first-child:last-child){
  margin-top:.5rem;
}

/* ————— 视频 / iframe 16:9 自适应 ————— */
.product-desc-card .video-wrapper{
  position:relative;
  width:100%;
  padding-top:56.25%;      /* 16:9 */
  margin:1.5rem 0;
}
.product-desc-card .video-wrapper iframe,
.product-desc-card .video-wrapper video{
  position:absolute;
  inset:0;
  width:100%; height:100%;
  border:0;
  object-fit:cover;
}

/* 代码块横向滚动 */
.product-desc-card pre,
.product-desc-card code{
  overflow-x:auto;
}

/* =========================================================
   移动端优化 (≤768px)
   ========================================================= */
@media (max-width:768px){
  .product-desc-card{
    padding:1.25rem;
    font-size:.9375rem;
  }

  /* 主详情页模块排序（田字形 → 纵向） */
  .product-detail-box{
    display:flex;
    flex-direction:column;
    padding:1rem;
  }
  .product-gallery{order:1;margin-bottom:2rem;}
  .color-select  {order:2;margin-bottom:2rem;}
  .product-info  {order:3;margin-bottom:2rem;}
  .buy-area      {order:4;margin-bottom:2rem;}

  /* 购买按钮 & 图标尺寸 */
  .buy-btn{font-size:1rem;}
}
@media (max-width: 500px) {
  .main-img {        
    max-width: 100%;
    height: 370px;
    overflow: hidden;
    margin-bottom: 1rem;
  }
}