/* ==========================================================================
   Huangqi Packaging — Main Stylesheet (Layout Hardening & Responsive System)
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text-main);
  background-color: var(--bg-page);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--brand-accent-dark);
  text-decoration: none;
  transition: color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

a:hover {
  color: var(--brand-primary);
}

/* Defensive Layout Hardening */
.grid, .flex, [class*="grid-"], [class*="col-"] {
  min-width: 0;
}

.card, .card-body, p, h1, h2, h3, h4, li, td, th {
  min-width: 0;
  word-break: break-word;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 20px;
}

/* Top Utility Bar (Global Localization & Multi-Currency) */
.header-topbar {
  background: var(--bg-darker);
  color: var(--text-on-dark-muted);
  font-size: var(--text-xs);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 10000;
}

.header-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  flex-wrap: wrap;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.locale-select {
  background: #0F172A;
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  z-index: 99999;
}

.locale-select option {
  background: #0F172A;
  color: #F8FAFC;
}

/* Main Navigation Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 9000;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  gap: 16px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--brand-primary);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--brand-primary);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.brand-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 6px 2px;
  white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--brand-accent-dark);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--brand-primary);
  font-weight: 700;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.92rem;
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--brand-accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--brand-accent-dark);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.28);
}

.btn-navy {
  background: var(--brand-primary);
  color: #FFFFFF;
}

.btn-navy:hover {
  background: var(--brand-primary-hover);
  color: #FFFFFF;
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(6px);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

.btn-outline-dark {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-outline-dark:hover {
  background: var(--brand-primary);
  color: #FFFFFF;
}

.btn-whatsapp {
  background: #15803D;
  color: #FFFFFF;
}

.btn-whatsapp:hover {
  background: #166534;
  color: #FFFFFF;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.84rem;
}

/* Full-Bleed Product Showcase Hero */
.hero-fullbleed {
  position: relative;
  width: 100%;
  min-height: 600px;
  background: var(--bg-dark);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 56px 0;
}

.hero-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.34;
  pointer-events: none;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(9, 26, 43, 0.94) 0%, rgba(15, 41, 66, 0.82) 55%, rgba(15, 41, 66, 0.55) 100%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 40px;
  align-items: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(2, 132, 199, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #E0F2FE;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 18px;
}

.hero-title {
  font-size: var(--text-hero);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  color: #FFFFFF;
}

.hero-lead {
  font-size: 1.06rem;
  color: #E2E8F0;
  margin: 0 0 26px;
  max-width: 620px;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.hero-proof-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 20px;
}

.hero-proof-item strong {
  display: block;
  font-size: 1.1rem;
  color: #FFFFFF;
  font-family: var(--font-mono);
}

.hero-proof-item span {
  font-size: 0.8rem;
  color: #CBD5E1;
}

/* Macro Specimen Switcher */
.specimen-card {
  background: rgba(255, 255, 255, 0.98);
  color: var(--text-main);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.specimen-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.specimen-tab {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.specimen-tab.active {
  background: var(--brand-primary);
  color: #FFFFFF;
  border-color: var(--brand-primary);
}

.specimen-visual {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
  margin-bottom: 12px;
}

.specimen-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.specimen-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(15, 41, 66, 0.9);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.specimen-meta h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  color: var(--brand-primary);
}

.specimen-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.specimen-specs div {
  background: var(--bg-page);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

/* KPI Strip with Count-Up & Jelly Pulse */
.kpi-section {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 36px 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.kpi-card {
  background: var(--bg-page);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 22px 18px;
  text-align: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kpi-card:hover {
  transform: translateY(-3px);
}

.kpi-number {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 2.5vw, 2.3rem);
  font-weight: 800;
  color: var(--brand-primary);
  line-height: 1.1;
  margin-bottom: 6px;
  display: inline-block;
}

@keyframes jellyPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.12, 0.92); }
  65% { transform: scale(0.95, 1.06); }
  100% { transform: scale(1); }
}

.jelly-pop {
  animation: jellyPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kpi-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Sections */
.section {
  padding: 68px 0;
}

.section-alt {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.section-dark {
  background: var(--bg-dark);
  color: var(--text-on-dark);
}

.section-header {
  max-width: 780px;
  margin-bottom: 38px;
}

.section-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-accent-dark);
  background: #E0F2FE;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 10px;
}

.section-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 12px;
  color: var(--brand-primary);
  letter-spacing: -0.02em;
}

.section-dark .section-title {
  color: #FFFFFF;
}

.section-desc {
  color: var(--text-secondary);
  margin: 0;
  font-size: 1rem;
}

.section-dark .section-desc {
  color: var(--text-on-dark-muted);
}

/* Product & Category Grids (Strict Flex Alignment) */
.cards-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}

.cards-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.cards-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 26px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
  overflow: hidden;
  display: block;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.card:hover .card-media img {
  transform: scale(1.04);
}

.sku-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(15, 41, 66, 0.9);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
}

.card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.35;
}

.card-title a {
  color: var(--brand-primary);
}

.card-title a:hover {
  color: var(--brand-accent-dark);
}

.card-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0 0 14px;
}

.spec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.spec-pill {
  font-size: 0.74rem;
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.card-footer-action {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.price-tag {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--brand-primary);
}

.btn-sku-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--brand-accent-dark);
}

/* GEO Direct Answer Box (134-167 words) */
.geo-answer-box {
  background: #FFFFFF;
  border: 1px solid #BAE6FD;
  border-left: 5px solid var(--brand-accent);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
}

.geo-answer-box h2, .geo-answer-box h3 {
  margin: 0 0 10px;
  color: var(--brand-primary);
  font-size: 1.2rem;
}

.geo-answer-box p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.96rem;
}

/* Calculator Workbench */
.workbench-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--brand-primary);
}

.form-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: #FFFFFF;
}

.calc-results {
  background: var(--bg-dark);
  color: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.calc-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 14px 0 18px;
}

.calc-metric {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.calc-metric span {
  display: block;
  font-size: 0.76rem;
  color: #CBD5E1;
}

.calc-metric strong {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: #38BDF8;
}

/* Google Maps & Logistics Gateway */
.map-gateway-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: stretch;
}

.map-frame-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  min-height: 360px;
  background: var(--bg-subtle);
}

.map-frame-wrap iframe {
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: 0;
  display: block;
}

.logistics-ledger {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ledger-row {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.ledger-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

/* Tables */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #FFFFFF;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th, table.data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

table.data-table th {
  background: var(--bg-subtle);
  color: var(--brand-primary);
  font-weight: 700;
}

/* Breadcrumbs & Subpage Hero */
.subpage-hero {
  background: var(--bg-dark);
  color: #FFFFFF;
  padding: 46px 0 42px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
  color: #CBD5E1;
  margin-bottom: 14px;
}

.breadcrumb a {
  color: #7DD3FC;
}

/* Blog Article Layout */
.article-prose {
  max-width: 860px;
  margin: 0 auto;
  background: #FFFFFF;
  padding: 36px 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.article-prose h2 {
  color: var(--brand-primary);
  margin-top: 32px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.article-prose h3 {
  color: var(--brand-primary-hover);
  margin-top: 22px;
}

.article-figure {
  margin: 24px 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-page);
}

.article-figure figcaption {
  padding: 10px 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background: var(--bg-darker);
  color: var(--text-on-dark-muted);
  padding: 58px 0 28px;
  font-size: 0.88rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1.1fr;
  gap: 32px;
  margin-bottom: 36px;
}

.site-footer h4 {
  color: #FFFFFF;
  margin: 0 0 14px;
  font-size: 0.96rem;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  color: #CBD5E1;
}

.footer-links a:hover {
  color: #38BDF8;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
}

/* Floating WhatsApp & Quick RFQ Modal */
.wa-float-btn {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 9500;
  background: #15803D;
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(21, 128, 61, 0.36);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wa-float-btn:hover {
  background: #166534;
  color: #FFFFFF;
  transform: translateY(-2px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 26, 43, 0.72);
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: var(--bg-subtle);
  border: 0;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1.2rem;
  cursor: pointer;
}

.hp-field {
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .hero-grid, .workbench-box, .map-gateway-grid {
    grid-template-columns: 1fr;
  }
  .cards-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .cards-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #FFFFFF;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
  }
  .nav-links.open {
    display: flex;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .kpi-grid, .cards-grid-4, .cards-grid-3, .cards-grid-2, .form-grid-2, .footer-grid, .hero-proof-strip {
    grid-template-columns: 1fr;
  }
  .map-frame-wrap, .map-frame-wrap iframe {
    min-height: 300px;
    max-height: 340px;
  }
  .article-prose {
    padding: 22px 18px;
  }
  .brand-sub {
    display: none;
  }
}
