:root {
  --bg: #FBF9F4;
  --ink: #17150F;
  --muted: #6b675e;
  --card-radius: 6px;
  --row-h: 460px; /* 作品牆每排高度 */
  /* Roca（Adobe Fonts）優先，未載入時退回 Fraunces/Noto Sans TC */
  --serif: 'roca', 'Fraunces', 'Noto Sans TC', serif;
  --sans: 'roca', 'Noto Sans TC', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.7; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== Header ===== */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 40px 72px; max-width: 1680px; margin: 0 auto; position: relative; z-index: 50;
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo-img { height: var(--logo-h, 56px); width: auto; }
.logo-mark { font-size: 40px; }
.logo-text { font-family: var(--serif); font-weight: 700; font-size: 40px; letter-spacing: 0.5px; }
.site-nav { display: flex; gap: 44px; align-items: center; }
.site-nav a { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.site-nav > a:hover, .site-nav > a.active,
.nav-item > a:hover, .nav-item > a.active { text-decoration: underline; text-underline-offset: 6px; }

/* Selected Works 下拉 */
.nav-item { position: relative; }
.sub-menu {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.12); border-radius: 4px;
  padding: 18px 26px; min-width: 260px;
  display: none; flex-direction: column; gap: 14px;
}
.nav-item:hover .sub-menu, .nav-item:focus-within .sub-menu { display: flex; }
.sub-menu::before { /* hover 橋接，避免游標移過去時關閉 */
  content: ''; position: absolute; top: -14px; left: 0; right: 0; height: 14px;
}
.sub-menu a { font-size: 18px; white-space: nowrap; }
.sub-menu a:hover, .sub-menu a.active { text-decoration: underline; text-underline-offset: 5px; }

/* 漢堡按鈕（桌機隱藏） */
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; z-index: 60; }
.nav-toggle span {
  display: block; width: 28px; height: 3px; background: var(--ink);
  margin: 6px 0; border-radius: 2px; transition: transform .3s, opacity .3s;
}
body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

main { max-width: 1680px; margin: 0 auto; padding: 32px 72px 96px; }

/* ===== 作品牆：等高不等寬 justified 版面 =====
   每張卡片依封面長寬比 (--ar) 決定寬度，同一排高度一致 */
.grid { display: flex; flex-wrap: wrap; gap: 24px; }
.grid .card {
  position: relative; border-radius: var(--card-radius); overflow: hidden; display: block;
  height: var(--row-h);
  width: calc(var(--ar, 1) * var(--row-h));
  flex-grow: calc(var(--ar, 1) * 100);
}
.grid::after { content: ''; flex-grow: 1000000; } /* 避免最後一排過度拉伸 */
.card img, .card video { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card:hover img { transform: scale(1.04); }
.card .placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 28px; color: #fff; text-align: center; padding: 24px;
}
.card .overlay {
  position: absolute; inset: 0; background: rgba(10, 10, 10, .55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: #fff; opacity: 0; transition: opacity .35s ease; text-align: center; padding: 24px;
}
.card:hover .overlay { opacity: 1; }
.card .overlay h3 { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.card .overlay p { font-size: 16px; opacity: .9; }

/* 頁面標題 */
.page-head { margin: 8px 0 40px; }
.page-head h1 { font-family: var(--serif); font-size: var(--title-size, 44px); font-weight: var(--title-weight, 700); color: var(--title-color, var(--ink)); }
.page-head p { color: var(--muted); margin-top: 8px; }

/* 作品內頁 */
.project-hero { border-radius: var(--card-radius); overflow: hidden; margin-bottom: 40px; }
.project-title h1 { font-family: var(--serif); font-size: var(--title-size, 40px); font-weight: var(--title-weight, 700); color: var(--title-color, var(--ink)); }
.project-title .meta { color: var(--subtitle-color, var(--muted)); font-size: var(--subtitle-size, 16px); font-weight: var(--subtitle-weight, 400); margin: 8px 0 32px; }
.project-body { max-width: 860px; font-size: var(--body-size, 17px); font-weight: var(--body-weight, 400); color: var(--body-color, var(--ink)); }
.project-body p { margin-bottom: 1.2em; }
/* 內文裡的連結：明顯底線＋hover 變化 */
.project-body a, .about-wrap .text a:not(.btn-download) {
  color: var(--ink); font-weight: 600;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
.project-body a:hover, .about-wrap .text a:not(.btn-download):hover { opacity: .65; }
.project-link { margin-top: 36px; }
.project-media { margin-top: 48px; display: flex; flex-direction: column; gap: 32px; }
.project-media figure figcaption { color: var(--muted); font-size: 14px; margin-top: 8px; text-align: center; }
.project-media video { width: 100%; border-radius: var(--card-radius); }
.project-media img { border-radius: var(--card-radius); margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--muted); }
.back-link:hover { color: var(--ink); }

/* About */
.about-wrap { display: grid; grid-template-columns: 1fr 1.6fr; gap: 64px; align-items: start; }
.about-wrap .photo img { border-radius: var(--card-radius); }
.about-wrap .text { font-size: var(--body-size, 17px); font-weight: var(--body-weight, 400); color: var(--body-color, var(--ink)); }
.about-wrap .text p { margin-bottom: 1.2em; }
.about-contact { margin-top: 32px; font-weight: 500; }
.download-btns { margin-top: 28px; display: flex; gap: 16px; flex-wrap: wrap; }
.btn-download {
  display: inline-block; padding: 13px 26px; border: 1.5px solid var(--ink);
  border-radius: 999px; font-family: var(--serif); font-size: 16px; font-weight: 500;
  transition: background .25s, color .25s;
}
.btn-download:hover { background: var(--ink); color: var(--bg); }
.footer-downloads { margin-bottom: 10px; }
.footer-downloads a { text-decoration: underline; text-underline-offset: 4px; }

/* Footer */
.site-footer {
  border-top: 1px solid #e5e0d5; padding: 32px 72px;
  color: var(--muted); font-size: 14px;
  max-width: 1680px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.footer-icons { display: flex; align-items: center; gap: 22px; }
.footer-icons a { display: inline-flex; color: var(--muted); transition: color .25s; }
.footer-icons a:hover { color: var(--ink); }
.footer-icons svg { width: 22px; height: 22px; }
@media (max-width: 640px) {
  .site-footer { flex-direction: column; justify-content: center; text-align: center; gap: 16px; }
}

/* ===== RWD ===== */
@media (max-width: 1200px) { :root { --row-h: 360px; } }
@media (max-width: 1024px) {
  .site-header, main, .site-footer { padding-left: 28px; padding-right: 28px; }
  :root { --row-h: 300px; }
}

/* 手機版：Hamburger menu */
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .logo-text { font-size: 30px; }
  .logo-img { height: min(var(--logo-h, 44px), 44px); }

  .site-nav {
    display: none;
    position: fixed; inset: 0; z-index: 55;
    background: var(--bg);
    flex-direction: column; align-items: flex-start; justify-content: flex-start;
    gap: 26px; padding: 110px 40px 40px; overflow-y: auto;
  }
  body.nav-open .site-nav { display: flex; }
  body.nav-open { overflow: hidden; }
  body.nav-open .nav-toggle { position: fixed; top: 34px; right: 24px; }

  .site-nav a { font-size: 26px; }
  /* 手機版子選單直接展開列出 */
  .sub-menu {
    display: flex; position: static; transform: none; box-shadow: none; background: none;
    padding: 14px 0 0 22px; gap: 18px; min-width: 0;
  }
  .sub-menu::before { display: none; }
  .sub-menu a { font-size: 20px; color: #3d3a33; white-space: normal; }

  :root { --row-h: auto; }
  .grid { display: flex; flex-direction: column; gap: 20px; }
  .grid .card { width: 100%; height: auto; aspect-ratio: var(--ar, 1); }
  .grid::after { display: none; }

  .about-wrap { grid-template-columns: 1fr; gap: 32px; }
  .page-head h1 { font-size: 34px; }
}
