html { scroll-behavior: smooth; }

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

body {
  margin: 0;
  background: #fff;
}

.matrix-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #fff;
}

.matrix-pattern {
  position: relative;
  width: 100%;
  height: 100%;
}

.matrix-column {
  position: absolute;
  top: -100%;
  width: 20px;
  height: 100%;
  font-size: 16px;
  line-height: 18px;
  font-weight: bold;
  animation: fall linear infinite;
  white-space: nowrap;
}

.matrix-column::before {
  content: "ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  position: absolute;
  top: 0; left: 0;
  background: #000;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  writing-mode: vertical-lr;
  letter-spacing: 1px;
  -webkit-font-smoothing: antialiased;
}

.matrix-column:nth-child(odd)::before  { content: "ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣ123456789"; }
.matrix-column:nth-child(even)::before { content: "ㄲㄸㅃㅆㅉㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
.matrix-column:nth-child(3n)::before   { content: "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣㄱㄴㄷㄹㅁㅂㅅ0987654321"; }
.matrix-column:nth-child(4n)::before   { content: "ㅎㅍㅌㅋㅊㅈㅇㅅㅂㅁㄹㄷㄴㄱㅣㅡㅠㅜㅛㅗㅕㅓㅑㅏ"; }
.matrix-column:nth-child(5n)::before   { content: "ㄲㄸㅃㅆㅉㄳㄵㄶㄺㄻㄼㄽㄾㄿㅀㅄㄱㄴㄷㄹ!@#$%^&*()_+-=[]{}|;:,.<>?"; }

/* ── Background text ───────────────────────── */

#bg-text {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

#bg-text p {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: clamp(15px, 1.8vw, 18px);
  color: #111;
  line-height: 1.8;
  text-align: center;
  -webkit-text-stroke: 3px white;
  paint-order: stroke fill;
}

#bg-text p:first-child {
  font-size: clamp(22px, 3vw, 32px);
}

/* ── Inline links in bg-text ────────────────── */

#bg-text p a {
  color: inherit;
  text-decoration: none;
  -webkit-text-stroke: inherit;
  paint-order: stroke fill;
  pointer-events: all;
}
#bg-text p a:hover { text-decoration: none; }

/* ── Social links (home page) ───────────────── */

#social-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  pointer-events: all;
}

#social-links a {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #111;
  text-decoration: none;
  -webkit-text-stroke: 2px white;
  paint-order: stroke fill;
}
#social-links a:hover { text-decoration: none; }

.social-sep {
  font-size: 13px;
  color: #111;
  -webkit-text-stroke: 2px white;
  paint-order: stroke fill;
}



/* ── Blog & post pages ──────────────────────── */

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 24px;
  font-family: 'Inter', sans-serif;
}
.page nav { margin-bottom: 48px; font-size: 13px; }
.page nav a { color: #111; text-decoration: none; }
.page nav a:hover { text-decoration: none; }
.page h2 { font-size: 13px; font-weight: 500; color: #888; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 32px; }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { padding: 24px 0; border-bottom: 1px solid #eee; }
.post-list li:first-child { border-top: 1px solid #eee; }
.post-list a { font-size: 18px; font-weight: 500; color: #111; text-decoration: none; }
.post-list a:hover { text-decoration: none; }
.post-meta { font-size: 11px; color: #111; margin-top: 4px; }
.post-desc { font-size: 13px; color: #444; margin-top: 8px; line-height: 1.6; }

/* ── Post back nav (above container) ────────── */

.post-nav {
  position: relative;
  z-index: 2;
  max-width: 816px;
  margin: 48px auto 16px;
  padding: 0;
  font-size: 13px;
  color: #888;
  font-family: 'Inter', sans-serif;
}
.post-nav a { color: #888; text-decoration: none; }

/* ── Post page card ─────────────────────────── */

.post-page {
  position: relative;
  z-index: 2;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 8px 40px rgba(0,0,0,0.08);
  border-radius: 2px;
  max-width: 816px;
  margin: 48px auto;
  padding: 80px 96px 100px;
  min-height: calc(100vh - 96px);
}


/* ── Post body ──────────────────────────────── */

.post-body h1 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: center;
  margin: 0 0 16px;
  color: #111;
}

.post-body .authors {
  font-size: 13px;
  text-align: center;
  color: #333;
  margin: 0 0 4px;
}

.post-body .affiliation {
  font-size: 11px;
  text-align: center;
  color: #111;
  margin: 0 0 40px;
}

.post-body .abstract {
  margin: 32px 0 40px;
  padding: 0 16px;
  border-left: 3px solid #eee;
}

.post-body .abstract-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #111;
  margin: 0 0 6px;
}

.post-body .abstract p {
  font-size: 13px;
  line-height: 1.7;
  color: #444;
  margin: 0;
  text-align: left;
}

.post-body p {
  font-size: 15px;
  line-height: 1.8;
  color: #222;
  margin: 0 0 18px;
  text-align: justify;
  hyphens: auto;
}

/* Numbered sections via CSS counter */
.post-body { counter-reset: section; }

.post-body h2 {
  counter-increment: section;
  font-size: 13px;
  font-weight: 700;
  color: #111;
  text-transform: none;
  letter-spacing: 0;
  margin: 40px 0 14px;
}

.post-body h2::before {
  content: counter(section) ". ";
}

.post-body h2.no-counter {
  counter-increment: none;
}
.post-body h2.no-counter::before {
  content: none;
}

/* Equations */
.post-body .katex-display {
  margin: 24px 0;
  overflow-x: auto;
}

.post-body .eq-row {
  display: flex;
  align-items: center;
  margin: 24px 0;
}
.post-body .eq-row > div {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.post-body .eq-row .katex-display {
  margin: 0;
  overflow: visible;
}
.post-body .eq-num {
  font-size: 13px;
  color: #888;
  padding-left: 16px;
  white-space: nowrap;
}

.post-body h3 {
  font-size: 13px;
  font-weight: 700;
  color: #333;
  letter-spacing: 0;
  text-transform: none;
  margin: 28px 0 10px;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 16px 0 8px;
}
.post-body th, .post-body td {
  border: 1px solid #ddd;
  padding: 6px 12px;
  text-align: left;
}
.post-body th {
  background: #f8f8f8;
  font-weight: 600;
}
.post-body td:not(:first-child),
.post-body th:not(:first-child) {
  text-align: center;
}

.fig-caption {
  font-size: 11px;
  color: #777;
  text-align: center;
  margin: 4px 0 28px;
}

.fig-placeholder {
  background: #f7f7f7;
  border: 1px solid #e8e8e8;
  border-radius: 3px;
  padding: 28px;
  text-align: center;
  font-size: 11px;
  color: #aaa;
  margin: 16px 0 4px;
}

.post-body sup {
  font-size: 10px;
  font-weight: 600;
  color: #888;
}

.post-body hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 48px 0 36px;
}

.references {
  font-size: 13px;
  color: #444;
  line-height: 1.7;
  padding-left: 20px;
}
.references li { margin-bottom: 8px; }

.demo-frame {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  border-radius: 4px;
  margin: 32px 0;
  display: block;
}

/* ── PDF pages ──────────────────────────────── */

#pdf-pages {
  margin-top: 0;
}

.pdf-page {
  display: block;
  width: 100%;
  margin-bottom: 2px;
}

/* ── Mobile ─────────────────────────────────── */

@media (max-width: 860px) {
  .post-nav {
    margin: 24px auto 12px;
    padding: 0 28px;
  }
  .post-page {
    padding: 48px 28px 72px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ── Canvas ────────────────────────────────── */

#c {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  z-index: 1;
  background: transparent;
  outline: none;
}



@keyframes fall {
  0%   { transform: translateY(-10%); opacity: 1; }
  100% { transform: translateY(200%); opacity: 0; }
}

@media (max-width: 768px) { .matrix-column { font-size: 14px; line-height: 16px; width: 18px; } }
@media (max-width: 480px) { .matrix-column { font-size: 12px; line-height: 14px; width: 15px; } }
