/* 1. CSS Reset & 變數定義 */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 主色調 */
  --color-bg: #f5f7fa;         /* 淺灰底 */
  --color-primary: #1f3d3d;    /* 深森林綠 */
  --color-accent: #3caea3;     /* 活力青綠 */
  --color-text: #2e2e2e;       /* 深灰文字 */
  --font-sans: 'Noto Sans TC', sans-serif;
  --transition-speed: 0.3s;
}

/* 2. 全局轉場樣式 */
body {
  opacity: 0;
  animation: fadeInPage var(--transition-speed) ease-in-out forwards;
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  scroll-behavior: smooth;
}
.fade-out {
  animation: fadeOutPage var(--transition-speed) ease-in-out forwards;
}
@keyframes fadeInPage { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOutPage { from { opacity: 1; } to { opacity: 0; } }

/* 3. 全局樣式 */
img {
  max-width: 100%;
  display: block;
}

/* 4. Header & 導航 */
header {
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo img {
  height: 50px;
}

nav ul {
  display: flex;
  gap: 1.5rem;
}

nav a {
  text-decoration: none;
  color: var(--color-primary);
  font-weight: 500;
  transition: color var(--transition-speed);
}

nav a:hover {
  color: var(--color-accent);
}

.lang-switch a {
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.9rem;
  margin-left: 0.8rem;
  transition: color var(--transition-speed);
}

.lang-switch a:hover {
  color: var(--color-primary);
}

/* 5. Hero 橫幅 */
.hero {
  position: relative;
  height: 60vh;
  overflow: hidden;
}

.hero img {
  object-fit: cover;
  width: 100%;
  height: 100%;
  filter: brightness(0.7);
}

.hero .slogan {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  text-align: center;
}

.hero .slogan h1 {
  font-size: 2.5rem;
  font-weight: 700;
}

/* 6. 快速導覽卡片 */
.quick-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
}

.quick-links .card {
  background-color: #ffffff;
  padding: 1.5rem 2rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  transition: transform var(--transition-speed);
  text-align: center;
}

.quick-links .card a {
  text-decoration: none;
  color: var(--color-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.quick-links .card:hover {
  transform: translateY(-5px);
}

/* 7. Footer */
footer {
  background-color: #ffffff;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--color-text);
  border-top: 1px solid #e0e0e0;
}

/* 8. 響應式 (手機) */
@media (max-width: 768px) {
  nav ul { display: none; }
  .hero .slogan h1 {
    font-size: 1.8rem;
    padding: 0 1rem;
  }
  .quick-links { flex-direction: column; }
}

/* 9. 公司介紹頁：卡片佈局 */
.companies {
  padding: 3rem 2rem;
  text-align: center;
}

.companies h2 {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.company-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.company-card {
  background-color: #ffffff;
  padding: 1.5rem;
  border-radius: 0.6rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
  transition: transform var(--transition-speed);
}

.company-card img {
  height: 100px;
  margin-bottom: 1rem;
}

.company-card h3 {
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.company-card p {
  font-size: 0.95rem;
  color: var(--color-text);
}

.company-card:hover {
  transform: translateY(-5px);
}

/* 10. 產品介紹頁 */
.products {
  padding: 3rem 2rem;
  text-align: center;
}

.products h2 {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

/* 篩選工具列 */
.filter-bar {
  margin-bottom: 2rem;
}

.filter-bar select {
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  font-size: 1rem;
  transition: border-color var(--transition-speed);
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background-color: #ffffff;
  padding: 1rem;
  border-radius: 0.6rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
  transition: transform var(--transition-speed), opacity var(--transition-speed);
}

.product-card img {
  height: 120px;
  object-fit: contain;
  margin-bottom: 0.8rem;
}

.product-card h3 {
  margin-bottom: 0.5rem;
  color: var(--color-primary);
  font-size: 1.1rem;
}

.product-card p {
  font-size: 0.95rem;
  color: var(--color-text);
}

.product-card:hover {
  transform: translateY(-5px);
}

/* 11. 聯絡我們表單 */
.contact-form {
  max-width: 600px;
  margin: 3rem auto;
  padding: 2rem;
  background-color: #ffffff;
  border-radius: 0.6rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.contact-form h2 {
  text-align: center;
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.required {
  color: var(--color-accent);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  font-size: 1rem;
  transition: border-color var(--transition-speed);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.error {
  color: #d9534f;
  font-size: 0.85rem;
  height: 1em;
  display: block;
  margin-top: 0.2rem;
}

.btn-submit {
  display: block;
  width: 100%;
  padding: 0.8rem;
  background-color: var(--color-accent);
  color: #ffffff;
  border: none;
  border-radius: 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-speed);
}

.btn-submit:hover {
  background-color: var(--color-primary);
}

.form-success {
  text-align: center;
  color: #28a745;
  margin-top: 1rem;
  font-size: 1rem;
  height: 1.2em;
}

/* 12. 官方連結頁 */
.official-links {
  padding: 3rem 2rem;
  text-align: center;
}

.official-links h2 {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1.5rem;
  justify-items: center;
}

.link-item {
  background-color: #ffffff;
  width: 100%;
  max-width: 140px;
  padding: 1rem;
  border-radius: 0.6rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
  transition: transform var(--transition-speed);
  text-decoration: none;
  color: var(--color-text);
}

.link-item img {
  height: 40px;
  margin-bottom: 0.5rem;
}

.link-item span {
  display: block;
  font-size: 0.95rem;
}

.link-item:hover {
  transform: translateY(-5px);
}

/* 13. 3D 悬浮卡片 */
.company-card, .product-card {
  perspective: 800px;
}
.card-inner {
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  transform-style: preserve-3d;
}
.company-card:hover .card-inner,
.product-card:hover .card-inner {
  transform: rotateX(6deg) rotateY(-6deg) scale(1.05);
  box-shadow: 0 16px 32px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
  .hero .slogan {
    padding: 0 1rem;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
  }
  .hero .slogan h1 {
    font-size: 2rem !important;
    line-height: 1.3 !important;
    letter-spacing: normal !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    padding-right: 0 !important;
  }
  .hero .slogan p {
    font-size: 1rem !important;
    padding: 0 1rem;
    word-break: break-word;
  }
}

/* 浮動基本資料 */
.infobox {
  float: right;
  width: 320px;
  margin: 1rem 0 1rem 1.5rem;
  padding: 1rem;
  border: 1px solid var(--color-accent);
  background: rgba(60, 174, 163, 0.1);
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(60, 174, 163, 0.6);
  color: var(--color-text);
}

/* 主要內容容器，預留右側空間避開infobox，並清除浮動 */
.main-content {
  padding-right: 360px; /* 浮動框寬度320 + margin約40px */
  overflow: hidden;    /* 清除浮動，避免內容繞行 */
}

/* 章節標題 強制清除浮動，避免標題或橫線被infobox遮擋 */
.main-content h2 {
  clear: both;
  margin-bottom: 1rem;
}

/* 其他內容段落正常文字寬度，不用刻意設定margin-right */
.main-content p,
.main-content ul,
.main-content li {
  margin-right: 0;
  line-height: 1.6;
}

/* 響應式調整：手機時取消浮動並全寬 */
@media (max-width: 768px) {
  .infobox {
    float: none;
    width: 100%;
    margin: 1rem 0;
  }
  .main-content {
    padding-right: 0;
    overflow: visible; /* 手機取消清除浮動限制，讓內容自然流動 */
  }
  .main-content h2 {
    clear: none;
  }
}

@media (max-width: 768px) {
  main.content h1 {
    font-size: 1.8rem;
    border-right: none;
    white-space: normal;
    overflow: visible;
    animation: none;
    text-shadow: none;
  }
}

