/* ==========================================================================
   Frank Xing (邢志明) Personal Homepage — Editorial Design System
   Inspired by pascalhu.com/zh/ architecture & visual restraint
   ========================================================================== */

:root {
  --bg: #101719;
  --surface: #172326;
  --surface-deep: #1b3535;
  --surface-border: #36514c;
  --border: #344448;
  --text: #c5cece;
  --muted: #a2b3b5;
  --bright: #f1f1e9;
  --accent: #9adecf;
  --accent-ink: #102420;
  --svg-bright: #72d8d1;
  --svg-soft: #8ae0d5;
  --svg-dim: #466160;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: Georgia, "Songti SC", "Noto Serif SC", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(154, 222, 207, 0.24);
  color: var(--bright);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  z-index: 100;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
}

.container,
.header-inner {
  width: min(100% - 96px, 1120px);
  margin-inline: auto;
}

main {
  padding-top: 56px;
  padding-bottom: 40px;
}

section {
  margin-bottom: 72px;
  scroll-margin-top: 104px;
}

h1, h2, h3, h4 {
  color: var(--bright);
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: clamp(36px, 4.5vw, 52px);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h2 {
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.03em;
}

h3 {
  font-size: 21px;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.02em;
}

p {
  max-width: 70ch;
  margin: 0 0 18px;
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  text-decoration-color: rgba(154, 222, 207, 0.45);
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}

a:hover {
  color: var(--bright);
  text-decoration-color: var(--bright);
}

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

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(16, 23, 25, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 32px;
  font-weight: 400;
  line-height: 1;
  color: var(--bright);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.wordmark span {
  color: var(--accent);
}

.wordmark:hover {
  color: var(--bright);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 32px;
  font-size: 14px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--bright);
}

.lang-switch {
  padding-left: 24px;
  border-left: 1px solid var(--border);
  color: var(--text) !important;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  gap: 36px;
  align-items: center;
  padding-top: 12px;
}

.hero-alias {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.hero-role {
  margin: 18px 0 0;
  font-size: 17px;
  color: var(--bright);
}

.hero-role a {
  margin-left: 6px;
}

.hero-statement {
  margin: 22px 0 18px;
  font-size: clamp(20px, 2.2vw, 25px);
  line-height: 1.45;
  color: var(--bright);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.hero-summary {
  color: var(--text);
  font-size: 16px;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
  margin-bottom: 24px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  transition: transform 0.16s ease, background 0.16s ease;
}

.btn-primary:hover {
  background: var(--bright);
  color: var(--accent-ink);
  transform: translateY(-1px);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 14px;
  color: var(--muted);
}

.hero-links a {
  color: var(--muted);
  text-decoration-color: rgba(162, 179, 181, 0.35);
}

.hero-links a:hover {
  color: var(--bright);
  text-decoration-color: var(--bright);
}

/* Interactive Conceptual SVG Figure */
.network-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.network-art {
  width: 100%;
  max-width: 460px;
  height: auto;
  display: block;
}

.network-art .layer {
  transition: opacity 0.3s ease;
}

.network-art .ring,
.network-art .link-line,
.network-art .node-dot,
.network-art .trust-ring {
  transition: opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease, fill 0.3s ease;
}

.network-figure[data-active="see"] .layer-align,
.network-figure[data-active="see"] .layer-trust {
  opacity: 0.25;
}
.network-figure[data-active="see"] .layer-see {
  opacity: 1;
}
.network-figure[data-active="see"] .layer-see .signal-arc {
  stroke: var(--svg-bright);
  stroke-width: 2.2;
}

.network-figure[data-active="align"] .layer-see,
.network-figure[data-active="align"] .layer-trust {
  opacity: 0.25;
}
.network-figure[data-active="align"] .layer-align {
  opacity: 1;
}
.network-figure[data-active="align"] .layer-align .link-line {
  stroke: var(--svg-bright);
  stroke-width: 2.4;
}

.network-figure[data-active="trust"] .layer-see,
.network-figure[data-active="trust"] .layer-align {
  opacity: 0.25;
}
.network-figure[data-active="trust"] .layer-trust {
  opacity: 1;
}
.network-figure[data-active="trust"] .layer-trust .trust-ring {
  stroke: var(--svg-bright);
  stroke-width: 2.2;
}

.network-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 14px;
  text-align: center;
}

.mode-pills {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-pill:hover {
  border-color: var(--accent);
  color: var(--bright);
}

.mode-pill[aria-pressed="true"] {
  background: rgba(154, 222, 207, 0.14);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.network-caption {
  font-size: 14px;
  color: var(--text);
  text-align: center;
  max-width: 38ch;
  min-height: 48px;
  line-height: 1.6;
}

/* About */
.about {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 70px;
  padding: 48px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.about h2 {
  font-size: 24px;
}

.about-credentials {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(52, 68, 72, 0.6);
  font-size: 14px;
  color: var(--muted);
}

/* Section Headers */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-note {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px 48px;
}

.featured-project {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 0.85fr 1.6fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.project-identity {
  background: var(--surface-deep);
  border-right: 1px solid var(--surface-border);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-mark {
  width: 112px;
  height: 112px;
  margin-bottom: 18px;
}

.project-identity-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--bright);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.project-identity-sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.featured-copy {
  padding: 36px 40px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(154, 222, 207, 0.4);
  color: var(--accent);
  background: rgba(154, 222, 207, 0.08);
}

.status-badge.muted {
  border-color: var(--border);
  color: var(--muted);
  background: transparent;
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 20px;
  font-size: 14px;
}

.project-card {
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--border);
}

.project-card p {
  font-size: 15px;
  margin-bottom: 14px;
}

.meta-line {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Rail Layout */
.rail-section {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0 48px;
  align-items: start;
}

.rail-heading {
  position: sticky;
  top: 104px;
}

.rail-heading h2 {
  font-size: 24px;
}

.rail-heading .section-note {
  margin-top: 10px;
  line-height: 1.6;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
  border-left: 1px solid var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 36px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

.timeline-period {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 8px;
}

.timeline-org {
  font-size: 19px;
  font-weight: 600;
  color: var(--bright);
}

.timeline-role {
  font-size: 15px;
  color: var(--text);
}

.timeline-tags {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.milestones {
  margin-top: 14px;
  border-top: 1px solid rgba(52, 68, 72, 0.7);
}

.milestone-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(52, 68, 72, 0.5);
  font-size: 14px;
}

.milestone-date {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.milestone-context {
  color: var(--muted);
  font-style: italic;
}

/* Inverted Light Sage-Stone Section */
.paper-section {
  background: #e2e8e0;
  color: #36494a;
  --bright: #152c2d;
  --text: #36494a;
  --muted: #4e6363;
  --accent: #205d53;
  --border: #b5c2ba;
  color-scheme: light;
  padding: 48px;
  border-radius: 8px;
}

.paper-section h2,
.paper-section h3 {
  color: var(--bright);
}

.paper-section a {
  color: var(--accent);
  text-decoration-color: rgba(32, 93, 83, 0.45);
}

.paper-section a:hover {
  color: #0d3a33;
  text-decoration-color: #0d3a33;
}

.paper-intro {
  margin-bottom: 32px;
  font-size: 16px;
}

.writing-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 42px;
  margin-bottom: 44px;
}

.latest-essay {
  border-top: 2px solid #315f56;
  padding-top: 20px;
}

.eyebrow {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.latest-essay h3 {
  font-size: 24px;
  line-height: 1.35;
  margin-bottom: 14px;
  font-weight: 600;
}

.reading-list-box {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.essay-list {
  margin: 14px 0 20px;
  padding-left: 24px;
}

.essay-list li {
  margin-bottom: 12px;
  padding-left: 4px;
  line-height: 1.55;
}

.essay-list li::marker {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
}

.essay-tag {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.questions-block {
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.questions-block h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.question-card h4 {
  font-size: 16px;
  line-height: 1.45;
  color: var(--bright);
  margin-bottom: 8px;
}

.question-card p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 10px;
}

.question-ref {
  font-size: 13px;
  color: var(--muted);
}

/* Line Lists */
.line-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.line-list li {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.line-list li:first-child {
  padding-top: 0;
}

.item-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--bright);
  margin-bottom: 6px;
}

.item-desc {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 8px;
}

.item-meta {
  font-size: 13px;
  color: var(--muted);
}

/* Reading Cards */
.reading-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 36px;
}

.quote-card {
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.quote-text {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--bright);
  margin-bottom: 12px;
}

.quote-source {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.quote-note {
  font-size: 14px;
  color: var(--accent);
  margin: 0;
}

/* Contact & Footer */
.contact-section {
  padding-top: 44px;
  border-top: 1px solid var(--border);
}

.contact-section h2 {
  font-size: 24px;
  margin-bottom: 14px;
}

.contact-lead {
  font-size: 17px;
  color: var(--text);
}

.contact-email {
  font-size: 19px;
  font-weight: 500;
  margin-bottom: 18px;
}

.contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  font-size: 14px;
  color: var(--muted);
}

.contact-meta a,
.contact-meta button {
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  text-decoration-color: rgba(162, 179, 181, 0.35);
}

.contact-meta a:hover,
.contact-meta button:hover {
  color: var(--bright);
  text-decoration-color: var(--bright);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 48px;
  font-size: 13px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--bright);
}

/* Subtle Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* QR Modal */
.modal-mask[hidden] {
  display: none !important;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(10, 16, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-mask.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #f1f1e9;
  color: #152c2d;
  max-width: 400px;
  width: 100%;
  padding: 36px 28px 28px;
  border-radius: 8px;
  position: relative;
  text-align: center;
  transform: translateY(8px);
  transition: transform 0.25s ease;
}

.modal-mask.open .modal-card {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #4e6363;
}

.modal-close:hover {
  color: #152c2d;
}

.qr-img {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 18px;
  border-radius: 4px;
}

.qr-caption {
  font-size: 14px;
  color: #36494a;
  line-height: 1.65;
  margin: 0;
}

/* For-Agents Helpers */
.agent-step {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}

.step-num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--accent);
  margin-right: 10px;
}

.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--bright);
  overflow-x: auto;
  margin: 14px 0;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 950px) {
  .container,
  .header-inner {
    width: calc(100% - 64px);
  }

  .rail-section {
    grid-template-columns: 180px 1fr;
    gap: 0 32px;
  }

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

  .about {
    gap: 40px;
  }
}

@media (max-width: 680px) {
  .container,
  .header-inner {
    width: calc(100% - 40px);
  }

  .site-nav {
    gap: 18px;
    font-size: 13px;
  }

  .nav-optional {
    display: none;
  }

  .lang-switch {
    padding-left: 14px;
  }

  .hero,
  .about,
  .projects-grid,
  .featured-project,
  .writing-grid,
  .rail-section,
  .reading-grid {
    grid-template-columns: 1fr;
  }

  .project-identity {
    border-right: none;
    border-bottom: 1px solid var(--surface-border);
    padding: 28px 20px;
  }

  .featured-copy {
    padding: 24px 20px;
  }

  .rail-heading {
    position: static;
    margin-bottom: 20px;
  }

  .section-head {
    flex-direction: column;
    gap: 6px;
  }

  .paper-section {
    padding: 28px 22px;
  }

  .milestone-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    transition: none !important;
  }
}

@media print {
  body {
    background: #ffffff;
    color: #222222;
  }
  .site-header,
  .network-figure,
  .hero-actions,
  .site-footer,
  .toast {
    display: none;
  }
  .paper-section {
    background: #f5f5f5;
    padding: 20px;
  }
}
