:root {
  --font-serif: 'EB Garamond', 'Noto Serif TC', serif;
  --font-sans: 'Poppins', 'Noto Sans TC', sans-serif;
  --ink: #1a1a1a;
  --gap: 16px;
  --side-pad: 40px;
  --card-width: clamp(220px, 19vw, 383px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: var(--app-height, 100vh);
  min-height: 100svh;
  min-height: 100lvh;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }

/* Header */
.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 46px var(--side-pad) 0;
}

.logo {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: 0.3px;
}

.site-nav {
  display: flex;
  gap: 48px;
  padding-top: 6px;
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 300;
  letter-spacing: 0.2px;
  text-decoration: none;
  display: inline-block;
  padding-bottom: 5px;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover,
.site-nav a:active,
.site-nav a:focus-visible {
  border-bottom-color: currentColor;
}

/* Fills remaining viewport height and pins the track to the bottom,
   so the photo row always sits flush against the bottom of the page
   regardless of window size. */
.gallery {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 300px;
}

.gallery-track {
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
  padding: 0 var(--side-pad) calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  overflow-x: auto;
  cursor: grab;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.gallery-track:active {
  cursor: grabbing;
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

.project-card {
  flex: 0 0 var(--card-width);
  display: flex;
  flex-direction: column;
}

.project-tags {
  height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.project-tags li {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.5;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-tags li::before {
  content: '· ';
}

.project-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 3.9;
  overflow: hidden;
  background: #eee;
}

.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.project-thumb:hover img {
  transform: scale(1.03);
}

/* Project detail page — header floats over the hero photo column,
   which starts flush at the very top of the page. */
body.detail-page .site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 160;
}

body.detail-page main {
  flex: none;
}

.detail-layout {
  position: relative;
}

/* Positions below are proportions of the 2000x1191 reference canvas
   (內頁視覺), expressed as vw/vh so the text and photo columns stay
   coordinated with the header's right-aligned nav at any window size. */
.detail-text {
  position: absolute;
  left: 22.8vw;
  top: 56.7vh;
  width: min(320px, calc(17.15vw - 24px));
}

.detail-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  margin: 0 0 119px;
}

.detail-tags {
  display: flex;
  flex-direction: column;
}

.detail-tags li {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 300;
  line-height: 1.5;
  color: var(--ink);
}

.detail-tags li::before {
  content: '· ';
}

.detail-photos {
  margin-left: 39.95vw;
  padding: 0 var(--side-pad) var(--gap) 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-photos figure {
  margin: 0;
}

.detail-photos img {
  display: block;
  width: 100%;
  height: auto;
}

/* All photos share one width — the wider (landscape) measurement —
   regardless of orientation, so the column reads as a single even
   line instead of portrait photos looking narrower. */
.detail-photos .is-portrait,
.detail-photos .is-landscape {
  max-width: 36.65vw;
}

/* Lower-resolution photos are paired side-by-side, at roughly half
   the width, instead of shown full-size — smaller keeps them looking
   sharp rather than soft/blown-up. */
.photo-pair {
  display: flex;
  gap: 4px;
}

.photo-pair figure {
  flex: 1;
  min-width: 0;
}

@media (max-width: 1400px) {
  .detail-text {
    position: static;
    width: auto;
    padding: 46px var(--side-pad) 0;
    margin-bottom: 40px;
  }

  .detail-title {
    margin-bottom: 24px;
  }

  body.detail-page .site-header {
    position: static;
  }

  .detail-photos {
    margin-left: 0;
    padding: 0 var(--side-pad) var(--gap);
  }

  .detail-photos .is-portrait,
  .detail-photos .is-landscape {
    max-width: 100%;
  }
}

/* Simple content pages (about, contact) */
.simple-page {
  flex: 1;
  padding: clamp(140px, 22vw, 320px) var(--side-pad) 80px;
  max-width: 640px;
}

.simple-title {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 400;
  margin: 0 0 40px;
}

.simple-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.simple-list li {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.5;
  color: var(--ink);
}

.simple-list li::before {
  content: '· ';
}

.simple-list li a {
  display: inline-block;
  border-bottom: 1px solid transparent;
}

.simple-list li a:hover,
.simple-list li a:active,
.simple-list li a:focus-visible {
  border-bottom-color: currentColor;
}

@media (max-width: 768px) {
  .simple-page {
    padding-top: 140px;
  }

  .simple-title {
    font-size: 36px;
  }
}

/* Mobile menu toggle (hamburger) — hidden on desktop */
.menu-toggle {
  display: none;
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 1px;
  background: var(--ink);
  transition: transform 0.25s ease;
}

/* Scrim overlay for the open mobile menu — the actual page content
   stays in place underneath, just dimmed by a 90%-opacity white layer,
   rather than being replaced by a separate drawer screen. */
.menu-scrim {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  :root {
    --side-pad: 20px;
    --card-width: 68vw;
  }
  .logo { font-size: 24px; }
  .menu-toggle { display: flex; z-index: 210; }
  .site-header { position: relative; z-index: 160; }
  .project-tags { height: 92px; }
  .project-tags li { font-size: 13px; }

  .menu-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  body.menu-open .menu-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  body.menu-open .menu-toggle span:nth-child(1) {
    transform: translateY(3px) rotate(45deg);
  }

  body.menu-open .menu-toggle span:nth-child(2) {
    transform: translateY(-3px) rotate(-45deg);
  }

  /* Nav stays hidden until the menu opens, then appears top-right,
     stacked, on top of the scrim — matching the reference exactly. */
  .site-nav {
    display: none;
  }

  body.menu-open .site-nav {
    display: flex;
    position: fixed;
    top: 22.18vh;
    right: var(--side-pad);
    flex-direction: column;
    align-items: flex-end;
    gap: 4.03vh;
    z-index: 200;
  }
}
