/* ===== 01. 基本設定 ===== */
:root {
  --content-width: min(780px, 83vw);
  --ink: #495f4c;
  --border: #e4e7df;
  --hover: #f1f3ed;
  --gallery-gap: 32px;
  --home-gallery-gap: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: #fff;
  color: #242722;
  font: 14px/1.6 Arial, Helvetica, sans-serif;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
a:hover { color: #79866c; }
button { font: inherit; }
a:focus-visible,
button:focus-visible {
  outline: 2px solid #70805c;
  outline-offset: 5px;
}
.content-width { width: var(--content-width); margin-inline: auto; }
.skip {
  position: fixed;
  top: -80px;
  z-index: 50;
  padding: 12px;
  background: #fff;
}
.skip:focus { top: 0; }
body.lightbox-open { overflow: hidden; }

/* ===== 02. Logo 與選單基礎；手機與電腦設定在最後 ===== */
header { position: relative; padding: 30px 0 28px; }
.wordmark {
  display: block;
  width: min(360px, 44vw);
  margin-inline: auto;
}
.wordmark img { display: block; width: 100%; height: auto; }
header nav { z-index: 20; }
header nav a[aria-current="page"] {
  color: #242722;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}
.menu-toggle { display: none; }
.menu-symbol { font-size: 24px; line-height: 1; }
.desktop-nav-slot { display: contents; }
.intro {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: #73776e;
  font-size: 9px;
  letter-spacing: 1.5px;
}

/* ===== 03. 首頁 Banner 與捲簾 ===== */
#work-view { position: relative; isolation: isolate; }
.home-hero {
  position: sticky;
  top: 0;
  z-index: 0;
  width: 100%;
  overflow: hidden;
  background: #fff;
}
/* 獨立圖片：使用自己裁好的比例，不額外裁切。 */
.home-hero .banner-image { display: block; width: 100%; height: auto; }
.work-sheet { position: relative; z-index: 1; background: #fff; }
#work-view.is-home .work-sheet {
  min-height: 100svh;
  padding-top: 48px;
  padding-bottom: 40px;
}

/* ===== 04. 全分類瀑布流與淡入 ===== */
#gallery { column-count: 3; column-gap: var(--gallery-gap); }
#gallery.home-gallery { column-gap: var(--home-gallery-gap); }
#gallery > .work {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0 0 var(--gallery-gap);
  break-inside: avoid;
  page-break-inside: avoid;
}
#gallery.home-gallery > .work { margin-bottom: var(--home-gallery-gap); }
.work figcaption { display: none; }
.art {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: zoom-in;
}
.art img { display: block; width: 100%; height: auto; }
.reveal-work {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .25s ease, transform .25s ease;
}
.reveal-work.is-visible { opacity: 1; transform: none; }
/* 舊 HTML 即使還留有底部分類，也不佔空間。 */
.categories { display: none; }

/* ===== 05. 首頁聯絡區與按鈕 ===== */
.home-contact {
  margin: 70px 0 20px;
  padding: 70px 24px;
  border: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .45), rgba(255, 255, 255, .45)),
    url("assets/resource/contact-bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  text-align: center;
}
.home-contact h2 {
  margin: 0 0 16px;
  color: #242722;
  font: normal clamp(28px, 4vw, 40px)/1.3 Georgia, serif;
}
.home-contact p { color: var(--ink); }
.contact-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  min-height: 48px;
  margin-top: 20px;
  padding: 14px 22px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 1px;
}
.contact-button:hover,
.contact-button:focus-visible { background: var(--ink); color: #fff; }

/* ===== 06. About Me 與頁尾 ===== */
#about-view { max-width: 1000px; padding: 25px 0 80px; }
#about-view p { font-size: 16px; line-height: 1.9; }
h1 { font: normal 38px/1.3 Georgia, serif; }
.eyebrow { font-size: 10px !important; letter-spacing: 2px; }
.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 48px;
}
.about-art { display: block; width: 100%; height: auto; }
.about-copy { min-width: 0; }
.about-copy h1 { margin-top: 12px; }
footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 60px;
  padding: 20px 0 100px;
  background: #fff;
  color: #8a8d84;
  font-size: 9px;
  letter-spacing: 1px;
}

/* ===== 07. 右下角聯絡、左下角返回按鈕 ===== */
.social-links {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}
.social-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--ink);
}
.social-links svg {
  display: block;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.social-links a:hover,
.social-links a:focus-visible,
.back-home:hover,
#back-to-top:hover { background: var(--hover); }
.back-home {
  position: fixed;
  left: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}
#back-to-top {
  position: fixed;
  left: 20px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #d9dfd3;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
#back-to-top svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== 08. 圖示提示文字 ===== */
.social-links a::after,
#back-to-top::after,
.menu-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  padding: 6px 10px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font: normal 12px/1.4 Arial, sans-serif;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.social-links a::after { right: 0; bottom: calc(100% + 12px); }
#back-to-top::after { left: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
.menu-toggle::after { right: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
@media (hover: hover) {
  .social-links a:hover::after,
  #back-to-top:hover::after,
  .menu-toggle:hover::after { opacity: 1; visibility: visible; }
}
.social-links a:focus-visible::after,
#back-to-top:focus-visible::after,
.menu-toggle:focus-visible::after { opacity: 1; visibility: visible; }

/* ===== 09. 圖片放大視窗 ===== */
#lightbox {
  position: fixed;
  width: 88vw;
  max-width: 1100px;
  height: 86vh;
  height: 86dvh;
  max-height: 96dvh;
  margin: auto;
  padding: 44px 76px 20px;
  border: 0;
  background: #fff;
  overflow: auto;
}
#lightbox[open] { display: flex; flex-direction: column; gap: 12px; }
#lightbox::backdrop,
#stopmotion-player::backdrop { background: rgba(25, 29, 22, .85); }
#large-image {
  display: block;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: pan-y pinch-zoom;
}
.close {
  position: absolute;
  right: 14px;
  top: 5px;
  width: 44px;
  height: 36px;
  padding: 0;
  background: none;
  border: 0;
  font-size: 30px;
  cursor: pointer;
}
.lightbox-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}
.lightbox-controls button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #697363;
  cursor: pointer;
}
#previous-image { left: 14px; }
#next-image { right: 14px; }
.lightbox-controls button:hover { color: #242722; }
.lightbox-controls button:disabled { opacity: .25; cursor: default; }
.lightbox-controls svg,
#stopmotion-player .stopmotion-controls svg {
  display: block;
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#image-count { font-size: 12px; color: #73776e; }
.caption { flex-shrink: 0; }
.caption h2 { margin: 4px 0; font-size: 14px; font-weight: normal; }
.caption p { margin: 0; color: #757c6c; font-size: 12px; }

/* ===== 10. 陶藝角度縮圖 ===== */
#lightbox .artwork-photo-picker { flex: 0 0 auto; min-width: 0; width: 100%; }
#lightbox .artwork-photo-label { margin: 0 0 6px; color: #73776e; font-size: 11px; text-align: center; }
#lightbox .artwork-thumbnails { display: flex; gap: 10px; overflow-x: auto; padding: 4px; max-width: 100%; }
#lightbox .artwork-thumbnail {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  min-height: 44px;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: #f4f5f1;
  cursor: pointer;
}
#lightbox .artwork-thumbnail:first-child { margin-left: auto; }
#lightbox .artwork-thumbnail:last-child { margin-right: auto; }
#lightbox .artwork-thumbnail[aria-pressed="true"] { border-color: var(--ink); background: #fff; }
#lightbox .artwork-thumbnail:hover { border-color: #a6b09d; }
#lightbox .artwork-thumbnail:focus-visible { outline: 2px solid #70805c; outline-offset: 1px; }
#lightbox .artwork-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  object-fit: contain;
}

/* ===== 11. STOP MOTION 封面與 MP4 播放器 ===== */
.stopmotion-card { position: relative; cursor: pointer; }
.stopmotion-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  pointer-events: none;
}
.stopmotion-play svg { width: 25px; height: 25px; fill: currentColor; }
.stopmotion-card:hover .stopmotion-play { background: #fff; }
#stopmotion-player {
  width: min(1100px, 94vw);
  max-width: 94vw;
  height: auto;
  max-height: 94dvh;
  margin: auto;
  padding: 44px 24px 22px;
  border: 0;
  background: #fff;
  color: #242722;
  overflow: auto;
}
#stopmotion-player .stopmotion-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 65dvh;
  object-fit: contain;
  background: #171a15;
}
#stopmotion-player .stopmotion-close {
  position: absolute;
  top: 5px;
  right: 14px;
  width: 40px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 30px;
  cursor: pointer;
}
#stopmotion-player .stopmotion-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
#stopmotion-player .stopmotion-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #697363;
  cursor: pointer;
}
#stopmotion-player .stopmotion-count { color: #73776e; font-size: 12px; }
#stopmotion-player .stopmotion-caption h2 { margin: 12px 0 3px; font-size: 14px; font-weight: normal; }
#stopmotion-player .stopmotion-caption p { margin: 0; color: #757c6c; font-size: 12px; }

/* ===== 12. 陶藝品牌：顯示由 script.js 的開關決定 ===== */
.clay-brand { padding: 0 0 20px; text-align: center; }
.clay-brand-logo { display: block; width: min(210px, 60%); height: auto; max-height: 200px; object-fit: contain; margin: 0 auto; }
.clay-brand-name { margin: 18px 0 0; font: normal 24px/1.4 Georgia, serif; letter-spacing: 1px; color: var(--ink); }

/* ===== 13. 圖片拖曳／長按限制 ===== */
#gallery img,
#home-hero img,
#about-view img,
#large-image,
#lightbox .artwork-thumbnails img,
.clay-brand-logo {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* ===== 14. 電腦：橫排分類，捲走後顯示圓形選單 ===== */
@media (min-width: 701px) {
  header .desktop-nav-slot {
    display: block;
    width: 100%;
    min-height: var(--desktop-nav-height, 52px);
    margin-top: 22px;
  }
  header .desktop-nav-slot > nav {
    position: static;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 28px;
    width: calc(100% - 48px);
    max-width: 1100px;
    max-height: none;
    margin: 0 auto;
    padding: 4px 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  header .desktop-nav-slot > nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 6px 0;
    background: transparent;
    color: #626b5d;
    font-size: 11px;
    line-height: 1.5;
    letter-spacing: 1px;
    white-space: nowrap;
  }
  header .desktop-nav-slot > nav a:hover { color: #242722; }
  header .desktop-nav-slot > nav a[aria-current="page"] { color: #242722; }
  header.desktop-nav-collapsed .menu-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 35;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #d9dfd3;
    border-radius: 50%;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
  }
  header.desktop-nav-collapsed .menu-toggle:hover { background: var(--hover); }
  header.desktop-nav-collapsed .desktop-nav-slot > nav {
    position: fixed;
    display: none;
    top: 76px;
    right: 24px;
    z-index: 30;
    width: 260px;
    max-width: calc(100vw - 48px);
    max-height: calc(100dvh - 100px);
    margin: 0;
    padding: 12px;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(36, 39, 34, .08);
  }
  header.desktop-nav-collapsed .desktop-nav-slot > nav.is-open { display: flex; }
  header.desktop-nav-collapsed .desktop-nav-slot > nav a {
    justify-content: flex-start;
    padding: 10px 12px;
    font-size: 12px;
    white-space: normal;
  }
  header.desktop-nav-collapsed .desktop-nav-slot > nav a:hover { background: var(--hover); }
}

/* ===== 15. 大螢幕與平板 ===== */
@media (min-width: 1450px) {
  :root { --content-width: min(1000px, 68vw); }
}
@media (min-width: 701px) and (max-width: 1000px) {
  #gallery { column-count: 2; }
}

/* ===== 16. 手機 ===== */
@media (max-width: 700px) {
  header { padding: 20px 0; }
  .wordmark { width: min(260px, calc(100vw - 100px)); margin-left: 16px; margin-right: 0; }
  .menu-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 35;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #d9dfd3;
    border-radius: 50%;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
  }
  header nav {
    position: fixed;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    top: 72px;
    right: 16px;
    z-index: 30;
    width: 190px;
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 90px);
    margin: 0;
    padding: 12px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(36, 39, 34, .08);
  }
  header nav.is-open { display: flex; }
  header nav a { display: flex; align-items: center; min-height: 44px; padding: 10px 12px; font-size: 12px; letter-spacing: 1px; }
  .intro { margin-bottom: 10px; font-size: 8px; letter-spacing: .7px; }
  #work-view.is-home .work-sheet { padding-top: 20px; }
  #gallery { column-count: 1; }
  .home-contact { margin-top: 48px; padding: 48px 20px; }
  .about-layout { grid-template-columns: 1fr; gap: 28px; }
  footer { font-size: 8px; letter-spacing: .5px; }
  .social-links { right: 12px; }
  .back-home,
  #back-to-top { left: 12px; }
  #lightbox { width: 94vw; height: 88dvh; padding: 44px 12px 16px; }
  .lightbox-controls { justify-content: space-between; }
  .lightbox-controls button { position: static; transform: none; }
  #lightbox .artwork-thumbnail { flex-basis: 52px; width: 52px; height: 52px; }
  #lightbox .artwork-thumbnails { gap: 8px; }
  #stopmotion-player { padding: 44px 12px 18px; }
  .stopmotion-play { width: 44px; height: 44px; }
}

/* ===== 17. 減少動態效果 ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .home-hero { position: relative; }
  .reveal-work,
  .reveal-work.is-visible { opacity: 1; transform: none; transition: none; }
}
/* 自行調整選單與下方內容的距離 */
#work-view .intro {
  display: block;
  visibility: hidden;
  height: 30px; /* 電腦版：改這個數字 */
  margin: 0;
  padding: 0;
}

@media (max-width: 700px) {
  #work-view .intro {
    height: 20px; /* 手機版：改這個數字 */
  }
}
.about-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 48px;
  margin: 32px 0;
}

.contact-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.about-contacts .contact-group h2 {
  margin: 0 0 4px;
  color: #495f4c;
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.contact-group a {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.contact-group a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}