/* ---------------------------------------------------------------
   Channing Chen — personal site
   Typography-led, text-first. All legacy class names are preserved
   so existing pages keep working; only their presentation changed.
   --------------------------------------------------------------- */

:root {
  --bg: #fdfdfc;
  --text: #1c1c1a;
  --muted: #74736d;
  --faint: #9a998f;
  --rule: #e6e5df;
  --rule-soft: #f0efe9;
  --surface: #f6f5f0;

  --measure: 34rem;      /* comfortable reading width */
  --container: 44rem;    /* page width, images may fill this */
  --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --text: #e9e8e3;
    --muted: #97968e;
    --faint: #6f6e67;
    --rule: #2a2a27;
    --rule-soft: #201f1d;
    --surface: #1b1b19;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.75;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

/* Links: understated, underline as the only signal */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--rule);
  transition: text-decoration-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 1px;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 4rem 0;
}

/* ---------------------------------------------------------------
   Shell
   --------------------------------------------------------------- */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 4.5rem var(--gutter) 6rem;
}

/* ---------------------------------------------------------------
   Site header / navigation
   --------------------------------------------------------------- */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem 2rem;
  flex-wrap: wrap;
  margin-bottom: 5rem;
}

.site-name {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.site-name:hover {
  opacity: 0.6;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-nav a {
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
}

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

.site-nav a[aria-current='page'] {
  color: var(--text);
}

/* ---------------------------------------------------------------
   Homepage intro
   --------------------------------------------------------------- */

.intro {
  max-width: var(--measure);
  margin-bottom: 4.5rem;
}

.intro h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.021em;
  line-height: 1.2;
  margin-bottom: 0.4rem;
}

.intro-role {
  font-size: 1.0625rem;
  color: var(--muted);
  margin-bottom: 2.25rem;
}

.intro p + p {
  margin-top: 1.4rem;
}

.intro-portrait {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 2rem;
  filter: saturate(0.92);
}

/* ---------------------------------------------------------------
   Currently / Previously — label + entries
   --------------------------------------------------------------- */

.record {
  margin-bottom: 3.5rem;
}

.record-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 1.5rem;
}

.record-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 2rem;
  align-items: baseline;
  padding: 1.05rem 0;
  border-top: 1px solid var(--rule-soft);
}

.record-item:last-child {
  border-bottom: 1px solid var(--rule-soft);
}

.record-title {
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.45;
}

.record-when {
  font-size: 0.875rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.record-detail {
  grid-column: 1 / -1;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--muted);
  max-width: var(--measure);
}

/* ---------------------------------------------------------------
   Work page — numbered, substantial project entries
   --------------------------------------------------------------- */

.page-heading {
  max-width: var(--measure);
  margin-bottom: 4.5rem;
}

.page-heading h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.page-heading p {
  color: var(--muted);
  font-size: 1rem;
}

.project-entry {
  padding-top: 3.5rem;
  margin-bottom: 4.5rem;
  border-top: 1px solid var(--rule);
}

.project-entry:first-of-type {
  border-top: none;
  padding-top: 0;
}

.project-index {
  font-size: 0.8125rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  margin-bottom: 0.9rem;
}

.project-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.project-meta {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 2.25rem;
}

.project-body {
  max-width: var(--measure);
}

.project-body p {
  margin-bottom: 1.4rem;
}

.project-body p:last-child {
  margin-bottom: 0;
}

.project-body h3 {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 2.5rem;
  margin-bottom: 0.6rem;
}

.project-tools {
  font-size: 0.9375rem;
  color: var(--muted);
}

/* Images sit in the page, not in cards — full container width */
.project-figure {
  margin: 2.5rem 0;
  max-width: none;
}

.project-figure img {
  width: 100%;
  border-radius: 2px;
  background: var(--surface);
}

.project-figure img + img {
  margin-top: 0.75rem;
}

.project-figure--narrow {
  max-width: 34rem;
}

.project-figure figcaption {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--faint);
  margin-top: 0.85rem;
  max-width: var(--measure);
}

/* Legacy home-page card list (kept for compatibility) */
.project-list {
  display: flex;
  flex-direction: column;
}

.project-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 2rem;
  align-items: baseline;
  padding: 1.05rem 0;
  border-top: 1px solid var(--rule-soft);
}

.project-card a {
  font-weight: 500;
  text-decoration: none;
}

.project-card a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.line-separator {
  display: none;
}

.project-description {
  grid-column: 1 / -1;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--muted);
  max-width: var(--measure);
}

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

.section {
  margin-bottom: 4rem;
}

.section:last-of-type {
  margin-bottom: 0;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 3.5rem;
  margin-bottom: 1.5rem;
}

.section-title:first-child {
  margin-top: 0;
}

.prose {
  max-width: var(--measure);
}

.prose p {
  margin-bottom: 1.4rem;
}

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

/* ---------------------------------------------------------------
   Resume page
   --------------------------------------------------------------- */

.resume-actions {
  margin-bottom: 0.4rem;
  font-size: 0.9375rem;
}

.resume-availability {
  font-size: 0.9375rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.resume-item {
  padding: 1.75rem 0;
  border-top: 1px solid var(--rule-soft);
}

.resume-item:last-child {
  border-bottom: 1px solid var(--rule-soft);
}

.resume-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 2rem;
  flex-wrap: wrap;
}

.resume-role {
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.45;
}

.resume-date {
  font-size: 0.875rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.resume-org {
  font-size: 0.9375rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.resume-item ul {
  list-style: none;
  max-width: var(--measure);
}

.resume-item li {
  position: relative;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--muted);
  padding-left: 1.05rem;
  margin-bottom: 0.45rem;
}

.resume-item li:last-child {
  margin-bottom: 0;
}

.resume-item li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 4px;
  height: 1px;
  background: var(--faint);
}

.resume-skills {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 0.5rem;
  max-width: var(--measure);
}

.resume-skills:last-child {
  margin-bottom: 0;
}

.resume-skills strong {
  color: var(--text);
  font-weight: 500;
}

/* ---------------------------------------------------------------
   Now page
   --------------------------------------------------------------- */

.now-content {
  max-width: var(--measure);
}

.now-content p {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.now-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 2.75rem;
  margin-bottom: 1rem;
}

.now-updated {
  font-size: 0.875rem;
  color: var(--faint);
  margin-top: 2rem;
}

/* ---------------------------------------------------------------
   Contact
   --------------------------------------------------------------- */

.contact-list {
  max-width: var(--measure);
}

.contact-row {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule-soft);
  align-items: baseline;
}

.contact-row:last-child {
  border-bottom: 1px solid var(--rule-soft);
}

.contact-key {
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.contact-value {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------
   Blog
   --------------------------------------------------------------- */

.blog-list {
  max-width: var(--measure);
}

.blog-entry {
  padding: 1.75rem 0;
  border-top: 1px solid var(--rule-soft);
}

.blog-entry:last-child {
  border-bottom: 1px solid var(--rule-soft);
}

.blog-title {
  font-size: 1.1875rem;
  font-weight: 500;
  line-height: 1.4;
  display: block;
  margin-bottom: 0.3rem;
  text-decoration: none;
}

.blog-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.blog-date {
  font-size: 0.8125rem;
  color: var(--faint);
  display: block;
  margin-bottom: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.blog-excerpt {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--muted);
}

.blog-empty {
  font-size: 1rem;
  color: var(--muted);
}

/* Individual post */
.blog-post {
  max-width: var(--measure);
}

.blog-post-header {
  margin-bottom: 2.5rem;
}

.blog-post-title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.blog-post-date {
  font-size: 0.875rem;
  color: var(--faint);
  display: block;
}

.blog-post-content p {
  margin-bottom: 1.5rem;
}

.blog-post-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.85rem;
}

.blog-post-content ul,
.blog-post-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.25rem;
}

.blog-post-content li {
  margin-bottom: 0.45rem;
}

.blog-post-content blockquote {
  border-left: 1px solid var(--rule);
  padding-left: 1.5rem;
  margin: 2rem 0;
  color: var(--muted);
}

.blog-post-content pre {
  background-color: var(--surface);
  border-radius: 2px;
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.blog-post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875rem;
}

.blog-post-footer {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.back-link {
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
}

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

/* ---------------------------------------------------------------
   Gallery (behaviour preserved)
   --------------------------------------------------------------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.photo-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--surface);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.25s ease;
}

.photo-item:hover img {
  opacity: 0.88;
}

.photo-caption-overlay {
  position: absolute;
  inset: auto 0 0 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
  color: #fff;
  padding: 1.5rem 1rem 0.9rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.photo-item:hover .photo-caption-overlay {
  opacity: 1;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(10, 10, 9, 0.96);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.lightbox img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.lightbox-caption {
  color: #d8d7d1;
  font-size: 0.9375rem;
  margin-top: 1.25rem;
  text-align: center;
  max-width: 34rem;
  line-height: 1.6;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  padding: 0.5rem;
  transition: opacity 0.2s ease;
}

.lightbox-close:hover {
  opacity: 0.6;
}

/* ---------------------------------------------------------------
   Footer
   --------------------------------------------------------------- */

.site-footer {
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem 2rem;
  flex-wrap: wrap;
}

.site-footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.site-footer a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

.site-footer-meta {
  font-size: 0.875rem;
  color: var(--faint);
}

/* Legacy footer element, restyled to match */
.last-updated {
  font-size: 0.875rem;
  color: var(--faint);
  margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */

@media (max-width: 40rem) {
  :root {
    --gutter: 1.25rem;
  }

  body {
    font-size: 1rem;
    line-height: 1.7;
  }

  .container {
    padding: 2.5rem var(--gutter) 4rem;
  }

  .site-header {
    margin-bottom: 3.5rem;
    gap: 0.75rem;
  }

  .site-nav {
    gap: 1.125rem;
  }

  .site-nav a,
  .site-name {
    font-size: 0.9375rem;
  }

  .intro h1 {
    font-size: 1.75rem;
  }

  .intro,
  .record {
    margin-bottom: 3rem;
  }

  .page-heading {
    margin-bottom: 3rem;
  }

  .page-heading h1 {
    font-size: 1.5rem;
  }

  .project-entry {
    padding-top: 2.5rem;
    margin-bottom: 3.5rem;
  }

  .project-title,
  .blog-post-title {
    font-size: 1.3125rem;
  }

  .project-figure {
    margin: 1.75rem 0;
  }

  /* Stack the date under the title on narrow screens */
  .record-item,
  .project-card,
  .resume-item-head {
    grid-template-columns: 1fr;
    display: block;
  }

  .record-when,
  .resume-date {
    display: block;
    margin-top: 0.15rem;
  }

  .record-detail,
  .project-description {
    margin-top: 0.35rem;
  }

  .contact-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .lightbox {
    padding: 1.25rem;
  }

  hr {
    margin: 3rem 0;
  }

  .site-footer,
  .last-updated {
    margin-top: 4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
