/* ===========================================
   TOM CHU — PORTFOLIO STYLESHEET
   Colours and fonts are set as variables at the
   top — change them here and they update everywhere.
   =========================================== */

:root {
  --bg: #FAFAF8;
  --ink: #1A1A18;
  --ink-soft: #6B6A64;
  --line: #DEDDD6;
  --accent: #B5472A;
  --font-display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --max-width: 1200px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  cursor: url('images/cursor-dot.png') 12 12, auto;
}

/* On dark-background pages, swap to light cursor dot */
body.dark-bg {
  cursor: url('images/cursor-dot-light.png') 12 12, auto;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- HEADER ---------- */

.site-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo img {
  height: 44px;
  display: block;
}

.nav a {
  margin-left: 28px;
  font-size: 14px;
  color: var(--ink-soft);
}

.nav a:hover {
  color: var(--accent);
}

/* ---------- HERO (VIDEO BACKGROUND & IMAGE COMPATIBLE) ---------- */

.hero {
  min-height: 640px;
  display: flex;
  align-items: flex-end;
  background-size: cover;
  background-position: center;
  background-color: #EDECE6;
  position: relative;
  overflow: hidden;
}

.hero.hero-video-container {
  position: relative;
}

.hero-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.hero::after,
.hero.hero-video-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.15) 60%, rgba(0,0,0,0.3) 100%);
  z-index: 1;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 24px 56px;
  width: 100%;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 76px;
  line-height: 1.05;
  letter-spacing: 0.01em;
  max-width: 780px;
  color: #FAFAF8;
  text-transform: uppercase;
}

.hero-sub {
  margin-top: 18px;
  font-size: 16px;
  color: #FAFAF8;
  opacity: 0.85;
  max-width: 480px;
}

/* ---------- WORK GRID ---------- */

.work {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}

.project-tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #EDECE6;
}

.project-tile .frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.1s ease;
}

.project-tile .frame.active {
  opacity: 1;
}

.project-label {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-size: 18px;
  font-weight: 500;
  color: #FAFAF8;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.project-tile:hover .project-label {
  opacity: 1;
}

.project-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 0;
}

.project-tile:hover::before {
  opacity: 1;
}

/* ---------- MID-PAGE STATEMENT ---------- */

.statement {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
}

.statement-title {
  font-family: var(--font-display);
  font-size: 40px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.statement-sub {
  margin-top: 14px;
  font-size: 16px;
  color: var(--ink-soft);
}

/* ---------- ABOUT ---------- */

.about {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 60px 24px;
  border-top: 1px solid var(--line);
}

.about-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 48px;
  align-items: center;
}

.about-photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #EDECE6;
  display: block;
}

.about-text p {
  max-width: 560px;
  color: var(--ink-soft);
}

.about-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 32px;
  max-width: 560px;
}

.about-fact {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.about-fact-num {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.02em;
}

.about-fact-label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.about h2,
.contact h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.about p {
  max-width: 560px;
  color: var(--ink-soft);
}

/* ---------- CONTACT ---------- */

.contact {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.contact-link {
  display: inline-block;
  font-size: 16px;
  margin-right: 32px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}

.contact-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- FOOTER ---------- */

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 24px 48px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- DARK BACKGROUND VARIANT ---------- */

body.dark-bg .back-link,
body.dark-bg .project-subtitle,
body.dark-bg .nav a {
  color: rgba(250,250,248,0.7);
}

body.dark-bg .project-header h1 {
  color: #FAFAF8;
}

body.dark-bg .meta-card {
  border-color: rgba(250,250,248,0.25);
}

body.dark-bg .meta-label {
  color: rgba(250,250,248,0.55);
}

body.dark-bg .meta-value,
body.dark-bg .meta-summary {
  color: #FAFAF8;
}

body.dark-bg .project-nav {
  border-top-color: rgba(250,250,248,0.25);
}

body.dark-bg .project-nav-link,
body.dark-bg .site-footer p {
  color: rgba(250,250,248,0.7);
}

.back-link-row {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 24px 0;
}

.back-link {
  font-size: 14px;
  color: var(--ink-soft);
}

.back-link:hover {
  color: var(--accent);
}

.project-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.project-header h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 48px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.project-subtitle {
  margin-top: 6px;
  font-size: 15px;
  color: var(--ink-soft);
}

.detail-hero {
  min-height: 480px;
  display: flex;
  align-items: flex-end;
  background-size: cover;
  background-position: center;
  background-color: #EDECE6;
  position: relative;
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 55%);
}

.detail-hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 24px 40px;
  width: 100%;
}

.detail-hero-inner p {
  font-size: 20px;
  line-height: 1.5;
  max-width: 560px;
  color: #FAFAF8;
}

.meta-row {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 24px;
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 16px;
}

.meta-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.meta-label {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 14px;
}

.meta-label:first-child {
  margin-top: 0;
}

.meta-value {
  font-size: 16px;
  margin-top: 4px;
}

.meta-summary {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* ---------- MASONRY GALLERY (砌圖組合版：Project 03-12 用) ---------- */

.masonry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 24px;
  width: 100%;
}

.masonry img,
.masonry video {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 自動微裁切裁齊格仔 */
  display: block;
  background: #EDECE6;
}

/* 預設 1x1 方圖/影片 */
.masonry img:not([class]),
.masonry video:not([class]) {
  aspect-ratio: 1 / 1;
}

/* 橫圖 / 16:9 影片填滿 2 欄 */
.masonry .wide {
  grid-column: span 2;
  aspect-ratio: 2 / 1;
}

/* 直圖 / 直片 (跨 2 行) */
.masonry .tall {
  grid-row: span 2;
  aspect-ratio: 1 / 2;
}

/* 巨圖 2x2 (跨 2 欄 2 行正方形) */
.masonry .big {
  grid-column: span 2;
  grid-row: span 2;
  aspect-ratio: 1 / 1;
}

/* Poster 直圖 / 直片 (組合 G 專用) */
.masonry .poster {
  aspect-ratio: 3 / 4;
}

/* 16:9 影片專用（不裁切，完整 16:9 佔 2 欄） */
.masonry .video-16-9 {
  grid-column: span 2;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

/* ---------- 專門畀 Project 01 & 02 用嘅原圖彈性模式 ---------- */

.masonry.natural-ratio img,
.masonry.natural-ratio video {
  height: auto !important;
  aspect-ratio: unset !important;
  object-fit: contain !important;
}

/* ---------- PROJECT NAVIGATION & FOOTER ---------- */

.project-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: 24px;
  position: relative;
  z-index: 2;
  clear: both;
}

.project-nav-link {
  font-size: 15px;
}

.project-nav-link:hover {
  color: var(--accent);
}

/* ---------- MOBILE & TABLET ---------- */

@media (max-width: 900px) {
  .work {
    grid-template-columns: repeat(2, 1fr);
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .about-photo {
    max-width: 340px;
  }
}

@media (max-width: 640px) {
  .hero {
    min-height: 420px;
  }

  .hero h1 {
    font-size: 40px;
  }

  .statement-title {
    font-size: 28px;
  }

  .about-facts {
    grid-template-columns: 1fr;
  }

  .nav a {
    margin-left: 16px;
  }

  .project-header h1 {
    font-size: 32px;
  }

  .detail-hero {
    min-height: 320px;
  }

  .detail-hero-inner p {
    font-size: 16px;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }

  .project-nav {
    font-size: 14px;
  }
}