/* ============================================
   Personal Website — Styles
   ============================================ */

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

:root {
  --color-text: #111827;
  --color-text-secondary: #6B7280;
  --color-text-muted: #9CA3AF;
  --color-bg: #FFFFFF;
  --color-surface: #F9FAFB;
  --color-border: #E5E7EB;
  --color-accent: #8B5CF6;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 1080px;
  --max-width-article: 1100px;
  --content-width: 680px;
}

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

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Mobile Nav --- */
.mobile-nav {
  display: none;
}

.menu-toggle {
  display: none;
}

.menu-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 40px;
  height: 40px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

.menu-toggle:checked ~ .menu-btn span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle:checked ~ .menu-btn span:nth-child(2) {
  opacity: 0;
}
.menu-toggle:checked ~ .menu-btn span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-menu {
  position: fixed;
  top: 0;
  right: -240px;
  width: 240px;
  height: 100%;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  z-index: 99;
  padding: 72px 24px 24px;
  transition: right 0.25s ease;
  box-shadow: -4px 0 16px rgba(0,0,0,0.06);
}

.menu-toggle:checked ~ .mobile-menu {
  right: 0;
}

.mobile-menu ul {
  list-style: none;
}

.mobile-menu li {
  margin: 0;
}

.mobile-menu a {
  color: var(--color-text);
  font-size: 1.05rem;
  font-weight: 500;
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}

.mobile-menu a:hover,
.mobile-menu a:active {
  color: var(--color-accent);
  text-decoration: none;
}

/* --- Hero Banner --- */
.hero-banner {
  background: linear-gradient(135deg, #8B5CF6 0%, #C084FC 40%, #E879F9 70%, #F472B6 100%);
  height: 180px;
}

/* --- Profile Header --- */
.profile-header {
  margin-bottom: 40px;
}

.profile-photo {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  margin-top: -70px;
  object-fit: cover;
  background: linear-gradient(135deg, #8B5CF6, #C084FC);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}

.profile-photo-img {
  background: var(--color-surface);
}

.profile-name {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 12px;
  letter-spacing: -0.02em;
}

/* --- Intro Section --- */
.intro-section {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 48px;
  align-items: start;
  margin-bottom: 40px;
}

.intro-bio h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.intro-bio p {
  color: var(--color-text-secondary);
  margin-bottom: 14px;
  line-height: 1.7;
}

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

/* --- Quick Links --- */
.quick-links {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 24px;
  margin-top: 8px;
}

.quick-links h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}

.quick-links ul {
  list-style: none;
}

.quick-links li {
  margin-bottom: 8px;
}

.quick-links a {
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.95rem;
}

.quick-links a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0 0 40px;
}

/* --- Writing Section --- */
.writing-section { margin-bottom: 60px; }

.section-heading {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.section-desc {
  color: var(--color-text-secondary);
  margin-bottom: 32px;
  max-width: var(--content-width);
}

.subsection-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

/* --- Cards --- */
.card {
  display: block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  color: var(--color-text);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  text-decoration: none;
  border-color: #D1D5DB;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.card-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--color-surface);
}

.card-accent {
  height: 4px;
  background: linear-gradient(90deg, #8B5CF6 0%, #C084FC 40%, #E879F9 70%, #F472B6 100%);
  border-radius: 12px 12px 0 0;
}

.card-body { padding: 16px 20px 20px; }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-date {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* --- Pinned Grid --- */
.pinned-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 48px;
}

.card-pinned {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 280px;
}

.card-pinned .card-cover {
  aspect-ratio: auto;
  height: 100%;
  border-radius: 12px 0 0 12px;
}

.card-pinned .card-body { padding: 24px; }

.card-pinned .card-title { font-size: 1.2rem; }

/* --- Posts Grid --- */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.card-post .card-cover {
  aspect-ratio: 16 / 9;
}

.card-post .card-body { padding: 14px 16px 16px; }

.card-post .card-title { font-size: 0.95rem; }

/* --- Article Nav --- */
.article-nav {
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
}

.back-link {
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.95rem;
}

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

/* --- Article Cover --- */
.article-cover {
  width: 100%;
}

.article-cover img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  display: block;
}

/* --- Article Layout --- */
.article-container {
  max-width: var(--max-width-article);
  display: grid;
  grid-template-columns: minmax(0, var(--content-width)) 200px;
  gap: 48px;
  align-items: start;
  padding-top: 40px;
  padding-bottom: 60px;
}

.article-main { min-width: 0; }

/* --- Article Header --- */
.article-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.article-header h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.article-author { font-weight: 500; }

/* --- Article Body --- */
.article-body {
  font-size: 1.1rem;
  line-height: 1.8;
}

.article-body p { margin-bottom: 1.25em; }

.article-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  padding-top: 1em;
  border-top: 1px solid var(--color-border);
  letter-spacing: -0.01em;
}

.article-body h2:first-child,
.article-body > p:first-child + h2 {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.article-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2em;
  margin-bottom: 0.5em;
}

.article-body strong { font-weight: 600; }

.article-body em { font-style: italic; }

.article-body ul, .article-body ol {
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

.article-body li { margin-bottom: 0.5em; }

.article-body blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 20px;
  margin: 1.5em 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.article-body figure {
  margin: 2em 0;
}

.article-body figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 8px;
  text-align: center;
}

.article-body img {
  border-radius: 8px;
  margin: 0 auto;
}

.article-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Table of Contents --- */
.toc {
  position: sticky;
  top: 32px;
  padding-top: 8px;
}

.toc ul { list-style: none; }

.toc li { margin-bottom: 8px; }

.toc .toc-sub { padding-left: 14px; }

.toc a {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  display: block;
  border-left: 2px solid transparent;
  padding-left: 12px;
  transition: color 0.15s, border-color 0.15s;
}

.toc a:hover {
  color: var(--color-text);
  text-decoration: none;
}

.toc a.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .hero-banner { height: 140px; }

  .profile-name { font-size: 1.5rem; }

  .intro-section {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .quick-links { display: none; }

  .mobile-nav { display: block; }

  .article-container {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 24px;
  }

  .toc { display: none; }

  .article-header h1 { font-size: 1.75rem; }

  .article-body { font-size: 1rem; }

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

  .card-pinned {
    grid-template-columns: 1fr;
  }

  .card-pinned .card-cover {
    aspect-ratio: 16 / 9;
    border-radius: 12px 12px 0 0;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero-banner { height: 120px; }
  .profile-photo { width: 88px; height: 88px; margin-top: -44px; }
}
