/* ============================================================
   纸 · 墨 · 朱  —  Personal Portal
   ============================================================ */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; }

/* ---------- Tokens ---------- */
:root {
  --paper:    #F1EDE4;
  --paper-2:  #E7E1D3;
  --ink:      #15130F;
  --ink-2:    #443E34;
  --ink-3:    #736A5C;
  --accent:   #C0452B;
  --rule:     rgba(21, 19, 15, 0.16);
  --rule-2:   rgba(21, 19, 15, 0.08);
  --grid:     rgba(21, 19, 15, 0.045);
  --reverse:  #F6F2E9;

  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC",
           "Source Han Serif SC", "Songti TC", serif;
  --sans:  "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
           "Noto Sans CJK SC", system-ui, sans-serif;
  --mono:  "SFMono-Regular", Menlo, Consolas, "JetBrains Mono",
           "Courier New", monospace;

  --pad:   clamp(20px, 5vw, 72px);
  --max:   1280px;
  --ease:  cubic-bezier(0.22, 0.68, 0.24, 1);
}

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.6;
}

/* ---------- Texture layers ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 40%, transparent 100%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.42;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.16'/%3E%3C/svg%3E");
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px var(--pad);
  background: rgba(241, 237, 228, 0.82); /* fallback */
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--rule-2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.brand-name {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 11px;
  height: 11px;
  background: var(--accent);
  display: block;
  transition: transform 0.5s var(--ease);
}

.brand:hover .brand-mark { transform: rotate(135deg); }

.topnav {
  display: flex;
  gap: 26px;
  margin-left: auto;
  color: var(--ink-2);
}

.topnav a {
  position: relative;
  padding: 2px 0;
  transition: color 0.25s var(--ease);
}

.topnav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s var(--ease);
}

.topnav a:hover { color: var(--ink); }
.topnav a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.8); }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(130px, 17vh, 210px) var(--pad) clamp(60px, 9vh, 110px);
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 60px);
  align-items: start;
}

.hero-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--ink-3);
  writing-mode: vertical-rl;
  padding-top: 12px;
}

.hero-side-rule {
  flex: 1;
  width: 1px;
  min-height: 90px;
  background: var(--rule);
}

.eyebrow {
  color: var(--accent);
  margin-bottom: clamp(20px, 3vw, 34px);
}

.hero-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.4rem, 11.5vw, 9.2rem);
  line-height: 1.06;
  letter-spacing: 0.02em;
  margin-left: -0.06em;
}

.hero-title .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.04em;
}

.hero-title .line > span {
  display: inline-block;
  transform: translateY(115%);
  animation: rise 1s var(--ease) forwards;
}

.hero-title .line:nth-child(1) > span { animation-delay: 0.1s; }
.hero-title .line:nth-child(2) > span { animation-delay: 0.24s; }

.hero-title .line:nth-child(2) > span:first-child {
  color: var(--accent);
}

.hero-title .line:nth-child(2) > span:last-child { animation-delay: 0.34s; }

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

.hero-title .dot { margin-left: 0.04em; }

@keyframes rise {
  to { transform: translateY(0); }
}

.hero-lead {
  max-width: 46ch;
  margin-top: clamp(28px, 4vw, 48px);
  font-size: clamp(14px, 1.15vw, 16px);
  line-height: 2.05;
  color: var(--ink-2);
  opacity: 0;
  animation: fade 1s var(--ease) 0.55s forwards;
}

@keyframes fade {
  to { opacity: 1; }
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 36px;
  opacity: 0;
  animation: fade 1s var(--ease) 0.7s forwards;
}

.hero-tags li {
  padding: 6px 12px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}

.hero-tags li:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Seal ---------- */
.seal {
  position: absolute;
  right: clamp(4px, 3vw, 40px);
  top: clamp(120px, 19vh, 240px);
  width: clamp(78px, 9vw, 126px);
  color: var(--accent);
  mix-blend-mode: multiply;
  opacity: 0;
  animation: fade 1.4s var(--ease) 0.9s forwards, drift 26s linear infinite;
}

.seal svg {
  width: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
}

.seal text {
  fill: currentColor;
  stroke: none;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: 0;
}

.seal .seal-inner { stroke-width: 1; opacity: 0.5; }

@keyframes drift {
  0%   { transform: rotate(-6deg) translateY(0); }
  50%  { transform: rotate(-3.5deg) translateY(-9px); }
  100% { transform: rotate(-6deg) translateY(0); }
}

/* ---------- Marquee ---------- */
.marquee {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.marquee-track {
  display: flex;
  align-items: center;
  gap: 26px;
  width: max-content;
  padding: 13px 0;
  animation: slide 34s linear infinite;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  white-space: nowrap;
}

.marquee-track i {
  color: var(--accent);
  font-style: normal;
}

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

.marquee:hover .marquee-track { animation-play-state: paused; }

/* ---------- Section ---------- */
.section {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(72px, 11vh, 130px) var(--pad);
}

.section + .section { padding-top: clamp(48px, 7vh, 84px); }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding-bottom: 22px;
  margin-bottom: clamp(32px, 5vw, 56px);
  border-bottom: 1px solid var(--ink);
}

.idx { color: var(--accent); }

.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  letter-spacing: 0.04em;
}

.rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
  transform: translateY(-6px);
}

.count { color: var(--ink-3); }

/* ---------- Projects ---------- */
.project-list { border-top: 1px solid var(--rule-2); }

.project { border-bottom: 1px solid var(--rule-2); }

.project-link {
  position: relative;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto 30px;
  gap: clamp(16px, 3vw, 40px);
  align-items: center;
  padding: clamp(22px, 3vw, 34px) clamp(8px, 1.4vw, 20px);
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease);
}

.project-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.5s var(--ease);
}

.p-num { color: var(--ink-3); transition: color 0.45s var(--ease); }

.p-body { display: flex; flex-direction: column; gap: 8px; }

.p-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.15rem, 2.1vw, 1.6rem);
  letter-spacing: 0.03em;
  line-height: 1.4;
  transition: transform 0.5s var(--ease);
}

.p-desc {
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--ink-2);
  max-width: 62ch;
  transition: color 0.45s var(--ease);
}

.p-meta { color: var(--ink-3); transition: color 0.45s var(--ease); }

.p-arrow {
  font-size: 18px;
  color: var(--ink-3);
  transform: translate(-6px, 6px);
  opacity: 0;
  transition: transform 0.5s var(--ease), opacity 0.5s var(--ease), color 0.45s var(--ease);
}

/* hover: 反白 */
@media (hover: hover) {
  .project-link:hover {
    background: var(--ink);
    color: var(--reverse);
  }
  .project-link:hover::before { transform: scaleY(1); transform-origin: top; }
  .project-link:hover .p-num,
  .project-link:hover .p-meta,
  .project-link:hover .p-arrow { color: rgba(246, 242, 233, 0.62); }
  .project-link:hover .p-desc { color: rgba(246, 242, 233, 0.78); }
  .project-link:hover .p-title { transform: translateX(10px); }
  .project-link:hover .p-arrow {
    transform: translate(0, 0);
    opacity: 1;
    color: var(--accent) !important;
  }
}

/* ---------- Stack ---------- */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 1px;
  background: var(--rule-2);
  border: 1px solid var(--rule-2);
}

.stack-col {
  background: var(--paper);
  padding: clamp(20px, 2.6vw, 30px);
  transition: background-color 0.4s var(--ease);
}

.stack-col:hover { background: var(--paper-2); }

.stack-label {
  color: var(--accent);
  margin-bottom: 14px;
}

.stack-col ul { display: flex; flex-direction: column; gap: 5px; }

.stack-col li {
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.65;
  letter-spacing: 0.02em;
}

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 90px);
  align-items: start;
}

.about-text p {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.75vw, 1.35rem);
  line-height: 2.05;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.about-text p + p { margin-top: 1.5em; }

.about-text em {
  font-style: normal;
  color: var(--ink);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}

.about-facts {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--rule);
}

.about-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-2);
}

.about-facts dt { color: var(--ink-3); }

.about-facts dd {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  margin-top: clamp(40px, 8vh, 90px);
  padding: clamp(40px, 6vw, 70px) var(--pad) 30px;
  border-top: 1px solid var(--ink);
  background: var(--paper-2);
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: clamp(28px, 5vw, 52px);
}

.footer-sign {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 7.5vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: 0.09em;
  color: var(--ink);
}

.footer-sub { color: var(--ink-3); }

.footer-links {
  display: flex;
  gap: clamp(18px, 3vw, 38px);
  color: var(--ink-2);
}

.footer-links a {
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}

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

.footer-bottom {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 22px;
  border-top: 1px solid var(--rule-2);
  color: var(--ink-3);
}

.beian {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  transition: color 0.3s var(--ease);
}

.beian::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  transform: rotate(45deg);
  transition: background-color 0.3s var(--ease);
}

.beian:hover { color: var(--accent); }
.beian:hover::before { background: var(--accent); }

/* ---------- Scroll reveal ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}

[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: clamp(110px, 15vh, 150px);
  }
  .hero-side { display: none; }
  .seal { display: none; }
  .about { grid-template-columns: 1fr; }
  .project-link {
    grid-template-columns: 44px minmax(0, 1fr);
    row-gap: 14px;
  }
  .p-meta { grid-column: 2; }
  .p-arrow { display: none; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 620px) {
  .topnav { display: none; }
  .topbar-meta { margin-left: auto; }
  .hero-title { font-size: clamp(2.9rem, 15vw, 4.4rem); }
  .p-desc { font-size: 13px; }
  .section-head .rule { display: none; }
  .section-head { gap: 12px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .hero-title .line > span,
  .hero-lead,
  .hero-tags,
  .seal {
    opacity: 1;
    transform: none;
  }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent);
  color: var(--reverse);
}
