/* ===========================
   Font: Source Han Sans SC (self-hosted, subset)
   =========================== */

@font-face {
  font-family: 'Source Han Sans SC';
  src: url('fonts/SourceHanSansSC-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+4E00-9FFF, U+3000-303F, U+FF00-FFEF, U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Source Han Sans SC';
  src: url('fonts/SourceHanSansSC-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+4E00-9FFF, U+3000-303F, U+FF00-FFEF, U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===========================
   CSS Variables: Theme
   =========================== */

:root {
  --font-primary: 'Source Han Sans SC', 'Noto Sans SC', -apple-system, 'Microsoft YaHei', 'PingFang SC', sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace;

  --bg-primary: #FFFFFF;
  --bg-card: #F3F3F3;
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --accent: #0078D4;
  --accent-hover: #106EBE;
  --border: #E0E0E0;
  --sidebar-bg: #F3F3F3;
  --overlay: rgba(0, 0, 0, 0.4);
  --header-bg: #FFFFFF;
  --tag-bg: #E8E8E8;
  --tag-hover: #D0D0D0;

  --sidebar-width: 280px;
  --header-height: 56px;
  --transition-speed: 0.3s;
}

/* ===========================
   Dark Mode
   =========================== */

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #000000;
    --bg-card: #2D2D2D;
    --text-primary: #FFFFFF;
    --text-secondary: #CCCCCC;
    --accent: #4C9AFF;
    --accent-hover: #6BAEFF;
    --border: #3D3D3D;
    --sidebar-bg: #1A1A1A;
    --overlay: rgba(0, 0, 0, 0.6);
    --header-bg: #000000;
    --tag-bg: #2D2D2D;
    --tag-hover: #3D3D3D;
  }
}

/* ===========================
   Reset & Base
   =========================== */

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

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

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

body.sidebar-open {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-speed);
}

a:hover {
  color: var(--accent-hover);
}

ul {
  list-style: none;
}

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

/* ===========================
   Header
   =========================== */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Hamburger menu */
.menu-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
}

.menu-icon {
  position: relative;
  width: 24px;
  height: 24px;
}

.menu-bar {
  position: absolute;
  left: 0;
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  transition: transform var(--transition-speed), opacity var(--transition-speed), background-color var(--transition-speed);
}

.menu-bar:nth-child(1) { top: 3px; }
.menu-bar:nth-child(2) { top: 11px; }
.menu-bar:nth-child(3) { top: 19px; }

/* Menu open state — animate to X */
.menu-btn.open .menu-bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.menu-btn.open .menu-bar:nth-child(2) {
  opacity: 0;
}

.menu-btn.open .menu-bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Language switcher */
.lang-switcher {
  display: flex;
  gap: 2px;
}

.lang-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: color var(--transition-speed), background-color var(--transition-speed);
  border-radius: 0;
}

.lang-btn:hover {
  color: var(--accent);
  background-color: var(--bg-card);
}

.lang-btn.active {
  color: var(--accent);
  font-weight: 700;
}

/* ===========================
   Sidebar Overlay
   =========================== */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--overlay);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed);
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ===========================
   Sidebar
   =========================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  max-width: 80vw;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform var(--transition-speed), background-color var(--transition-speed), border-color var(--transition-speed);
  padding-top: var(--header-height);
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-nav {
  padding: 0.5rem 0;
}

.sidebar-link {
  display: block;
  padding: 0.875rem 1.5rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background-color: var(--bg-card);
  color: var(--accent);
}

.sidebar-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background-color: var(--bg-card);
}

/* ===========================
   Main Content
   =========================== */

.main {
  padding-top: var(--header-height);
  min-height: 100vh;
  transition: background-color var(--transition-speed);
}

/* ===========================
   Page System
   =========================== */

.page {
  display: none;
  min-height: calc(100vh - var(--header-height));
  animation: pageFadeIn 0.25s ease;
}

.page.active {
  display: flex;
  flex-direction: column;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.page-header {
  padding: 2rem 1.5rem 1rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 1.5rem;
}

/* Shared body wrapper for centered page sections */
.page-body {
  width: 100%;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ===========================
   Hero Section
   =========================== */

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  text-align: center;
  position: relative;
}

@media (min-width: 640px) {
  .hero {
    padding: 4rem 2rem;
  }
}

.hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ===========================
   Word Cloud
   =========================== */

.wordcloud-bg {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s ease;
}

.wordcloud-bg.wc-visible {
  opacity: 1;
}

.wordcloud-track {
  display: flex;
  height: 100%;
  animation: wc-scroll 70s linear infinite;
  will-change: transform;
}

@keyframes wc-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.wc-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.wc-row {
  display: flex;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.wc-word {
  color: var(--text-secondary);
  opacity: 0.35;
  font-family: var(--font-primary);
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-block;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .wordcloud-track {
    animation-play-state: paused;
  }
}

/* ===========================
   Small Screens (< 400px)
   =========================== */

@media (max-width: 400px) {
  .avatar {
    width: 96px;
    height: 96px;
    margin-bottom: 1rem;
  }

  .hero-name {
    font-size: 1.75rem;
  }

  .hero-tagline {
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
  }

  .hero-links {
    gap: 0.5rem;
  }

  .hero-link {
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    gap: 0.5rem;
  }

  .hero-link-icon {
    width: 16px;
    height: 16px;
  }

  .project-card {
    padding: 0.75rem;
  }

  .project-name {
    font-size: 1.0625rem;
  }
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1.5rem;
  user-select: none;
  display: block;
}

.hero-name {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.hero-tagline {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 480px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 2rem;
  background-color: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-speed);
  line-height: 1;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: #FFFFFF;
}

/* ===========================
   Hero Links Card
   =========================== */

.hero-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 520px;
}

.hero-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background-color: var(--accent);
  color: #FFFFFF;
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  min-height: 44px;
  transition: background-color var(--transition-speed);
  border-radius: 0;
}

.hero-link:hover {
  background-color: var(--accent-hover);
  color: #FFFFFF;
}

.hero-link-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.hero-link-name {
  flex-shrink: 0;
}

.hero-link-user {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===========================
   Social Bar (Footer)
   =========================== */

.icp-placeholder {
  text-align: center;
  padding: 0.75rem 1.5rem 1.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===========================
   Projects Page
   =========================== */

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 0 1.5rem 2rem;
}

.project-card {
  position: relative;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1rem;
  transition: border-color var(--transition-speed), background-color var(--transition-speed);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  min-height: 0;
}

/* Full-card link overlay: makes the whole card an <a>, so the browser
   natively supports middle-click / ctrl-click to open in a new tab. */
.project-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.project-card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.project-card:hover {
  border-color: var(--accent);
}

/* ---- Project status indicator ---- */
.project-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.status-stable .status-dot  { background: #1E90FF; }
.status-stable .status-label { color: #1E90FF; }
.status-developing .status-dot  { background: #FF8C00; }
.status-developing .status-label { color: #FF8C00; }
.status-suspended .status-dot  { background: #888; }
.status-suspended .status-label { color: #888; }
.status-laboratory .status-dot  { background: #DC143C; }
.status-laboratory .status-label { color: #DC143C; }

/* ---- Personal status bar ---- */
.status-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem auto 0;
  padding: 0.5rem 1rem;
  max-width: fit-content;
}
.status-bar-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FF8C00;
  animation: status-pulse 2s ease-in-out infinite;
}
@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.status-bar-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.project-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.project-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  flex: 1;
  line-height: 1.7;
}



/* ===========================
   Plans Page
   =========================== */

.plans-content {
  padding: 0 1.5rem 2rem;
  flex: 1;
}

.plans-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.8;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tag {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: var(--tag-bg);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: border-color var(--transition-speed), background-color var(--transition-speed), color var(--transition-speed);
  user-select: none;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===========================
   Markdown Content
   =========================== */

.plans-markdown {
  line-height: 1.8;
  color: var(--text-primary);
}

.plans-markdown h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 1.75rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
}

.plans-markdown h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}

.plans-markdown h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

.plans-markdown p {
  margin-bottom: 0.75rem;
}

.plans-markdown ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.plans-markdown li {
  margin-bottom: 0.3rem;
}

.plans-markdown strong {
  font-weight: 700;
}

.plans-markdown code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--tag-bg);
  padding: 0.15em 0.4em;
}

.plans-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.plans-markdown th,
.plans-markdown td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.plans-markdown th {
  font-weight: 700;
  border-bottom-width: 2px;
  border-bottom-color: var(--accent);
}

.plans-markdown blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 0.75rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.plans-markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.plans-markdown a {
  color: var(--accent);
}

/* ===========================
   Responsive: Tablet (640px+)
   =========================== */

@media (min-width: 640px) {
  .header {
    padding: 0 2rem;
  }

  .hero {
    padding: 4rem 2rem;
  }

  .hero-links {
    grid-template-columns: 1fr 1fr;
  }

  .hero-name {
    font-size: 2.75rem;
  }

  .project-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    padding: 0 2rem 2.5rem;
  }

  .page-header {
    padding: 2.5rem 2rem 1rem;
  }

  .plans-content {
    padding: 0 2rem 2.5rem;
  }
}

/* ===========================
   Responsive: Desktop (1024px+)
   =========================== */

@media (min-width: 1024px) {
  .hero {
    padding: 5rem 2rem;
  }

  .hero-name {
    font-size: 3rem;
  }

  .project-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
  }

  .page-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 2rem 1rem;
    width: 100%;
  }

  .page-body {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
  }

  .page-body .page-header {
    max-width: none;
    margin: 0;
    width: auto;
  }

  .plans-content {
    padding: 0 2rem 3rem;
  }

/* ===========================
   Reduced Motion
   =========================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================
   Project Sub-pages
   =========================== */

.subpage-hero {
  padding: 3rem 1.5rem 2rem;
  border-left: 4px solid var(--accent);
  margin: 0 1.5rem 1.5rem;
  background-color: var(--bg-card);
}

.subpage-back {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 500;
  transition: color var(--transition-speed);
}

.subpage-back:hover {
  color: var(--accent);
}

.subpage-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.subpage-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.subpage-body {
  padding: 0 1.5rem 3rem;
}

.subpage-section {
  margin-bottom: 2.5rem;
}

.subpage-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

/* Placeholder boxes — dashed border indicates to-be-filled content */
.ph-box {
  border: 2px dashed var(--border);
  background-color: var(--bg-card);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ph-box::after {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 0;
}

.ph-box-lg {
  min-height: 160px;
}

.ph-box-sm {
  min-height: 60px;
}

.ph-grid {
  display: grid;
  gap: 0.75rem;
}

.ph-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.ph-grid .ph-box {
  min-height: 100px;
}

/* Sub-page responsive */
@media (min-width: 640px) {
  .subpage-hero {
    padding: 3.5rem 2rem 2.5rem;
    margin: 0 2rem 2rem;
  }

  .subpage-body {
    padding: 0 2rem 4rem;
  }

  .subpage-title {
    font-size: 2.25rem;
  }

  .subpage-section {
    margin-bottom: 3rem;
  }

  .ph-box-lg {
    min-height: 200px;
  }

  .ph-grid {
    gap: 1rem;
  }

  .ph-grid .ph-box {
    min-height: 120px;
  }
}

@media (min-width: 1024px) {
  .subpage-hero {
    max-width: 900px;
    margin: 0 auto 2rem;
  }

  .subpage-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 0 5rem;
  }

  .subpage-title {
    font-size: 2.5rem;
  }
}