/* --- Variables --- */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7f;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --brand-med-green: #1f6f54;
  --brand-med-green-hover: #155a45;
  --header-h: 72px;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  --font: "Segoe UI", "Noto Sans TC", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

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

html {
  scroll-behavior: smooth;
  /* 避免換頁時捲軸出現／消失造成整頁水平位移 */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

/* --- Site header (wireframe: LOGO | nav | lang) --- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* 避免子項寬度變化時擠壓 logo 區造成整列左右晃動 */
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--brand-med-green);
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--brand-med-green-hover);
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}

.nav-link {
  color: var(--ink);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.nav-link.is-active {
  color: var(--accent);
  background: transparent;
}

/* --- Unified dropdown (服務項目 & 語言) --- */
.nav-dropdown {
  position: relative;
}

.nav-dropdown__split {
  display: inline-flex;
  align-items: center;
  gap: 0.05rem;
}

.nav-dropdown__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.38rem 0.6rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.nav-dropdown__toggle:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.nav-dropdown.is-open .nav-dropdown__toggle {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.nav-dropdown__caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  margin-top: 2px;
  transition: transform 0.2s;
}

.nav-dropdown.is-open .nav-dropdown__caret {
  transform: rotate(180deg);
}

.nav-dropdown__panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 130px;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  z-index: 50;
}

/* 服務項目：文字連結進總覽頁，僅箭頭按鈕展開；面板無外框 */
.nav-dropdown--services .nav-dropdown__panel {
  right: auto;
  left: 0;
  border: none;
}

.nav-dropdown--services .nav-dropdown__toggle.nav-dropdown__toggle--caretonly {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0.35rem 0.45rem;
  min-width: 1.75rem;
  justify-content: center;
  gap: 0;
}

.nav-dropdown--services .nav-dropdown__toggle.nav-dropdown__toggle--caretonly:hover {
  border: none;
  box-shadow: none;
  background: var(--accent-soft);
}

.nav-dropdown--services.nav-dropdown.is-open .nav-dropdown__toggle.nav-dropdown__toggle--caretonly {
  border: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 語言下拉：面板比服務項目略窄 */
.nav-dropdown:not(.nav-dropdown--services) .nav-dropdown__panel {
  min-width: 100px;
}

.nav-dropdown.is-open .nav-dropdown__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: none;
  background: transparent;
  border-radius: 7px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
}

.nav-dropdown__item:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.nav-dropdown__item.is-active-lang {
  font-weight: 700;
  color: var(--accent);
}

/* --- Main & footer --- */
main {
  flex: 1;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.page-head {
  margin-bottom: 2rem;
}

.page-head h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.site-footer {
  margin-top: auto;
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* --- Home hero + carousel --- */
.home-hero {
  text-align: center;
  padding: 2rem 1rem 1rem;
  max-width: 720px;
  margin: 0 auto;
}

.home-hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  letter-spacing: -0.03em;
}

.home-hero .lead {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn--primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #fff;
}

.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn--ghost:hover {
  border-color: #cbd5e1;
  text-decoration: none;
}

/* Carousel */
.carousel {
  max-width: 1100px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}

.carousel__viewport {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #0f172a;
  position: relative;
  width: 100%;
}

.carousel__track {
  display: flex;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel__slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  position: relative;
}

.carousel__slide img {
  width: 100%;
  height: auto;
  aspect-ratio: 21 / 8;
  object-fit: cover;
}

.carousel__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.18);
  transition: background 0.15s, transform 0.15s, color 0.15s;
}

.carousel__arrow:hover {
  background: #fff;
  color: var(--accent);
}

.carousel__arrow:active {
  transform: translateY(-50%) scale(0.96);
}

.carousel__arrow--prev {
  left: 10px;
}

.carousel__arrow--next {
  right: 10px;
}

.carousel__arrow-icon {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-top: -2px;
}

.carousel__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 48px 16px;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.55), transparent);
}

.carousel__dash {
  position: relative;
  flex: 1 1 0;
  max-width: 100px;
  min-width: 36px;
  height: 28px;
  padding: 0;
  border: none;
  cursor: pointer;
  background: transparent;
}

.carousel__dash::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.38);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.carousel__dash:hover::after {
  background: rgba(255, 255, 255, 0.6);
}

.carousel__dash.is-active::after {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scaleY(1.4);
}

/* Cards grid（services）：minmax(0,1fr) + 固定欄數，避免內容／比例改變時欄寬被撐開 */
.card-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.service-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

.service-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  text-decoration: none;
}

.service-card img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 8;
  object-fit: cover;
}

.service-card__body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.service-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.service-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  flex: 1;
}

/* Portfolio / news list */
.media-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.media-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.media-row img {
  width: 100%;
  height: 100%;
  min-height: 120px;
  object-fit: cover;
}

.media-row__text {
  padding: 1.25rem 1.25rem 1.25rem 0;
}

.media-row__text h3 {
  margin: 0;
  font-size: 1.1rem;
}

.media-row__text time {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

@media (max-width: 640px) {
  .media-row {
    grid-template-columns: 1fr;
  }
  .media-row img {
    min-height: 160px;
  }
  .media-row__text {
    padding: 0 1.25rem 1.25rem;
  }
}

/* Product / about prose */
.prose {
  max-width: 720px;
}

.prose img {
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.prose h1 {
  margin-top: 0;
}

.prose p {
  color: var(--muted);
  font-size: 1.05rem;
}
