/* Theme variables */
:root {
  color-scheme: light;
  --bg: #fdfdfc;
  --text: #151515;
  --muted: #6e6e6e;
  --line: #dededb;
  --accent: #1e343e;
  --surface: #ffffff;
  --hover: #f5f5f2;
  --image-bg: #f0f0ed;
  --header-offset: 88px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141515;
  --text: #f1f0eb;
  --muted: #a7aaa9;
  --line: #3a3d3d;
  --accent: #d6e2df;
  --surface: #1a1c1c;
  --hover: #252727;
  --image-bg: #252727;
}

/* Base styles and navigation */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', 'Noto Sans TC', sans-serif;
  transition: background .2s, color .2s;
  line-height: 1.75;
}

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

button {
  font: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.serif {
  font-family: 'Playfair Display', Georgia, 'Noto Sans TC', serif;
}

.container {
  width: min(1200px, calc(100% - 72px));
  margin: auto;
}

.site-header {
  height: 88px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
}

.nav {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 100%;
}

.brand {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.6px;
  white-space: nowrap;
}

.menu {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-left: auto;
}

.menu a {
  font-size: 14px;
  font-weight: 600;
}

.menu a:hover,
.contact-link:hover {
  opacity: .62;
}

.theme-button {
  height: 43px;
  width: 43px;
  flex: 0 0 43px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
}

.theme-button:hover {
  background: var(--hover);
}

/* Split Hero; data-hero-variant="b" remains the legacy centered preview. */
.hero {
  padding: 72px 0;
  border-bottom: 1px solid var(--line);
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 35vw, 440px);
  align-items: center;
  gap: 40px;
  max-width: 1080px;
}

.hero h1 {
  font-size: clamp(56px, 7vw, 100px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -3px;
  margin: 0;
}

.hero h1 span {
  display: block;
}

.hero-figure {
  width: 100%;
  aspect-ratio: 4 / 5;
  justify-self: end;
  margin: 0;
  overflow: hidden;
  background: var(--image-bg);
}

.hero-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 42%;
}

.hero[data-hero-variant="b"] .hero-layout {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 38px;
}

.hero[data-hero-variant="b"] h1 {
  text-align: center;
  font-size: clamp(48px, 6vw, 88px);
}

.hero[data-hero-variant="b"] h1 span {
  display: inline;
}

.hero[data-hero-variant="b"] .hero-figure {
  width: min(100%, 720px);
  aspect-ratio: 16 / 9;
  justify-self: center;
}

.hero[data-hero-variant="b"] .hero-photo {
  object-position: 50% 48%;
}

@media (min-width: 801px) {
  .hero[data-hero-variant="a"] .hero-photo {
    object-position: 50% 36%;
  }
}

/* About and section typography */
.section {
  padding: 71px 0 83px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: var(--header-offset);
}

.section-title {
  font-size: 34px;
  letter-spacing: -1.4px;
  font-weight: 700;
  margin: 0 0 40px;
  line-height: 1.3;
}

.about-copy {
  max-width: 1200px;
  font-size: 18px;
  line-height: 1.95;
}

#about > .container > .about-copy {
  max-width: 1200px;
}

.about-copy p {
  margin: 0 0 22px;
}

.about-copy p:last-child {
  margin-bottom: 0;
}

.no-break {
  white-space: nowrap;
}

.about-english {
  max-width: 1200px;
  margin-top: 30px;
  padding-top: 29px;
  border-top: 1px solid var(--line);
}

/* Selected Article */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.article-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background .2s;
}

.article-card:hover {
  background: var(--hover);
}

.media-frame {
  background: var(--image-bg);
  overflow: hidden;
}

.media-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.article-image {
  aspect-ratio: 16 / 10;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.article-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
}

.article-title {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: -.2px;
  margin: 0;
  overflow-wrap: anywhere;
}

.article-copy {
  flex: 1;
  min-width: 0;
}

.article-category {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 10px;
}

.article-arrow {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.125;
}

/* Independent featured showcase */
.lab-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
}

.lab-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  margin: 0;
  padding: 32px;
  background: var(--hover);
  border-right: 1px solid var(--line);
}

.lab-image {
  aspect-ratio: 1366 / 768;
  border: 1px solid var(--line);
}

.lab-content {
  align-self: center;
  min-width: 0;
  padding: 36px;
}

.lab-content h3 {
  font-size: 42px;
  letter-spacing: -1.4px;
  line-height: 1.2;
  margin: 0 0 20px;
}

.lab-description,
.lab-features {
  font-size: 13px;
  line-height: 1.95;
}

.lab-description {
  margin: 0 0 18px;
}

.lab-features {
  padding-left: 18px;
  margin: 0 0 24px;
}

.lab-features li + li {
  margin-top: 5px;
}

.chain-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chain-list span {
  font-size: 10px;
  padding: 4px 9px;
  border: 1px solid var(--line);
}

/* Selected Project */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.project-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
}

.project-image {
  aspect-ratio: 16 / 9;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.project-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 28px;
}

.project-card h3 {
  font-size: 25px;
  line-height: 1.45;
  letter-spacing: -.5px;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.project-ampersand {
  font-family: 'DM Sans', sans-serif;
}

.project-role {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  margin: 0 0 18px;
}

.project-copy {
  font-size: 15px;
  line-height: 1.9;
  margin: 0 0 24px;
}

.project-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
}

.project-media-links {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  max-width: 100%;
}

.project-link {
  display: inline-block;
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 10px 15px;
  transition: background .2s, color .2s;
}

.project-link:hover {
  background: var(--text);
  color: var(--bg);
}

.project-card .project-link,
.project-media {
  display: inline-block;
  font-size: 14px;
  line-height: 1.7;
  white-space: nowrap;
  padding: 0;
  border: 0;
  background: transparent;
}

.project-media {
  color: var(--muted);
}

.project-card .project-link:hover,
.project-media:hover {
  color: var(--text);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Existing Contact and Footer */
.contact {
  text-align: center;
  padding: 85px 0 105px;
  scroll-margin-top: var(--header-offset);
}

.contact .section-title {
  margin-bottom: 25px;
}

.contact p {
  max-width: 650px;
  color: var(--muted);
  font-size: 14px;
  margin: 0 auto 35px;
}

.contact-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.contact-link {
  border: 1px solid var(--line);
  padding: 12px 24px;
  font-size: 14px;
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 42px 0;
}

.footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.footer-quote {
  max-width: 1200px;
  margin: 0;
  font-size: 18px;
  line-height: 1.85;
  color: var(--text);
}

/* Tablet layout */
@media (max-width: 900px) {
  .articles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lab-showcase {
    grid-template-columns: 1fr;
  }

  .lab-visual {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 800px) {
  .hero-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 44px;
  }

  .container {
    width: min(1200px, calc(100% - 40px));
  }

  .nav {
    gap: 24px;
  }

  .menu {
    gap: 18px;
  }
}

/* Mobile layout */
@media (max-width: 600px) {
  :root {
    --header-offset: 111px;
  }

  .site-header {
    height: auto;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 16px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brand {
    font-size: 21px;
  }

  .theme-button {
    grid-column: 2;
    grid-row: 1;
    width: 35px;
    height: 35px;
    font-size: 19px;
  }

  .menu {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
  }

  .menu a {
    font-size: 11px;
  }

  .hero {
    padding: 48px 0 56px;
  }

  .hero-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .hero h1 {
    font-size: clamp(48px, 14vw, 60px);
    letter-spacing: -1.7px;
  }

  .hero-figure {
    width: min(100%, 300px);
    justify-self: center;
  }

  .hero[data-hero-variant="b"] .hero-layout {
    gap: 28px;
  }

  .hero[data-hero-variant="b"] h1 {
    font-size: clamp(34px, 10.3vw, 44px);
    letter-spacing: -1px;
  }

  .hero[data-hero-variant="b"] .hero-figure {
    width: 100%;
    aspect-ratio: 4 / 3;
  }

  .section {
    padding: 52px 0 65px;
  }

  .section-title {
    font-size: 29px;
    margin-bottom: 30px;
  }

  .about-copy {
    font-size: 17px;
    line-height: 1.95;
  }

  .articles-grid,
  .projects-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .article-content,
  .project-content,
  .lab-content {
    padding: 24px;
  }

  .article-title {
    font-size: 21px;
  }

  .article-category {
    font-size: 12px;
  }

  .lab-visual {
    padding: 20px;
  }

  .lab-content h3 {
    font-size: 36px;
  }

  .project-card h3 {
    font-size: 23px;
  }

  .contact {
    padding: 66px 0 85px;
  }

  .contact-link {
    font-size: 12px;
    padding: 10px 15px;
  }

  .footer-quote {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}
