/* =============================================
   首頁 — Hero、產品卡、公司優勢
   ============================================= */

.page-home .home-hero {
  position: relative;
  overflow: hidden;
  background: #041228;
}

.page-home .home-hero-media {
  position: relative;
  display: block;
  line-height: 0;
}

.page-home .home-hero-media picture {
  display: block;
}

.page-home .home-hero-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

.page-home .home-hero-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(3, 10, 22, 0.80) 0%,
    rgba(4, 14, 30, 0.62) 22%,
    rgba(5, 16, 34, 0.50) 40%,
    rgba(6, 20, 42, 0.18) 55%,
    rgba(6, 22, 44, 0) 65%
  );
}

.page-home .home-hero-copy {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: clamp(2rem, 4vw, 3.5rem) clamp(1.5rem, 4vw, 3.75rem);
  pointer-events: none;
}

.page-home .home-hero-copy-inner {
  width: 100%;
  max-width: min(32.5rem, 34vw);
  min-width: 0;
  pointer-events: auto;
}

.page-home .home-hero-eyebrow {
  font-size: clamp(1.25rem, 5vw, 1.5rem);
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.06em;
  line-height: 1.35;
  margin-bottom: 1.5rem;
  max-width: 100%;
  overflow-wrap: break-word;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

@media (min-width: 769px) {
  .page-home .home-hero-eyebrow {
    font-size: clamp(30px, 2.1vw, 42px);
    margin-bottom: 1.75rem;
  }

  html[lang="zh-Hant"] .page-home .home-hero-eyebrow {
    white-space: nowrap;
  }
}

.page-home .home-hero-title {
  font-size: clamp(1.7rem, 1.35rem + 1.15vw, 2.45rem);
  color: #ffffff;
  font-weight: 700;
  line-height: 1.28;
  margin-bottom: var(--space-lg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.page-home .home-hero-desc {
  font-size: clamp(0.9375rem, 0.9rem + 0.15vw, 1.02rem);
  color: #ffffff;
  line-height: 1.75;
  margin-bottom: var(--space-md);
  max-width: 100%;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.page-home .home-hero-meta {
  font-size: var(--text-sm);
  color: #f2f6fb;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xl);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.page-home .home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-home .home-hero-actions .btn {
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Desktop overlay hero: lift copy/CTA above product art; keep CTA group compact */
@media (min-width: 1121px) {
  .page-home .home-hero-copy-inner {
    transform: translateY(-6.75rem); /* ~108px — clear left-floor products */
  }

  .page-home .home-hero-actions {
    flex-wrap: nowrap;
    gap: 0.9375rem; /* 15px */
    width: max-content;
    max-width: 23.125rem; /* 370px */
  }

  .page-home .home-hero-actions .btn {
    width: 10.5rem; /* 168px — within 160–175px */
    max-width: 10.9375rem;
    min-width: 0;
    padding-inline: 1.125rem;
    box-sizing: border-box;
    white-space: nowrap;
  }
}

.page-home .home-hero-actions .btn svg {
  flex-shrink: 0;
}

.page-home .home-hero-actions .btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
}

.page-home .home-hero-actions .btn-primary:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary-light);
}

.page-home .home-hero-actions .btn-outline-light {
  background: transparent;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.page-home .home-hero-actions .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #ffffff;
}

/* ---------- 核心產品卡 ---------- */
.page-home .home-products {
  background: var(--color-bg-subtle);
  padding-block: clamp(2.25rem, 4vw, 3rem);
}

.page-home .home-products-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem;
}

.page-home .home-product-card {
  --home-card-title-row: 2.85rem;
  --home-card-copy-gap: 0.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 2.75rem;
  align-items: stretch;
  padding: 1.75rem 1.75rem;
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 0;
  height: 100%;
}

.page-home .home-product-card-body {
  display: grid;
  grid-template-rows: var(--home-card-title-row) 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  justify-items: start;
  row-gap: var(--home-card-copy-gap);
  min-width: 0;
  width: 100%;
  max-width: 28.75rem;
  height: 100%;
}

.page-home .home-product-card-heading {
  position: relative;
  display: block;
  width: 100%;
  height: var(--home-card-title-row);
  min-height: var(--home-card-title-row);
  max-height: var(--home-card-title-row);
  margin: 0;
  padding: 0;
  overflow: visible;
}

.page-home .home-product-card-title-row {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.page-home .home-product-card-title {
  position: relative;
  display: inline-block;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  font-size: clamp(1.875rem, 2.2vw, 2.375rem);
  line-height: 1.2;
  color: var(--color-primary-dark);
}

.page-home .home-product-card-title .patent-tech-badge {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin: 0 0 0 0.5rem;
  z-index: 1;
  pointer-events: none;
  white-space: nowrap;
}

.page-home .home-product-card-desc {
  margin: 0;
  padding: 0;
  max-width: 100%;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--color-text-muted);
  word-break: normal;
  overflow-wrap: anywhere;
  line-break: strict;
  hyphens: none;
  align-self: start;
}

.page-home .home-product-card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: auto;
  padding-top: 0.75rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.02em;
  max-width: 100%;
  align-self: start;
}

.page-home .home-product-card-link:hover {
  color: var(--color-primary-light);
}

.page-home .home-product-card-media {
  margin: 0;
  width: 180px;
  max-width: 180px;
  min-width: 0;
  align-self: stretch;
  display: flex;
  height: auto;
  justify-self: end;
}

.page-home .home-product-card-media .product-showcase {
  flex: 1;
  width: 100%;
  aspect-ratio: auto;
  min-height: 168px;
  max-height: none;
  height: 100%;
  padding: 0.5rem;
}

.page-home .home-product-card-media .product-showcase picture {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.page-home .home-product-card-media .product-photo {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

/* ---------- 核心能力 ---------- */
.page-home .home-capabilities {
  background: var(--color-bg);
  padding-block: clamp(2.75rem, 5vw, 4rem);
  border-top: 1px solid var(--color-border-light);
}

.page-home .home-capabilities-header {
  margin-bottom: var(--space-3xl);
}

.page-home .home-capabilities-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}

.page-home .home-capability {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem 1.5rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  min-width: 0;
}

.page-home .home-capability-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.875rem;
  color: var(--color-primary-light);
  flex-shrink: 0;
}

.page-home .home-capability-icon svg {
  width: 1.375rem;
  height: 1.375rem;
}

.page-home .home-capability-title {
  font-size: clamp(1.25rem, 1.1rem + 0.4vw, 1.5rem);
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 0.5rem;
  line-height: 1.35;
  hyphens: none;
}

.page-home .home-capability-desc {
  font-size: clamp(0.875rem, 0.85rem + 0.15vw, 1rem);
  color: var(--color-text-muted);
  line-height: 1.55;
  margin: 0;
}

@media (min-width: 1200px) {
  .page-home .home-capability-title,
  .page-home .home-capability-desc {
    white-space: nowrap;
  }
}

@media (max-width: 1199px) {
  .page-home .home-capability {
    padding: 1.15rem 1.35rem;
  }

  .page-home .home-capability-title,
  .page-home .home-capability-desc {
    white-space: normal;
    overflow-wrap: break-word;
  }
}

.page-home .home-capabilities-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg) var(--space-2xl);
  margin-top: var(--space-2xl);
}

.page-home .home-capabilities-links .section-link {
  margin-top: 0;
}

/* ---------- 合作單位 ---------- */
.page-home .home-orgs {
  background: var(--color-bg-subtle);
  padding-block: clamp(2.75rem, 5vw, 4rem);
  border-top: 1px solid var(--color-border-light);
}

.page-home .home-orgs-header {
  margin-bottom: var(--space-3xl);
  max-width: 42rem;
}

.page-home .home-orgs-desc {
  margin: 0.85rem 0 0;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text-muted);
}

html[lang="en"] .page-home .home-orgs-header {
  max-width: 46rem;
}

html[lang="en"] .page-home .home-orgs-desc {
  font-size: 0.9375rem;
  line-height: 1.65;
  max-width: 44rem;
}

.page-home .home-orgs-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.875rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: stretch;
}

.page-home .home-org-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  min-height: 0;
  padding: 1.1rem 0.9rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(7, 22, 40, 0.04);
  transition: box-shadow 0.3s ease;
}

.page-home .home-org-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.75rem;
  flex-shrink: 0;
  margin-bottom: 0.875rem;
}

.page-home .home-org-logo img {
  display: block;
  width: 100%;
  max-width: 10rem;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.page-home .home-org-name {
  margin: 0;
  width: 100%;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  color: var(--color-primary-dark);
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
  text-wrap: pretty;
}

.page-home .home-org-card:hover {
  box-shadow: 0 8px 20px rgba(7, 22, 40, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .page-home .home-org-card {
    transition: none;
  }
}

@media (max-width: 1024px) {
  .page-home .home-orgs-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-home .home-orgs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .page-home .home-org-card {
    padding: 0.9rem 0.7rem 0.85rem;
  }

  .page-home .home-org-logo {
    height: 2.35rem;
    margin-bottom: 0.75rem;
  }

  .page-home .home-org-logo img {
    max-width: 8.5rem;
  }

  .page-home .home-org-name {
    font-size: 0.75rem;
    line-height: 1.4;
  }
}

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  .page-home .home-products-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .page-home .home-product-card {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    padding: clamp(1.5rem, 4vw, 2rem);
    height: auto;
    align-items: stretch;
  }

  .page-home .home-product-card-body {
    display: contents;
    max-width: none;
    height: auto;
  }

  .page-home .home-product-card-heading,
  .page-home .home-product-card-title-row {
    height: auto;
    min-height: 0;
    max-height: none;
  }

  /* Keep patent badge in flow so it does not spill past the card edge */
  .page-home .home-product-card-title {
    display: inline;
    max-width: 100%;
  }

  .page-home .home-product-card-title .patent-tech-badge {
    position: static;
    display: inline-block;
    transform: none;
    margin: 0 0 0 0.4rem;
    vertical-align: middle;
    white-space: normal;
  }

  .page-home .home-product-card-desc {
    max-width: none;
    min-height: 0;
    font-size: var(--text-base);
    line-height: 1.7;
    overflow-wrap: anywhere;
  }

  .page-home .home-product-card-media {
    width: 100%;
    max-width: none;
    max-height: none;
    height: auto;
    justify-self: stretch;
    align-self: stretch;
  }

  .page-home .home-product-card-media .product-showcase {
    min-height: 11rem;
    height: auto;
    max-height: 16rem;
  }

  /* 標題區 → 文字 → 圖片 → CTA */
  .page-home .home-product-card-heading {
    order: 1;
  }

  .page-home .home-product-card-desc {
    order: 2;
  }

  .page-home .home-product-card-media {
    order: 3;
  }

  .page-home .home-product-card-link {
    order: 4;
    margin-top: 0;
    padding-top: var(--space-md);
  }

  .page-home .home-capabilities-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Stacked hero: tablet, mobile, zoomed laptops ---------- */
@media (max-width: 1120px) {
  .page-home .home-hero {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .page-home .home-hero-media {
    order: 2;
  }

  .page-home .home-hero-overlay {
    display: none;
  }

  .page-home .home-hero-copy {
    position: relative;
    inset: auto;
    order: 1;
    width: 100%;
    padding: clamp(2rem, 6vw, 2.75rem) var(--container-pad);
    background: linear-gradient(165deg, #0b2a52 0%, #071d3c 48%, #041228 100%);
    pointer-events: auto;
  }

  .page-home .home-hero-copy-inner {
    width: 100%;
    max-width: 40rem;
  }

  .page-home .home-hero-image {
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .page-home .home-hero-eyebrow,
  .page-home .home-hero-title,
  .page-home .home-hero-desc,
  .page-home .home-hero-meta {
    text-shadow: none;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .page-home .home-hero-copy {
    padding-block: var(--space-2xl);
  }

  .page-home .home-hero-actions {
    flex-direction: column;
  }

  .page-home .home-hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .page-home .home-products-grid {
    grid-template-columns: 1fr;
  }

  .page-home .home-capabilities-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- English length tweaks only ---------- */
html[lang="en"] .page-home .home-hero-eyebrow {
  font-size: clamp(1.2rem, 4.2vw, 1.375rem);
  letter-spacing: 0.03em;
  white-space: normal;
  overflow-wrap: break-word;
  margin-bottom: 1.5rem;
}

@media (min-width: 769px) {
  html[lang="en"] .page-home .home-hero-eyebrow {
    font-size: clamp(1.5rem, 1.55vw, 1.75rem);
    margin-bottom: 1.75rem;
  }
}

html[lang="en"] .page-home .home-hero-title {
  font-size: clamp(1.55rem, 1.2rem + 1.1vw, 2.15rem);
  letter-spacing: -0.015em;
  margin-bottom: var(--space-md);
  line-height: 1.22;
}

html[lang="en"] .page-home .home-hero-desc {
  font-size: 0.9375rem;
  line-height: 1.7;
  margin-bottom: var(--space-sm);
  letter-spacing: -0.01em;
}

html[lang="en"] .page-home .home-hero-meta {
  margin-bottom: var(--space-xl);
  letter-spacing: 0.04em;
}

@media (min-width: 769px) {
  .page-home .home-hero-meta {
    white-space: nowrap;
  }
}

html[lang="en"] .page-home .home-product-card-title {
  font-size: clamp(1.25rem, 1.05rem + 0.55vw, 1.375rem);
}

@media (min-width: 1024px) {
  html[lang="en"] .page-home .home-product-card-title {
    white-space: normal;
    overflow-wrap: break-word;
    font-size: clamp(1.15rem, 0.9rem + 0.45vw, 1.3rem);
  }
}

html[lang="en"] .page-home .home-capability-title {
  font-size: clamp(1.25rem, 1.1rem + 0.35vw, 1.375rem);
}

html[lang="en"] .page-home .home-capability-desc {
  font-size: 0.875rem;
}

@media (min-width: 1200px) {
  html[lang="en"] .page-home .home-capability-title {
    font-size: 1.375rem;
  }

  html[lang="en"] .page-home .home-capability-desc {
    font-size: 0.875rem;
  }
}

@media (max-width: 768px) {
  html[lang="en"] .page-home .home-hero-eyebrow {
    font-size: clamp(1.2rem, 4.2vw, 1.375rem);
    letter-spacing: 0.02em;
    white-space: normal;
    overflow-wrap: break-word;
    margin-bottom: 1.5rem;
  }
}

/* Allow translated CTA labels to determine button width. */
html[lang="en"] .page-home .home-hero-actions {
  width: 100%; max-width: 100%; flex-wrap: wrap;
}
html[lang="en"] .page-home .home-hero-actions .btn {
  width: auto; max-width: 100%; min-width: 0; height: auto;
  flex: 0 1 auto; white-space: normal; overflow-wrap: anywhere;
  text-align: center; box-sizing: border-box;
}
