/* ===== Tokens ===== */
:root {
  --bg: #FFFFFF;
  --bg-2: #F5F5F5;
  --text: #222222;
  --text-2: #888888;
  --line: #E6E6E6;
  --vb: #EED6DF;               /* Vital Baby 專案識別色，只用在產品展示區 */
  --home-tint: #E7ECEF;        /* 首頁右側區塊的底色，想換顏色改這裡 */
  --edge: max(var(--gutter), calc((100vw - var(--max)) / 2)); /* 與導覽列內容對齊的左右邊界 */

  --font: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --max: 1200px;
  --gutter: clamp(20px, 5vw, 48px);
  --header-h: 52px;           /* 固定在最上方的導覽列高度 */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.container { width: 100%; max-width: calc(var(--max) + var(--gutter) * 2); margin: 0 auto; padding-inline: var(--gutter); }

.eyebrow { font-size: 13px; font-weight: 500; letter-spacing: .14em; color: var(--text-2); }

/* ===== Header：固定在最上方，往下滑也不動 ===== */
.site-header { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--line); background: var(--bg); }
.header-inner { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.header-inner .back-link { margin: 0; font-size: 14px; }
.brand { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.header-nav { display: flex; align-items: center; gap: 28px; font-size: 14px; margin-left: auto; }
.header-nav > a { color: var(--text-2); transition: color .2s; }
.header-nav > a:hover, .header-nav > a.is-current { color: var(--text); }
.lang-switch { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.lang-switch button { color: var(--text-2); transition: color .2s; }
.lang-switch button:hover, .lang-switch button.is-active { color: var(--text); }
.lang-switch button.is-active { font-weight: 500; }

/* ===== Home: one screen, intro left + guide right ===== */
body.page-home { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
body.page-home .site-footer { margin-top: 0; }
.home {
  flex: 1;
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}
.home-intro {
  align-self: center;
  padding: clamp(48px, 8vh, 96px) clamp(32px, 5vw, 88px) clamp(48px, 8vh, 96px) var(--edge);
}
.home-panel {
  background: var(--home-tint);
  display: flex; flex-direction: column; justify-content: center; gap: clamp(32px, 5vh, 56px);
  padding: clamp(40px, 7vh, 80px) var(--edge) clamp(40px, 7vh, 80px) clamp(32px, 4vw, 72px);
}
.hero-title {
  margin-top: 28px;
  font-size: clamp(40px, 5.4vw, 84px);
  font-weight: 600; line-height: 1.03; letter-spacing: -.035em;
  max-width: 11em; text-wrap: balance;
}

.guide { display: grid; gap: 48px; }
.guide-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-bottom: 16px; }
.guide-head h2 { font-size: 13px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }
.guide-head span { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.guide ol { border-top: 1px solid var(--text); }
.guide li { border-bottom: 1px solid var(--line); }
.guide-item {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding-block: clamp(22px, 3.2vh, 32px);
}
.guide-num { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; transition: color .25s; }
.guide-text { display: grid; gap: 4px; min-width: 0; }
.guide-label { font-size: clamp(20px, 1.9vw, 26px); font-weight: 500; letter-spacing: -.015em; line-height: 1.3; }
.guide-meta { font-size: 13px; color: var(--text-2); }
.guide-arrow { font-size: 22px; color: var(--text-2); transition: transform .3s cubic-bezier(.2, .7, .2, 1), color .25s; }
.guide-item:hover .guide-num, .guide-item:hover .guide-arrow { color: var(--text); }
.guide-item:hover .guide-arrow { transform: translateX(8px); }

/* ===== Projects page ===== */
.page-intro { padding-block: clamp(56px, 8vw, 104px) clamp(40px, 5vw, 64px); }
.page-title { font-size: clamp(48px, 8vw, 104px); font-weight: 600; letter-spacing: -.04em; line-height: 1; }
.hero-roles { margin-top: 40px; font-size: clamp(15px, 1.6vw, 18px); font-weight: 500; }
.hero-intro { margin-top: 14px; font-size: clamp(15px, 1.6vw, 18px); color: var(--text-2); max-width: 36em; }
.hero-links { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 40px; font-size: 14px; }
.hero-links:empty { display: none; }
.hero-links a { border-bottom: 1px solid var(--text); padding-bottom: 2px; }
.hero-links a:hover { color: var(--text-2); border-color: var(--text-2); }

/* ===== Home: selected work ===== */
.work { padding-bottom: clamp(96px, 12vw, 160px); }
.section-bar {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 40px;
}
.section-label { font-size: 15px; font-weight: 500; }
.section-meta { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.project { display: block; }
.project + .project { margin-top: clamp(80px, 10vw, 128px); }

/* 產品展示區（粉色只在這裡） */
.showcase { background: var(--vb); position: relative; overflow: hidden; }
.showcase--phones {
  display: flex; justify-content: center; align-items: center;
  gap: clamp(12px, 3.5vw, 48px);
  aspect-ratio: 16 / 8;
  padding: clamp(24px, 5vw, 64px);
}
a.showcase--phones { transition: background-color .3s; }
.phone {
  height: 100%; aspect-ratio: 9 / 19.5;
  background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(34, 34, 34, .06);
  display: grid; place-items: center;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.phone img { width: 100%; height: 100%; object-fit: cover; }
.phone:nth-child(2) { height: 108%; }
a.showcase:hover .phone { transform: translateY(-6px); }
a.showcase:hover .phone:nth-child(2) { transform: translateY(-10px); }

.ph-label { font-size: 12px; letter-spacing: .06em; color: var(--text-2); text-align: center; padding: 0 8px; }

.project-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 48px; align-items: end; margin-top: 32px; }
.project-name { font-size: clamp(26px, 3.2vw, 36px); font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.project-sub { margin-top: 8px; font-size: 16px; font-weight: 500; }
.project-tags { margin-top: 4px; font-size: 14px; color: var(--text-2); }
.project-desc { margin-top: 20px; font-size: 16px; color: var(--text-2); max-width: 34em; }
.project-info .btn { justify-self: start; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--text); color: #FFFFFF;
  font-size: 14px; font-weight: 500; letter-spacing: .02em;
  padding: 14px 28px; white-space: nowrap;
  transition: background-color .2s;
}
.btn:hover { background: #000000; }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--line); padding-block: 32px; font-size: 13px; color: var(--text-2); }

/* ===== Project page ===== */
.back-link { display: inline-block; margin-top: 28px; font-size: 14px; color: var(--text-2); transition: color .2s; }
.back-link:hover { color: var(--text); }

.project-hero {
  min-height: calc(100vh - var(--header-h)); min-height: calc(100svh - var(--header-h));
  display: flex; flex-direction: column; justify-content: center;
  padding-block: clamp(16px, 3vh, 32px);
}
.project-intro { padding-block: 0; }
.project-title { margin-top: clamp(12px, 2.5vh, 24px); font-size: clamp(48px, min(7.5vw, 14vh), 112px); font-weight: 600; letter-spacing: -.045em; line-height: .95; }
.project-subtitle { margin-top: clamp(14px, 3vh, 28px); font-size: clamp(22px, 2.8vw, 32px); font-weight: 500; letter-spacing: -.015em; }
.project-lead { margin-top: 16px; font-size: clamp(15px, 1.6vw, 18px); color: var(--text-2); max-width: 34em; }

.showcase--video { aspect-ratio: 16 / 9; display: grid; place-items: center; }
/* 左側文字整塊略往上提（底部多留一點空間，垂直置中時視覺中心就會往上） */
.project-intro-text { padding-bottom: clamp(24px, 7vh, 72px); }

/* 專案標題右側：三張 App 畫面並排，不交疊，高低錯開 */
.project-intro {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);  /* 右欄（圖片）較寬 */
  gap: clamp(32px, 4vw, 64px); align-items: center;
}
.intro-screens {
  width: 100%; justify-self: end; min-width: 0;
  /* 依視窗高度限制大小：輪播舞台高度約為寬度的 0.78 倍，再加上圓點與按鈕，剛好一屏 */
  max-width: min(780px, calc((100vh - var(--header-h) - 140px) * 1.25 + 96px));
  max-width: min(780px, calc((100svh - var(--header-h) - 140px) * 1.25 + 96px));
}

/* ===== App 畫面輪播（Coverflow） =====
   每張的位置由 main.js 依「離中央幾格」設定：0 = 中央、±1 = 左右兩側、±2 = 藏在舞台外 */
.cf-stage {
  position: relative; width: 100%;
  aspect-ratio: 1.28;                 /* 固定尺寸，輪播時版面不位移 */
  overflow: hidden;                   /* 舞台外的圖片藏起來，不會出現水平捲軸 */
  perspective: 1600px;
  touch-action: pan-y;                /* 手機可以上下捲頁面，左右滑交給輪播 */
  overscroll-behavior-x: contain;
  user-select: none; -webkit-user-select: none;
  cursor: grab;
}
.cf-stage.is-dragging { cursor: grabbing; }
.cf-slide {
  position: absolute; left: 50%; top: 50%;
  width: 42%; aspect-ratio: 868 / 1517;   /* 圖片原始比例 */
  transform-origin: 50% 50%;
  transition: transform 700ms cubic-bezier(.22, .61, .36, 1), opacity 700ms cubic-bezier(.22, .61, .36, 1);
  will-change: transform, opacity;
}
.cf-slide.no-anim { transition: none; }
.cf-slide img {
  width: 100%; height: 100%; object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(34, 34, 34, .08), 0 1px 3px rgba(34, 34, 34, .06);
  -webkit-user-drag: none; pointer-events: none;
}
.cf-slide.is-side { cursor: pointer; }

/* 左右箭頭：放在圖片區的外側（左右各一欄），不會蓋到圖片 */
.cf {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px;
  column-gap: 8px; align-items: center;
}
.cf-stage { grid-column: 2; grid-row: 1; }
.cf-dots  { grid-column: 2; grid-row: 2; }
.cf-arrow--prev { grid-column: 1; grid-row: 1; }
.cf-arrow--next { grid-column: 3; grid-row: 1; }
.cf-arrow {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color .2s, background-color .2s;
}
.cf-arrow:hover { border-color: var(--text); }
.cf-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 520px) {
  .cf { grid-template-columns: 32px minmax(0, 1fr) 32px; column-gap: 4px; }
  .cf-arrow { width: 32px; height: 32px; }
  .cf-arrow svg { width: 15px; height: 15px; }
}

.cf-dots { display: flex; justify-content: center; gap: 2px; margin-top: 6px; }
.cf-dots button { width: 18px; height: 18px; display: grid; place-items: center; }
.cf-dots button::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #D4D4D4; transition: background-color .3s, transform .3s;
}
.cf-dots button:hover::before { background: var(--text-2); }
.cf-dots button.is-active::before { background: var(--text); transform: scale(1.15); }

@media (prefers-reduced-motion: reduce) {
  .cf-slide { transition: none; }
}

.screens-controls { display: flex; justify-content: flex-end; margin-top: clamp(8px, 1.5vh, 16px); }

.project-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 32px;
}
.project-meta dl { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); gap: 24px clamp(32px, 7vw, 112px); }
.project-meta dt { font-size: 12px; letter-spacing: .14em; color: var(--text-2); }
.project-meta dd { margin-top: 6px; font-size: 16px; font-weight: 500; }

/* ===== Journey ===== */
.journey { border-top: 1px solid var(--line); padding-top: clamp(56px, 7vw, 104px); padding-bottom: clamp(64px, 8vw, 120px); }
.journey-head { margin-bottom: clamp(48px, 6vw, 80px); }
.journey-title { margin-top: 16px; font-size: clamp(36px, 5vw, 64px); font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }

.journey-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: clamp(40px, 5vw, 80px); }
.journey-nav { position: relative; }
/* 「開發歷程」標題和目錄包在一起固定；太矮的視窗可在裡面捲動 */
.journey-sticky {
  position: sticky; top: calc(var(--header-h) + 24px);
  max-height: calc(100svh - var(--header-h) - 48px); overflow-y: auto; scrollbar-width: none;
}
.journey-sticky::-webkit-scrollbar { display: none; }
.journey-sticky .journey-head { margin-bottom: clamp(24px, 6vh, 56px); }
.journey-nav ol { border-left: 1px solid var(--line); }
/* 右欄往下推到和目錄同高，「01 專案起源」才會和左邊的 01 對齊（數值由 main.js 量） */
.journey-body { padding-top: var(--journey-offset, 0px); }
.journey-nav a {
  display: grid; grid-template-columns: 28px 1fr; gap: 4px;
  padding: 9px 0 9px 18px; margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 14px; line-height: 1.45; color: var(--text-2);
  transition: color .2s, border-color .2s;
}
.journey-nav a:hover { color: var(--text); }
.journey-nav a.is-active { color: var(--text); border-left-color: var(--text); font-weight: 500; }
.chapter-num { font-variant-numeric: tabular-nums; }

.chapter { padding-block: clamp(56px, 6vw, 88px); border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-h) + 24px); }
.chapter:first-child { border-top: 0; padding-top: 0; }
.chapter-eyebrow { font-size: 12px; letter-spacing: .14em; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chapter-title { margin-top: 12px; font-size: clamp(28px, 3.4vw, 40px); font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.chapter-note { margin-top: 12px; font-size: 15px; color: var(--text-2); }
.chapter-body { margin-top: 40px; display: grid; gap: 20px; }

/* Placeholders（灰色素材預留區） */
.ph { background: var(--bg-2); display: grid; place-items: center; min-width: 0; }
.ph--wide { aspect-ratio: 16 / 9; }
.ph--ultra { aspect-ratio: 21 / 9; }
.ph--photo { aspect-ratio: 4 / 3; }
.ph--square { aspect-ratio: 1; }
.ph--phone { aspect-ratio: 9 / 19.5; }
.ph-caption { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.ph-lines { display: grid; gap: 12px; padding-block: 4px; }
.ph-lines span { display: block; height: 10px; background: var(--bg-2); }
.ph-lines span:nth-child(1) { width: 100%; }
.ph-lines span:nth-child(2) { width: 92%; }
.ph-lines span:nth-child(3) { width: 96%; }
.ph-lines span:nth-child(4) { width: 64%; }

.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.cols-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.split-text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.phones-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: 20px; justify-content: start; }
.phones-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.ai-layout { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 32px; align-items: start; }
.sub-label { font-size: 12px; letter-spacing: .14em; color: var(--text-2); margin-bottom: 12px; }

.iter-table { border-top: 1px solid var(--text); }
.iter-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding-block: 20px; border-bottom: 1px solid var(--line); }
.iter-row--head { font-size: 12px; letter-spacing: .14em; color: var(--text-2); padding-block: 14px; }

/* 編輯頁面填進來的真實內容 */
.chapter-text { max-width: 680px; font-size: 16px; line-height: 1.9; color: var(--text); }
.chapter-text p + p { margin-top: 1.1em; }
.media { margin: 0; min-width: 0; }
.media img, .media video { display: block; max-width: 100%; max-height: 78vh; width: auto; height: auto; background: var(--bg-2); }
.media video { width: 100%; }
.media-grid { align-items: start; }
.media-one { display: block; }

/* Mobile chapter menu */
.chapter-menu { display: none; }

/* ===== 中文排版：中文字不適合英文那種負字距 ===== */
.eyebrow:empty { display: none; }
html:lang(zh-Hant) .hero-title { letter-spacing: .01em; line-height: 1.18; white-space: pre-line; max-width: none; }
html:lang(zh-Hant) .project-title { letter-spacing: .02em; line-height: 1.1; }
html:lang(zh-Hant) .journey-title,
html:lang(zh-Hant) .chapter-title,
html:lang(zh-Hant) .guide-label,
html:lang(zh-Hant) .project-subtitle { letter-spacing: .02em; }
html:lang(zh-Hant) .guide-head h2 { letter-spacing: .2em; }

/* ===== Reveal ===== */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .phone { transition: none; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .home { grid-template-columns: minmax(0, 1fr); }
  .home-intro { padding: clamp(48px, 10vw, 80px) var(--gutter); }
  .home-panel { padding: 40px var(--gutter) 48px; }
}
@media (max-width: 960px) {
  .journey-grid { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .journey-sticky { position: static; max-height: none; overflow: visible; }
  .journey-sticky .journey-head { margin-bottom: clamp(40px, 6vw, 64px); }
  .journey-nav ol { display: none; }
  .journey-body { padding-top: 0; }
  .chapter-menu {
    display: block; position: sticky; top: var(--header-h); z-index: 10; align-self: start;
    background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    margin-bottom: 40px;
  }
  .chapter-menu summary {
    list-style: none; cursor: pointer;
    display: flex; justify-content: space-between; gap: 16px;
    padding-block: 14px; font-size: 14px; font-weight: 500;
  }
  .chapter-menu summary::-webkit-details-marker { display: none; }
  .chapter-menu summary::after { content: "+"; color: var(--text-2); }
  .chapter-menu[open] summary::after { content: "−"; }
  .chapter-menu-current { color: var(--text-2); font-weight: 400; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chapter-menu-list { padding-bottom: 12px; }
  .chapter-menu-list a { display: grid; grid-template-columns: 28px 1fr; padding-block: 8px; font-size: 14px; color: var(--text-2); }
  .chapter-menu-list a.is-active { color: var(--text); font-weight: 500; }
  .chapter { scroll-margin-top: calc(var(--header-h) + 64px); }
  .chapter:first-child { padding-top: 0; }
}
@media (max-width: 820px) {
  .project-intro { grid-template-columns: minmax(0, 1fr); }
  .intro-screens { justify-self: center; max-width: 440px; }
}
@media (max-width: 720px) {
  .header-nav { gap: 20px; }
  .showcase--phones { aspect-ratio: 4 / 3; }
  .project-info { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .project-meta { flex-direction: column; align-items: flex-start; }
  .project-meta dl { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 16px; }
  .split-text, .ai-layout { grid-template-columns: minmax(0, 1fr); }
  .ai-layout > .ph--phone { width: 60%; max-width: 240px; }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .phones-3 { gap: 10px; }
  .phones-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .iter-row { gap: 12px; }
}
@media (max-width: 420px) {
  .project-meta dl { grid-template-columns: minmax(0, 1fr); }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
