/* 首頁專用：緊湊的格線拼貼排版（只影響 <body class="home">） */
/* 首頁左右留白跟其他頁一樣，用 style.css 的 .wrap */
.home .site-header .wrap { padding-block: 10px; }

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; }
.tile { min-width: 0; border-radius: 4px; background: var(--surface); padding: 20px; }
.tile.line { background: transparent; border: 1px solid var(--line); }
.tile-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }

/* ---------- Hero：左邊標題與資訊，右邊 Reel ---------- */
.home-hero { padding-block: 8px 8px; }
.hero-left { grid-column: span 5; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.t-title { flex: 1; container-type: inline-size; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; padding: 20px 22px; }
.t-title h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: min(72px, 11cqi); /* 跟著格子寬度縮放，「Designer/」不會超出格子 */ line-height: 0.88; letter-spacing: -0.035em; }
.t-title h1 .slash { color: var(--accent); }
.t-title .tile-label { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.t-intro { padding: 16px 20px; }
.t-intro p { margin: 0; font-size: 15px; line-height: 1.6; }
.hero-meta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.t-status { background: var(--accent); color: var(--on-accent); display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; }
.t-status .pulse { width: 9px; height: 9px; border-radius: 999px; background: var(--on-accent); flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.t-where { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }

.t-reel { grid-column: span 7; padding: 0; background: none; position: relative; }
.t-reel::before { content: ""; display: block; aspect-ratio: 16 / 9; } /* 撐住格子大小，開場時 Reel 被拿去全螢幕也不會塌 */
.reel-media { position: absolute; left: 0; top: 0; width: 100%; height: 100%; /* 跟左欄一樣高，不留空 */ border-radius: 4px; container-type: size; background-color: #000; }
/* 影片永遠填滿畫面（像 object-fit: cover），全螢幕時也不會有黑邊 */
.reel-media video.reel-bg { object-fit: cover; z-index: 0; }
.reel-media iframe.reel-bg {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(100cqw, 177.78cqh); height: max(100cqh, 56.25cqw);
  z-index: 0; pointer-events: none;
}
.reel-media > img { z-index: 0; }
/* 「開聲音看」按鈕：小小的放左下，不擋畫面 */
.t-reel .player.reel-sound { inset: auto; left: 12px; bottom: 12px; width: auto; height: auto; z-index: 3; }
.t-reel .player.reel-sound .play { position: static; transform: none; font-size: 14px; padding: 10px 16px; gap: 10px; }
.t-reel .player.reel-sound:hover .play { transform: scale(1.04); }

/* ---------- 客戶跑馬燈 ---------- */
.ticker { margin-top: 8px; border-block: 1px solid var(--line); overflow: hidden; white-space: nowrap; }
.ticker-track { display: inline-flex; gap: 0; padding-block: 14px; animation: ticker 32s linear infinite; }
.ticker-track span { font-family: var(--display); font-weight: 600; font-size: clamp(20px, 2.2vw, 30px); color: var(--muted); padding-inline: 28px; }
.ticker-track span.sep { padding-inline: 0; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- 區塊標題列 ---------- */
.bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; padding-block: 40px 12px; }
.bar h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(28px, 3.2vw, 44px); line-height: 1; }
.bar h2 sup { font-family: var(--mono); font-weight: 400; font-size: 13px; color: var(--accent); vertical-align: top; margin-left: 6px; }

/* ---------- 精選作品：大小不一的格子 ---------- */
.works { grid-auto-flow: dense; }
#work { container-type: inline-size; }
.w { position: relative; display: block; grid-column: span 4; border-radius: 4px; overflow: hidden; min-width: 0; }
.w .media { aspect-ratio: 16 / 10; border-radius: 0; }
.w-xl { grid-column: span 8; grid-row: span 2; }
.w-xl .media { aspect-ratio: auto; height: 100%; min-height: 320px; }
.w .no { position: absolute; top: 12px; right: 14px; z-index: 2; font-family: var(--mono); font-size: 12px; color: var(--fg); background: var(--bg); padding: 2px 8px; border-radius: 999px; }
.w .cap { position: absolute; left: 0; bottom: 0; z-index: 2; max-width: calc(100% - 16px); background: var(--bg); padding: 10px 14px 10px 0; display: flex; flex-direction: column; gap: 2px; border-top-right-radius: 4px; }
.w .cap h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 20px; line-height: 1.15; }
.w-xl .cap h3 { font-size: clamp(24px, 2.6vw, 36px); }
.w .cap span { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.w .media { outline: 2px solid transparent; outline-offset: -2px; transition: outline-color .2s; }
.w:hover .media, .w:focus-visible .media { outline-color: var(--accent); }
.w:hover .cap h3 { color: var(--accent); }
.w video { opacity: 0; transition: opacity .3s; }
.w.is-playing video { opacity: 1; }

/* 分割變形：桌機滑鼠在作品區移動時，不規則格線的欄寬與列高跟著游標伸縮（main.js 加 .is-split 並設定切法） */
.works.is-split {
  /* 欄、列的切法和每張的位置由 main.js 4c 設定 */
  grid-auto-flow: row;
  /* 最高不超過「螢幕高 − 頂部導覽 − 標題列」，標題＋格子一個畫面就看得完 */
  height: min(calc(100cqw / 1.6), calc(100svh - 160px));
}
.works.is-split .w .media { aspect-ratio: auto; height: 100%; min-height: 0; }
.works.is-split .w .cap { white-space: nowrap; overflow: hidden; }

/* ---------- LAB ＋ About ---------- */
.duo { padding-top: 8px; }
.lab-block { grid-column: span 7; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lab-block .bar { padding-block: 32px 4px; }
.lab-row { flex: 1; min-height: 360px; display: grid; grid-template-columns: 1.5fr 0.75fr 1.15fr 0.6fr; gap: 8px; transition: grid-template-columns .5s cubic-bezier(.6,0,.2,1); }
/* 不等寬直條：滑過哪一張，那張就展開變寬 */
.lab-row:has(.lab-tile:nth-child(1):hover) { grid-template-columns: 2.4fr 0.6fr 0.8fr 0.5fr; }
.lab-row:has(.lab-tile:nth-child(2):hover) { grid-template-columns: 0.8fr 2.2fr 0.8fr 0.5fr; }
.lab-row:has(.lab-tile:nth-child(3):hover) { grid-template-columns: 0.8fr 0.6fr 2.2fr 0.5fr; }
.lab-row:has(.lab-tile:nth-child(4):hover) { grid-template-columns: 0.8fr 0.6fr 0.8fr 2.2fr; }
.lab-tile { position: relative; display: block; border-radius: 4px; overflow: hidden; }
.lab-tile .media { aspect-ratio: auto; height: 100%; border-radius: 0; }
.lab-tile .tag { position: absolute; left: 8px; bottom: 8px; z-index: 2; font-family: var(--mono); font-size: 11px; background: var(--bg); color: var(--accent); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.lab-tile .no { position: absolute; top: 10px; left: 10px; z-index: 2; font-family: var(--mono); font-size: 11px; color: var(--fg); background: var(--bg); padding: 2px 7px; border-radius: 999px; }
.lab-tile:hover .media { outline: 2px solid var(--accent); outline-offset: -2px; }

.t-about { grid-column: span 5; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; padding: 24px; margin-top: 32px; }
.t-about .statement { margin: 0; font-family: var(--body); font-weight: 700; font-size: clamp(20px, 1.9vw, 26px); line-height: 1.45; }
.t-about .statement em { font-style: normal; color: var(--accent); }
.t-about { container-type: inline-size; }
.t-about .facts-row { display: grid; grid-template-columns: repeat(3, minmax(max-content, 1fr)); column-gap: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.t-about .facts-row > div { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.t-about .facts-row b { display: block; font-family: var(--display); font-weight: 800; font-size: clamp(17px, 8cqi, 28px); line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-about .facts-row span { font-size: 12px; color: var(--muted); white-space: nowrap; }
@container (max-width: 300px) {
  .t-about .facts-row { grid-template-columns: repeat(3, minmax(0, auto)); justify-content: space-between; column-gap: 14px; }
  .t-about .facts-row span { white-space: normal; }
}
.t-about .who { display: flex; align-items: center; gap: 14px; }
.t-about .who .media { width: 56px; height: 56px; border-radius: 999px; flex: none; }
.t-about .who p { margin: 0; font-size: 14px; line-height: 1.4; }

/* ---------- Footer 收緊 ---------- */
.home .site-footer { margin-top: 48px; }
.home .site-footer .wrap { padding-block: 56px 24px; gap: 24px; }

/* ---------- 平板 ---------- */
@media (max-width: 1000px) {
  .hero-left, .t-reel { grid-column: span 12; }
  .w { grid-column: span 6; }
  .w-xl { grid-column: span 12; grid-row: auto; }
  .w-xl .media { aspect-ratio: 16 / 9; height: auto; min-height: 0; }
  .lab-block, .t-about { grid-column: span 12; }
  .t-about { margin-top: 0; }
}
/* ---------- 手機 ---------- */
@media (max-width: 640px) {
  .t-title { padding: 20px; }
  .t-title h1 { font-size: 10.5vw; }
  .player .play { font-size: 15px; padding: 12px 18px; gap: 10px; }
  .w { grid-column: span 12; }
  /* 手機：橫向滑動的直式片條 */
  .lab-row { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; min-height: 0; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); scrollbar-width: none; }
  .lab-tile { flex: 0 0 62%; scroll-snap-align: start; }
  .lab-tile .media { aspect-ratio: 3 / 4; height: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track, .t-status .pulse { animation: none; }
}

/* ---------- 開場：Reel 全螢幕播放，往下滑才縮進首頁 ---------- */
html.intro-playing { overflow: hidden; }
[data-layer] { transition: clip-path .75s cubic-bezier(.75,0,.2,1), opacity .3s ease; }
html.intro-playing [data-layer] { clip-path: inset(0 100% 0 0); opacity: 0; }
html.intro-playing [data-layer].in { clip-path: inset(0 0 0 0); opacity: 1; }

.reel-intro {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #000;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  transition: background-color .6s ease;
}
html:not(.intro-playing) .reel-intro { display: none; }
.ri-screen { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr) 260px; gap: 8px; }
.ri-stage { position: relative; min-width: 0; min-height: 0; container-type: size; background: #0a0a0b; border: 1px solid var(--line); border-radius: 6px; }

/* 仿 AE 的側邊面板（裝飾用） */
.ri-side { min-height: 0; overflow: hidden; display: flex; flex-direction: column; background: #141416; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; color: #9a9aa0; }
.ri-tab { display: flex; gap: 14px; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.ri-tab span.on { color: var(--fg); }
.ri-tab em, .ri-meta em { font-style: normal; color: var(--accent); }
.ri-tab.sub { border-top: 1px solid var(--line); margin-top: auto; }
.ri-foot { margin-top: auto; padding: 6px 10px; border-top: 1px solid var(--line); color: #6c6c72; }
.ri-meta { display: flex; gap: 10px; padding: 10px; line-height: 1.55; border-bottom: 1px solid #1f1f22; }
.ri-meta.small { padding: 6px 10px; }
.ri-meta b { color: var(--fg); font-weight: 500; }
.ri-meta .thumb { width: 64px; aspect-ratio: 16 / 9; flex: none; border-radius: 2px; background: linear-gradient(135deg, #2b6cff, #c6ff3d 55%, #ff5b8a); opacity: .85; }
.ri-search { margin: 8px 10px; padding: 3px 8px; border-radius: 4px; background: #0d0d0f; border: 1px solid #222226; color: #5a5a60; }
.ri-cols { display: flex; justify-content: space-between; padding: 4px 10px; border-block: 1px solid #1f1f22; color: #6c6c72; }
.ri-list { margin: 0; padding: 4px 0; list-style: none; overflow: hidden; }
.ri-list li { display: flex; align-items: center; gap: 7px; padding: 2px 10px 2px 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-list li.dir { padding-left: 10px; color: #c8c8cc; }
.ri-list li.sel { background: #24331a; color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.ri-list .ic { font-style: normal; width: 12px; text-align: center; flex: none; }
.ic-comp { color: #C9A6FF; } .ic-img { color: #FFD84D; } .ic-vid { color: #5CC8FF; } .ic-aud { color: #FF8A3D; }
.ri-fxlist { margin: 0; padding: 4px 0; list-style: none; overflow: hidden; }
.ri-fxlist .fx-name { display: flex; align-items: center; gap: 6px; padding: 3px 10px; color: #d6d6da; }
.ri-fxlist .fx:not(.open) .tw { transform: rotate(-90deg); }
.ri-fxlist .tw { display: inline-block; width: 10px; color: #6c6c72; }
.ri-fxlist .fx-on { font-size: 9px; padding: 0 3px; border: 1px solid #3a3a40; border-radius: 2px; color: #8a8a90; }
.ri-fxlist .reset { margin-left: auto; color: #5a5a60; text-decoration: underline; }
.ri-fxlist .fx-p { display: flex; justify-content: space-between; padding: 2px 10px 2px 38px; }
.ri-fxlist .fx-p b { font-weight: 400; color: #5CA8FF; text-decoration: underline dotted; text-underline-offset: 2px; }
@media (max-width: 1100px) { .ri-screen { grid-template-columns: minmax(0, 1fr); } .ri-side { display: none; } }
/* 影片在中間的預覽區裡置中，四邊留 24px，保持 16:9 */
.ri-frame { position: absolute; inset: 0; margin: auto; width: min(100cqw - 48px, (100cqh - 48px) * 16 / 9); height: min(100cqh - 48px, (100cqw - 48px) * 9 / 16); }
.ri-panel { background: #141416; border: 1px solid var(--line); border-radius: 6px; transition: transform .6s cubic-bezier(.7,0,.2,1), opacity .4s ease; }
.tl-enter { min-height: 36px; padding: 0 14px; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 999px; font: inherit; font-weight: 500; cursor: pointer; }
.tl-enter:hover { filter: brightness(1.1); }

/* 開場時，首頁的 Reel 本身被固定到全螢幕的位置（位置由 js/intro.js 設定），所以不用重新載入影片 */
.reel-media.is-intro { position: fixed; z-index: 61; aspect-ratio: auto; }
.reel-media.is-intro .reel-sound { opacity: 0; pointer-events: none; }
.reel-media.flying { transition: left .95s cubic-bezier(.76,0,.24,1), top .95s cubic-bezier(.76,0,.24,1), width .95s cubic-bezier(.76,0,.24,1), height .95s cubic-bezier(.76,0,.24,1); }
.reel-sound { transition: opacity .4s ease; }

/* 離場：黑底淡掉、時間軸往下滑走、Reel 縮進首頁的格子 */
.reel-intro.leaving { background-color: transparent; pointer-events: none; }
.reel-intro.leaving .ri-panel { transform: translateY(130%); opacity: 0; }
.ri-side, .ri-stage { transition: opacity .4s ease, transform .6s cubic-bezier(.7,0,.2,1); }
.reel-intro.leaving .ri-stage { opacity: 0; }
.reel-intro.leaving .ri-project { transform: translateX(-110%); opacity: 0; }
.reel-intro.leaving .ri-fx { transform: translateX(110%); opacity: 0; }

/* 時間軸（開場面板用） */
.tl-head { display: flex; align-items: center; gap: 16px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); }
.tl-file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-tc { color: var(--accent); font-size: 15px; font-variant-numeric: tabular-nums; }
.tl-body { display: grid; grid-template-columns: 180px minmax(0, 1fr); }
.tl-labels { margin: 0; padding: 0; list-style: none; border-right: 1px solid var(--line); }
.tl-labels li, .tl-row { height: 22px; display: flex; align-items: center; border-bottom: 1px solid #1f1f22; }
.tl-labels li { gap: 10px; padding-left: 14px; color: var(--fg); letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; }
.tl-labels .n { width: 16px; color: var(--muted); flex: none; }
.tl-labels .sw { width: 8px; height: 8px; border-radius: 2px; background: var(--c, #555); flex: none; opacity: .8; }
.tl-labels li.on .n { color: var(--accent); }
.tl-tracks { position: relative; }
.tl-row { position: relative; }
.tl-row .tl-bar { position: absolute; top: 6px; bottom: 6px; background: #2A2A2D; border-radius: 2px; }
.tl-row .tl-bar { background: color-mix(in srgb, var(--c, #555) 22%, #1c1c1f); }
.tl-row.on .tl-bar { background: color-mix(in srgb, var(--c, #C6FF3D) 35%, #141416); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--accent); }
.playhead::before { content: ""; position: absolute; top: -6px; left: -5px; border: 6px solid transparent; border-top-color: var(--accent); }
@media (max-width: 640px) {
  .tl-body { grid-template-columns: 112px minmax(0, 1fr); }
  .tl-labels li { font-size: 11px; padding-left: 10px; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .reel-intro { display: none; }
  .reel-media.flying { transition: none; }
}

/* 玻璃效果（變數在 style.css） */
.w .cap {
  left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  padding: 10px 14px; border-radius: 6px;
  background: var(--glass-bg); border: 1px solid var(--glass-edge); box-shadow: var(--glass-hi);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.lab-tile .tag {
  background: var(--glass-bg); border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.ri-panel {
  background: rgba(14, 14, 16, 0.5); border-color: var(--glass-edge); box-shadow: var(--glass-hi);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}

/* 首頁作品格子：封面和預覽影片都對準正中間（全站預設是對齊下方） */
.works .w .media > img, .works .w .media > video { object-position: center; }
