:root {
  --bg: #0b0b0c;
  --bg-alt: #111113;
  --surface: #18181b;
  --surface-2: #232327;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #edebe6;
  --muted: #a19e96;
  --faint: #6f6d66;
  --accent: #e8a33d;
  --rec: #e5484d;

  --font-display: "Space Grotesk", "Noto Sans TC", system-ui, sans-serif;
  --font-body: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --gutter: 16px;
  --radius: 10px;
  --header-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

@media (min-width: 768px) {
  :root { --gutter: 32px; }
}

/* 英文版內文用系統西文字型（中文字型的引號、破折號是全形，夾在英文裡會很寬） */
:root:lang(en) {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans TC", sans-serif;
}

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

html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video, iframe { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 8px 14px; border-radius: 6px;
  background: var(--text); color: var(--bg);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- header ---------- */

.site-header {
  position: fixed; inset: 0 0 auto; z-index: 20;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: background-color 0.3s, border-color 0.3s;
}
.site-header.scrolled {
  background: rgba(11, 11, 12, 0.78);
  border-bottom-color: var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; }
.brand-alias { color: var(--muted); font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 24px; }
/* 手機只留名字與語言切換，選單太擠就不放（頁面往下滑就是各區塊） */
.site-nav { display: none; gap: 28px; font-size: 15px; }
.site-nav a { color: var(--muted); transition: color 0.2s; }
.site-nav a:hover { color: var(--text); }
@media (min-width: 760px) {
  .site-nav { display: flex; }
}
.lang-toggle {
  height: 32px; min-width: 48px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.lang-toggle:hover { border-color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  padding: calc(var(--header-h) + 48px) 0 clamp(72px, 13vh, 140px);
  overflow: hidden;
  isolation: isolate;
}

.hero-media { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.hero-gradient {
  position: absolute; inset: -25%;
  background:
    radial-gradient(38% 34% at 30% 42%, rgba(38, 98, 110, 0.6), transparent 70%),
    radial-gradient(34% 30% at 72% 60%, rgba(216, 130, 52, 0.42), transparent 70%),
    radial-gradient(28% 28% at 58% 18%, rgba(128, 62, 96, 0.3), transparent 70%),
    var(--bg);
  filter: blur(24px);
  animation: drift 26s var(--ease) infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-5%, -3%, 0) scale(1); }
  to { transform: translate3d(5%, 4%, 0) scale(1.14); }
}
.hero-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, rgba(11, 11, 12, 0.6) 32%, rgba(11, 11, 12, 0.12) 68%, rgba(11, 11, 12, 0.45) 100%);
}
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.09;
  animation: grain 0.9s steps(6) infinite;
  pointer-events: none;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* 觀景窗：四角框線與機身資訊 */
.viewfinder {
  position: absolute;
  inset: calc(var(--header-h) + 8px) var(--gutter) 20px;
  pointer-events: none;
}
.corner { position: absolute; width: 22px; height: 22px; border: 0 solid rgba(255, 255, 255, 0.55); }
.corner-tl { top: 0; left: 0; border-top-width: 1.5px; border-left-width: 1.5px; }
.corner-tr { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.corner-bl { bottom: 0; left: 0; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.corner-br { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }
.hud {
  position: absolute;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.72);
}
.hud-tl { top: 12px; left: 16px; }
.hud-tr { top: 12px; right: 16px; }
.hud-br { bottom: 12px; right: 16px; display: none; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }
.timecode { font-variant-numeric: tabular-nums; }
@media (min-width: 768px) {
  .viewfinder { inset: calc(var(--header-h) + 12px) var(--gutter) 28px; }
  .corner { width: 28px; height: 28px; }
  .hud { font-size: 12px; }
  .hud-tl { top: 16px; left: 20px; }
  .hud-tr { top: 16px; right: 20px; }
  .hud-br { display: flex; bottom: 16px; right: 20px; }
}

.hero-content { position: relative; }
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(52px, 11vw, 136px);
  line-height: 1;
  letter-spacing: -0.01em;
}
.hero-alias {
  display: inline-block;
  vertical-align: top;
  margin: 0.32em 0 0 0.35em;
  font-family: var(--font-mono);
  font-size: 0.24em;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.hero-title {
  margin-top: 18px;
  font-size: clamp(19px, 2.4vw, 26px);
  font-weight: 500;
  letter-spacing: 0.06em;
}
.hero-tagline { margin-top: 12px; max-width: 34em; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 48px; padding: 0 24px;
  border-radius: 999px; border: 1px solid transparent;
  font-size: 15px; font-weight: 500; letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.btn svg { width: 14px; height: 14px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: #fff; }
.btn-ghost { border-color: var(--line-strong); color: var(--text); background: rgba(11, 11, 12, 0.2); }
.btn-ghost:hover { border-color: var(--text); }

/* ---------- sections ---------- */

.section { padding: 80px 0; }
.section-alt { background: var(--bg-alt); }
@media (min-width: 768px) {
  .section { padding: 120px 0; }
}
.section-head { margin-bottom: 36px; }
.section-kicker {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 4.6vw, 52px);
  font-weight: 700;
  line-height: 1.15;
}

/* ---------- works ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.chip {
  height: 36px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--muted);
  font-size: 14px; cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { color: var(--text); border-color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.works-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-flow: dense;
  gap: 36px 20px;
}
@media (min-width: 640px) {
  .works-grid { grid-template-columns: repeat(2, 1fr); }
  .work-card.is-featured { grid-column: span 2; }
}
@media (min-width: 1024px) {
  .works-grid { grid-template-columns: repeat(3, 1fr); gap: 40px 24px; }
  /* 大格佔兩列：縮圖往下延伸，跟右邊兩張卡片等高 */
  .work-card.is-featured { grid-row: span 2; display: flex; flex-direction: column; }
  .is-featured .work-button { flex: 1; display: flex; flex-direction: column; }
  .is-featured .work-thumb { flex: 1 0 auto; }
}

.work-button {
  display: block; width: 100%;
  padding: 0; border: 0; background: none;
  text-align: left; cursor: pointer;
}
.work-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
}
.work-thumb img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s, transform 0.7s var(--ease);
}
.work-thumb img.loaded { opacity: 1; }
.work-button:hover .work-thumb img,
.work-button:hover .work-placeholder { transform: scale(1.04); }

.work-placeholder {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 90% at 25% 30%, hsl(var(--h) 38% 26% / 0.9), transparent 70%),
    linear-gradient(135deg, hsl(var(--h) 30% 16%), hsl(calc(var(--h) + 50) 24% 8%));
  transition: transform 0.7s var(--ease);
}
.work-number {
  position: absolute; left: 16px; bottom: 6px;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(56px, 7vw, 88px); line-height: 1;
  color: rgba(255, 255, 255, 0.14);
}
.work-pending {
  position: absolute; right: 12px; top: 12px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
}

.work-play {
  position: absolute; left: 50%; top: 50%;
  width: 60px; height: 60px; margin: -30px 0 0 -30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(11, 11, 12, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0; transform: scale(0.9);
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.work-play svg { width: 18px; height: 18px; margin-left: 3px; }
.work-button:hover .work-play,
.work-button:focus-visible .work-play { opacity: 1; transform: none; }
@media (hover: none) {
  .work-play { opacity: 0.9; transform: scale(0.8); }
}

.work-badges { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; }
.badge, .work-duration {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 4px;
  background: rgba(11, 11, 12, 0.66); color: rgba(255, 255, 255, 0.85);
}
.work-duration { position: absolute; right: 12px; bottom: 12px; font-variant-numeric: tabular-nums; }

.work-meta { margin-top: 14px; }
.work-title { font-size: 18px; font-weight: 500; line-height: 1.45; }
.is-featured .work-title { font-size: clamp(18px, 2vw, 24px); }
.work-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }
.work-roles { margin-top: 4px; font-family: var(--font-mono); font-size: 12px; color: var(--faint); }

.works-empty { color: var(--muted); }

/* 連結卡片（YouTube 頻道）：不是影片，點了開新分頁；畫面上只有一個斜箭頭 */
.link-thumb {
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--line);
}
.link-arrow {
  width: clamp(48px, 6vw, 72px);
  color: var(--muted);
  transition: color 0.3s, transform 0.4s var(--ease);
}
.link-arrow svg { display: block; width: 100%; height: auto; }
.work-link:hover .link-arrow { color: var(--text); transform: translate(4px, -4px); }

/* ---------- about ---------- */

.about { display: grid; gap: 40px; }
@media (min-width: 900px) {
  .about { grid-template-columns: 5fr 7fr; gap: 72px; align-items: start; }
}
.about-photo {
  position: relative;
  aspect-ratio: 4 / 5;
  max-width: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  display: grid; place-items: center;
  color: var(--faint); font-size: 14px;
}
.about-photo.has-photo { border: 0; }
.about-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 900px) {
  .about-photo { position: sticky; top: calc(var(--header-h) + 32px); }
}
.about-text { display: grid; gap: 16px; color: var(--muted); max-width: 38em; }
.about-text p:first-child { color: var(--text); font-size: 18px; }

.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px 16px;
  margin-top: 40px; padding-top: 28px;
  border-top: 1px solid var(--line);
}
/* 版面夠寬時四個數字排一列（900–1179px 關於區是兩欄，右欄太窄就維持 2×2） */
@media (min-width: 640px) and (max-width: 899px), (min-width: 1180px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
/* dt 是說明、dd 是數字；用 column-reverse 讓數字顯示在上面 */
.stat { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 4px; }
.stats dd { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 3vw, 40px); line-height: 1.1; white-space: nowrap; }
.stats dt { font-size: 13px; color: var(--muted); line-height: 1.5; }

.skills { display: grid; gap: 22px; margin-top: 40px; }
.skill-group h3 {
  font-family: var(--font-mono); font-size: 12px; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}
.skill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.skill-list li {
  padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--line-strong);
  font-size: 14px;
}

/* ---------- experience ---------- */

.timeline { border-bottom: 1px solid var(--line); }
.timeline-item {
  display: grid; gap: 6px;
  padding: 28px 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 768px) {
  .timeline-item { grid-template-columns: 220px 1fr; gap: 32px; }
}
.timeline-period { font-family: var(--font-mono); font-size: 13px; color: var(--muted); padding-top: 4px; font-variant-numeric: tabular-nums; }
.timeline-role { font-size: 20px; font-weight: 500; line-height: 1.45; }
.timeline-org { color: var(--accent); font-size: 15px; }
.timeline-desc { margin-top: 8px; color: var(--muted); max-width: 40em; }

.clients { margin-top: 64px; }
.clients-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 400; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 18px;
}
.clients-list { display: flex; flex-wrap: wrap; gap: 10px 36px; }
.clients-list li {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(18px, 2.2vw, 24px);
  color: var(--muted);
}

/* ---------- contact ---------- */

.contact { border-top: 1px solid var(--line); }
.contact-heading {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(40px, 7.5vw, 96px);
  line-height: 1.1;
  margin-top: 6px;
}
.contact-message { margin-top: 18px; color: var(--muted); max-width: 32em; }
.contact-email {
  display: inline-block;
  margin-top: 32px;
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(22px, 4vw, 40px);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 4px;
  overflow-wrap: anywhere;
  transition: color 0.2s, border-color 0.2s;
}
.contact-email:hover { color: var(--accent); border-color: var(--accent); }
.contact-links { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 36px; }
.contact-links a {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s;
}
.contact-links a:hover { color: var(--text); }
.contact-links a::after { content: " ↗"; }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0; }
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  font-family: var(--font-mono); font-size: 12px; color: var(--faint);
}

/* ---------- player ---------- */

.player {
  width: 100%; max-width: none;
  height: 100%; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--text);
}
.player::backdrop { background: rgba(6, 6, 7, 0.94); }
.player[open] { animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; } }

.player-inner {
  --frame-w: min(100%, 1200px, calc((100vh - 220px) * var(--arw, 16) / var(--arh, 9)));
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  padding: 64px var(--gutter) 32px;
}
.player-frame, .player-info { width: var(--frame-w); }
.player-frame {
  aspect-ratio: var(--arw, 16) / var(--arh, 9);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.player-frame iframe, .player-frame video { width: 100%; height: 100%; border: 0; }
.player-empty {
  height: 100%;
  display: grid; place-content: center; gap: 6px;
  padding: 24px; text-align: center;
  background: var(--surface);
  color: var(--muted); font-size: 14px;
}
.player-empty strong { color: var(--text); font-size: 17px; font-weight: 500; }
.player-title { font-size: 20px; font-weight: 500; line-height: 1.4; }
.player-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }
.player-desc { margin-top: 10px; color: var(--muted); font-size: 15px; }
.player-desc:empty { display: none; }
.player-link {
  display: inline-block; margin-top: 12px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.2s;
}
.player-link:hover { color: var(--text); }

.player-close {
  position: fixed; top: 14px; right: 14px; z-index: 2;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 0.2s;
}
.player-close:hover { background: #33333a; }
.player-close svg { width: 16px; height: 16px; }

/* ---------- reveal on scroll ---------- */

.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-gradient, .grain, .rec-dot { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .work-thumb img, .work-placeholder { transition: none; }
}
