/* ============================================================
   Junming Huang — personal site
   Light page + dark terminal panel. No framework, no build.
   ============================================================ */

:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --line: #e4e7eb;
  --accent: #3b5bdb;

  /* terminal palette (always dark) */
  --term-bg: #0d1117;
  --term-fg: #e6edf3;
  --term-muted: #8b949e;
  --term-link: #58a6ff;
  --term-user: #3fb950;
  --term-path: #58a6ff;
  --term-accent: #d2a8ff;
  --term-bar: #161b22;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco, "Cascadia Code",
    Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

/* The page stays light in both OS themes (matching the reference); the
   terminal panel is always dark. To follow the visitor's OS dark mode for the
   page too, re-add a `@media (prefers-color-scheme: dark) { :root { ... } }`
   block overriding --bg / --fg / --line here. */

* {
  box-sizing: border-box;
}

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

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 22px 40px;
}

/* ---------- intro / header ---------- */

.intro {
  display: flex;
  gap: 20px;
  align-items: center;
}

/* Profile photo is a button: click it for the "Vina" easter egg —
   circle → square morph + crossfade to the alt avatar (wired in main.js). */
.avatar-btn {
  position: relative;
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}
.avatar-btn:hover {
  transform: translateY(-2px) scale(1.03);
}
.avatar-btn:active {
  transform: scale(0.97);
}
.avatar-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #e9eef7, #d8dee9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  transition: border-radius 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.5s ease;
}
.avatar-alt {
  opacity: 0;
}
.intro.vina .avatar {
  border-radius: 16px;
}
.intro.vina .avatar-base {
  opacity: 0;
}
.intro.vina .avatar-alt {
  opacity: 1;
}

/* quick crossfade of the name + tagline during the persona swap */
.id {
  transition: opacity 0.18s ease;
}
.intro.swapping .id {
  opacity: 0;
}

.id h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.id .alias {
  color: var(--muted);
  font-weight: 400;
  font-size: 1.1rem;
}

.tagline {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

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

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.9rem;
}
.links a {
  color: var(--fg);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}
.links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

/* ---------- section nav ---------- */

.sections {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 30px 0 12px;
}
.sections .navsep {
  width: 1px;
  align-self: stretch;
  margin: 2px 2px;
  background: var(--line);
}

.sections button {
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.sections button::before {
  content: "/";
  opacity: 0.5;
  margin-right: 1px;
}
.sections button:hover {
  color: var(--fg);
  border-color: var(--muted);
}
.sections button[aria-current="true"] {
  color: var(--term-user);
  border-color: var(--term-user);
  background: rgba(63, 185, 80, 0.08);
}

/* visible keyboard focus */
.sections button:focus-visible,
.links a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.postlist button:focus-visible,
.backlink:focus-visible {
  outline: 2px solid var(--term-link);
  outline-offset: 2px;
}

/* ---------- terminal ---------- */

.terminal {
  border-radius: 12px;
  overflow: hidden;
  background: var(--term-bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--term-bar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.dots {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red {
  background: #ff5f56;
}
.dot.yellow {
  background: #ffbd2e;
}
.dot.green {
  background: #27c93f;
}
.term-title {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--term-muted);
}

/* language switch — lives in the terminal title bar, like a window control */
.term-bar .lang-toggle {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1;
  color: var(--term-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.term-bar .lang-toggle:hover {
  color: var(--term-fg);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}
.term-bar .lang-toggle:focus-visible {
  outline: 2px solid var(--term-link);
  outline-offset: 2px;
}

.term-body {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--term-fg);
  padding: 18px 18px 22px;
  max-height: 60vh;
  min-height: 220px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* the command-echo line: ~ $ cat about.md */
.term-body .cmdline {
  margin: 0 0 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.term-body .cmdline:not(:first-child) {
  margin-top: 22px;
}
.term-body .user {
  color: var(--term-user);
}
.term-body .path {
  color: var(--term-path);
}
.term-body .prompt-sym {
  color: var(--term-muted);
}

/* blinking caret shown while typing */
.term-body.typing .output:after,
.term-body.typing .cmdline:last-child:after {
  content: "▋";
  color: var(--term-fg);
  animation: blink 1s steps(1) infinite;
  margin-left: 1px;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* rendered markdown inside the terminal */
.output {
  display: block;
  overflow-wrap: anywhere;
}
.output > :first-child {
  margin-top: 0;
}
.output > :last-child {
  margin-bottom: 0;
}
.output h1,
.output h2,
.output h3 {
  font-family: var(--mono);
  line-height: 1.35;
  margin: 18px 0 8px;
}
.output h1 {
  font-size: 1.15rem;
  color: #fff;
}
.output h2 {
  font-size: 1.02rem;
  color: var(--term-accent);
}
.output h3 {
  font-size: 0.92rem;
  color: var(--term-link);
  text-transform: lowercase;
}
.output h2::before {
  content: "## ";
  color: var(--term-muted);
}
.output h3::before {
  content: "# ";
  color: var(--term-muted);
}
.output p {
  margin: 8px 0;
}
.output a {
  color: var(--term-link);
}
.output a.pdflink {
  display: inline-block;
  margin-top: 4px;
  font-weight: 600;
}

/* Typewriter: hold an element's decorative chrome (list bullet, code-block
   box, heading prefix, blockquote rule, inline-code pill) until the reveal
   reaches its text. main.js tags pending elements with .tw-pending and clears
   it as each one's text starts typing. Scoped to .typing so the chrome always
   reappears once the reveal finishes, even if a class were left behind. */
.term-body.typing .output li.tw-pending::marker {
  color: transparent;
}
.term-body.typing .output h2.tw-pending::before,
.term-body.typing .output h3.tw-pending::before {
  color: transparent;
}
.term-body.typing .output pre.tw-pending {
  background: transparent;
  border-color: transparent;
}
.term-body.typing .output code.tw-pending {
  background: transparent;
}
.term-body.typing .output blockquote.tw-pending {
  border-left-color: transparent;
}

/* diffusion / dLLM-style fade-in reveal (blog posts) */
.output .tok {
  opacity: 0;
  filter: blur(7px);
  transition: opacity 0.5s ease, filter 0.5s ease;
}
.output .tok.in {
  opacity: 1;
  filter: blur(0);
}
.term-body.skip .tok {
  opacity: 1 !important;
  filter: none !important;
  transition: none !important;
}
.output strong {
  color: #fff;
  font-weight: 600;
}
.output em {
  color: var(--term-accent);
  font-style: normal;
}
.output ul,
.output ol {
  margin: 8px 0;
  padding-left: 1.4em;
}
.output li {
  margin: 3px 0;
}
.output ul li::marker {
  content: "› ";
  color: var(--term-user);
}
.output hr {
  border: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
  margin: 16px 0;
}
.output code {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}
.output pre {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 12px 0;
}
.output pre code {
  background: none;
  padding: 0;
  color: var(--term-muted);
}
.output blockquote {
  margin: 12px 0;
  padding-left: 12px;
  border-left: 2px solid var(--term-user);
  color: var(--term-muted);
}

/* blog list */
.postlist {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}
.postlist li {
  margin: 0;
}
.postlist button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  color: var(--term-fg);
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 9px 2px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.postlist button:hover {
  color: var(--term-link);
}
.postlist .date {
  color: var(--term-muted);
  flex: 0 0 auto;
}
.postlist button > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.backlink {
  display: inline-block;
  margin-top: 14px;
  color: var(--term-muted);
  font-family: var(--mono);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 0.85rem;
}
.backlink:hover {
  color: var(--term-link);
}

/* ---------- footer ---------- */

.foot {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.foot .sep {
  opacity: 0.5;
}

/* ---------- responsive ---------- */

@media (max-width: 540px) {
  .wrap {
    padding: 36px 16px 32px;
  }
  .intro {
    gap: 16px;
  }
  .avatar-btn {
    width: 72px;
    height: 72px;
  }
  .id h1 {
    font-size: 1.3rem;
  }
  .term-body {
    font-size: 0.84rem;
    max-height: 64vh;
  }
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .term-body,
  * {
    scroll-behavior: auto;
  }
  .term-body.typing .output:after,
  .term-body.typing .cmdline:last-child:after {
    animation: none;
  }
  .output .tok {
    opacity: 1;
    filter: none;
    transition: none;
  }
  .avatar,
  .avatar-btn,
  .id {
    transition: none;
  }
}
