/* ── Variables ─────────────────────────── */
:root {
  --bg:          #faf9f6;
  --surface:     #f3f1ec;
  --surface-2:   #eae8e1;
  --border:      #e2dfd7;
  --border-mid:  #c8c4ba;
  --text:        #1c1a17;
  --text-muted:  #6e6860;
  --text-dim:    #aba59a;
  --accent:      #2d5a3d;
  --accent-dim:  rgba(45, 90, 61, 0.08);

  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono:  'JetBrains Mono', monospace;

  --max-w:     820px;
  --header-h:  56px;
}

/* ── Reset ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
}

#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ── Header ────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  isolation: isolate;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--text);
  transition: color 0.2s;
}
.logo:hover { color: var(--accent); }
.logo span {
  display: inline-block;
}
@keyframes char-flip {
  0%   { opacity: 1; transform: scaleY(1); }
  40%  { opacity: 0; transform: scaleY(0); }
  60%  { opacity: 0; transform: scaleY(0); }
  100% { opacity: 1; transform: scaleY(1); }
}
.logo span.flipping {
  animation: char-flip 0.35s ease-in-out;
}

.site-header nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.site-header nav a {
  font-size: 0.825rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.site-header nav a:hover { color: var(--text); }

/* ── Main ──────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4rem 2rem 8rem;
}

/* ── Footer ────────────────────────────── */
footer { position: relative; z-index: 1; }
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}
.footer-links a {
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }

/* ── Hero ──────────────────────────────── */
.hero {
  padding: 4.5rem 0 5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5rem;
  display: flex;
  align-items: center;
  gap: 3.5rem;
}

.hero-photo {
  position: relative;
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}

.hero-photo-default,
.hero-photo-hover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}

.hero-photo-hover { opacity: 0; }
.hero-photo:hover .hero-photo-hover { opacity: 1; }
.hero-photo:hover .hero-photo-default { opacity: 0; }

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-intro {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.hero-intro strong {
  color: var(--accent);
  font-weight: 500;
}

.hero-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  font-weight: 300;
  line-height: 1.75;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.hero-location {
  font-size: 0.825rem;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

/* ── Section ───────────────────────────── */
.section {
  margin-bottom: 5rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.section > h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: 2.25rem;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 2rem;
}

.section-footer {
  margin-top: 1.25rem;
}
.section-footer a {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s;
}
.section-footer a:hover { color: var(--accent); }

.section-empty {
  font-size: 0.875rem;
  color: var(--text-dim);
  padding: 1.5rem 0;
}

/* ── Post List (homepage) ──────────────── */
.post-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.post-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.15s;
}
.post-row:hover { opacity: 0.6; }

.post-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.post-category {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.post-title {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Project Grid ──────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.project-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.project-card:hover {
  border-color: var(--border-mid);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.card-trigger {
  cursor: pointer;
  user-select: none;
}

.card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  position: relative;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.project-card:hover .card-image img {
  transform: scale(1.03);
}

.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 2rem;
  opacity: 0.45;
}

.card-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.card-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.card-icon {
  font-size: 1.1rem;
  color: var(--text-dim);
  line-height: 1;
  font-weight: 300;
  transition: transform 0.25s ease, color 0.2s;
}
.project-card.is-open .card-icon {
  transform: rotate(45deg);
  color: var(--accent);
}

.card-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.project-card.is-open .card-detail {
  max-height: 260px;
}

.card-detail-inner {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.card-detail p {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 0.875rem;
}

.card-links {
  display: flex;
  gap: 0.875rem;
  flex-wrap: wrap;
}

.card-link {
  font-size: 0.78rem;
  color: var(--accent);
  transition: opacity 0.15s;
}
.card-link:hover { opacity: 0.7; }

/* ── About ─────────────────────────────── */
.about-text {
  font-size: 0.9375rem;
  line-height: 1.85;
  color: var(--text-muted);
  max-width: 580px;
}
.about-text p + p { margin-top: 1.1rem; }

/* ── Career ────────────────────────────── */
.career-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.career-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}
.career-item:first-child { border-top: 1px solid var(--border); }

.career-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.career-role {
  font-size: 0.875rem;
  color: var(--text);
}

.career-company {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.career-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.career-period {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.career-duration {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.career-now {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
}

.featured-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
  margin-left: auto;
  white-space: nowrap;
}

/* ── Contact ───────────────────────────── */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.contact-item {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
}

.contact-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: 72px;
  flex-shrink: 0;
}

.contact-value {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.contact-value:hover { color: var(--accent); }

/* ── Category / Tags ───────────────────── */
.category {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.date {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.875rem; }
.tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  letter-spacing: 0.04em;
}

/* ── Category Nav (blog index) ─────────── */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.cat-btn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 2px;
  transition: all 0.15s;
  cursor: pointer;
}
.cat-btn:hover { border-color: var(--border-mid); color: var(--text); }
.cat-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Post Grid (blog index) ────────────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 1.5rem;
  transition: background 0.2s;
  position: relative;
}

.post-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.post-card:hover { background: var(--surface); }
.post-card:hover::after { transform: scaleX(1); }

.post-card img {
  height: 140px;
  object-fit: cover;
  margin: -1.5rem -1.5rem 1.25rem;
  width: calc(100% + 3rem);
  max-width: none;
}

.post-card .post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
}

.post-card h3 {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 0.5rem;
  flex: 1;
}

.post-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Article ───────────────────────────── */
.article { max-width: 680px; }

.cover {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 2.5rem;
}

.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.article-header .post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.article-header time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}
.article-header h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
}
.article-header .summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ── Prose ─────────────────────────────── */
.prose {
  font-size: 0.9375rem;
  line-height: 1.85;
  color: var(--text-muted);
}
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-serif);
  font-weight: 300;
  color: var(--text);
  margin: 2.25rem 0 1rem;
  letter-spacing: -0.01em;
}
.prose h2 { font-size: 1.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.2rem; }
.prose p { margin-bottom: 1.25rem; }
.prose a { color: var(--accent); border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.prose a:hover { border-bottom-color: var(--accent); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 2px;
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: 4px;
}
.prose pre code { background: none; border: none; padding: 0; font-size: 0.8rem; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
  color: var(--text-muted);
  margin: 1.75rem 0;
  font-style: italic;
}
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
.prose li { margin-bottom: 0.4rem; }
.prose img { border: 1px solid var(--border); margin: 1.75rem 0; border-radius: 4px; }
.prose figure { margin: 1.75rem 0; }
.prose figure img { margin: 0; }
.prose figcaption { font-size: 0.8rem; color: var(--text-dim); padding: 0.4rem 0 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.75rem 0; font-size: 0.875rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.875rem; text-align: left; }
.prose th { background: var(--surface); color: var(--text); font-weight: 500; font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* ── Misc ──────────────────────────────── */
.empty { font-size: 0.875rem; color: var(--text-dim); padding: 2rem 0; }
.hidden { display: none !important; }

/* ── Substack Embed ─────────────────────── */
.substack-embed {
  margin-top: 4rem;
  padding: 2rem 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.substack-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.substack-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}
.substack-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1.5rem;
  max-width: 400px;
}
.substack-embed iframe {
  display: block;
}
@media (max-width: 620px) {
  .substack-embed { padding: 1.5rem 1.25rem; }
  .substack-embed iframe { width: 100%; }
}

/* ── Animations ────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero    { animation: fadeUp 0.6s ease both; }
.section { animation: fadeUp 0.6s ease both; }
.section:nth-child(2) { animation-delay: 0.07s; }
.section:nth-child(3) { animation-delay: 0.14s; }
.section:nth-child(4) { animation-delay: 0.21s; }
.section:nth-child(5) { animation-delay: 0.28s; }
.section:nth-child(6) { animation-delay: 0.35s; }
.section:nth-child(7) { animation-delay: 0.42s; }

/* ── Responsive ─────────────────────────── */
@media (max-width: 620px) {
  .site-header { padding: 0 1.25rem; }
  .site-header nav { gap: 1.25rem; }
  main { padding: 3rem 1.25rem 5rem; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: 1rem; padding: 1.5rem 1.25rem; }
  .hero { padding: 3rem 0 3.5rem; margin-bottom: 3.5rem; flex-direction: column; align-items: flex-start; gap: 1.5rem; }
  .hero-photo { width: 110px; height: 110px; }
  .hero-photo-default, .hero-photo-hover { position: absolute; }
  .project-grid { grid-template-columns: 1fr; gap: 1rem; }
  .post-grid { grid-template-columns: 1fr; }
  .post-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .post-date { display: none; }
  .contact-item { flex-direction: column; gap: 0.25rem; }
  .contact-label { width: auto; }
  .career-item { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .career-right { align-items: flex-start; }
}
