/* ============================================================
   HuaQuan Master V1 — Site-wide adaptation layer (catalog site)
   Extends pilot master-v1.css to non-.content-section page types:
   category listing, news article, key-takeaways, page-hero,
   product cards, standalone section[id] tables.
   Loaded AFTER style.css + home.css + master-v1.css.
   NOTE: most catalog pages have NO <main> tag, so selectors are
   unprefixed; homepage uses hq-hero/hq-main classes and no
   section[id], so it is naturally not matched.
   ============================================================ */

/* ---- Shared text safety (RU hyphens / long words) ---- */
p,
li,
h1,
h2,
h3,
td,
th {
  overflow-wrap: anywhere;
  word-break: break-word;
}
p { hyphens: auto; -webkit-hyphens: auto; }
li { hyphens: auto; -webkit-hyphens: auto; }

/* ---- Section heading accent (non content-section headings) ---- */
.page-hero h2,
.key-takeaways h2,
.toc h2,
section[id] > h2,
.news-article h2,
.summary-section h2,
.faq-topic h2 {
  position: relative;
  padding-left: .85rem;
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 2.3rem 0 .95rem;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}
.page-hero h2::before,
.key-takeaways h2::before,
.toc h2::before,
section[id] > h2::before,
.news-article h2::before,
.summary-section h2::before,
.faq-topic h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: .08em;
  bottom: .08em;
  width: 4px;
  border-radius: 2px;
  background: var(--color-primary);
}

/* ---- Page hero (category & content pages use .page-hero) ---- */
.page-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: 6px;
  padding: 1.7rem clamp(1.4rem, 2.6vw, 2.6rem);
  margin: .3rem 0 1.5rem;
}
.page-hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2.9vw, 2.3rem);
  letter-spacing: -.4px;
  line-height: 1.24;
  color: var(--color-primary);
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}
.page-hero p {
  margin: .65rem 0 0;
  max-width: 66ch;
  font-size: 1.02rem;
  line-height: 1.62;
  color: var(--color-text-secondary);
}

/* ---- Key takeaways: quiet summary panel ---- */
.key-takeaways {
  margin: 0 auto 2rem;
  padding: 1.2rem 1.5rem 1.15rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: 6px;
}
.key-takeaways h2 { margin: 0 0 .7rem; padding-left: .85rem; }
.key-takeaways ul,
.key-takeaways ol {
  list-style: none;
  padding-left: .4rem;
  margin: 0;
}
.key-takeaways ul > li,
.key-takeaways ol > li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: .42rem;
  line-height: 1.62;
  color: var(--color-text-secondary);
}
.key-takeaways ul > li::before,
.key-takeaways ol > li::before {
  content: "";
  position: absolute;
  left: .15rem;
  top: .6em;
  width: 6px;
  height: 6px;
  background: var(--color-accent);
  transform: rotate(45deg);
}

/* ---- TOC: link index as quiet cards ---- */
.toc {
  margin: 0 auto 1.8rem;
  padding: .2rem 0 .4rem;
}
.toc ul {
  list-style: none;
  padding-left: 0;
  margin: .4rem 0 1rem;
  columns: 2;
  column-gap: 1.8rem;
}
.toc ul li { break-inside: avoid; margin-bottom: .45rem; }
.toc a {
  display: block;
  padding: .55rem .85rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-secondary);
  font-size: .95rem;
  transition: border-color 150ms ease, border-left-color 150ms ease, padding-left 150ms ease;
}
.toc a:hover {
  border-color: var(--color-accent);
  border-left-color: var(--color-accent);
  padding-left: 1.05rem;
  color: var(--color-primary);
}

/* ---- Spec tables site-wide (any .table-wrap) ---- */
.table-wrap,
.news-article .table-wrap {
  max-width: 1040px;
  margin-left: auto;
  margin-right: auto;
  overflow-x: auto;
  margin-top: .4rem;
  margin-bottom: 2.2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.table-wrap table,
.news-article .table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: .94rem;
  table-layout: fixed;
}
.table-wrap thead th,
.news-article .table-wrap thead th {
  background: var(--color-primary);
  color: #ffffff;
  text-align: left;
  font-weight: 700;
  font-size: .84rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .68rem 1rem;
  border-bottom: 2px solid rgba(255,255,255,.12);
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* ---- Legacy header row (no thead: first tr contains th) ---- */
.table-wrap table tr:first-child th,
.news-article table tr:first-child th,
.content-section table tr:first-child th,
.content-section table thead th {
  background: var(--color-primary);
  color: #ffffff;
  text-align: left;
  font-weight: 700;
  font-size: .84rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .68rem 1rem;
  border-bottom: 2px solid rgba(255,255,255,.12);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table-wrap tbody td,
.news-article .table-wrap tbody td {
  padding: .68rem 1rem;
  vertical-align: top;
  line-height: 1.55;
  border-bottom: 1px solid var(--color-border-light);
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--color-text);
}
.table-wrap tbody tr:last-child td,
.news-article .table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody td:first-child,
.news-article .table-wrap tbody td:first-child {
  width: 34%;
  background: #f4f7fb;
  color: #17233d;
  font-weight: 600;
  border-right: 1px solid var(--color-border);
}
.table-wrap tbody td:last-child,
.news-article .table-wrap tbody td:last-child { color: var(--color-text-secondary); }

/* ---- Product card grid (category listing) ---- */
.product-grid {
  margin: 1.8rem auto 2.4rem;
}
.product-grid .product-card,
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.4rem 1.5rem 1.5rem;
  margin-bottom: 1.4rem;
}
.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 1.4rem; }
.product-grid .product-card { margin-bottom: 0; }
.product-card h3 {
  font-size: 1.08rem;
  line-height: 1.4;
  margin: 0 0 .8rem;
  color: var(--color-primary);
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}
.product-card img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto .9rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.product-card .table-wrap {
  width: 100%;
  max-width: none;
  margin: 0 0 1rem;
  border: 0;
  border-radius: 0;
  overflow-x: auto;
}
.product-card .table-wrap table {
  font-size: .86rem;
  table-layout: fixed;
}
.product-card .table-wrap tbody td {
  padding: .45rem .5rem;
  border-bottom: 1px solid var(--color-border-light);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.product-card .table-wrap tbody td:first-child {
  width: 44%;
  background: transparent;
  color: var(--color-text-secondary);
  font-weight: 500;
  border-right: 1px solid var(--color-border);
}
.product-card .table-wrap tbody td:last-child {
  color: var(--color-text);
  font-weight: 600;
}
.product-card .btn-cta {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  background: var(--color-accent);
  color: #ffffff;
  font-weight: 600;
  font-size: .92rem;
  padding: .58rem 1.3rem;
  border-radius: 5px;
  text-decoration: none;
  transition: background 150ms ease;
}
.product-card .btn-cta:hover { background: var(--color-accent-hover); }

/* ---- News article ---- */
.news-article h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.3;
  color: var(--color-primary);
  margin: 1.2rem 0 1.4rem;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.news-article p {
  font-size: 1rem;
  line-height: 1.72;
  color: var(--color-text);
  margin-bottom: 1rem;
  max-width: 840px;
}
.news-article h2 + p { margin-top: .2rem; }
.related-news {
  margin-top: 2.4rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.4rem;
}
.related-news h2 { margin-top: 0; }
.related-news ul { list-style: none; padding-left: 0; }
.related-news ul li { margin-bottom: .45rem; }
.related-news a {
  color: var(--color-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
  transition: color 150ms ease, border-color 150ms ease;
}
.related-news a:hover { color: var(--color-accent); border-color: var(--color-accent); }

/* ---- FAQ sections outside content-section (category pages) ---- */
.faq-section details { border-bottom: 1px solid var(--color-border); }
.faq-section summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: .9rem .15rem .85rem;
  font-weight: 650;
  font-size: 1.02rem;
  line-height: 1.5;
  color: #17233d;
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary:hover { color: var(--color-accent); }
.faq-section summary::after {
  content: "\25B8";
  flex: 0 0 auto;
  font-size: .85rem;
  line-height: 1.6;
  margin-top: .3rem;
  color: var(--color-accent);
  transition: transform 150ms ease;
}
.faq-section details[open] summary::after { transform: rotate(90deg); }
.faq-section details[open] > *:not(summary) {
  margin: 0;
  padding: .05rem .15rem 1.05rem .9rem;
  border-left: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
  line-height: 1.7;
  font-size: .98rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .toc ul { columns: 1; }
  .page-hero { padding: 1.35rem 1.15rem; }
  .key-takeaways { padding: 1rem 1.1rem .95rem; }
  .table-wrap thead th,
  .news-article .table-wrap thead th { font-size: .78rem; padding: .6rem .6rem; }
  .table-wrap tbody td,
  .news-article .table-wrap tbody td { padding: .58rem .6rem; line-height: 1.5; }
  .product-grid { grid-template-columns: 1fr; }
  .page-hero h1,
  .news-article h1 { font-size: 1.45rem; }
}

@media (max-width: 480px) {
  .page-hero h1,
  .news-article h1 { font-size: 1.3rem; }
  .page-hero p { font-size: .98rem; }
  .product-card .table-wrap table { font-size: .8rem; }
  section[id] > h2,
  .news-article h2 { font-size: 1.3rem; margin: 2.15rem 0 .9rem; }
}
